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

Thermal channels NinJoTIFF writing fail with AttributeError due to lost attributes #1616

Closed
gerritholl opened this issue Mar 24, 2021 · 0 comments · Fixed by #1617
Closed

Comments

@gerritholl
Copy link
Collaborator

Describe the bug

Writing to NinJoTIFF a thermal channel with Celsius units fails with an AttributeError because the dataset attributes are lost in the new unit conversion introduced in #1615

To Reproduce

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"])
ls = sc.resample("eurol")
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)

Expected behavior

Writing a file.

Actual results

bla bla bla, then

Traceback (most recent call last):
  File "/home/gholl/checkouts/protocode/mwe/ninjotiff-crash.py", line 8, in <module>
    ls.save_dataset("4",
  File "/home/gholl/checkouts/satpy/satpy/scene.py", line 993, in save_dataset
    return writer.save_dataset(self[dataset_id],
  File "/home/gholl/checkouts/satpy/satpy/writers/ninjotiff.py", line 202, in save_dataset
    return super(NinjoTIFFWriter, self).save_dataset(
  File "/home/gholl/checkouts/satpy/satpy/writers/__init__.py", line 811, in save_dataset
    return self.save_image(img, filename=filename, compute=compute, fill_value=fill_value, **kwargs)
  File "/home/gholl/checkouts/satpy/satpy/writers/ninjotiff.py", line 174, in save_image
    return nt.save(img, filename, data_is_scaled_01=True, compute=compute, **kwargs)
  File "/data/gholl/miniconda3/envs/py39/lib/python3.9/site-packages/pyninjotiff/ninjotiff.py", line 541, in save
    area_def = img.data.area
  File "/data/gholl/miniconda3/envs/py39/lib/python3.9/site-packages/xarray/core/common.py", line 239, in __getattr__
    raise AttributeError(
AttributeError: 'DataArray' object has no attribute 'area'

Environment Info:

  • Satpy Version: master

Additional context

Mea culpa, mea culpa, mea massima culpa. PR coming shortly.

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