-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
specl: ACTIONS (parser and code) #105
Comments
This was referenced Oct 25, 2022
Making the actions work with STATE.
Table 1: Example for class ACTIONS that increases IVOL by 1.0 on January 1st, 1984 .
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tasks
hdf5 Data Model
/SPEC_ACTIONS/ACTIONS/table
HSPF UCI Data Model
Execution Code
Runtime steps to integrate with STATE
state_ix
get_state(state_ix, state_paths, var_path)
; wherevar_path
is the full hdf5 path to the data quantityif var_ix == False: var_ix = set_state(state_ix, state_paths, var_path, default_value)
state_ix
)var_value = state_ix[var_ix]
var_value = some_function(var_value, some_other_operand)
state_ix[var_ix] = var_value
Manual STATE Example
Using
ModelObject
STATE ExampleThis outlines a process that use an object class to handle pre-run parsing of operation data to tokenization and runtime execution and state integration via the variable
op_tokens
. Details of this can be found in branchhydrocomp
https://github.com/HARPgroup/HSPsquared/tree/hydrocompModelObject
class SpeclAction(ModelObject):
state_paths
andstate_ix
op_codes
, 'model_exec_list`)model_object = [new class name](model_props.get('name'), container, model_props)
[new class name]
is the class defined for the specact handler i.e.SpeclAction
function
is used inmain.py
to dynamically call model activity functions.model_loader_recursive(model_data, model_root_object)
model_path_loader(model_object_cache)
model_tokenizer_recursive(model_root_object, model_object_cache, model_exec_list)
tokenization
in an integer Dict with individual integer values referring to the state_ix of source and destination variables, function types and operators (if a function has multiple modes).model_tokenizer_recursive()
Handles hierarchical execution, sorts operators prior to runtime based on dependencies, stored in an ordered listmodel_exec_list
Supporting STATE inside an hsp2
njit
functionhydr()
) must allow argumentstate
which contains all persistent state info as well as domain specific info, like the current function, operation, and segment.njit
function (ex:_hydr()
) must allow arguments:state_ix
,state_paths
, andstate_info
state_info
is Dict with character key and character value, containingdomain
infodomain
is defined asstate['domain'] = "/STATE/" + operation + "_" + segment + "/" + activity
main.py
via call tostate_context_hsp2(state, operation, segment, activity)
domain
is essentially thehdf5
path to the state variables for the given activity/segment and operationstate_ix
is Dict with integer key and floating point value for containing actual runtime data state for scalar variablesstate_info
is Dict with character key (the hdf5 path of the variable) and integer value, with value being a pointer to the integer key of the variable in thestate_ix
Dictnjit
function must explicitly define which variables will be modifiable via the state facility.hydr_ix = hydr_get_ix(state_ix, state_paths, state_info['domain'])
hydr_get_ix()
returns a Dict with local variable character name as a key, and integer value of the key in state_ixstate_info['domain'] = '/RCHRES/...
Testing / Debugging
Parse UCI
Parser now successfully handle simple "classic" actions.
hsp2 import_uci hwmA51800.uci hwmA51800.h5
Verify ACTIONS parsing in R
UCI 1: Excerpt of ACTION block
Code 1: View contents of uci parsed to hdf5 in R.
Outputs:
View contents of uci parsed to hdf5 in python.
Code 2: Print in python, and convert byte encoding.
Outputs:
The text was updated successfully, but these errors were encountered: