Skip to content

Commit

Permalink
Promote 6S factory. MET_FLAG attribute. Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
oceancolorcoder committed Aug 27, 2024
1 parent bc34f36 commit 64ea754
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
5 changes: 2 additions & 3 deletions Config/sample_SEABIRD_pySAS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"fL1bqcSpecFilterEs": 5.0,
"fL1bqcSpecFilterLi": 8.0,
"fL1bqcSpecFilterLt": 3.0,
"bL1bqcEnableQualityFlags": 0,
"bL1bqcEnableQualityFlags": 1,
"fL1bqcCloudFlag": 1.0,
"fL1bqcSignificantEsFlag": 2.0,
"fL1bqcDawnDuskFlag": 1.0,
Expand Down Expand Up @@ -148,9 +148,8 @@
"seaBASSHeaderFileName": "sample_SEABIRD_pySAS.hdr",
"bL2SaveSeaBASS": 1,
"bL2WriteReport": 1,
"bL1b_InterpPlotTimeInterp": 1,
"bL1dDeglitch": 1,
"bL2EnableQualityFlags": 0,
"bL2EnableQualityFlags": 1,
"bL2Prodoc3m": 1,
"bL2Prodkd490": 0,
"bL2Prodpic": 0,
Expand Down
2 changes: 1 addition & 1 deletion Config/sample_SEABIRD_pySAS.hdr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"south_latitude": "",
"east_longitude": "",
"west_longitude": "",
"comments": "! HyperInSPACE vers = 1.2.4\n! HyperInSPACE Config = sample_SEABIRD_pySAS.cfg\n! Rotator Home Angle = 0.0\n! Rotator Delay = 2.0\n! Pitch/Roll Filter = On\n! Max Pitch/Roll = 5.0\n! Rotator Min/Max Filter = On\n! Rotator Min = -126.0\n! Rotator Max = 42.0\n! Rel Azimuth Filter = On\n! Rel Azimuth Min = 90.0\n! Rel Azimuth Max = 135.0\n! Deglitch Filter = On\n! ES Dark Window = 11\n! ES Light Window = 5\n! ES Dark Sigma = 3.2\n! ES Light Sigma = 2.3\n! LI Dark Window = 11\n! LI Light Window = 5\n! LI Dark Sigma = 3.3\n! LI Light Sigma = 3.0\n! LT Dark Window = 11\n! LT Light Window = 13\n! LT Dark Sigma = 3.2\n! LT Light Sigma = 2.7\n! FRM Pathway = FRM_Class-based\n! Wavelength Interp Int = 3.3\n! Max Wind = 10.0\n! Min SZA = 20.0\n! Max SZA = 60.0\n! Spectral Filter = On\n! Filter Sigma Es = 5.0\n! Filter Sigma Li = 8.0\n! Filter Sigma Lt = 3.0\n! Meteorological Filter = Off\n! Cloud Flag = 1.0\n! Es Flag = 2.0\n! Dawn/Dusk Flag = 1.0\n! Rain/Humidity Flag = 1.095\n! Ensemble Interval = 300\n! Percent Lt Filter = On\n! Percent Light = 10.0\n! Remove Negatives = On",
"comments": "! HyperInSPACE vers = 1.2.4\n! HyperInSPACE Config = sample_SEABIRD_pySAS.cfg\n! Rotator Home Angle = 0.0\n! Rotator Delay = 2.0\n! Pitch/Roll Filter = On\n! Max Pitch/Roll = 5.0\n! Rotator Min/Max Filter = On\n! Rotator Min = -126.0\n! Rotator Max = 42.0\n! Rel Azimuth Filter = On\n! Rel Azimuth Min = 90.0\n! Rel Azimuth Max = 135.0\n! Deglitch Filter = On\n! ES Dark Window = 11\n! ES Light Window = 5\n! ES Dark Sigma = 3.2\n! ES Light Sigma = 2.3\n! LI Dark Window = 11\n! LI Light Window = 5\n! LI Dark Sigma = 3.3\n! LI Light Sigma = 3.0\n! LT Dark Window = 11\n! LT Light Window = 13\n! LT Dark Sigma = 3.2\n! LT Light Sigma = 2.7\n! FRM Pathway = FRM_Class-based\n! Wavelength Interp Int = 3.3\n! Max Wind = 10.0\n! Min SZA = 20.0\n! Max SZA = 60.0\n! Spectral Filter = On\n! Filter Sigma Es = 5.0\n! Filter Sigma Li = 8.0\n! Filter Sigma Lt = 3.0\n! Meteorological Filter = On\n! Cloud Flag = 1.0\n! Es Flag = 2.0\n! Dawn/Dusk Flag = 1.0\n! Rain/Humidity Flag = 1.095\n! Ensemble Interval = 300\n! Percent Lt Filter = On\n! Percent Light = 10.0\n! Remove Negatives = On",
"other_comments": "!\n! COMMENTS\n!\n! FRM4SOC-2 Field InterComparison Experiment (FICE)\n! July 11 - 21, 2022\n! Acqua Alta Oceanographic Tower (AAOT), CNR-ISMAR\n!\n! Ancillary data from: % https://www.comune.venezia.it/content/3-piattaforma-ISMAR-CNR\n! and field notes. relAz refers to target relative azimuth in pySAS.\n!\n! Home",
"missing": -9999,
"delimiter": "comma",
Expand Down
2 changes: 2 additions & 0 deletions Source/ProcessL1b_FactoryCal.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def processL1b_SeaBird(node, calibrationMap):
node.attributes["SATPYR_UNITS"] = pyrUnits

# Calculate 6S model
print('Running Py6S')

sensortype = "ES"
# Irradiance direct and diffuse ratio
res_py6s = ProcessL1b_FRMCal.get_direct_irradiance_ratio(node, sensortype)
Expand Down
13 changes: 6 additions & 7 deletions Source/ProcessL1bqc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

''' Process L1B to L1BQC '''
import numpy as np
import scipy as sp
import datetime as datetime

from Source.MainConfig import MainConfig
from Source.Utilities import Utilities
Expand Down Expand Up @@ -120,8 +119,8 @@ def ltQuality(sasGroup):

badTimes = np.unique(badTimes)
# Duplicate each element to a list of two elements in a list
''' BUG: This is not optimal as it creates one badTimes record for each bad
timestamp, rather than span of timestamps from badtimes[i][0] to badtimes[i][1]'''
# BUG: This is not optimal as it creates one badTimes record for each bad
# timestamp, rather than span of timestamps from badtimes[i][0] to badtimes[i][1]
badTimes = np.rot90(np.matlib.repmat(badTimes,2,1), 3)
msg = f'{len(np.unique(badTimes))/len(ltDatetime)*100:.1f}% of spectra flagged'
print(msg)
Expand Down Expand Up @@ -191,7 +190,6 @@ def metQualityCheck(refGroup, sasGroup, py6sGroup, ancGroup):
if li750[indx]/es750[indx] >= cloudFLAG:
badTimes.append(dateTime)
flags2[indx] = True


# Flag for significant es
# Wernand 2002
Expand All @@ -208,7 +206,7 @@ def metQualityCheck(refGroup, sasGroup, py6sGroup, ancGroup):

# Flag spectra affected by rainfall and high humidity
# Wernand 2002 (940/370), Garaba et al. 2012 also uses Es(940/370), presumably 720 was developed by Wang...???
''' Follow up on the source of this flag'''
# NOTE: Follow up on the source of this flag
if es720[indx]/es370[indx] < humidityFlag:
badTimes.append(dateTime)
flags5[indx] = True
Expand All @@ -218,7 +216,7 @@ def metQualityCheck(refGroup, sasGroup, py6sGroup, ancGroup):
msg = f'{len(np.unique(badTimes))/len(esTime)*100:.1f}% of spectra flagged (not filtered)'
print(msg)
Utilities.writeLogFile(msg)

# Restore timestamps to columns (since it's not going to filterData, where it otherwise happens)
esData.datasetToColumns()
liData.datasetToColumns()
Expand Down Expand Up @@ -719,6 +717,7 @@ def processL1bqc(node):
gp.attributes["HUMIDITY_UNITS"] = "percent"
gp.attributes["LATITUDE_UNITS"] = "dec. deg. N"
gp.attributes["LONGITUDE_UNITS"] = "dec. deg. E"
gp.attributes["MET_FLAGS"] = "1: 6S Cloud, 2: Ruddick Cloud, 3: Es, 4: Dark,s 5: Rain"
gp.attributes["PITCH_UNITS"] = "degrees"
gp.attributes["POINTING_UNITS"] = "degrees"
gp.attributes["REL_AZ_UNITS"] = "degrees"
Expand Down
7 changes: 3 additions & 4 deletions Source/ProcessL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,6 @@ def stationsEnsemblesReflectance(node, root, station=None):
rootCopy.getGroup('PY6S_MODEL').copy(root.getGroup('PY6S_MODEL'))
break


if ConfigFile.settings['SensorType'].lower() == 'seabird':
rootCopy.addGroup("ES_DARK_L1AQC")
rootCopy.addGroup("ES_LIGHT_L1AQC")
Expand Down Expand Up @@ -2112,17 +2111,17 @@ def stationsEnsemblesReflectance(node, root, station=None):
for index, stn in enumerate(stations):
# print(f'index: {index}, station: {station}, datetime: {dateTime[index]}')
# if np.isnan(station) and start == False:
if (stn != station) and (start == False):
if (stn != station) and (start is False):
start = dateTime[index]
# if not np.isnan(station) and not (start == False) and (stop == False):
if not (stn!=station) and not (start == False) and (stop == False):
if not (stn!=station) and (start is not False) and (stop is False):
stop = dateTime[index-1]
badTimes.append([start, stop])
start = False
stop = False
# End of file, no active station
# if np.isnan(station) and not (start == False) and (index == len(stations)-1):
if (stn != station) and not (start == False) and (index == len(stations)-1):
if (stn != station) and not (start is False) and (index == len(stations)-1):
stop = dateTime[index]
badTimes.append([start, stop])

Expand Down

0 comments on commit 64ea754

Please sign in to comment.