Skip to content

Net2Cog fails on converting PREFIRE SAT1 3 SFC data due to the absent of Coordinate value #63

Description

@vutrannasa

Problem:
Net2Cog fails on converting PREFIRE SAT1 3 SFC data due to the absent of Coordinate value.

Error Output:

rioxarray.exceptions.MissingSpatialDimensionError: y dimension not found. 'rio.set_spatial_dims()' or using 'rename()' to change the dimension name to 'y' can address this. Data variable: emis_mean

net2cog.utilities.Net2CogError: Variable Sfc-Sorted/emis_mean cannot be converted to tif: 'DataTree' object has no attribute 'lat'

Analysis:
I believe the MissingSpatialDimensionError exception is cause by variables coordinates with empty values
Ex. Sfc-Sorted/emis_mean

variable.dims: ('xtrack', 'sfc_type', 'lat', 'lon', 'spectral')
variable.coords: Coordinates:
    *empty*
variable: <xarray.DataArray 'emis_mean' (xtrack: 8, sfc_type: 9, lat: 168, lon: 360,
                               spectral: 63)> Size: 1GB
[274337280 values with dtype=float32]
Dimensions without coordinates: xtrack, sfc_type, lat, lon, spectral
Attributes:
    long_name:    mean surface emissivity
    description:  mean surface emissivity per latitude/longitude grid cell, c... 

Reproduce Problem:

$ git clone https://github.com/podaac/net2cog.git
$ cd net2cog
$ ./run_tests
  • Add the following code to end of tests/test_netcdf_convert.py
def test_PREFIRE_SAT1_3_SFC_SORTED_ALLSKY(logger):
    """Verify a SPL2SMP nested variable in a hierarchical granule can be converted."""
    temp_dir2 = pathlib.Path('<path to downloaded PREFIRE SAT1 3 SFC granule')
    test_file = pathlib.Path(temp_dir2, 'PREFIRE_SAT1_3-SFC-SORTED-ALLSKY_R01_P00_20250601000000_20250630235959.nc')

    # Process test file:
    results = netcdf_converter(
        test_file,
        pathlib.Path(temp_dir2),
        ['Sfc-Sorted/emis_mean'],
        logger
    )

    # Check results are as expected:
    assert len(results) == 1, 'Incorrect number of output file names.'

    assert pathlib.Path(results[0]).is_file(), 'No file created.'
            
     # Verify correct CRS from .tif
    assert cog_validate(pathlib.Path(results[0])) == (True, [], [])
  • Rerun tests
$ source .venv/bin/activate
(.venv) $ poetry run pytest -s poetry run pytest -s tests/test_netcdf_convert.py::test_PREFIRE_SAT1_3_SFC_SORTED_ALLSKY
  • Verify Error
E                   net2cog.utilities.Net2CogError: Variable Sfc-Sorted/emis_mean cannot be converted to tif: 'DataTree' object has no attribute 'lat'

net2cog/netcdf_convert.py:131: Net2CogError
============================================================================ warnings summary =============================================================================
tests/test_netcdf_convert.py::test_PREFIRE_SAT1_3_SFC_SORTED_ALLSKY
  <frozen importlib._bootstrap>:488: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 96 from PyObject

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info =========================================================================
FAILED tests/test_netcdf_convert.py::test_PREFIRE_SAT1_3_SFC_SORTED_ALLSKY - net2cog.utilities.Net2CogError: Variable Sfc-Sorted/emis_mean cannot be converted to tif: 'DataTree' object has no attribute 'lat'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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