Skip to content

Commit

Permalink
update to SHADOZ 6 model
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Sep 6, 2024
1 parent 6669906 commit 0d8f04f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
44 changes: 23 additions & 21 deletions woudc_formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
Press = ''
else:
Press = format(Press, '.3f')
O3PP = row[s.get_data_index('O3', 'mPa')]
O3PP = row[s.get_data_index('O3_mPa', 'mPa')]
if (type(O3PP) is str and '*' in O3PP) or str(int(round(float(O3PP)))) == bad_value: # noqa
O3PP = ''
else:
Expand All @@ -124,20 +124,20 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
Temp = ''
else:
Temp = format(Temp, '.3f')
WSPD = row[s.get_data_index('W Spd', 'm/s')]
WSPD = row[s.get_data_index('Wind_Spd', 'm/s')]
if (type(WSPD) is str and '*' in WSPD) or str(int(round(float(WSPD)))) == bad_value: # noqa
WSPD = ''
else:
WSPD = format(WSPD, '.3f')
WDIR = row[s.get_data_index('W Dir')]
WDIR = row[s.get_data_index('Wind_Dir')]
if (type(WDIR) is str and '*' in WDIR) or str(int(round(float(WDIR)))) == bad_value: # noqa
WDIR = ''
else:
WDIR = format(WDIR, '.3f')
Duration = str(row[s.get_data_index('Time', 'sec')])
if '*' in Duration or str(int(round(float(Duration)))) == bad_value: # noqa
Duration = ''
GPHeight = row[s.get_data_index('Alt', 'km')]
GPHeight = row[s.get_data_index('GeopAlt', 'km')]
if (type(GPHeight) is str and '*' in GPHeight) or str(int(round(float(GPHeight)))) == bad_value: # noqa
GPHeight = ''
else:
Expand All @@ -147,7 +147,7 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
RelativeHumidity = ''
else:
RelativeHumidity = format(RelativeHumidity, '.3f')
SampleTemperature = row[s.get_data_index('T Pump')]
SampleTemperature = row[s.get_data_index('TPump')]
if (type(SampleTemperature) is str and '*' in SampleTemperature) or str(int(round(float(SampleTemperature)))) == bad_value: # noqa
SampleTemperature = ''
else:
Expand Down Expand Up @@ -189,6 +189,7 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
station = station_name
else:
try:
print("M", s.metadata.keys())
number = s.metadata['STATION'].index(',')
station = s.metadata['STATION'][0:number]
except Exception as err:
Expand Down Expand Up @@ -264,9 +265,9 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
launch_date,
launch_time]

if 'Integrated O3 until EOF (DU)' in s.metadata:
if 'Integrated O3 to end of data (DU)' in s.metadata:
self.station_info['Flight_Summary'] = [
str(s.metadata['Integrated O3 until EOF (DU)']),
str(s.metadata['Integrated O3 to end of data (DU)']),
'', '', '', '', '', '', '', '']

elif 'Final Integrated O3 (DU)' in s.metadata:
Expand All @@ -276,9 +277,9 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):

radiosonde = ''
try:
idx = str(s.metadata['Radiosonde, SN']).index(',')
radiosonde = str(s.metadata['Radiosonde, SN'])[0:idx]
except Exception as err:
idx = str(s.metadata['Radiosonde Serial Number']).index(',')
radiosonde = str(s.metadata['Radiosonde Serial Number'])[0:idx]
except RuntimeError as err:
msg = 'Radiosonde invalid value or not found in file'
LOGGER.error(msg)
LOGGER.warning(err)
Expand All @@ -292,24 +293,24 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
radiosonde.replace(',', ''),
str(s.metadata['Sonde/Sage Climatology(1988-2002)']).replace(',', ''), # noqa
background_current.replace(',', ''),
str(s.metadata['Pump flow rate (sec/100ml)']).replace(',', ''),
str(s.metadata['Applied pump corrections']).replace(',', ''),
str(s.metadata['Pump flowrate (sec/100ml)']).replace(',', ''),
str(s.metadata['Applied pump efficiency factors']).replace(',', ''),
str(s.metadata['KI Solution']).replace(',', '')]
elif 'Sonde/MLS Climatology(1988-2010)' in s.metadata:
self.station_info['Auxiliary_Data'] = [
radiosonde.replace(',', ''),
str(s.metadata['Sonde/MLS Climatology(1988-2010)']).replace(',', ''), # noqa
background_current.replace(',', ''),
str(s.metadata['Pump flow rate (sec/100ml)']).replace(',', ''),
str(s.metadata['Applied pump corrections']).replace(',', ''),
str(s.metadata['Pump flowrate (sec/100ml)']).replace(',', ''),
str(s.metadata['Applied pump efficiency factors']).replace(',', ''),
str(s.metadata['KI Solution']).replace(',', '')]
else:
self.station_info['Auxiliary_Data'] = [
radiosonde.replace(',', ''),
'',
background_current.replace(',', ''),
str(s.metadata['Pump flow rate (sec/100ml)']).replace(',', ''),
str(s.metadata['Applied pump corrections']).replace(',', ''),
str(s.metadata['Pump flowrate (sec/100ml)']).replace(',', ''),
str(s.metadata['Applied pump efficiency factors']).replace(',', ''),
str(s.metadata['KI Solution']).replace(',', '')]

try:
Expand All @@ -320,6 +321,7 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
LOGGER.error(msg)
return False, msg

print("TOM", station_metadata)
# Collecting station metadata by using pywoudc
# Station name and agency name is required to find
# Station metadata from pywoudc
Expand All @@ -331,7 +333,7 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):
temp_dict[item] = ''
# Pre set an empty dictionary, if user passed in
# this specified information, insert into dictionary
if item in metadata_dic.keys():
if item in metadata_dic:
temp_dict[item] = metadata_dic[item]

try:
Expand Down Expand Up @@ -380,12 +382,12 @@ def parser(self, file_content, station_name, agency_name, metadata_dic):

key = ''
if inst_model == 'UNKNOWN' and inst_number == 'UNKNOWN':
if ',' in str(s.metadata['Sonde Instrument, SN']) or ' ' in str(s.metadata['Sonde Instrument, SN']).strip(): # noqa
key = re.split(',| ', str(s.metadata['Sonde Instrument, SN']).strip()) # noqa
if ',' in str(s.metadata['Ozonesonde Instrument']) or ' ' in str(s.metadata['Ozonesonde Instrument']).strip(): # noqa
key = re.split(',| ', str(s.metadata['Ozonesonde Instrument']).strip()) # noqa
key = key[len(key) - 1]
else:
key = str(s.metadata['Sonde Instrument, SN']).strip()
if str(s.metadata['Sonde Instrument, SN']) == bad_value:
key = str(s.metadata['Ozonesonde Instrument']).strip()
if str(s.metadata['Ozonesonde Instrument']) == bad_value:
inst_model = 'UNKNOWN'
inst_number = 'UNKNOWN'
else:
Expand Down
1 change: 1 addition & 0 deletions woudc_formats/resource.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ PLATFORM.San Cristobal Is., Galapagos : SAN CRISTOBAL
PLATFORM.Pago Pago, American Samoa : SAMOA
PLATFORM.La Reunion, France : LA REUNION ISLAND
PLATFORM.San Marco Station - Malindi, Kenya : MALINDI
PLATFORM.Ascension Island : Ascension Island

[NDACC]
host: ftp.cpc.ncep.noaa.gov
Expand Down

0 comments on commit 0d8f04f

Please sign in to comment.