Skip to content

Commit

Permalink
Merge pull request pytroll#62 from adybbroe/master
Browse files Browse the repository at this point in the history
Add support for HY-1C
  • Loading branch information
adybbroe authored Jan 21, 2019
2 parents 55dd8bd + 46626bc commit 76627fa
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/platforms_supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ have been included in PySpectral.
* - FY-3D mersi-2
- `rsr_mersi-2_FY-3D.h5`
- CMA_ (Acquired via personal contact)
* - HY-1C cocts
- `rsr_cocts_HY-1C.h5`
- (Acquired via personal contact)


.. _Eumetsat: https://www.eumetsat.int/website/home/Data/Products/Calibration/MSGCalibration/index.html
Expand All @@ -90,3 +93,4 @@ have been included in PySpectral.
.. _NESDIS: https://ncc.nesdis.noaa.gov/J1VIIRS/J1VIIRSSpectralResponseFunctions.php
.. _CMA: http://www.cma.gov.cn/en2014/


6 changes: 3 additions & 3 deletions pyspectral/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2014-2018 Pytroll
# Copyright (c) 2014-2019 Pytroll

# Author(s):

Expand Down Expand Up @@ -123,9 +123,9 @@
'Feng-Yun 3D': 'mersi-2'
}

HTTP_PYSPECTRAL_RSR = "https://zenodo.org/record/1491277/files/pyspectral_rsr_data.tgz"
HTTP_PYSPECTRAL_RSR = "https://zenodo.org/record/2545299/files/pyspectral_rsr_data.tgz"
RSR_DATA_VERSION_FILENAME = "PYSPECTRAL_RSR_VERSION"
RSR_DATA_VERSION = "v1.0.3"
RSR_DATA_VERSION = "v1.0.4"

ATM_CORRECTION_LUT_VERSION = {}
ATM_CORRECTION_LUT_VERSION['antarctic_aerosol'] = {'version': 'v1.0.1',
Expand Down
90 changes: 90 additions & 0 deletions rsr_convert_scripts/cocts_rsr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2019 Adam.Dybbroe

# Author(s):

# Adam.Dybbroe <[email protected]>

# 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 HY-1C COCTS relative spectral responses. Data from
[email protected]
NB! The two IR bands are NOT included.
See issue
https://github.com/pytroll/pyspectral/issues/61
"""
import os
import numpy as np
from pyspectral.utils import INSTRUMENTS
from pyspectral.utils import convert2hdf5 as tohdf5
from pyspectral.raw_reader import InstrumentRSR

import logging
LOG = logging.getLogger(__name__)

COCTS_BAND_NAMES = ['ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'ch7', 'ch8']


class COCTS_RSR(InstrumentRSR):

"""Container for the HY-1C COCTS RSR data"""

def __init__(self, bandname, platform_name):

super(COCTS_RSR, self).__init__(bandname, platform_name, COCTS_BAND_NAMES)

self.instrument = INSTRUMENTS.get(platform_name, 'cocts')

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(bandname)

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, bandname, scale=0.001):
"""Load the COCTS RSR data for the band requested.
Wavelength is given in nanometers.
"""
data = np.genfromtxt(self.requested_band_filename,
unpack=True,
names=['wavelength', 'ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'ch7', 'ch8'],
skip_header=0)

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

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


def main():
"""Main"""
for platform_name in ["HY-1C", ]:
tohdf5(COCTS_RSR, platform_name, COCTS_BAND_NAMES)


if __name__ == "__main__":
main()

0 comments on commit 76627fa

Please sign in to comment.