Open rburghol opened 2 years ago
Note. np array slices are views (pass by references), but a simple extract of a value is NOT.
a = np.array([[1,2,3],[2,4,6]])
b = a[1,2] # extracts the 6
b
> 6
b = 77
b
> 77
a # is unchanged
> array([[1, 2, 3],
> [2, 4, 6]])
b = a[1:2,2:3] # extract a slice
b # show the contents and it is an array, with 6 as value
> array([[6]])
# now, set the value of the extracted element
b[[0]] = 77
a # now the final element of a has been set to 77
> array([[ 1, 2, 3],
> [ 2, 4, 77]])
b = 99 # doing this OVERWRITES b, rather than setting the *view* element
a # so final element of a is STILL 77
array([[ 1, 2, 3],
[ 2, 4, 77]])
@jdkleiner -- just tagged you in this so we can review at least some of this in todays work session.
@rburghol Below works as well, so it might not be just slicing that does it, setting b = a and then setting a value in the b array updates the a array
a = np.array([[1,2,3],[2,4,6]])
b = a
print(b)
[[1 2 3]
[2 4 6]]
b[1,2] = 77
print(a)
[[ 1 2 3]
[ 2 4 77]]
Overview
All data paths are to be added to hdf5 structure.
/SPECL
: holds old-style special action definitions from parser/OBJECTS
: holds new styled dynamic object simulation (may be used to replicate or provide backend for specl)/STATE
: Use to store state, facilitates cross-domain (like RCHRES_001 to RCHRES_002) data transfer, and for storing the last state in the event of an exception that halts model execution.Dict
with namestate_ix
(see below, In Memory Runtime Variables)/STATE/RCHRES_R001/HYDR/IVOL
- Holds state ofIVOL
variable from river reach with ID 1 in model.See also:
python/hsp2
#18In Memory Runtime Variables
As it stands, it appears that the entirety of the
hsp2
simulation state data is stored in thehdf5
table, meaning there are no persistentobject
of any sort, but rather, functions that operate on the data that is present in thehdf5
, passed in to the given function in the form of theui
andts
variables. SPECL or other dynamic objects may need to be stored in the hdf5 table? Or do we deviate from the standard process?entity_type
andentity_id
/objects/equation/eq0001/
has columnsentity_type
,entity_id
,equation
, 'default`, .../objects/datamatrix/dm0001/
has columnsentity_type
,entity_id
,matrix
,lucol1
,lutype1
, 'default`, ...hsp2 import_uci
step, then use them to log during simulation?/timeseries/facility001/specl/Qintake
hasobject_class
,equation
,default
/timeseries/facility001/specl/base_demand_pstatus_mgd
hasobject_class
,matrix
,default
,lucol1
,lucol2
,intmethod1
,...hdf5
state storage only (if we have objects that use the state variables, does instantiating them each time come at a cost?)numpy
https://jakevdp.github.io/PythonDataScienceHandbook/02.00-introduction-to-numpy.htmlnumba
which "... is a just-in-time compiler for Python that works best on code that uses NumPy arrays and functions, and loops."numpy
array slicesNote: np array slices are views (pass by references), but a simple extract of a value is NOT.