diff --git a/CHANGELOG_RSR_DATA.rst b/CHANGELOG_RSR_DATA.rst index e12cb87..ab35bf3 100644 --- a/CHANGELOG_RSR_DATA.rst +++ b/CHANGELOG_RSR_DATA.rst @@ -1,6 +1,22 @@ Changelog for the Relative Spectral Response data ================================================= +Version v1.6.1 (Wed Apr 1 08:14:23 PM CEST 2026) + +------------------------------------------- + +* Bugfix adding the new MODIS RSR files and now also with an extra attribute + for the sensor name + + +Version v1.6.0 (Mon Mar 30 06:58:54 PM CEST 2026) + +------------------------------------------- + +* Updated the MODIS RSR files with new platform names, Terra and Aqua instead + of the previous EOS-Terra and EOS-Aqua, see the WMO OSCAR database + + Version v1.5.1 (Mon Mar 9 09:13:07 PM CET 2026) ------------------------------------------- diff --git a/bin/composite_rsr_plot.py b/bin/composite_rsr_plot.py index 29f3c9d..859e9d4 100644 --- a/bin/composite_rsr_plot.py +++ b/bin/composite_rsr_plot.py @@ -5,11 +5,13 @@ """ +import logging + import matplotlib.pyplot as plt import numpy as np from pyspectral.rsr_reader import RelativeSpectralResponse -from pyspectral.utils import INSTRUMENTS, get_logger, logging_off, logging_on +from pyspectral.utils import INSTRUMENTS, get_logger, logging_on def plot_band(plt_in, band_name, rsr_obj, **kwargs): @@ -114,7 +116,7 @@ def get_arguments(): if verbose: logging_on() else: - logging_off() + logging_on(level=logging.ERROR) req_wvl = None band = None @@ -141,8 +143,8 @@ def get_arguments(): try: rsr = RelativeSpectralResponse(platform, sensor) except IOError: - # LOG.exception('Failed getting the rsr data for platform %s ' + - # 'and sensor %s', platform, sensor) + LOG.exception('Failed getting the rsr data for platform %s ' + + 'and sensor %s', platform, sensor) rsr = None else: break diff --git a/pyspectral/utils.py b/pyspectral/utils.py index 270da46..14a9dca 100644 --- a/pyspectral/utils.py +++ b/pyspectral/utils.py @@ -64,6 +64,8 @@ "Metop-SG-A1": "metimage", "EOS-Aqua": "modis", "EOS-Terra": "modis", + "Aqua": "modis", + "Terra": "modis", "Sentinel-2A": "msi", "Sentinel-2B": "msi", "Sentinel-2C": "msi", @@ -93,10 +95,9 @@ "avhrr-2": "avhrr/2", "avhrr-3": "avhrr/3"} -HTTP_PYSPECTRAL_RSR = "https://zenodo.org/records/18928854/files/pyspectral_rsr_data.tgz" - +HTTP_PYSPECTRAL_RSR = "https://zenodo.org/records/19373017/files/pyspectral_rsr_data.tgz" RSR_DATA_VERSION_FILENAME = "PYSPECTRAL_RSR_VERSION" -RSR_DATA_VERSION = "v1.5.1" +RSR_DATA_VERSION = "v1.6.1" ATM_CORRECTION_LUT_VERSION = {} diff --git a/rsr_convert_scripts/modis_old2new_rsr.py b/rsr_convert_scripts/modis_old2new_rsr.py new file mode 100644 index 0000000..8489087 --- /dev/null +++ b/rsr_convert_scripts/modis_old2new_rsr.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2026 Pytroll developers + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""Script to convert Pyspectral internal Terra/Aqua RSR files. + +Read the internally generated hdf5 file with MODIS RSR and fix platform name +and write to a new file. + +""" + +import shutil +from pathlib import Path + +import h5py + + +def get_arguments(): + """Get the command line arguments.""" + import argparse + parser = argparse.ArgumentParser( + description='Convert old modis files to new ones using the platform names now standard at WMO Oscar') + + parser.add_argument("--directory", '-d', + help="The directory path to where the old EOS-Aqua/EOS-Terra RSR files are stored", + type=str, required=True) + + return parser.parse_args() + + +if __name__ == "__main__": + + args = get_arguments() + basedir = args.directory + + for satname in ['Aqua', 'Terra']: + OLD_MODIS_FILE = Path(basedir) / f'rsr_modis_EOS-{satname}.h5' + NEW_MODIS_FILE = Path(basedir) / f'rsr_modis_{satname}.h5' + shutil.copy(OLD_MODIS_FILE, NEW_MODIS_FILE) + + remove_attrs = ["platform", "sat_number"] + new_attrs = { + "sensor": "modis", + "platform_name": satname, + } + + with h5py.File(NEW_MODIS_FILE, "r+") as f: + # Remove + for key in remove_attrs: + if key in f.attrs: + del f.attrs[key] + + # Add/update + for key, value in new_attrs.items(): + f.attrs[key] = value