Skip to content

_get_period_varnames does not work as documented #1681

@Huite

Description

@Huite

This function:

    def _get_period_varnames(self) -> list[str]:
        """
        Get variable names for transient data of this package.

        Returns
        -------
        list[str]
            List of variable names that are used for transient data in this
            package.

        Examples
        --------
        To get the variable names for transient data in a package, e.g. a River
        package:

        >>> river = imod.mf6.River.from_file("river_with_concentration.nc")
        >>> river._get_period_varnames()
        >>> # prints: ['stage', 'conductance', 'bottom_elevation', 'concentration']
        """
        result = []
        if hasattr(self, "_period_data"):
            result.extend(self._period_data)
        if hasattr(self, "_auxiliary_data"):
            result.extend(get_variable_names(self))

        return result

Does not return what the docstring mentions: ['stage', 'conductance', 'bottom_elevation', 'concentration'].

Instead of "concentration", it returns the name of species. This is due to how get_variable_names works, and the fact that _auxiliary_data is a dict.

This has rather bad effects; in _get_unfiltered_pkg_options, not_options should be skipped. Currently, it will read the entire concentration array into memory as .values[()] is called.

However, changing the function to:

        if hasattr(self, "_auxiliary_data"):
            result.extend(self._auxiliary_data.keys())

Seems to result in other errors, so it looks like other functionality relies on the incorrect behavior!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    📯 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions