Open rburghol opened 2 years ago
Testing work flow from: https://github.com/HARPgroup/vahydro/issues/457
Goals:
Run ID | Scenario Name |
---|---|
0 | CFBASE30Y20180615 |
4 | CFBASE30Y20180615 |
5 | CBASE1808L55CY55R45P50R45P50Y |
6 | CBASE1808L55CY55R45P10R45P10Y |
7 | CBASE1808L55CY55R45P90R45P90Y |
8 | CFBASE30Y20180615 |
100 | CFBASE30Y20180615 |
omcbid=343608 # OM elementid for "CBP6 Flows" model object attached to river segment model object
cbid=4834152 # vahydro pid for "CBP6 Flows" model object attached to river segment model object
lrseg="A51105_TU3_8880_9230"
drush scr modules/om/src/om_create_pair.php cmd 352129 $omcbid $cbid om_class_cbp_eos_file "$lrseg" prop_feature CBPLandDataConnectionFile 37
drush scr modules/om/src/om_create_pair.php cmd 352129 $omcbid $cbid om_class_cbp_eos_file "$lrseg" prop_feature CBPLandDataConnectionFile 37
drush scr modules/om/src/om.migrate.element.php prop_feature 352127
Alternate work flow:
om_copy_subcomp.php
drush scr modules/om/src/om_copy_subcomp.php cmd dh_properties 6564010 dh_feature 445692 "File-Based Land Segment Runoff Template" 1
Replace the code below with:
version='p532'
scenario='CFBASE30Y20180615_vadeq'
lseg_pid=`drush scr modules/om/src/om_create_landseg.php 68331 445607 $scenario $version`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
lseg_pid=`drush scr modules/om/src/om_create_landseg.php 68331 445608 $scenario $version`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
lseg_pid=`drush scr modules/om/src/om_create_landseg.php 68331 445670 $scenario $version`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
Test in South Fork Roanoke - only use VAHydro now
$lseg_hydroid = 445607;
drush scr modules/om/src/om_copy_subcomp.php cmd dh_properties 6564010 dh_feature 445607 "File-Based Land Segment Runoff Template" 1
$lseg_feature = entity_load_single('dh_feature', $lseg_hydroid);
/media/model/p532
cd /var/www/html/om;
To use dev code on deq2: rm -Rf /var/www/html/d.dh/modules/om; ln -s /opt/model/om/drupal/om /var/www/html/d.dh/modules/om
version='p532'
scenario='CFBASE30Y20180615_vadeq'
lseg_pid=`drush scr modules/om/src/om_create_landseg.php 68105 445586 $scenario $version`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
lseg_pid=`drush scr modules/om/src/om_create_landseg.php 68105 445651 $scenario $version`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
lseg_pid=`drush scr modules/om/src/om_create_landseg.php 68105 445654 $scenario $version`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
drush scr modules/om/src/model_json.php 6735179 1
Debug: land use area is zero. Check:
Load them:
#filename='/var/www/html/files/vahydro/sova_p532_p6_runoff-exist.txt'
filename='/var/www/html/files/vahydro/sova_p532_p6_runoff.txt'
version='p532'
scenario='CFBASE30Y20180615_vadeq'
template=6711736
while IFS= read -r line; do
#echo "Text read from file: $line"
read river_hydroid lrseg_hydroid pid vahydro_version <<< "$line"
echo "Line: $river_hydroid $lrseg_hydroid $pid $version"
lseg_pid=`drush scr modules/om/src/om_create_landseg.php $river_hydroid $lrseg_hydroid $version $scenario`
drush scr modules/om/src/om_cbp_lrseg_landuse_file_import.php cmd $lseg_pid $version $scenario
# this causes an endless loop now...
drush scr modules/om/src/om_copy_subcomp.php cmd dh_properties $template dh_properties $lseg_pid landuse_var
done < $filename
The supporting queries:
create temp view tmp_p532_lrseg_models as (
select a.hydroid as rseg_hydroid,
b.hydroid as lseg_hydroid,
c.pid as model_pid,
c.propcode as model_version
from dh_feature as a
left outer join dh_feature as b
on (
substr(b.hydrocode,8,13) = substr(a.hydrocode,17,13)
)
left outer join dh_properties as c
on (
c.entity_type = 'dh_feature'
and c.featureid = b.hydroid
and c.propcode = 'vahydro-1.0'
)
where b.ftype = 'cbp532_lrseg'
and substr(a.hydrocode,17,2) in ('NR', 'OD', 'OR', 'TU', 'BS', 'MN')
and b.hydroid is not null
and a.bundle='watershed'
and b.bundle='landunit'
and a.ftype='vahydro'
and (
NOT (c.propcode = 'vahydro-0.9')
OR (c.propcode is null)
)
and length(a.hydrocode) = 29
-- uncomment below to sort by either hydrocode
-- or in a special order to prioritize a given watershed
order by a.hydrocode
-- ORDER BY CASE WHEN substr(a.hydrocode,17,1) = 'O' THEN 1 ELSE 2 END
);
copy (
select * from tmp_p532_lrseg_models
) to '/tmp/sova_p532_p6_runoff.txt' WITH CSV DELIMITER E'\t';
-- just ones that have models already
copy (
select * from tmp_p532_lrseg_models
where model_version = 'vahydro-1.0'
) to '/tmp/sova_p532_p6_runoff-exist.txt' WITH CSV DELIMITER E'\t';
P6 runoff
create temp view tmp_p6_lrseg_models as (
select a.hydroid as rseg_hydroid,
b.hydroid as lseg_hydroid,
c.pid as model_pid,
c.propcode as model_version
from dh_feature as a
left outer join dh_feature as b
on (
substr(b.hydrocode,13,13) = substr(a.hydrocode,17,13)
)
left outer join dh_properties as c
on (
c.entity_type = 'dh_feature'
and c.featureid = b.hydroid
and c.propcode = 'vahydro-1.0'
)
where b.ftype = 'cbp6_lrseg'
and b.hydroid is not null
and a.bundle='watershed'
and b.bundle='landunit'
and a.ftype='vahydro'
and (
NOT (c.propcode = 'vahydro-0.9')
OR (c.propcode is null)
)
and length(a.hydrocode) = 29
order by a.hydrocode
);
copy (
select * from tmp_p6_lrseg_models
) to '/tmp/sova_p6_runoff.txt' WITH CSV DELIMITER E'\t';
filename='/var/www/html/files/vahydro/sova_p532_p6_runoff-O-1st.txt'
while IFS= read -r line; do
#echo "Text read from file: $line"
read river_hydroid lrseg_hydroid pid vahydro_version <<< "$line"
echo "Line: $river_hydroid $lrseg_hydroid $pid $version"
drush scr modules/om/src/om_saveprop.php pid $pid
done < $filename
Find runoff container with the erroneous variable landuse_var (they shouldn't have one) and delete that property.
filename="/var/www/html/files/vahydro/sova_runoff_containers_with_badvar.txt"
for i in `cat $filename`; do
drush scr modules/om/src/om_deleteprop.php pid $i
done
The file:
copy (
select b.pid
from dh_properties as a
left outer join dh_properties as b
on (
b.featureid = a.pid
and b.entity_type = 'dh_properties'
and b.propname = 'landuse_var'
)
where a.propname = '1. Local Runoff Inflows'
and b.pid is not null
) to '/tmp/sova_runoff_containers_with_badvar.txt' ;
mkdir /media/model/p532
mkdir /media/model/p532/out
mkdir /media/model/p532/out/land
mkdir /media/model/p532/out/land/p532sova_2021
mkdir /media/model/p532/out/land/p532sova_2021/eos
mkdir /media/model/p532/out/land/p532sova_2021/landuse
ln -s /media/model/p532/out/land/p532sova_2021 /media/model/p532/out/land/CFBASE30Y20180615_vadeq
ln -s /media/model/p532/out/land/p532sova_2021 /media/model/p532/out/land/CFBASE30Y20180615
cd /opt/model/cbp6/R
./R/Examples/export_all_landuse.R
to point to/media/model/p532
and/opt/model/p53/p532c-sova
Rscript Examples/export_all_landuse.R
pg_dump -s -U postgres -d model_scratch -p 5444 -t cbp_p532_cfbase30y20180615_a51105 > /opt/model/om/sh/cbp_p5_lseg_runoff_template.sql
cbp_p532_cfbase30y20180615_a51105
tocbp_p5_lseg_runoff_template
cat /opt/model/om/sh/cbp_p5_lseg_runoff_template.sql | psql model_scratch -p 5444 -U postgres
/opt/model/om/sh/setup.model_scratch.sh
Batch to update landuse for each SOVA watershed
SOVA Local Runoff Folders use same Runit data matrix as NOVA
NOVA Land-River runoff elements get updated landuse_var component
tmp_p6_lrseg_models