HARPgroup / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
1 stars 0 forks source link

Write a parser for basic SPECL (just setting variables till we decide on our final approach) #24

Closed rburghol closed 8 months ago

rburghol commented 2 years ago

RESPEC issue development here: https://github.com/respec/HSPsquared/issues/99

Testing dataset:

git fetch origin psa
git checkout psa
git pull origin psa
cd [some dir]
wget https://deq1.bse.vt.edu/hsp2/land_spec.tar.gz
tar -xvf land_spec.tar.gz
cd land_spec
hsp2 import_uci hwmA51800.uci hwmA51800.h5
hsp2 run hwmA51800.h5

How Parsing is Done in hsp2

rburghol commented 2 years ago

Hey @jdkleiner check this out when you get to a place where we want to start loading data.

rburghol commented 1 year ago

Testing:

Find and load the h5 file

library("rhdf5")
dir()
[1] "hwmA51800.h5"          "hwmA51800.uci"         "hwmA51800.wdm"
[4] "met_A51800.wdm"        "prad_A51800.wdm"       "pytables-8ng29y_8.tmp"

h5_file_path = "hwmA51800.h5"
fid = H5Fopen(h5_file_path) # Opens the h5 file, fid is a h5 identifier

Look for the SPECL table

data_source_table = "/SPEC_ACTIONS/ACTIONS/table"
did = H5Dopen(fid, data_source_table)

# alternative when conversion errors occur data <- H5Dread(did, bit64conversion = "double")
h5read(fid, "/SPEC_ACTIONS/ACTIONS/table")[1:2,]
  index OPERATION RANGE1 RANGE2 DC DS   YR MO DA HR MN D T VARI S1 S2 AC
1     0       NaN      1        DY    1984  1  1 12    2 3 FNO3       +=
2     1       NaN      1        DY    1984  2  1 12    2 3 FNO3       +=
     VALUE TC TS NUM CURLVL
1 0.000000                1
2 0.090044                1

Test the EXT SOURCES table

> h5read(fid, "/CONTROL/EXT_SOURCES/table")[1:2,]
  index SVOL SVOLNO SMEMN SMEMSB SSYST SGAPST MFACTOR TRAN   TVOL TGRPN  TMEMN
1     0    * TS1000  EVAP     31  ENGL          1.082 SAME PERLND       PETINP
2     1    * TS1001  DEWP     31  ENGL          1.000 SAME PERLND        DTMPG
  TMEMSB TVOLNO COMMENT
1          P001
2          P001
rburghol commented 1 year ago
  HYDR-INIT
    RCHRES  Initial conditions for HYDR section    ***
    # -  #       VOL     Initial  value  of COLIND *** Initial  value  of OUTDGT
             (ac-ft)     for  each  possible  exit *** for  each  possible  exit
                           EX1  EX2  EX3  EX4  EX5 ***   EX1  EX2  EX3  EX4  EX5
    1            30.       4.0  5.0
    2    5       0.0       4.0
  END HYDR-INIT

HSPF Manual 12.2 image