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

Saving scene resampled to EPSG4326 (longlat) fails with ValueError: Could not determine pixel size from projection name 'epgs4326europa' (Unknown) #27

Open
gerritholl opened this issue Oct 4, 2021 · 2 comments

Comments

@gerritholl
Copy link
Collaborator

When resampling a scene to an area that has pixel sizes defined in long/lat, such as EPSG 4326, saving the dataset fails with a ValueError.

Code example:

from pyresample import create_area_def
from pyproj import CRS
from satpy import Scene
from satpy.utils import debug_on; debug_on()
sc = Scene(
        filenames=["/media/nas/x21308/scratch/hrpt_metop03_20210323_1809_12327.l1b"],
        reader=["avhrr_l1b_aapp"])
sc.load(["4"])
ar = create_area_def(
        (nm:="epgs4326europa"),
        CRS.from_epsg(4326),
        resolution=1/128,
        area_extent=(-20, 35, 20, 55),
        proj_id=nm)
ls = sc.resample(ar)
ls.save_dataset("4",
        "/tmp/test.tif",
        writer="ninjotiff",
        physic_unit="C",
        sat_id=7900014,
        chan_id=900015,
        data_cat="PORN",
        nbits=8,
        data_source="HRPT",
        ch_min_measurement_unit=40,
        ch_max_measurement_unit=-87.5)

Full output including traceback:

[DEBUG: 2021-10-04 15:57:59 : satpy.readers.yaml_reader] Reading ('/data/gholl/checkouts/satpy/satpy/etc/readers/avhrr_l1b_aapp.yaml',)
[DEBUG: 2021-10-04 15:57:59 : satpy.readers.yaml_reader] Assigning to avhrr_l1b_aapp: ['/media/nas/x21308/scratch/hrpt_metop03_20210323_1809_12327.l1b']
[DEBUG: 2021-10-04 15:57:59 : satpy.readers.aapp_l1b] Reading time 0:00:00.003103
[DEBUG: 2021-10-04 15:57:59 : satpy.composites.config_loader] Looking for composites config file avhrr-3.yaml
[DEBUG: 2021-10-04 15:57:59 : satpy.composites.config_loader] Looking for composites config file visir.yaml
[DEBUG: 2021-10-04 15:57:59 : satpy.readers.yaml_reader] No coordinates found for DataID(name='longitude', resolution=1050, modifiers=())
[DEBUG: 2021-10-04 15:57:59 : satpy.readers.yaml_reader] No coordinates found for DataID(name='latitude', resolution=1050, modifiers=())
[DEBUG: 2021-10-04 15:57:59 : satpy.scene] Resampling DataID(name='4', wavelength=WavelengthRange(min=10.3, central=10.8, max=11.3, unit='µm'), resolution=1050, calibration=<calibration.brightness_temperature>, modifiers=())
[INFO: 2021-10-04 15:57:59 : satpy.scene] Not reducing data before resampling.
[INFO: 2021-10-04 15:57:59 : satpy.resample] Using default KDTree resampler
[DEBUG: 2021-10-04 15:57:59 : satpy.resample] Check if ./resample_lut-f3500887016a9e9a9b23b19c6fedf95a426076bb.npz exists
[DEBUG: 2021-10-04 15:57:59 : satpy.resample] Computing kd-tree parameters
/data/gholl/checkouts/pyresample/pyresample/kd_tree.py:1012: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  input_coords = input_coords.astype(np.float)
/data/gholl/checkouts/pyresample/pyresample/kd_tree.py:1034: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  radius=self.radius_of_influence, dtype=np.int,
[DEBUG: 2021-10-04 15:57:59 : satpy.resample] Resampling where-9f3f1f4d3c037162a3d408d41ea4566f
[DEBUG: 2021-10-04 15:57:59 : satpy.writers] Reading ['/data/gholl/checkouts/satpy/satpy/etc/writers/ninjotiff.yaml']
/data/gholl/checkouts/pyninjotiff/pyninjotiff/tifffile.py:154: UserWarning: failed to import the optional _tifffile C extension module.
Loading of some compressed images will be slow.
Tifffile.c can be obtained at http://www.lfd.uci.edu/~gohlke/
  warnings.warn(
[DEBUG: 2021-10-04 15:58:00 : satpy.writers] Enhancement configuration options: [{'name': 'stretch', 'method': <function stretch at 0x7fbb6ec2ac10>, 'kwargs': {'stretch': 'linear'}}]
[DEBUG: 2021-10-04 15:58:00 : trollimage.xrimage] Applying stretch linear with parameters {}
[DEBUG: 2021-10-04 15:58:00 : trollimage.xrimage] Perform a linear contrast stretch.
[DEBUG: 2021-10-04 15:58:00 : trollimage.xrimage] Calculate the histogram quantiles:
[DEBUG: 2021-10-04 15:58:00 : trollimage.xrimage] Left and right quantiles: 0.005 0.005
[INFO: 2021-10-04 15:58:00 : pyninjotiff.ninjotiff] Will generate single band product
/data/gholl/mambaforge/envs/py39/lib/python3.9/site-packages/pyproj/crs/crs.py:1256: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  return self._crs.to_proj4(version=version)
/data/gholl/mambaforge/envs/py39/lib/python3.9/site-packages/pyproj/crs/crs.py:1256: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  return self._crs.to_proj4(version=version)
Traceback (most recent call last):
  File "/data/gholl/checkouts/protocode/mwe/ninjotiff-crash.py", line 16, in <module>
    ls.save_dataset("4",
  File "/data/gholl/checkouts/satpy/satpy/scene.py", line 1037, in save_dataset
    return writer.save_dataset(self[dataset_id],
  File "/data/gholl/checkouts/satpy/satpy/writers/ninjotiff.py", line 206, in save_dataset
    return super(NinjoTIFFWriter, self).save_dataset(
  File "/data/gholl/checkouts/satpy/satpy/writers/__init__.py", line 809, in save_dataset
    return self.save_image(img, filename=filename, compute=compute, fill_value=fill_value, **kwargs)
  File "/data/gholl/checkouts/satpy/satpy/writers/ninjotiff.py", line 178, in save_image
    return nt.save(img, filename, data_is_scaled_01=True, compute=compute, **kwargs)
  File "/data/gholl/checkouts/pyninjotiff/pyninjotiff/ninjotiff.py", line 560, in save
    return write(data, filename, area_def, ninjo_product_name, **kwargs)
  File "/data/gholl/checkouts/pyninjotiff/pyninjotiff/ninjotiff.py", line 665, in write
    ninjo_nav_parameters(options, area_def)
  File "/data/gholl/checkouts/pyninjotiff/pyninjotiff/ninjotiff.py", line 582, in ninjo_nav_parameters
    _get_pixel_size(options['projection'], area_def)
  File "/data/gholl/checkouts/pyninjotiff/pyninjotiff/ninjotiff.py", line 311, in _get_pixel_size
    raise ValueError(
ValueError: Could not determine pixel size from projection name 'epgs4326europa' (Unknown)
@gerritholl
Copy link
Collaborator Author

Looking at the source code, this would appear to be closely related to #25.

@gerritholl
Copy link
Collaborator Author

The problem can be circumvented by using proj_id=EQC_PLAT.

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