HARPgroup / HARParchive

This repo houses HARP code development items, resources, and intermediate work products.
1 stars 0 forks source link

HARP Weekly 9/12/2022 #536

Open rburghol opened 1 year ago

rburghol commented 1 year ago
glenncampagna commented 1 year ago

Using sqldf to add withdrawals and point sources to hydr

Example in R script:

hydr <- sqldf( 
  "select a.*, b.divr_cfs 
from hydr as a
left outer join divr as b
on (  
a.year = b.year
and a.month = b.month
and a.day = b.day
)
order by a.year,a.month,a.day,a.hour
")

Testing the hydr conversion script that creates aliases: Use (new): hsp_hydr_conversion.R [riverseg] [output/scenario path] Example: Rscript HARP-2022-Summer/AutomatedScripts/hsp_hydr_conversion.R OR1_7700_7980 /media/model/p532/out/river/hsp2_2022 Output: the hydr csv now includes columns for withdrawals and point sources

head(hydr)
                 index       DEP     IVOL O1 O2       O3 OVOL1 OVOL2     OVOL3
1: 1984-01-01 01:00:00 0.2415072 8.847264  0  0 2.055183     0     0 0.1229398
2: 1984-01-01 02:00:00 0.3002159 8.828485  0  0 3.175832     0     0 0.2161576
3: 1984-01-01 03:00:00 0.3486096 8.810900  0  0 4.282218     0     0 0.3081839
4: 1984-01-01 04:00:00 0.3905506 8.793962  0  0 5.374578     0     0 0.3990412
5: 1984-01-01 05:00:00 0.4279465 8.777404  0  0 6.453111     0     0 0.4887475
6: 1984-01-01 06:00:00 0.4619085 8.761090  0  0 7.517995     0     0 0.5773184
   PRSUPY       RO     ROVOL     SAREA        TAU     USTAR      VOL VOLEV
1:      0 2.055183 0.1229398  67.47366 0.02344255 0.1099862 15.79433     0
2:      0 3.175832 0.2161576  83.87602 0.02914127 0.1226281 24.40666     0
3:      0 4.282218 0.3081839  97.39652 0.03383873 0.1321425 32.90938     0
4:      0 5.374578 0.3990412 109.11423 0.03790982 0.1398658 41.30430     0
5:      0 6.453111 0.4887475 119.56212 0.04153978 0.1464090 49.59296     0
6:      0 7.517995 0.5773184 129.05061 0.04483640 0.1521076 57.77673     0
         date hour day month year     Qout divr_cfs ps_afd
1: 1984-01-01    1   1     1 1984 1.487572        0      0
2: 1984-01-01    2   1     1 1984 2.615507        0      0
3: 1984-01-01    3   1     1 1984 3.729025        0      0
4: 1984-01-01    4   1     1 1984 4.828398        0      0
5: 1984-01-01    5   1     1 1984 5.913844        0      0
6: 1984-01-01    6   1     1 1984 6.985553        0      0
rburghol commented 1 year ago

This is excellent @glenncampagna . Thanks!

glenncampagna commented 1 year ago

Confirming Units for diversions/withdrawals and point sources

From River UCI file: image Withdrawals/Diversions are given type OUTDGT image Point sources are given type IVOL From HSPF manual: image OUTDGT has units of cfs and from our Data Dictionary #237 : IVOL = sum of inflows to the RCHRES [ac.ft/ivld] We found that both point sources and diversions are given as daily data, so:

Point sources = ac-ft/day Withdrawals/diversions = cfs

rburghol commented 1 year ago

This is perfect @glenncampagna. Thanks!

rburghol commented 1 year ago

Follow up for @glenncampagna and @juliabruneau -- looking through the code today Joey and I realized that the rchres/hydr routines can reject some demand from OUTDGT, so the OUTDGT should be thought of as demand, while we need to think about the actual withdrawal as potentially something else. I'm gonna do a little re-org on the issue tomorrow to flesh this out but off the top of my head I am thinking we will do OUTDGT aliased as demand, and see if one (or more) of the ROVOLx/OVOLx variables contain just the amount withdrawn. We may put that into wd_mgd -- talk later on this.