Skip to content

Request: new optional required: list parameter on data fetcher functions #97

Description

@mxkpp

Currently, the method RasPlanHdf.mesh_faces_timeseries_output and similar silently do not include RAS variables if those variables are not available in the HDF file at the time of read:

rashdf/src/rashdf/plan.py

Lines 976 to 977 in 6b8f7ff

if self.get(var_path) is None:
continue

For example, optional output parameters that a RAS modeler may have chosen not to include when running the plan.

If a user wants to assert that certain variables are available, they have to first receive the xr.Dataset returned by the method and then assert that it has what they need. It would be convenient to be able to pass in a list of required variables, and raise a custom exception if any required variables are missing.

For example a new optional required parameter used like this:

hdf = rashdf.RasPlanHdf("foobar.hdf")
faces_timeseries: xr.Dataset = hdf.mesh_faces_timeseries_output(
    mesh_name="FlowArea",
    required=[TimeSeriesOutputVar.FACE_VELOCITY, TimeSeriesOutputVar.FACE_WATER_SURFACE],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions