Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for VIIRS-JPSS2, add sensor specific tau_r, K_OZ, and K_NO2 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions polymer/level1_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from polymer.common import L2FLAGS
from polymer.utils import raiseflag, coeff_sun_earth_distance
from polymer.level1_meris import central_wavelength_meris
from polymer.level1_nasa import tau_r_seadas_modis, tau_r_seadas_seawifs, tau_r_seadas_viirsn, tau_r_seadas_viirsj1
from polymer.level1_nasa import tau_r_seadas_modisa, tau_r_seadas_modist, tau_r_seadas_seawifs, tau_r_seadas_viirsn, tau_r_seadas_viirsj1

# bands stored in the ASCII extractions
BANDS_MODIS = [412,443,469,488,531,547,555,645,667,678,748,859,869,1240]
Expand Down Expand Up @@ -303,13 +303,16 @@ def read_block(self, size, offset, bands):
block.altitude = np.zeros(size)

# tau_ray
if self.sensor in ['SeaWiFS', 'MODIS', 'VIIRS', 'VIIRSN', 'VIIRSJ1']:
if self.sensor in ['SeaWiFS', 'MODIS', 'MODISA', 'MODIST', 'VIIRS', 'VIIRSN', 'VIIRSJ1', 'VIIRSJ2']:
tau_r_seadas = {
'MODIS': tau_r_seadas_modis,
'MODISA': tau_r_seadas_modisa,
'MODIST': tau_r_seadas_modisb,
'SeaWiFS': tau_r_seadas_seawifs,
'VIIRS': tau_r_seadas_viirsn,
'VIIRSN': tau_r_seadas_virrsn,
'VIIRSJ1': tau_r_seadas_viirsj1
'VIIRSJ1': tau_r_seadas_viirsj1,
'VIIRSJ2': tau_r_seadas_viirsj2
}[self.sensor]
block.tau_ray = np.zeros((ysize, xsize, nbands), dtype='float32') + np.NaN
for iband, band in enumerate(bands):
Expand Down
11 changes: 10 additions & 1 deletion polymer/level1_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@ def __init__(self, dirname, blocksize=198, resolution='60',

add_noise: function (band, reflectance, sza) -> stdev_reflectance
'''
self.sensor = 'MSI'

# self.sensor = 'MSI'
fname = Path(dirname).parent.parent.name
if fname.startswith('S2A_MSIL1C') and fname.endswith('.SAFE'):
self.sensor = 'MSIA'
elif fname.startswith('S2B_MSIL1C') and fname.endswith('.SAFE'):
self.sensor = 'MSIB'
else:
self.sensor = 'MSI'

dirname = Path(dirname).resolve()
if list(dirname.glob('GRANULE')):
granules = list((dirname/'GRANULE').glob('*'))
Expand Down
81 changes: 77 additions & 4 deletions polymer/level1_nasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,25 @@


# Rayleigh optical thicknesses as defined in SeaDAS
tau_r_seadas_modis = {
# tau_r_seadas_modis = {
# 412: 3.099E-01,
# 443: 2.367E-01,
# 469: 1.914E-01,
# 488: 1.592E-01,
# 531: 1.126E-01,
# 547: 9.906E-02,
# 555: 9.432E-02,
# 645: 5.082E-02,
# 667: 4.443E-02,
# 678: 4.146E-02,
# 748: 2.849E-02,
# 859: 1.613E-02,
# 869: 1.540E-02,
# 1240: 3.617E-03,
# }

# from https://oceancolor.gsfc.nasa.gov/resources/docs/rsr_tables/
tau_r_seadas_modisa = {
412: 3.099E-01,
443: 2.367E-01,
469: 1.914E-01,
Expand All @@ -33,6 +51,24 @@
1240: 3.617E-03,
}

# from https://oceancolor.gsfc.nasa.gov/resources/docs/rsr_tables/
tau_r_seadas_modist = {
412: 3.161E-01,
443: 2.369E-01,
469: 1.914E-01,
488: 1.603E-01,
531: 1.130E-01,
547: 9.936E-02,
555: 9.432E-02,
645: 5.083E-02,
667: 4.431E-02,
678: 4.139E-02,
748: 2.842E-02,
859: 1.613E-02,
869: 1.545E-02,
1240: 3.617E-03,
}

tau_r_seadas_seawifs = {
412: 3.128E-01,
443: 2.329E-01,
Expand Down Expand Up @@ -70,6 +106,20 @@
2258: 3.285E-04,
}

# from https://oceancolor.gsfc.nasa.gov/resources/docs/rsr_tables/
tau_r_seadas_viirsj2 = {
411 : 3.205E-01,
445 : 2.307E-01,
489 : 1.573E-01,
556 : 9.338E-02,
667 : 4.307E-02,
746 : 2.791E-02,
868 : 1.528E-02,
1238: 3.618E-03,
1604: 1.266E-03,
2258: 3.327E-04,
}


def filled(A, ok=None, fill_value=np.NaN):
"""
Expand Down Expand Up @@ -144,9 +194,15 @@ def init_ancillary(self):
def init_spectral_info(self):
# NOTE: central wavelengths are from SeaDAS

if self.sensor == 'MODIS':
# if self.sensor == 'MODIS':
# bands = [412,443,469,488,531,547,555,645,667,678,748,859,869,1240,1640,2130]
# self.tau_r_seadas = tau_r_seadas_modis
if self.sensor == 'MODISA':
bands = [412,443,469,488,531,547,555,645,667,678,748,859,869,1240,1640,2130]
self.tau_r_seadas = tau_r_seadas_modis
self.tau_r_seadas = tau_r_seadas_modisa
elif self.sensor == 'MODIST':
bands = [412,443,469,488,531,547,555,645,667,678,748,859,869,1240,1640,2130]
self.tau_r_seadas = tau_r_seadas_modist
elif self.sensor == 'SeaWiFS':
self.tau_r_seadas = tau_r_seadas_seawifs
bands = [412,443,490,510,555,670,765,865]
Expand All @@ -156,6 +212,9 @@ def init_spectral_info(self):
elif self.sensor == 'VIIRSJ1':
self.tau_r_seadas = tau_r_seadas_viirsj1
bands = [411,445,489,556,667,746,868,1238,1604,2258]
elif self.sensor == 'VIIRSJ2':
self.tau_r_seadas = tau_r_seadas_viirsj2
bands = [411,445,489,556,667,746,868,1238,1604,2258]
else:
raise Exception('Invalid sensor "{}"'.format(self.sensor))

Expand Down Expand Up @@ -296,6 +355,7 @@ def __init__(self, filename, **kwargs):
sensor = {
'Suomi-NPP':'VIIRSN',
'JPSS-1': 'VIIRSJ1',
'JPSS-2': 'VIIRSJ2',
}[platform]
super(self.__class__, self).__init__(
filename, sensor=sensor, **kwargs)
Expand All @@ -309,6 +369,19 @@ def __init__(self, filename, **kwargs):
class Level1_MODIS(Level1_NASA):
''' Interface to MODIS Level-1C '''
def __init__(self, filename, **kwargs):
root = Dataset(filename)
platform = root.getncattr('platform')
sensor = {
'Aqua':'MODISA',
'Terra': 'MODIST',
}[platform]
super(self.__class__, self).__init__(
filename, sensor='MODIS', **kwargs)
filename, sensor=sensor, **kwargs)


# class Level1_MODIS(Level1_NASA):
# ''' Interface to MODIS Level-1C '''
# def __init__(self, filename, **kwargs):
# super(self.__class__, self).__init__(
# filename, sensor='MODIS', **kwargs)

48 changes: 45 additions & 3 deletions polymer/level1_olci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# -*- coding: utf-8 -*-

from .level1_safe import Level1_SAFE
from pathlib import Path

central_wavelength_olci = {
central_wavelength_olci = { # original center wavelength of POLYMER
400 : 400.664 , 412 : 412.076 ,
443 : 443.183 , 490 : 490.713 ,
510 : 510.639 , 560 : 560.579 ,
Expand All @@ -18,6 +19,38 @@
1610: 1610. , 2250: 2250. ,
}

# from https://oceancolor.gsfc.nasa.gov/resources/docs/rsr_tables/
central_wavelength_olcia = {
400 : 399.939 , 412 : 411.854 ,
443 : 442.957 , 490 : 490.469 ,
510 : 510.445 , 560 : 560.44 ,
620 : 620.393 , 665 : 665.259 ,
674 : 674.022 , 681 : 681.563 ,
709 : 709.112 , 754 : 754.184 ,
760 : 761.726 , 764 : 764.826 ,
767 : 767.917 , 779 : 779.227 ,
865 : 865.549 , 885 : 884.336 ,
900 : 899.346 , 940 : 939.306 ,
1020: 1012.932 , 1375: 1375. ,
1610: 1610. , 2250: 2250. ,
}

# from https://oceancolor.gsfc.nasa.gov/resources/docs/rsr_tables/
central_wavelength_olcib = {
400 : 400.33 , 412 : 411.944 ,
443 : 443.003 , 490 : 490.384 ,
510 : 510.379 , 560 : 560.357 ,
620 : 620.267 , 665 : 665.117 ,
674 : 673.864 , 681 : 681.382 ,
709 : 708.975 , 754 : 754.029 ,
760 : 761.56 , 764 : 764.692 ,
767 : 767.821 , 779 : 779.083 ,
865 : 865.391 , 885 : 884.159 ,
900 : 899.16 , 940 : 939.137 ,
1020: 1012.824 , 1375: 1375. ,
1610: 1610. , 2250: 2250. ,
}


def Level1_OLCI(dirname,
sline=0, eline=-1,
Expand Down Expand Up @@ -45,7 +78,16 @@ def Level1_OLCI(dirname,
# central wavelength of the detector (for normalization)
# (detector 374 of camera 3)

central_wavelength = central_wavelength_olci
fname = Path(dirname).name
if fname.startswith('S3A_OL_1') and fname.endswith('.SEN3'):
central_wavelength = central_wavelength_olcia
sensor = 'OLCIA'
elif fname.startswith('S3B_OL_1') and fname.endswith('.SEN3'):
central_wavelength = central_wavelength_olcib
sensor = 'OLCIB'
else:
central_wavelength = central_wavelength_olci
sensor = 'OLCI'

band_names = {
400 : 'Oa01_radiance', 412 : 'Oa02_radiance',
Expand Down Expand Up @@ -95,7 +137,7 @@ def Level1_OLCI(dirname,
ancillary=ancillary,
landmask=landmask,
altitude=altitude,
sensor='OLCI',
sensor=sensor,
central_wavelength=central_wavelength,
band_names=band_names,
band_index=band_index,
Expand Down
Loading