Skip to content

Allow mapping NetCDF variable names independently from HydPy sequence names #191

Open

Description

@sivogel

I stumbled upon the following issue while working with input time series from a NetCDF file.

I want to read an input time series from a NetCDF file, but the variable names in the file do not follow the HydPy naming convention. After changing the file path via element.model.sequences.inputs.nied.filepath, I noticed that HydPy expects the sequence name to match the filename (or, more generally, the name it uses for reading the sequence from the file).

Example:

RuntimeError: While trying to read data from NetCDF file `snow_rain_water_1h.nc`, the following error occurred: NetCDF file snow_rain_water_1h.nc` does not contain variable `snow_rain_water_1h`.

This behavior feels somewhat restrictive. I would suggest one of the following approaches:

  1. The variable in the NetCDF file must follow the HydPy standard sequence name.
  2. The variable name can be specified explicitly, for example via an attribute such as seq.variablenameinfile (or a similar mechanism).

I would personally prefer the second option, as it provides more flexibility. For example, I currently receive data that does not yet represent the final HydPy variable. I first read the data, perform some transformations, and only afterwards does it correspond to the intended HydPy sequence. In such cases, being able to map an arbitrary NetCDF variable name to a HydPy sequence would be very useful.

Would it be possible to support configurable variable name mappings for NetCDF input files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions