Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

longitude and latitude dimensions lost in rename_cmip6 #299

Open
JoranAngevaare opened this issue Jun 1, 2023 · 0 comments
Open

longitude and latitude dimensions lost in rename_cmip6 #299

JoranAngevaare opened this issue Jun 1, 2023 · 0 comments

Comments

@JoranAngevaare
Copy link
Contributor

Thanks again for this fantastic tool!

The problem

In a particular dataset, the lon and lat dimentions are called latitude and longitude. The dataset is:
'ScenarioMIP.UA.MCM-UA-1-0.ssp585.r1i1p1f2.Amon.gn.none.tas'.
The issue is causing the loss of longitude and latitude information in rename_cmip6. This causes issues down the road as broadcast_lonlat will interpret each of the xy indexes as corresponding lon and lat values.

The data looks like

print(ds)
Setup
<xarray.Dataset>
Dimensions:         (time: 86, bnds: 2, longitude: 96, latitude: 80)
Coordinates:
  * time            (time) object 2015-07-01 18:00:00 ... 2100-07-01 18:00:00
  * longitude       (longitude) float64 0.0 3.75 7.5 11.25 ... 348.8 352.5 356.2
  * latitude        (latitude) float64 -88.29 -86.07 -83.84 ... 86.07 88.29
Dimensions without coordinates: bnds
Data variables:
    time_bnds       (time, bnds) object dask.array<chunksize=(86, 2), meta=np.ndarray>
    longitude_bnds  (longitude, bnds) float64 dask.array<chunksize=(96, 2), meta=np.ndarray>
    latitude_bnds   (latitude, bnds) float64 dask.array<chunksize=(80, 2), meta=np.ndarray>
    tas             (time, latitude, longitude) float32 dask.array<chunksize=(86, 80, 96), meta=np.ndarray>
Attributes: (12/48)
    CDI:                    Climate Data Interface version 2.0.3 (https://mpi...
    Conventions:            CF-1.7 CMIP-6.2 
    source:                 Manabe Climate Model at U of Arizona             ...
    institution:            Department of Geosciences, University of Arizona,...
    activity_id:            ScenarioMIP
    branch_method:          standard
    ...                     ...
    variant_label:          r1i1p1f2
    variant_info:           2015 to 2100 time varying equiv CO2 and aerosol f...
    title:                  UArizona MCM-UA-1-0 ssp585              
    product:                model-output
    license:                CMIP6 model data produced by the U of Arizona is ...
    CDO:                    Climate Data Operators version 2.0.3 (https://mpi...

running this through rename_cmip6 loses the longitude and latitude dimensions. I fear this is because of the special treatment of lon and lat in rename_cmip6:

>>> print(rename_cmip6(ds))
<xarray.Dataset>
Dimensions:         (time: 86, bnds: 2, x: 96, y: 80)
Coordinates:
  * time            (time) object 2015-07-01 18:00:00 ... 2100-07-01 18:00:00
Dimensions without coordinates: bnds, x, y
Data variables:
    time_bounds     (time, bnds) object dask.array<chunksize=(86, 2), meta=np.ndarray>
    longitude_bnds  (x, bnds) float64 dask.array<chunksize=(96, 2), meta=np.ndarray>
    latitude_bnds   (y, bnds) float64 dask.array<chunksize=(80, 2), meta=np.ndarray>
    tas             (time, y, x) float32 dask.array<chunksize=(86, 80, 96), meta=np.ndarray>
Attributes: (12/48)
    CDI:                    Climate Data Interface version 2.0.3 (https://mpi...
    Conventions:            CF-1.7 CMIP-6.2 
    source:                 Manabe Climate Model at U of Arizona             ...
    institution:            Department of Geosciences, University of Arizona,...
    activity_id:            ScenarioMIP
    branch_method:          standard
    ...                     ...
    variant_label:          r1i1p1f2
    variant_info:           2015 to 2100 time varying equiv CO2 and aerosol f...
    title:                  UArizona MCM-UA-1-0 ssp585              
    product:                model-output
    license:                CMIP6 model data produced by the U of Arizona is ...
    CDO:                    Climate Data Operators version 2.0.3 (https://mpi...

Possible fix

Maybe the dimension renaming should occur earlier? For example, see this simple alteration:

>>> print(rename_cmip6(ds.rename(dict(longitude='lon', latitude='lat'))))
<xarray.Dataset>
Dimensions:         (time: 86, bnds: 2, x: 96, y: 80)
Coordinates:
  * time            (time) object 2015-07-01 18:00:00 ... 2100-07-01 18:00:00
  * x               (x) float64 0.0 3.75 7.5 11.25 ... 345.0 348.8 352.5 356.2
  * y               (y) float64 -88.29 -86.07 -83.84 ... 83.84 86.07 88.29
Dimensions without coordinates: bnds
Data variables:
    time_bounds     (time, bnds) object dask.array<chunksize=(86, 2), meta=np.ndarray>
    longitude_bnds  (x, bnds) float64 dask.array<chunksize=(96, 2), meta=np.ndarray>
    latitude_bnds   (y, bnds) float64 dask.array<chunksize=(80, 2), meta=np.ndarray>
    tas             (time, y, x) float32 dask.array<chunksize=(86, 80, 96), meta=np.ndarray>
Attributes: (12/48)
    CDI:                    Climate Data Interface version 2.0.3 (https://mpi...
    Conventions:            CF-1.7 CMIP-6.2 
    source:                 Manabe Climate Model at U of Arizona             ...
    institution:            Department of Geosciences, University of Arizona,...
    activity_id:            ScenarioMIP
    branch_method:          standard
    ...                     ...
    variant_label:          r1i1p1f2
    variant_info:           2015 to 2100 time varying equiv CO2 and aerosol f...
    title:                  UArizona MCM-UA-1-0 ssp585              
    product:                model-output
    license:                CMIP6 model data produced by the U of Arizona is ...
    CDO:                    Climate Data Operators version 2.0.3 (https://mpi...
@JoranAngevaare JoranAngevaare changed the title longitude and latitude dimentions lost in rename_cmip6 longitude and latitude dimensions lost in rename_cmip6 Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant