Skip to content

Time Coordinate Detection Failure when multiple numpy.datetime64 with units exist in the variables. #223

Description

@david-sh-csiro

Using dataset.ems.time_coordinate on some datasets yields an unexpected time coordinate.

When multiple numpy.datetime64 that have units exist within the dataset variables, the logic for looking up time coordinates can pick the unexpected one.

For the below dataset, it will find the 'forecast_reference_time' as the time coordinate variable instead of 'time'.

Excerpt of the dataset.

        int64 forecast_reference_time(time) ;
                forecast_reference_time:units = "seconds since 2024-02-28 00:00:00" ;
                forecast_reference_time:standard_name = "forecast_reference_time" ;
                forecast_reference_time:calendar = "gregorian" ;
        float sfc_temp(time, lat, lon) ;
                sfc_temp:standard_name = "surface_temperature" ;
                sfc_temp:long_name = "surface temperature" ;
                sfc_temp:units = "degrees C" ;
                sfc_temp:coordinates = "time, lat, lon" ;
        double time(time) ;
                time:axis = "T" ;
                time:bounds = "time_bnds" ;
                time:calendar = "gregorian" ;
                time:long_name = "time" ;
                time:standard_name = "time" ;
                time:units = "days since 1970-01-01 00:00:00 00" ;
                time:coordinate_type = "time" ;

Looking at the source code it appears to prioritise finding the first variable that is a numpy.datatime64 with units over things like the CF convention standard name.

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