pytroll / pygac

A python package to read and calibrate NOAA and Metop AVHRR GAC and LAC data
https://pygac.readthedocs.org/
GNU General Public License v3.0
20 stars 25 forks source link

Reading of files broken for numpy 2.0.0 #128

Closed ninahakansson closed 1 month ago

ninahakansson commented 2 months ago

Reading of GAC data fails for numpy >= 2.0.0. Works for numpy = 1.26.4. This comes from the tests in level1c4pps.

level1c4pps INFO: |14:03:54|: Reading NSS.GHRR.TN.D80003.S1147.E1332.B0630506.GC
level1c4pps WARNING: |14:03:54|: Expected 12660 scan lines, but found 17!
/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/pygac/pod_reader.py:291: RuntimeWarning: Unexpected number of scanlines!
  self._read_scanlines(buffer, count)
level1c4pps INFO: |14:03:54|: Reading tiros n data
Traceback (most recent call last):
  File "/home/a001865/miniconda_2024/envs/python_311/bin/gac2pps.py", line 68, in <module>
    process_one_file(options.file, options.out_dir,
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/level1c4pps/gac2pps_lib.py", line 132, in process_one_file
    scn_.load(BANDNAMES)
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/scene.py", line 1453, in load
    self._read_datasets_from_storage(**kwargs)
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/scene.py", line 1476, in _read_datasets_from_storage
    return self._read_dataset_nodes_from_storage(nodes, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/scene.py", line 1482, in _read_dataset_nodes_from_storage
    loaded_datasets = self._load_datasets_by_readers(reader_datasets, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/scene.py", line 1507, in _load_datasets_by_readers
    new_datasets = reader_instance.load(ds_ids, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 948, in load
    ds = self._load_dataset_with_area(dsid, coords, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 836, in _load_dataset_with_area
    ds = self._load_dataset_data(file_handlers, dsid, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 736, in _load_dataset_data
    proj = self._load_dataset(dsid, ds_info, file_handlers, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/readers/yaml_reader.py", line 712, in _load_dataset
    projectable = fh.get_dataset(dsid, ds_info)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/satpy/readers/avhrr_l1b_gaclac.py", line 156, in get_dataset
    _, data = self.reader.get_lonlat()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/pygac/reader.py", line 587, in get_lonlat
    self.update_meta_data()
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/pygac/reader.py", line 515, in update_meta_data
    self.get_sun_earth_distance_correction())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/pygac/reader.py", line 507, in get_sun_earth_distance_correction
    self.get_times()
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/pygac/reader.py", line 453, in get_times
    year, jday, msec = self.correct_times_median(year=year, jday=jday,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/pygac/reader.py", line 880, in correct_times_median
    if_wrong_msec = np.ediff1d(msec, to_begin=0)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a001865/miniconda_2024/envs/python_311/lib/python3.11/site-packages/numpy/lib/_arraysetops_impl.py", line 101, in ediff1d
    raise TypeError("dtype of `to_begin` must be compatible "
TypeError: dtype of `to_begin` must be compatible with input `ary` under the `same_kind` rule.