respec / HSPsquared

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

specl: UVNAME (parser and code) #106

Open rburghol opened 2 years ago

rburghol commented 2 years ago

Overview

Tasks

UCI Structure

From HSPF v12.2 manual image

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) 

### Implementation with Operational Model
- Equation object, has 3 main attributes: 
   - "name": "UNO3"
   - "equation": "0.5 * FNO3"
   - "object_class": "Equation"
- Resides in nested hierarchy which determines it's `PERLND`, etc. See below "Example JSON", and compare to below "Original Special Action".

#### Example JSON - Option 2 UVNAME declaration. Must create a unique equation in each RCHRES or PERLND (or other domain) tree for every `UVNAME` defined.

{ "PERLND_P005": { "name": "PERLND_P005", "object_class": "ModelObject", "value": "0", "UNO3": { "name": "UNO3", "object_class": "Equation", "equation": "0.5 FNO3" }, "SNO3": { "name": "SNO3", "object_class": "Equation", "equation": "0.5 FNO3" }, "UNO3": { "name": "UNO3", "object_class": "Equation", "equation": "0.5 * FNO3" } }
}

#### Or, as a globally applied `UVNAME` (non-domain specific), will be loaded by OM code at each domain.

{

"UVNAME": {
    "name": "UVNAME",
    "object_class": "ModelObject",
    "value": "0",
    "UNO3": {
        "name": "UNO3",
        "object_class": "Equation",
        "equation": "0.5 * FNO3"
    },
    "SNO3": {
        "name": "SNO3",
        "object_class": "Equation",
        "equation": "0.5 * FNO3"
    }
}

}


#### Original Special Action `FNO3` partition.
rburghol commented 1 month ago

Meeting notes: