Skip to content

Commit

Permalink
Merge f50091a into 04f7076
Browse files Browse the repository at this point in the history
  • Loading branch information
adybbroe committed Nov 19, 2018
2 parents 04f7076 + f50091a commit ffeb51e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,7 +1,9 @@
language: python
env:
global:
- NUMPY_VERSION=stable
# Set defaults to avoid repeating in most cases
- PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
#- NUMPY_VERSION=stable
- MAIN_CMD='python setup.py'
- CONDA_DEPENDENCIES='scipy numpy coveralls coverage h5py mock requests six appdirs python-geotiepoints dask docutils pyyaml xlrd'
- PIP_DEPENDENCIES=''
Expand Down
3 changes: 3 additions & 0 deletions doc/platforms_supported.rst
Expand Up @@ -43,6 +43,9 @@ have been included in PySpectral.
* - Metop-B avhrr
- `rsr_avhrr3_Metop-B.h5`
- GSICS_
* - Metop-C avhrr
- `rsr_avhrr3_Metop-C.h5`
- GSICS_ (Acquired via personal contact)
* - EOS-Terra modis
- `rsr_modis_EOS-Terra.h5`
- GSICS_
Expand Down
12 changes: 7 additions & 5 deletions pyspectral/avhrr_rsr.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2014, 2015, 2016, 2017 Adam.Dybbroe
# Copyright (c) 2014, 2015, 2016, 2017, 2018 Adam.Dybbroe

# Author(s):

Expand Down Expand Up @@ -88,12 +88,14 @@ def _load(self, scale=1.0):

def main():
"""Main"""
for platform_name in ["NOAA-17", "NOAA-16", "NOAA-14", "NOAA-12",
"NOAA-11", "NOAA-9", "NOAA-7",
"NOAA-10", "NOAA-8", "NOAA-6", "TIROS-N",
"NOAA-15"]:
# for platform_name in ["NOAA-17", "NOAA-16", "NOAA-14", "NOAA-12",
# "NOAA-11", "NOAA-9", "NOAA-7",
# "NOAA-10", "NOAA-8", "NOAA-6", "TIROS-N",
# "NOAA-15"]:
for platform_name in ["Metop-C", ]:
tohdf5(AvhrrRSR, platform_name, AVHRR_BAND_NAMES[
INSTRUMENTS[platform_name]])


if __name__ == "__main__":
main()
81 changes: 81 additions & 0 deletions pyspectral/split_metop_avhrr_rsrfile.py
@@ -0,0 +1,81 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2018 Adam.Dybbroe

# Author(s):

# Adam.Dybbroe <a000680@c20671.ad.smhi.se>

# 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/>.

"""Take the 'original' Metop-C AVHRR spectral responses from the file
AVHRR_A309_METOPC_SRF_PRELIMINARY.TXT and split it in one file per band and
convert the wavenumbers to wavelengths.
"""

import numpy as np
import os

DATAFILE = "/home/a000680/data/SpectralResponses/avhrr/AVHRR_A309_METOPC_SRF_PRELIMINARY.TXT"
OUTPUT_DIR = "/home/a000680/data/SpectralResponses/avhrr"

CH1_NAME = "Metop_C_A309C001.txt"
CH2_NAME = "Metop_C_A309C002.txt"
CH3A_NAME = "Metop_C_A309C03A.txt"
CH3B_NAME = "Metop_C_A309C03B.txt"
CH4_NAME = "Metop_C_A309C004.txt"
CH5_NAME = "Metop_C_A309C005.txt"

CH_FILES = {'ch1': CH1_NAME,
'ch2': CH2_NAME,
'ch3A': CH3A_NAME,
'ch3B': CH3B_NAME,
'ch4': CH4_NAME,
'ch5': CH5_NAME
}

HEADERLINE = "Wavelegth (um) Normalized RSF"

with open(DATAFILE) as fpt:
lines = fpt.readlines()

idx = 0
for counter, channel in enumerate(['ch1', 'ch2', 'ch3A', 'ch3B', 'ch4', 'ch5']):
for line in lines[idx::]:
if line.startswith('AVHRR'):
break
idx = idx + 1

# print(lines[idx+2])
wvn = []
response = []
for line in lines[idx+2:-1]:
try:
waven, resp = line.split()
except ValueError:
break

wvn.append(float(waven))
response.append(float(resp))
idx = idx + 1

# Convert from wavenumbers (cm-1) to wavelength (microns, um)
wvl = 1./np.array(wvn) * 10000.0
response = np.array(response)
filename = os.path.join(OUTPUT_DIR, CH_FILES[channel])
data = np.stack((wvl[::-1], response[::-1]), axis=-1)
print(counter, filename)
np.savetxt(filename, data, fmt="%8.6f %10.8f", header=HEADERLINE)
4 changes: 2 additions & 2 deletions pyspectral/utils.py
Expand Up @@ -121,9 +121,9 @@
'NOAA-20': 'viirs'
}

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

ATM_CORRECTION_LUT_VERSION = {}
ATM_CORRECTION_LUT_VERSION['antarctic_aerosol'] = {'version': 'v1.0.1',
Expand Down

0 comments on commit ffeb51e

Please sign in to comment.