Skip to content

affine 3.0 incompatible with climada hdf5 files #1311

Description

@emanuel-schmid

Problem

CLIMADA Exposures hdf5 files cannot be read when affine 3.0 is installed.

The error occurs in climada.entity.exposures.base:1211:

cls = <class 'climada.entity.exposures.base.Exposures'>

    @classmethod
    def from_hdf5(cls, file_name):
        """Read data frame and metadata in hdf5 format
    
        Parameters
        ----------
        file_name : str
            (path and) file name to read from.
        additional_vars : list
            list of additional variable names, other than the attributes of the Exposures class,
            whose values are to be read into the Exposures object
            class.
    
        Returns
        -------
        Exposures
        """
        LOGGER.info("Reading %s", file_name)
        if not Path(file_name).is_file():
            raise FileNotFoundError(str(file_name))
        with pd.HDFStore(file_name, mode="r") as store:
            metadata = store.get_storer("exposures").attrs.metadata
            # in previous versions of CLIMADA and/or geopandas, the CRS was stored in '_crs'/'crs'
>           crs = metadata.get("crs", metadata.get("_crs"))
                  ^^^^^^^^^^^^
E           AttributeError: 'numpy.bytes_' object has no attribute 'get'

climada/entity/exposures/base.py:1211: AttributeError

Files create with climada 6.1 / affine 2.4 do not have this issue. But all files created with e.g. climada 4 are affected. That is, basically all files available from the data-api or stored as test data.

Solution

  • for the time being, pin affine to 2.4.0 #80a297
  • eventually - when we must upgrade it - "up-cycle" all datasets on the api (download -> read -> write -> upload)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions