Skip to content

Commit

Permalink
Add RSR script for MERSI-3 onboard FY-3F
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrp84 committed Jun 25, 2024
1 parent ff4400d commit fcf8d51
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 2 deletions.
29 changes: 29 additions & 0 deletions pyspectral/etc/pyspectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,35 @@ download_from_internet: True
# ch24: FY3D_MERSI_SRF_CH24_Pub.txt
# ch25: FY3D_MERSI_SRF_CH25_Pub.txt


# FY-3F-mersi-3:
# path: D:/sat_data/fy_rsr/
# ch1: FY3F_MERSI_SRF_CH01_Pub.txt
# ch2: FY3F_MERSI_SRF_CH02_Pub.txt
# ch3: FY3F_MERSI_SRF_CH03_Pub.txt
# ch4: FY3F_MERSI_SRF_CH04_Pub.txt
# ch5: FY3F_MERSI_SRF_CH05_Pub.txt
# ch6: FY3F_MERSI_SRF_CH06_Pub.txt
# ch7: FY3F_MERSI_SRF_CH07_Pub.txt
# ch8: FY3F_MERSI_SRF_CH08_Pub.txt
# ch9: FY3F_MERSI_SRF_CH09_Pub.txt
# ch10: FY3F_MERSI_SRF_CH10_Pub.txt
# ch11: FY3F_MERSI_SRF_CH11_Pub.txt
# ch12: FY3F_MERSI_SRF_CH12_Pub.txt
# ch13: FY3F_MERSI_SRF_CH13_Pub.txt
# ch14: FY3F_MERSI_SRF_CH14_Pub.txt
# ch15: FY3F_MERSI_SRF_CH15_Pub.txt
# ch16: FY3F_MERSI_SRF_CH16_Pub.txt
# ch17: FY3F_MERSI_SRF_CH17_Pub.txt
# ch18: FY3F_MERSI_SRF_CH18_Pub.txt
# ch19: FY3F_MERSI_SRF_CH19_Pub.txt
# ch20: FY3F_MERSI_SRF_CH20_Pub.txt
# ch21: FY3F_MERSI_SRF_CH21_Pub.txt
# ch22: FY3F_MERSI_SRF_CH22_Pub.txt
# ch23: FY3F_MERSI_SRF_CH23_Pub.txt
# ch24: FY3F_MERSI_SRF_CH24_Pub.txt
# ch25: FY3F_MERSI_SRF_CH25_Pub.txt

# FY-3G-mersi-rm:
# path: D:/FY-3G_MERSI-RM_SRF
# ch1: SRF_FY3G_SRF_CH01.txt
Expand Down
5 changes: 3 additions & 2 deletions pyspectral/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
'HY-1C': 'cocts',
'Meteosat-12': 'fci',
'MTG-I1': 'fci',
'FY-3D': 'mersi-2',
'FY-3G': 'mersi-rm',
'Metop-SG-A1': 'metimage',
'EOS-Aqua': 'modis',
'EOS-Terra': 'modis',
Expand All @@ -97,6 +95,9 @@
'FY-3A': ['virr', 'mersi-1'],
'FY-3B': ['virr', 'mersi-1'],
'FY-3C': ['virr', 'mersi-1'],
'FY-3D': 'mersi-2',
'FY-3F': 'mersi-3',
'FY-3G': 'mersi-rm',
'DSCOVR': 'epic'}


Expand Down
86 changes: 86 additions & 0 deletions rsr_convert_scripts/mersi3_rsr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018-2022 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 <http://www.gnu.org/licenses/>.

"""Read the MERSI-III relative spectral responses.
Data available from NSMC:
http://gsics.nsmc.org.cn/portal/en/fycv/srf.html
"""
import logging
import os

import numpy as np

from pyspectral.raw_reader import InstrumentRSR
from pyspectral.utils import INSTRUMENTS
from pyspectral.utils import convert2hdf5 as tohdf5

LOG = logging.getLogger(__name__)

MERSI3_BAND_NAMES = ['ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'ch7', 'ch8',
'ch9', 'ch10', 'ch11', 'ch12', 'ch13', 'ch14', 'ch15', 'ch16',
'ch17', 'ch18', 'ch19', 'ch20', 'ch21', 'ch22', 'ch23', 'ch24',
'ch25']


class Mersi3RSR(InstrumentRSR):
"""Container for the FY3D MERSI-II RSR data."""

def __init__(self, bandname, platform_name):
"""Initialize the MERSI-2 RSR class."""
super(Mersi3RSR, self).__init__(bandname, platform_name, MERSI3_BAND_NAMES)

self.instrument = INSTRUMENTS.get(platform_name, 'mersi-3')

self._get_options_from_config()
self._get_bandfilenames()

LOG.debug("Filenames: %s", str(self.filenames))
if self.filenames[bandname] and os.path.exists(self.filenames[bandname]):
self.requested_band_filename = self.filenames[bandname]
self._load()

else:
LOG.warning("Couldn't find an existing file for this band: %s",
str(self.bandname))

# To be compatible with VIIRS....
self.filename = self.requested_band_filename

def _load(self, scale=0.001):
"""Load the MERSI-3 RSR data for the band requested.
Wavelength is given in nanometers.
"""
res = np.genfromtxt(self.requested_band_filename,
unpack=True,
skip_header=0)

data = {'wavelength': res[0, :],
'response': res[1, :], }

wavelength = data['wavelength'] * scale
response = data['response']

self.rsr = {'wavelength': wavelength, 'response': response}


if __name__ == "__main__":
for platform_name in ["FY-3F", ]:
tohdf5(Mersi3RSR, platform_name, MERSI3_BAND_NAMES)

0 comments on commit fcf8d51

Please sign in to comment.