state /
__init__.py
state.py
specl.py
om.py
model_object.py
actions.py
sedtrn_ix = sedtrn_get_ix(state_ix, state_paths, state_info["domain"])
# these are integer placeholders faster than calling the array look each timestep
rsed4_ix, rsed5_ix, rsed6_ix = (
sedtrn_ix["RSED4"],
sedtrn_ix["RSED5"],
sedtrn_ix["RSED6"],
)
Developmental Code: https://github.com/HARPgroup/HSPsquared/blob/develop-state-class/src/hsp2/hsp2/
This branch will perform some code reorganization and add class-based
statedata structures, I think it will enhance readability and organization. Specifically:ModelSTATEwhich contains all state related entities (state_ix,dict_ix,state_paths, ...) as attributesjit-ed.state.func_name()it is guaranteed to bejitcompatiblejit-able object with these properties in https://github.com/HARPgroup/HSPsquared/blob/develop-hydrclass/src/hsp2/hsp2/classes/model.test.class.pyGoals
Info
Tasks
importstatementsinit_state_dictsstate_siminfo_hsp2(parameter_obj, siminfo, io_manager, state)model_object_cachefrom state and go intoom_operationsor just be separate argument (these objects cannot be jitted)omis fairly simple, asom_operationscan be created and passed aroundModelObjectand children classes, this can be more challenging. Will need to pass in at creation, or modify the state that is passed in... maybe pass inom_operationsinstead of state, or as a container that includes state?om_operations, this should be fine and propagate all changes up to the actual state object?model_root_objectom_operationsstate_load_dynamics_hsp2(state, io_manager, siminfo)model_data- put intoom_operationsstate_init_hsp2(state, opseq, activities)model_input_dependencies- this function is actually unused, but maye will be used for timeseries? Add timeseries/other DSN access to STATE/specl HARPgroup/HSPsquared#60 (comment)state_context_hsp2:operation,segmentactivity, anddomainsiminfo['tindex']jittindexis actually needed, and that could be obtained elsewhereSimTimerobject needs to have itstindexupdated each time that the time step switches, so we should tackle all of this at once if possible.ModelLinkageto Load SimTimer from model_object_cache and get, or, just grab from thedict_ixof SimTimerom_init_state(state) # set up operational model specific state entries -- now Inom_operations`specactions: this was in state only to pass to the specl parsing routine at startup, and really, can be passed as an argument anyway. Easy fix.specl_load_state(state, specactions) # traditional special actionsspecl_load_ommodel_exec_listfrom inside functions to prep routine. Stored as domain_action specific arrayHYDRSEDTRNstate_load_dynamics_om(state, io_manager, siminfo ) # operational model for custom pythonstate_om_model_run_prep(state, io_manager, siminfo)timerto state, which eliminates the need to implementdict_ixat this time which is most likely going to be far better as an object with runtime declarednparrayHYDRSEDMNTSEDTRNRQUAL_classomom_model_objectom_special_actionom_equationom_model_linkageom_sim_timerModule Declaration / Outline
from state.state import *SEDTRN,HYDRadaptation to newstateobject classSEDTRN,HYDRneed to load the pointers to state-mutable variables from stateSEDTRN:RSED4,RSED5andRSED6HYDR:SEDTRNwhich will:stateclass methods to obtain the indices.domainwill similarly be obsolete since the domain will be associated with theSEDTRNobjectstate_pathpropertydomain: For now, we passdomainin as a property of thestateobject, but this will also be obsolete as we move to an object based system for functional areas.state_infodictionary as:model_exec_listhas been replaced as an array on thestateobject, keyed byixvalue for eachdomain+function, like/STATE/RCHRES_R001/HYDR, somodel_exec_list = state.op_exec_lists[op_ix]will contain the list of dynamically executed operations for that function area. In the future this couldstate_step_hydris a stringenabledordisabled, and determines if a function calledstate_step_hydro()has been defined in a local code file (in the h5 directory)-- this is now located onstate.state_step_hydr. The string variablestate_step_hydris actually somewhat superfluous as we could maybe call the stub functionstate_step_hydr()which does nothing. But we will keep it onstatefor now as it costs nothing and will keep code changes smaller. Also, it may be that the process of using that functon will require a recompile every time regardless of whether or not the function is new, just the location of the include forces it in thejited function.state.state_step_hydris also passed in tohydr()as part of the oldstatedicionary, and this contains the actual function passed into the non-jitted parent functionhydr()(which callsjittedfunction_hydr()--