-
Notifications
You must be signed in to change notification settings - Fork 4
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
Inquiry API for D-Flow FM_his.nc output files #268
Comments
@arthurvd, thanks for setting some ideas!
|
As a user, my main issue with history files is currently that .sel() is not available for stations/generalstructures. This is easy to work around with via this method, and maybe this is already good enough. However, it would be convenient to query via station name and e.g. also via a depth of -5m (arbitrary value). The code I am using currently is this:
Edit: this code is currently outdated. Label based indexing works now, see comment below. |
Today I created a preprocess function for hisfiles called preprocess_hisnc(): https://github.com/openearth/dfm_tools/blob/master/dfm_tools/xarray_helpers.py#L12 It can be used as an xarray argument like this: Some extension might be needed, but I think this was the most important feature needed to nicely interact with hisfiles. I created an example script for reading/selecting/plotting hisfiles here: |
In response to @priscavdsluis:
I've updated the issue description to use The following questions are put on hold until further notice, but I'll answer with my original idea in mind:
The idea was to avoid to much hardcoding. Instead of querying 'weirgen_s1up' and 'uniweir_s1up', you would query for
You are right, the only way via our API is then to use a basename. Or do full hardcoding in an xarray dataset instead: data_xr = xr.open_dataset(ncfile, ...)
data_xr.waterlevel.sel(stations=stations_requested)
data_xr.orifice_s1up.sel(orifice=orifices_requested)
No, the user manual only lists the MDU settings and the long name. |
@rbruijnshkv: please check out the above example code by veenstrajelmer (Oct 6, 2022) #268 (comment) for example code that reads timeseries from his files. |
Describe the solution you'd like
Recommendation: use @d2hydro's his reader as a starting point:
https://github.com/Deltares/HYDROLIB/blob/case_management_tools/hydrolib/case_management_tools/src/cmt/utils/read_his.py
object_type
to distinguish the various types of objects in the file: all structure stypes/observation point/observation cross section/lateral/sourcesink type. In the above linked d2hydro code, it is still called "layer", but I'd like to reserve that for 3D vertical layers in the future.global
,observationPoint
,observationCrossSection
,weir
,universalWeir
,culvert
,longCulvert
,bridge
,pump
,orifice
,gate
,generalStructure
,damBreak
,compound
,lateral
,sourceSink
.get_object_count(object_type)
, forobject_type
in the above enum.get_object_ids(object_type)
, returning the character string ids for all objects/structures (coming from the variable for the right object type AND with attribute:cf_role="timeseries_id"
).On hold: the following requested functionalities are on hold until we've experimented enough with xarray and decided whether we still need this or not. This concerns the actual timeseries data variables.
Click for original text
* Variable getter functions **not** for the data itself, but the **name** of data variables, for example: * `get_datavar_name(object_type, standard_name = None, basename = None)`, returning a single character string variable name that the caller can use to actually get data from that var using another package/direct netcdf access. Identification of the variable (name) is based on these checks: * if standard_name is present, it should literally match the variable's `candidatevar:standard_name` attribute. * otherwise, if basename is present, the variable name should end with that basename. * also, the variable must have at least one netcdf dimension that is exactly the so-called *instance dimension* for the requested structure type. For example, our files contain: ``` netcdf mk1d2d_his { dimensions: time = UNLIMITED ; // (1 currently) // [..] gategens = 27 ; gategen_geom_nNodes = 54 ; variables: // [..] double gategen_crest_width(time, gategens) ; gategen_crest_width:long_name = "gate crest width (via general structure)" ; gategen_crest_width:units = "m" ; gategen_crest_width:coordinates = "gategen_name" ; gategen_crest_width:geometry = "gategen_geom" ; ``` Here, `gategensg` is the instance dimension for the "gate" structure type.Describe alternatives you've considered
Packages such as xarray are still in scope for the data reading, but this issue/feature request is mainly about the implementation of CF-convention-based indexing/inquiry of the D-Flow FM his file contents.
Some further refinement of this issue may be needed, please contact me (@arthurvd) for discussion.
The text was updated successfully, but these errors were encountered: