respec / HSPsquared

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

specl: UVNAME (parser and code) #106

Open rburghol opened 1 year ago

rburghol commented 1 year ago

Overview

Tasks

UCI Structure

From HSPF v12.2 manual image

Example UCI

ACTIONS optyp range dc ds yr mo da hr mn d t vari s1 s2 s3 ac value tc ts num <****><-><--><><-><--><-><-><-><-><><> <----><-><-><-><-><--------> <> <-><-> PERLND 1 DY 11984 3 1 12 2 3 FNO3 += 1.917460

...

UVNAMES kwd varnam ct vari s1 s2 s3 frac oper vari s1 s2 s3 frac oper <****> <----><-> <----><-><-><-> <---> <--> <----><-><-><-> <---> <--> UVNAME FNO3 2 SNO3 0.5 QUAN UNO3 0.5 QUAN



### hdf5 Data Model
- hdf5 Path: `/SPEC_ACTIONS/UVNAME/table`
- Example (from **Example UCI** above)
- May need a simpler table, with one line for each target variable, and then the quantity is used in parsing to make sure that all targets get read, but are not needed in the final table?  Then each SPECL can be rendered at runtime as individual equations stemming from the source variable?
   - Function `` in SPECL.py would need to query these by UVNAME

#### Original 1 to many table mimics UCI incompletely
| index|UVNAME |CNT |VNAME1 |CSUB1 |ADDR1 |FRAC1   |ACTCD1 |VNAME2 |CSUB2 |ADDR2 |FRAC2   |ACTCD2 |VNAME3 |CSUB3 |ADDR3 |FRAC3   |ACTCD3 |
|-----:|:------|:------|:------|:--|:--|:----|:----|:----|:----|:----|:----|:----|:----|:----|:----|:----|:----|
|     0|FNO3 |2      | SNO3      |   |   |   | 0.5 | QUAN | UNO3      |   |   |   | 0.5 |  QUAN  |   |   |   |  

#### Possible streamlined many to 1 table
| index|UVNAME |VNAME |CSUB |ADDR |FRAC   |ACTCD |
|-----:|:------|:------|:------|:--|:----|:----|
|     0|FNO3 | SNO3      |  |   | 0.5 | QUAN | 
|     1|FNO3 | UNO3      |  |   | 0.5 | QUAN | 

### Execution Code
- Fortran version [SUBROUTINE PSPACT in 12.2](https://github.com/respec/FORTRAN/blob/cb2cbf8ec09f11eb290b01fe7646295fcfcdbf1a/lib3.0/SRC/HSPF122/Specact.FOR#L2285)