Skip to content

Commit

Permalink
Merge 8ccfe52 into 1ad2b38
Browse files Browse the repository at this point in the history
  • Loading branch information
adybbroe committed Nov 29, 2018
2 parents 1ad2b38 + 8ccfe52 commit ba5e495
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 68 deletions.
25 changes: 0 additions & 25 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,6 @@ Spectral responses
:undoc-members:
:show-inheritance:

SEVIRI
^^^^^^

.. automodule:: pyspectral.seviri_rsr
:members:
:undoc-members:
:show-inheritance:


VIIRS
^^^^^

.. automodule:: pyspectral.viirs_rsr
:members:
:undoc-members:
:show-inheritance:

AVHRR
^^^^^

.. automodule:: pyspectral.avhrr_rsr
:members:
:undoc-members:
:show-inheritance:


Solar irradiance
----------------
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __getattr__(cls, name):

# General information about the project.
project = u'Pyspectral'
copyright = u'2013-2017, Adam Dybbroe'
copyright = u'2013-2018, PyTroll'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -99,7 +99,7 @@ def __getattr__(cls, name):
import pyspectral.version as current_version

# The full version, including alpha/beta/rc tags.
release = current_version.__version__
release = current_version.get_versions()['version']
# The short X.Y version.
version = ".".join(release.split(".")[: 2])

Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ color imagery.
rad_definitions
37_reflectance
rayleigh_correction
rsr_formatting
api

Indices and tables
Expand Down
18 changes: 6 additions & 12 deletions doc/rad_definitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,13 @@ we see that this is indeed true:
>>> print(round(1./wvc*1e4, 6))
0.637648

This was using the PySpectral unified HDF5 formated spectral response data. If
you want to use the original spectral response data from EUMETSAT the code may
look like this:

>>> from pyspectral.seviri_rsr import Seviri
>>> seviri = Seviri()
>>> print("Central wavelength = {cwl}".format(cwl=round(seviri.central_wavelength['VIS0.6']['Meteosat-8'], 6)))

In the PySpectral unified HDF5 formated spectral response data we also store
the central wavelength, so you actually don't have to calculate them yourself:

>>> from pyspectral.rsr_reader import RelativeSpectralResponse
>>> print("Central wavelength = {cwl}".format(cwl=round(seviri.rsr['VIS0.6']['det-1']['central_wavelength'], 6)))
Central wavelength = 0.640216
>>> seviri = Seviri(wavespace='wavenumber')
>>> print("Central wavenumber = {wvn}".format(wvn=round(seviri.central_wavenumber['VIS0.6']['Meteosat-8'], 6)))
Central wavenumber = 15682.623379
>>> print(round(1./seviri.central_wavenumber['VIS0.6']['Meteosat-8']*1e4, 6))
0.637648


Spectral Irradiance
Expand Down
143 changes: 143 additions & 0 deletions rsr_convert_scripts/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
Convert from original RSR data to pyspectral hdf5 format
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The python modules in the directory ``rsr_convert_scripts`` contain code to convert
from the original agency specific relative spectral responses to the internal
unified pyspectral format in HDF5.

This conversion should normally never be done by the user. It will only be
relevant if the original responses are updated. It that case we will need to
redo the conversion and include the updated hdf5 file in the package data on
zenodo.org.

Running the conversion scripts requires the pyspectral.yaml file to point to
the directory of the original spectral response data. For AVHRR/3 onboard
Metop-C this may look like this:

.. code-block:: ini
Metop-C-avhrr/3:
path: /home/a000680/data/SpectralResponses/avhrr
ch1: Metop_C_A309C001.txt
ch2: Metop_C_A309C002.txt
ch3a: Metop_C_A309C03A.txt
ch3b: Metop_C_A309C03B.txt
ch4: Metop_C_A309C004.txt
ch5: Metop_C_A309C005.txt
Here <path> points to the place with the response functions for each
channel. For Metop-C, the case was a bit special, as we got one file with all
bands and using wavenumber and not wavelength. Therefore we first converted the
file using script "split_metop_avhrr_rsrfile.py".

For all the other sensors supported in Pyspectral we run the conversion script
directly on the files downloaded from internet (or acquired via mail-contact).


Conversion scripts
^^^^^^^^^^^^^^^^^^

.. code::
%> python abi_rsr.py
Converting from original GOES-16&17 ABI responses. The file names look like this: ``GOES-R_ABI_PFM_SRF_CWG_ch1.txt``


.. code::
%> python avhrr_rsr.py
Converting from original Metop/NOAA AVHRR responses. The file names look like this: ``NOAA_10_A101C004.txt``

As mentioned above for Metop-C we chopped up the single original file into band
specific files to be consistent with the other AVHRRs. The original file we got
from EUMETSAT: ``AVHRR_A309_METOPC_SRF_PRELIMINARY.TXT``

.. code::
%> python mersi2_rsr.py
Converts the FY-3D MERSI-2 spectral responses. Original files acquired via
personal contact has names like this: ``FY3D_MERSI_SRF_CH01_Pub.txt``

.. code::
%> python modis_rsr.py
Converting the Terra/Aqua MODIS spectral responses to hdf5. Original Aqua MODIS files have names like this: ``01.amb.1pct.det``

Terra files have names like this: ``rsr.1.oobd.det``

.. code::
%> python olci_rsr.py
Converting the Sentinel 3A OLCI RSR data to hdf5. The original OLCI
responses comes in a single netCDF4 file: ``OLCISRFNetCDF.nc4``

.. code::
%> python seviri_rsr.py
Converting the Meteosat (second generation) SEVIRI responses to hdf5. Original
filename: ``MSG_SEVIRI_Spectral_Response_Characterisation.XLS``

.. code::
%> python slstr_rsr.py
Converting the Sentinel-3 SLSTR spectral responses to hdf5. Original responses
from ESA comes as a set of netCDF files. One file per band. Band 1:
``SLSTR_FM02_S1_20150122.nc``

.. code::
%> python viirs_rsr.py
Converting the NOAA-20 Suomi-NPP VIIRS original responses to hdf5. File names
follow 9 different naming conventions depending on the band, here as given in
the pyspectral.yaml file:

.. code-block:: ini
section1:
filename: J1_VIIRS_Detector_RSR_V2/J1_VIIRS_RSR_{bandname}_Detector_Fused_V2.txt
bands: [M1, M2, M3, M4, M5, M6, M7]
section2:
filename: J1_VIIRS_Detector_RSR_V2/J1_VIIRS_RSR_{bandname}_Detector_Fused_V2.txt
bands: [I1, I2]
section3:
filename: J1_VIIRS_V1_RSR_used_in_V2/J1_VIIRS_RSR_M8_Det_V1.txt
bands: [M8]
section4:
filename: J1_VIIRS_Detector_RSR_V2.1/J1_VIIRS_RSR_M9_Det_V2.1.txt
bands: [M9]
section5:
filename: J1_VIIRS_V1_RSR_used_in_V2/J1_VIIRS_RSR_{bandname}_Det_V1.txt
bands: [M10, M11, M12, M14, M15]
section6:
filename: J1_VIIRS_Detector_RSR_V2/J1_VIIRS_RSR_M13_Det_V2.txt
bands: [M13]
section7:
filename: J1_VIIRS_V1_RSR_used_in_V2/J1_VIIRS_RSR_M16A_Det_V1.txt
bands: [M16]
section8:
filename: J1_VIIRS_V1_RSR_used_in_V2/J1_VIIRS_RSR_{bandname}_Det_V1.txt
bands: [I3, I4, I5]
section9:
filename: J1_VIIRS_Detector_RSR_V2/J1_VIIRS_RSR_DNBLGS_Detector_Fused_V2S.txt
bands: [DNB]
Adam Dybbroe
Thu Nov 29 13:36:01 2018
6 changes: 2 additions & 4 deletions pyspectral/abi_rsr.py → rsr_convert_scripts/abi_rsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
import os
import numpy as np
from pyspectral.utils import convert2hdf5 as tohdf5

from pyspectral.raw_reader import InstrumentRSR
import logging
LOG = logging.getLogger(__name__)

LOG = logging.getLogger(__name__)

ABI_BAND_NAMES = ['ch1', 'ch2', 'ch3', 'ch4',
'ch5', 'ch6', 'ch7', 'ch8',
'ch9', 'ch10', 'ch11', 'ch12',
'ch13', 'ch14', 'ch15', 'ch16']

from pyspectral.raw_reader import InstrumentRSR


class AbiRSR(InstrumentRSR):

Expand Down
6 changes: 2 additions & 4 deletions pyspectral/avhrr_rsr.py → rsr_convert_scripts/avhrr_rsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
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__)

AVHRR_BAND_NAMES = {'avhrr/3': ['ch1', 'ch2', 'ch3a', 'ch3b', 'ch4', 'ch5'],
'avhrr/2': ['ch1', 'ch2', 'ch3', 'ch4', 'ch5'],
'avhrr/1': ['ch1', 'ch2', 'ch3', 'ch4']}


from pyspectral.raw_reader import InstrumentRSR


class AvhrrRSR(InstrumentRSR):

"""Container for the NOAA/Metop AVHRR RSR data"""
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions pyspectral/modis_rsr.py → rsr_convert_scripts/modis_rsr.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-2017 Adam.Dybbroe
# Copyright (c) 2014-2018 Adam.Dybbroe

# Author(s):

Expand All @@ -26,14 +26,12 @@
import os
import numpy as np
import logging

from pyspectral.utils import sort_data
from pyspectral.utils import get_central_wave
from pyspectral.config import get_config

LOG = logging.getLogger(__name__)


MODIS_BAND_NAMES = [str(i) for i in range(1, 37)]
SHORTWAVE_BANDS = [str(i) for i in range(1, 20) + [26]]

Expand Down Expand Up @@ -213,5 +211,6 @@ def main():
for sat in ['EOS-Terra', 'EOS-Aqua']:
convert2hdf5(sat)


if __name__ == "__main__":
main()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
import os
from xlrd import open_workbook
import numpy as np

import logging
LOG = logging.getLogger(__name__)

from pyspectral.config import get_config

import pkg_resources
import logging

LOG = logging.getLogger(__name__)
DATA_PATH = pkg_resources.resource_filename('pyspectral', 'data/')


Expand Down Expand Up @@ -269,5 +267,6 @@ def main():
generate_seviri_file(sev_obj, 'Meteosat-{0:d}'.format(satnum))
print("Meteosat-{0:d} done...".format(satnum))


if __name__ == "__main__":
main()
9 changes: 3 additions & 6 deletions pyspectral/slstr_rsr.py → rsr_convert_scripts/slstr_rsr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2016 Adam.Dybbroe
# Copyright (c) 2016, 2018 Adam.Dybbroe

# Author(s):

Expand Down Expand Up @@ -29,18 +29,15 @@

import os
from netCDF4 import Dataset

from pyspectral.utils import convert2hdf5 as tohdf5

from pyspectral.raw_reader import InstrumentRSR
import logging
LOG = logging.getLogger(__name__)

LOG = logging.getLogger(__name__)

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

from pyspectral.raw_reader import InstrumentRSR


class SlstrRSR(InstrumentRSR):

Expand Down
File renamed without changes.

0 comments on commit ba5e495

Please sign in to comment.