Open jdkleiner opened 4 years ago
Re-run elfgen analysis for rsegs that have been rerun since 11/30/20
# Create tmp file of rseg model pids
copy (
SELECT model.pid AS model_pid
FROM dh_feature AS rseg
INNER JOIN dh_properties as model
ON (
model.featureid = rseg.hydroid
AND model.varid IN (SELECT hydroid
FROM dh_variabledefinition
WHERE varkey = 'om_water_model_node' AND
propcode = 'vahydro-1.0')
)
INNER JOIN dh_properties as run_object
ON (
run_object.featureid = model.pid
AND run_object.varid IN (SELECT hydroid
FROM dh_variabledefinition
WHERE varkey = 'om_scenario' AND
run_object.propname = 'runid_11')
)
WHERE rseg.bundle = 'watershed' AND
rseg.ftype = 'vahydro' AND
TO_CHAR(TO_TIMESTAMP(run_object.modified), 'MM/DD/YYYY HH24:MI:SS') > '11/30/2020'
GROUP BY model.pid, run_object.pid
ORDER BY TO_CHAR(TO_TIMESTAMP(run_object.modified), 'MM/DD/YYYY HH24:MI:SS') DESC
) to '/tmp/rseg_models_runid_11_12.16.20.txt'
;
COPY 41
Ctrl + D to exit psql console
Ctrl + D to close dbase2 connection
# Copy file to vahydro directory
cd /var/www/html/files/vahydro
sftp dbase2
get /tmp/rseg_models_runid_11_12.16.20.txt
bye
###################
# runid_11 FULL RUN
###################
#Bash for loop
cd /var/www/R
#Execute using 'nohup' to hide output
#!/bin/sh
for r in 11; do
echo $r
for i in `cat /var/www/html/files/vahydro/rseg_models_runid_11_12.16.20.txt`; do
echo $i
nohup Rscript /opt/model/om/R/summarize/run_rseg_elfgen.R $i $r huc8 VAHydro-EDAS
done
done
tail -f /home/jkleiner/nohup.out
Step 0.0 - Test recent elfgen package updates
[x] 1. Reinstall elfgen package to get access to the new vahydro functions
devtools::install_github("HARPgroup/elfgen")
[x] 2. Test the new functions (run the following code block)
Step 1.0 - Build automated code for generating ELF analysis for VWP scenarios
dh-feature-contained-within-export/59776/watershed
only need to supply hydroid of intake)[FLOW REDUCTION @ INTAKE]
[MEAN FLOW @ INTAKE]
site <- "http://deq2.bse.vt.edu/d.dh"
inputs <- list( varkey = "erom_q0001e_mean", featureid = 320509, entity_type = "dh_feature" )
property dataframe returned
dataframe <- getProperty(inputs, site)
DOWNLOAD RSEG LAYER DIRECT FROM VAHYDRO
localpath <- tempdir() filename <- paste("vahydro_riversegs_export.csv",sep="") destfile <- paste(localpath,filename,sep="\") download.file(paste(site,"vahydro_riversegs_export",sep=""), destfile = destfile, method = "libcurl") RSeg.csv <- read.csv(file=paste(localpath , filename,sep="\"), header=TRUE, sep=",")
Input arguments: run_rseg_elfgen.R [rseg model pid] [run id] [huc level] [datasource]
cd /var/www/R Rscript /opt/model/om/R/summarize/run_rseg_elfgen.R 4711908 11 huc8 VAHydro-EDAS
Create tmp file of rseg model pids
deq2.bse.vt.edu ssh dbase2 psql drupal.dh03
copy ( SELECT model.pid AS model_pid FROM dh_feature AS rseg INNER JOIN dh_properties as model ON ( model.featureid = rseg.hydroid
AND model.varid IN (SELECT hydroid FROM dh_variabledefinition WHERE varkey = 'om_water_model_node' AND propcode = 'vahydro-1.0') )
WHERE rseg.bundle = 'watershed' AND rseg.ftype = 'vahydro' GROUP BY model.pid ORDER BY model.pid ASC ) to '/tmp/rseg_models.txt' ; COPY 686 Ctrl + D to exit psql console Ctrl + D to close dbase2 connection
Copy file to vahydro directory
cd /var/www/html/files/vahydro sftp dbase2 get /tmp/rseg_models.txt bye
##########
TEST RUNS
##########
Use the "head" command to take the first 5 records for a test run
head -n 5 rseg_models.txt > rseg_models_test5.txt
Bash for loop
cd /var/www/R
!/bin/sh
for r in 11 13; do echo $r for i in
cat /var/www/html/files/vahydro/rseg_models_test5.txt
; do echo $i Rscript /opt/model/om/R/summarize/run_rseg_elfgen.R $i $r huc8 VAHydro-EDASdone done
##########
FULL RUN
##########
Bash for loop
cd /var/www/R
Execute using 'nohup' to hide output
!/bin/sh
for r in 13; do echo $r for i in
cat /var/www/html/files/vahydro/rseg_models.txt
; do echo $i nohup Rscript /opt/model/om/R/summarize/run_rseg_elfgen.R $i $r huc8 VAHydro-EDASdone done
tail -f /home/jkleiner/nohup.out
!/bin/sh
for r in 11; do echo $r for i in
cat /var/www/html/files/vahydro/rseg_models_reruns_list_12.4.20.txt
; do echo $i nohup Rscript /opt/model/om/R/summarize/run_rseg_elfgen.R $i $r huc8 VAHydro-EDASdone done