Skip to content

Commit

Permalink
a working version
Browse files Browse the repository at this point in the history
  • Loading branch information
xincjin-NOAA committed Jun 5, 2024
1 parent 923353b commit 05d81bc
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 47 deletions.
34 changes: 16 additions & 18 deletions ush/ioda/bufr2ioda/bufr2ioda_ncep_1bamua_ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bufr:
hour: '*/HOUR'
minute: '*/MINU'
month: '*/MNTH'
second: '*/SECO'
year: '*/YEAR'
encoder:
backend: netcdf
Expand All @@ -61,24 +62,6 @@ encoder:
value: MTYP 021-023 PROC AMSU-A 1B Tb
obsdataout: temporary_ta_{splits/satId}_1716389684.nc
variables:
- longName: Datetime
name: MetaData/dateTime
source: variables/timestamp
units: seconds since 1970-01-01T00:00:00Z
- longName: Latitude
name: MetaData/latitude
range:
- -90
- 90
source: variables/latitude
units: degree_north
- longName: Longitude
name: MetaData/longitude
range:
- -180
- 180
source: variables/longitude
units: degree_east
- longName: Satellite Identifier
name: MetaData/satelliteIdentifier
source: variables/satelliteIdentifier
Expand Down Expand Up @@ -135,3 +118,18 @@ encoder:
- 380
source: variables/brightnessTemperature
units: K
- longName: Datetime
name: MetaData/dateTime
source: variables/timestamp
units: seconds since 1970-01-01T00:00:00Z
- longName: Latitude
name: MetaData/latitude
range:
- -90
- 90
source: variables/latitude
units: degree_north
- longName: Longitude
name: MetaData/longitude
source: variables/longitude
units: degree_east
34 changes: 16 additions & 18 deletions ush/ioda/bufr2ioda/bufr2ioda_ncep_esamua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bufr:
hour: '*/HOUR'
minute: '*/MINU'
month: '*/MNTH'
second: '*/SECO'
year: '*/YEAR'
encoder:
backend: netcdf
Expand All @@ -61,24 +62,6 @@ encoder:
value: MTYP 021-033 RARS(EARS,AP,SA) AMSU-A 1C Tb DATA)
obsdataout: temporary_es_{splits/satId}_1716389684.nc
variables:
- longName: Datetime
name: MetaData/dateTime
source: variables/timestamp
units: seconds since 1970-01-01T00:00:00Z
- longName: Latitude
name: MetaData/latitude
range:
- -90
- 90
source: variables/latitude
units: degree_north
- longName: Longitude
name: MetaData/longitude
range:
- -180
- 180
source: variables/longitude
units: degree_east
- longName: Satellite Identifier
name: MetaData/satelliteIdentifier
source: variables/satelliteIdentifier
Expand Down Expand Up @@ -136,3 +119,18 @@ encoder:
- 500
source: variables/brightnessTemperature
units: K
- longName: Datetime
name: MetaData/dateTime
source: variables/timestamp
units: seconds since 1970-01-01T00:00:00Z
- longName: Latitude
name: MetaData/latitude
range:
- -90
- 90
source: variables/latitude
units: degree_north
- longName: Longitude
name: MetaData/longitude
source: variables/longitude
units: degree_east
18 changes: 11 additions & 7 deletions ush/ioda/bufr2ioda/bufr2ioda_ssmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'longitude': {'query': '*/CLON'},
'orbitNumber': {'query': '*/ORBN'},
'rainFlag': {'query': '*/RFLAG'},
'scanAngle': {'query': '*/SCLINGEO/RAIA'},
'remappedBT': {'remappedBrightnessTemperature': {'brightnessTemperature': '*/SSMISCHN/TMBR',
'fieldOfViewNumber': '*/FOVN',
'obsTime': {'day': '*/DAYS',
Expand Down Expand Up @@ -78,6 +79,9 @@
{'longName': 'Sensor Channel Number',
'name': 'MetaData/sensorChannelNumber',
'source': 'variables/sensorChannelNumber'},
{'longName': 'Sensor Scan Angle',
'name': 'MetaData/sensorScanAngle',
'source': 'variables/scanAngle'},
{'chunks': [10000, 22],
'longName': '3-by-3 Averaged Brightness '
'Temperature',
Expand All @@ -94,13 +98,13 @@ def __init__(self, *args, **kwargs):
self.update_config(config_json)
self.yaml_config = ssmis_yaml

def re_map_variable(self):

for sat_id in self.sat_ids:
logger.info(f'Converting for {sat_id}, ...')
ta = self.get_container_variable('variables', 'brightnessTemperature', sat_id)
tb = self.apply_corr(ta)
self.replace_container_variable('variables', 'brightnessTemperature', tb, sat_id)
# def re_map_variable(self):
#
# for sat_id in self.sat_ids:
# logger.info(f'Converting for {sat_id}, ...')
# ta = self.get_container_variable('variables', 'brightnessTemperature', sat_id)
# tb = self.apply_corr(ta)
# self.replace_container_variable('variables', 'brightnessTemperature', tb, sat_id)

def apply_corr(self, ta):
ta = ta * 100
Expand Down
5 changes: 5 additions & 0 deletions ush/ioda/bufr2ioda/bufr2ioda_ssmis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ bufr:
query: '*/ORBN'
rainFlag:
query: '*/RFLAG'
scanAngle:
query: '*/SCLINGEO/RAIA'
remappedBT:
remappedBrightnessTemperature:
brightnessTemperature: '*/SSMISCHN/TMBR'
Expand Down Expand Up @@ -68,6 +70,9 @@ encoder:
- longName: Sensor Channel Number
name: MetaData/sensorChannelNumber
source: variables/sensorChannelNumber
- longName: Sensor Scan Angle
name: MetaData/sensorScanAngle
source: variables/scanAngle
- chunks:
- 10000
- 22
Expand Down
4 changes: 2 additions & 2 deletions ush/ioda/bufr2ioda/combine_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def get_container_variable(self, group, variable, sat_id):
def replace_container_variable(self, group, variable, var, sat_id):
self.container.replace(group + '/' + variable, var, [sat_id, ])

def add_container_variable(self, group, variable, var, sat_id):
self.container.replace(group + '/' + variable, var, [sat_id, ])
def add_container_variable(self, group, variable, var, path, sat_id):
self.container.replace(group + '/' + variable, var, path, [sat_id, ])

def get_yaml_file(self):
return self.config['yaml_file']
Expand Down
8 changes: 6 additions & 2 deletions ush/ioda/bufr2ioda/run_bufr_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

from wxflow import Logger, parse_j2yaml, cast_strdict_as_dtypedict
from bufr2ioda_ssmis import Bufr2IodaSsmis
from bufr2ioda_ncep_1bmusa import Bufr2IodaAmusa
from bufr2ioda_ncep_esamua import Bufr2IodaEsamusa

# Initialize root logger
logger = Logger('gen_bufr2ioda_json.py', level='INFO', colored_log=True)

bufr_classes = [
Bufr2IodaSsmis,
# Bufr2IodaSsmis,
Bufr2IodaAmusa,
Bufr2IodaEsamusa,
]

config = {
Expand All @@ -22,7 +26,7 @@


if __name__ == "__main__":

#TODO mp
for bufr_class in bufr_classes:
converter = bufr_class(config)
converter.execute()
Expand Down

0 comments on commit 05d81bc

Please sign in to comment.