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

Doubtful coordinates at ante-meridian #402

Open
martin-boettcher opened this issue Sep 16, 2024 · 0 comments
Open

Doubtful coordinates at ante-meridian #402

martin-boettcher opened this issue Sep 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@martin-boettcher
Copy link

martin-boettcher commented Sep 16, 2024

What happened?

Opening a GRIB file AUX_ECMWFT provided as part of a Sentinel-2 granule with xarray and engine "cfgrib" returns a dataset. The AUX_ECMWF is a subset of 9x9 points in geographic projection just covering the Sentinel-2 image data which is in UTM.
If the granule overlaps the ante-meridian then the coordinates returned in the dataset look strange. Longitude seem to be somehow rotated by one pixel, while the geophysical data is not.

What are the steps to reproduce the bug?

#The example input S2B_MSIL1C_20240103T221939_N0510_R029_T01KAB_20240103T232410.SAFE can be downloaded from CDSE.

import xarray as xr

ds1 = xr.open_dataset("/windows/tmp/sen2water/S2B_MSIL1C_20240103T221939_N0510_R029_T01KAB_20240103T232410.SAFE/GRANULE/L1C_T01KAB_A035662_20240103T221938/AUX_DATA/AUX_ECMWFT", engine="cfgrib")
ds2 = xr.open_dataset("/windows/tmp/sen2water/S2B_MSIL1C_20240103T221939_N0510_R029_T01KAB_20240103T232410.SAFE/GRANULE/L1C_T01KAB_A035662_20240103T221938/AUX_DATA/AUX_ECMWFT", engine="rasterio")

rotated lon with cfgrib, lon in sequence with rasterio

ds1.longitude.values
ds2.x.values

same data values, not rotated, with both engines

ds1.tcwv.values[0]
ds2.band_data[0].values[0]

#Python 3.11.5, xarray 2024.9.0, cfgrib 0.9.13.0

Version

0.9.13.0, reproduced in 0.9.14.1

Platform (OS and architecture)

Linux vm1 5.15.0-119-generic #129-Ubuntu SMP Fri Aug 2 19:25:20 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output

(base) ~/ > python
Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xarray as xr
>>> 
>>> ds1 = xr.open_dataset("/windows/tmp/sen2water/S2B_MSIL1C_20240103T221939_N0510_R029_T01KAB_20240103T232410.SAFE/GRANULE/L1C_T01KAB_A035662_20240103T221938/AUX_DATA/AUX_ECMWFT", engine="cfgrib")
>>> ds2 = xr.open_dataset("/windows/tmp/sen2water/S2B_MSIL1C_20240103T221939_N0510_R029_T01KAB_20240103T232410.SAFE/GRANULE/L1C_T01KAB_A035662_20240103T221938/AUX_DATA/AUX_ECMWFT", engine="rasterio")
>>> 
>>> # rotated lon with cfgrib (THIS IS WHAT LOOKS STRANGE), while lon in sequence with rasterio
>>> ds1.longitude.values
array([-179.73    ,  179.259   ,  179.385375,  179.51175 ,  179.638125,
        179.7645  ,  179.890875,  180.01725 ,  180.143625])
>>> ds2.x.values
array([179.259   , 179.385375, 179.51175 , 179.638125, 179.7645  ,
       179.890875, 180.01725 , 180.143625, 180.27    ])
>>> 
>>> # data values are the same, not rotated, with both engines
>>> ds1.tcwv.values[0]
array([43.576996, 44.617767, 44.970184, 44.210175, 42.982147, 42.479706,
       43.116547, 43.36252 , 43.907074], dtype=float32)
>>> ds2.band_data[0].values[0]
array([43.57699585, 44.61776733, 44.97018433, 44.21017456, 42.98214722,
       42.47970581, 43.11654663, 43.36251831, 43.90707397])


>>> ds1
<xarray.Dataset> Size: 2kB
Dimensions:        (latitude: 9, longitude: 9)
Coordinates:
    number         int64 8B ...
    time           datetime64[ns] 8B ...
    step           timedelta64[ns] 8B ...
    surface        float64 8B ...
  * latitude       (latitude) float64 72B -16.25 -16.37 -16.5 ... -17.13 -17.25
  * longitude      (longitude) float64 72B -179.7 179.3 179.4 ... 180.0 180.1
    valid_time     datetime64[ns] 8B ...
    isobaricInhPa  float64 8B ...
Data variables:
    tcwv           (latitude, longitude) float32 324B ...
    msl            (latitude, longitude) float32 324B ...
    tco3           (latitude, longitude) float32 324B ...
    u10            (latitude, longitude) float32 324B ...
    v10            (latitude, longitude) float32 324B ...
    r              (latitude, longitude) float32 324B ...
Attributes:
    GRIB_edition:            1
    GRIB_centre:             ecmf
    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             European Centre for Medium-Range Weather Forecasts
    history:                 2024-09-16T16:06 GRIB to CDM+CF via cfgrib-0.9.1...
>>> ds2
<xarray.Dataset> Size: 4kB
Dimensions:      (band: 6, x: 9, y: 9)
Coordinates:
  * band         (band) int64 48B 1 2 3 4 5 6
  * x            (x) float64 72B 179.3 179.4 179.5 179.6 ... 180.0 180.1 180.3
  * y            (y) float64 72B -16.25 -16.37 -16.5 ... -17.0 -17.13 -17.25
    spatial_ref  int64 8B ...
Data variables:
    band_data    (band, y, x) float64 4kB ...

Accompanying data

CDSE does not provide links to data items,

Organisation

Brockmann Consult GmbH

@martin-boettcher martin-boettcher added the bug Something isn't working label Sep 16, 2024
@martin-boettcher martin-boettcher changed the title Doubtful coordinates at anti-meridian Doubtful coordinates at ante-meridian Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant