From 91a7e8222880216cebe1d173f549c46dd121e18a Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Mon, 30 Mar 2026 19:12:38 +0200 Subject: [PATCH 1/4] Prepared for latest RSR data files - with the new modis platform names (Aqua and Terra) Signed-off-by: Adam.Dybbroe --- CHANGELOG_RSR_DATA.rst | 8 ++++ pyspectral/utils.py | 4 +- rsr_convert_scripts/modis_old2new_rsr.py | 53 ++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 rsr_convert_scripts/modis_old2new_rsr.py diff --git a/CHANGELOG_RSR_DATA.rst b/CHANGELOG_RSR_DATA.rst index e12cb87..4b57237 100644 --- a/CHANGELOG_RSR_DATA.rst +++ b/CHANGELOG_RSR_DATA.rst @@ -1,6 +1,14 @@ Changelog for the Relative Spectral Response data ================================================= +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/pyspectral/utils.py b/pyspectral/utils.py index 270da46..9806d4d 100644 --- a/pyspectral/utils.py +++ b/pyspectral/utils.py @@ -93,10 +93,10 @@ "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/19338051/files/pyspectral_rsr_data.tgz" RSR_DATA_VERSION_FILENAME = "PYSPECTRAL_RSR_VERSION" -RSR_DATA_VERSION = "v1.5.1" +RSR_DATA_VERSION = "v1.6.0" 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..8d38764 --- /dev/null +++ b/rsr_convert_scripts/modis_old2new_rsr.py @@ -0,0 +1,53 @@ +#!/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 + +BASEDIR = "/data/pyspectral/" + +if __name__ == "__main__": + + 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 = { + "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 From 821411d4377fdd95414d5243b61a6f9b95e61438 Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Wed, 1 Apr 2026 19:39:55 +0200 Subject: [PATCH 2/4] Require the path to the old files to be provided on the command line Signed-off-by: Adam.Dybbroe --- rsr_convert_scripts/modis_old2new_rsr.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/rsr_convert_scripts/modis_old2new_rsr.py b/rsr_convert_scripts/modis_old2new_rsr.py index 8d38764..8489087 100644 --- a/rsr_convert_scripts/modis_old2new_rsr.py +++ b/rsr_convert_scripts/modis_old2new_rsr.py @@ -28,17 +28,33 @@ import h5py -BASEDIR = "/data/pyspectral/" + +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' + 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, } From afd184f400396d3fa967bfdea6c5a85d44566c0e Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Wed, 1 Apr 2026 20:08:35 +0200 Subject: [PATCH 3/4] Make the rsr plot script report errors even in non-verbose mode Signed-off-by: Adam.Dybbroe --- bin/composite_rsr_plot.py | 10 ++++++---- pyspectral/utils.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) 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 9806d4d..055caec 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", From 7a61fdfb6d71a9c37390c0ac7f340ab54fd05d24 Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Wed, 1 Apr 2026 20:20:06 +0200 Subject: [PATCH 4/4] Update to use new/latest rsr files from Zenodo.org Signed-off-by: Adam.Dybbroe --- CHANGELOG_RSR_DATA.rst | 8 ++++++++ pyspectral/utils.py | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG_RSR_DATA.rst b/CHANGELOG_RSR_DATA.rst index 4b57237..ab35bf3 100644 --- a/CHANGELOG_RSR_DATA.rst +++ b/CHANGELOG_RSR_DATA.rst @@ -1,6 +1,14 @@ 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) ------------------------------------------- diff --git a/pyspectral/utils.py b/pyspectral/utils.py index 055caec..14a9dca 100644 --- a/pyspectral/utils.py +++ b/pyspectral/utils.py @@ -95,10 +95,9 @@ "avhrr-2": "avhrr/2", "avhrr-3": "avhrr/3"} -HTTP_PYSPECTRAL_RSR = "https://zenodo.org/records/19338051/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.6.0" +RSR_DATA_VERSION = "v1.6.1" ATM_CORRECTION_LUT_VERSION = {}