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

CF writer output wrong for area with geographic CRS #2227

Closed
gerritholl opened this issue Oct 7, 2022 · 1 comment · Fixed by #2236
Closed

CF writer output wrong for area with geographic CRS #2227

gerritholl opened this issue Oct 7, 2022 · 1 comment · Fixed by #2236

Comments

@gerritholl
Copy link
Collaborator

gerritholl commented Oct 7, 2022

Describe the bug

When writing to a geographic CRS, meaning unprojected with lat/long coordinates, the Satpy cf writer output is incorrect.

To Reproduce

from satpy import Scene
from glob import glob
from satpy.utils import debug_on; debug_on()
from pyresample import create_area_def
filenames = glob("/media/nas/x21308/scratch/wcm/in/H-000*MSG4*")
sc = Scene(filenames=filenames, reader=["seviri_l1b_hrit"])
sc.load(["IR_108"])
ar = create_area_def("world4326", projection=4326, width=1000, height=500,
        area_extent=[-180, -90, 180, 90])
ls = sc.resample(ar)
ls.save_datasets(
        writer="cf",
        filename="/tmp/{platform_name}-{sensor}-{start_time:%Y%m%d%H%M%S}-{end_time:%Y%m%d%H%M%S}.nc",
        encoding={
            "IR_108":
            {"zlib": True,
             "complevel": 9,
             "scale_factor": 0.1,
             "dtype": "int16",
             "_FillValue": 0}},
        include_lonlats=False)

Expected behavior

I expect a CF-conform file.

Actual results

All seems file from the console output:

/data/gholl/checkouts/satpy/satpy/_config.py:125: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
  for entry_point in entry_points().get(name, []):
[DEBUG: 2022-10-07 18:03:07 : satpy.readers.yaml_reader] Reading ('/data/gholl/checkouts/satpy/satpy/etc/readers/seviri_l1b_hrit.yaml',)
/data/gholl/checkouts/satpy/satpy/readers/seviri_base.py:452: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  ('GsicsCalMode', np.bool),
/data/gholl/checkouts/satpy/satpy/readers/seviri_base.py:453: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  ('GsicsCalValidity', np.bool),
[DEBUG: 2022-10-07 18:03:07 : satpy.readers.yaml_reader] Assigning to seviri_l1b_hrit: ['/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000013___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000021___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000018___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000015___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000011___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000009___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000016___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000010___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000022___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000024___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000023___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000012___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000017___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000020___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000014___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-HRV______-000019___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_016___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_039___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_087___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_097___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_108___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_120___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-IR_134___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS006___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-VIS008___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_062___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000004___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000002___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000008___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000003___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000005___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000007___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000001___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-WV_073___-000006___-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-_________-PRO______-202210061200-__', '/media/nas/x21308/scratch/wcm/in/H-000-MSG4__-MSG4________-_________-EPI______-202210061200-__']
[INFO: 2022-10-07 18:03:07 : hrit_msg] No IMPF configuration field found in prologue.
[DEBUG: 2022-10-07 18:03:08 : satpy.composites.config_loader] Looking for composites config file seviri.yaml
[DEBUG: 2022-10-07 18:03:08 : satpy.composites.config_loader] Looking for composites config file visir.yaml
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.012144
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.009238
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.008799
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.008809
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.008895
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.008920
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.009019
[DEBUG: 2022-10-07 18:03:08 : hrit_msg] Calibration time 0:00:00.008937
[DEBUG: 2022-10-07 18:03:08 : satpy.readers.yaml_reader] Requested orientation for Dataset None is 'native' (default). No flipping is applied.
[DEBUG: 2022-10-07 18:03:08 : satpy.scene] Resampling DataID(name='IR_108', wavelength=WavelengthRange(min=9.8, central=10.8, max=11.8, unit='µm'), resolution=3000.403165817, calibration=<calibration.brightness_temperature>, modifiers=())
[INFO: 2022-10-07 18:03:08 : satpy.resample] Using default KDTree resampler
[DEBUG: 2022-10-07 18:03:08 : satpy.resample] Computing kd-tree parameters
[DEBUG: 2022-10-07 18:03:08 : satpy.resample] Resampling from-value-2049b281c17ce40f8e59fde1009083ab
[DEBUG: 2022-10-07 18:03:08 : satpy.writers] Reading ['/data/gholl/checkouts/satpy/satpy/etc/writers/cf.yaml']
[INFO: 2022-10-07 18:03:08 : satpy.writers.cf_writer] Saving datasets to NetCDF4/CF.
/data/gholl/checkouts/satpy/satpy/writers/cf_writer.py:571: FutureWarning: The default behaviour of the CF writer will soon change to not compress data by default.
  warnings.warn("The default behaviour of the CF writer will soon change to not compress data by default.",
/data/gholl/checkouts/satpy/satpy/writers/cf_writer.py:197: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if LooseVersion(pyproj.__version__) < LooseVersion('2.4.1'):
[WARNING: 2022-10-07 18:03:08 : satpy.writers.cf_writer] No time dimension in datasets, skipping time bounds creation.
/data/gholl/mambaforge/envs/py310/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in sin
  return func(*(_execute_task(a, cache) for a in args))
/data/gholl/mambaforge/envs/py310/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in cos
  return func(*(_execute_task(a, cache) for a in args))

But the NetCDF file is wrong:

$ ncdump -h /tmp/Meteosat-11-seviri-20221006120009-20221006121242.nc
netcdf Meteosat-11-seviri-20221006120009-20221006121242 {
dimensions:
        y = 500 ;
        x = 1000 ;
variables:
        int64 world4326 ;
                world4326:crs_wkt = "GEOGCRS[\"WGS 84\",ENSEMBLE[\"World Geodetic System 1984 ensemble\",MEMBER[\"World Geodetic System 1984 (Transit)\"],MEMBER[\"World Geodetic System 1984 (G730)\"],MEMBER[\"World Geodetic System 1984 (G873)\"],MEMBER[\"World Geodetic System 1984 (G1150)\"],MEMBER[\"World Geodetic System 1984 (G1674)\"],MEMBER[\"World Geodetic System 1984 (G1762)\"],MEMBER[\"World Geodetic System 1984 (G2139)\"],ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]],ENSEMBLEACCURACY[2.0]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],CS[ellipsoidal,2],AXIS[\"geodetic latitude (Lat)\",north,ORDER[1],ANGLEUNIT[\"degree\",0.0174532925199433]],AXIS[\"geodetic longitude (Lon)\",east,ORDER[2],ANGLEUNIT[\"degree\",0.0174532925199433]],USAGE[SCOPE[\"Horizontal component of 3D system.\"],AREA[\"World.\"],BBOX[-90,-180,90,180]],ID[\"EPSG\",4326]]" ;
                world4326:geographic_crs_name = "WGS 84" ;
                world4326:grid_mapping_name = "latitude_longitude" ;
                world4326:inverse_flattening = 298.257223563 ;
                world4326:long_name = "world4326" ;
                world4326:longitude_of_prime_meridian = 0. ;
                world4326:prime_meridian_name = "Greenwich" ;
                world4326:reference_ellipsoid_name = "WGS 84" ;
                world4326:semi_major_axis = 6378137. ;
                world4326:semi_minor_axis = 6356752.31424518 ;
        double y(y) ;
                y:standard_name = "projection_y_coordinate" ;
                y:units = "m" ;
        double x(x) ;
                x:standard_name = "projection_x_coordinate" ;
                x:units = "m" ;
        short IR_108(y, x) ;
                IR_108:_FillValue = 0s ;
                IR_108:calibration = "brightness_temperature" ;
                IR_108:end_time = "2022-10-06 12:12:42.452000" ;
                IR_108:georef_offset_corrected = "true" ;
                IR_108:grid_mapping = "world4326" ;
                IR_108:modifiers = "" ;
                IR_108:nominal_end_time = "2022-10-06 12:15:09.440806" ;
                IR_108:nominal_start_time = "2022-10-06 12:00:09.745348" ;
                IR_108:orbital_parameters = "{\"projection_longitude\": 0.0, \"projection_latitude\": 0.0, \"projection_altitude\": 35785831.0, \"satellite_nominal_longitude\": 0.0, \"satellite_nominal_latitude\": 0.0, \"satellite_actual_longitude\": -0.20576979596176986, \"satellite_actual_latitude\": 0.4534231231653645, \"satellite_actual_altitude\": 35782964.803299606}" ;
                IR_108:platform_name = "Meteosat-11" ;
                IR_108:reader = "seviri_l1b_hrit" ;
                IR_108:resolution = 3000.403165817 ;
                IR_108:sensor = "seviri" ;
                IR_108:standard_name = "toa_brightness_temperature" ;
                IR_108:start_time = "2022-10-06 12:00:09.745000" ;
                IR_108:units = "K" ;
                string IR_108:wavelength = "10.8 µm (9.8-11.8 µm)" ;
                IR_108:scale_factor = 0.1 ;

// global attributes:
                :history = "Created by pytroll/satpy on 2022-10-07 16:03:08.723359" ;
                :Conventions = "CF-1.7" ;
}

Note how the x- and y-coordinates are reported to have standard name projection_x_coordinate and units m. This is wrong. The standard name should be longitude respectively latitude, and the units should be degrees_north and degrees_east.

Environment Info:

  • OS: Linux
  • Satpy Version: v0.37.1-116-g7a30eb87
  • PyResample Version: v1.25.1-13-g8da4081

Additional context

Related to #2226, as it is one of multiple causes why a round trip writing-reading fails with the CF writer/reader. The reader rejects the coordinates (rightly so) and concludes there is no area defined at all.

@gerritholl
Copy link
Collaborator Author

The dimensions for Satpy datasets are always y and x (I think). The cf writer always writes m when the dimensions are y and x:

@staticmethod
def _encode_coords(new_data):
if 'x' in new_data.coords:
new_data['x'].attrs['standard_name'] = 'projection_x_coordinate'
new_data['x'].attrs['units'] = 'm'
if 'y' in new_data.coords:
new_data['y'].attrs['standard_name'] = 'projection_y_coordinate'
new_data['y'].attrs['units'] = 'm'
if 'crs' in new_data.coords:
new_data = new_data.drop_vars('crs')
return new_data

gerritholl added a commit to gerritholl/satpy that referenced this issue Oct 13, 2022
Test that datasets are stored in a CF-compliant way when the area has
a geodetic (unprojected) CRS, such as a CRS described in latitude and
longitude.

The test is currently failing due to pytroll#2227.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant