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

Config and mapping files for ADPUPA prepBUFR #17

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
20 changes: 10 additions & 10 deletions dump/mapping/bufr_adpupa_prepbufr.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def logging(comm, level, message):
log_method(message)


def Compute_dateTime(cycleTimeSinceEpoch, hrdr):
def _compute_datetime(cycleTimeSinceEpoch, hrdr):

int64_fill_value = np.int64(0)
dateTime = np.zeros(hrdr.shape, dtype=np.int64)
Expand All @@ -96,7 +96,7 @@ def Compute_dateTime(cycleTimeSinceEpoch, hrdr):
return dateTime


def Mask_typ_for_var(typ, var):
def _mask_typ_for_var(typ, var):

typ_var = copy.deepcopy(typ)
for i in range(len(typ_var)):
Expand All @@ -109,7 +109,7 @@ def Mask_typ_for_var(typ, var):
def _make_description(mapping_path, cycle_time, update=False):
description = bufr.encoders.Description(mapping_path)

ReferenceTime = np.int64(calendar.timegm(time.strptime(str(int(cycle_time)), '%Y%m%d%H')))
reference_time = np.int64(calendar.timegm(time.strptime(str(int(cycle_time)), '%Y%m%d%H')))

if update:
# Define the variables to be added in a list of dictionaries
Expand All @@ -131,7 +131,7 @@ def _make_description(mapping_path, cycle_time, update=False):
longName=var['longName']
)

description.add_global(name='datetimeReference', value=str(ReferenceTime))
description.add_global(name='datetimeReference', value=str(reference_time))

return description

Expand Down Expand Up @@ -163,30 +163,30 @@ def _make_obs(comm, input_path, mapping_path, cycle_time):

logging(comm, 'DEBUG', f'Do DateTime calculation')
hrdr = container.get('variables/obsTimeMinusCycleTime')
hrdr_paths = container.get_paths('variables/obsTimeMinusCycleTime')
#hrdr_paths = container.get_paths('variables/obsTimeMinusCycleTime')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete commented out code, this example and the following ones..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmclaren thanks, deleted all the commented lines.

cycleTimeSinceEpoch = np.int64(calendar.timegm(time.strptime(str(int(cycle_time)), '%Y%m%d%H')))
dateTime = Compute_dateTime(cycleTimeSinceEpoch, hrdr)
dateTime = _compute_datetime(cycleTimeSinceEpoch, hrdr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result of dateTime doesn't seem to be used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmclaren thanks, reading dateTime now.

logging(comm, 'DEBUG', f'dateTime min/max = {dateTime.min()} {dateTime.max()}')

logging(comm, 'DEBUG', f'Change longitude range from [0,360] to [-180,180]')
lon = container.get('variables/longitude')
lon_paths = container.get_paths('variables/longitude')
#lon_paths = container.get_paths('variables/longitude')
lon[lon>180] -= 360

logging(comm, 'DEBUG', f'observationType')
typ = container.get('variables/observationType')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typ doesn't seem to be used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmclaren thanks, fixed.

typ_paths = container.get_paths('variables/observationType')
#typ_paths = container.get_paths('variables/observationType')

logging(comm, 'DEBUG', f'Do ps calculation')
pob = container.get('variables/pressure')
pob_paths = container.get_paths('variables/pressure')
#pob_paths = container.get_paths('variables/pressure')
ps = np.full(pob.shape[0], pob.fill_value)
ps = np.where(cat == 0, pob, ps)

logging(comm, 'DEBUG', f'Do tsen and tv calculation')
tpc = container.get('variables/temperatureEventProgramCode')
tob = container.get('variables/airTemperature')
tob_paths = container.get_paths('variables/airTemperature')
#tob_paths = container.get_paths('variables/airTemperature')
tsen = np.full(tob.shape[0], tob.fill_value)
tsen = np.where(((tpc >= 1) & (tpc < 8)), tob, tsen)
tvo = np.full(tob.shape[0], tob.fill_value)
Expand Down
18 changes: 9 additions & 9 deletions dump/mapping/bufr_adpupa_prepbufr_mapping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,25 @@ encoder:
type: netcdf

globals:
- name: "data_format"
- name: "dataOriginalFormatSpec"
type: string
value: "prepbufr"

- name: "data_type"
- name: "platforms"
type: string
value: "ADPUPA"

- name: "subsets"
- name: "source"
type: string
value: "ADPUPA"

- name: "data_provider"
type: string
value: "U.S. NOAA"
value: "prepBUFR"

- name: "data_description"
- name: "description"
type: string
value: "UPPER-AIR (RAOB, PIBAL, RECCO, DROPS) REPORTS"

- name: "dataProviderOrigin"
type: string
value: "U.S. NOAA NCEP"

variables:
# Observation Type: stationPressure
Expand Down Expand Up @@ -369,3 +368,4 @@ encoder:
- name: "ObsError/specificHumidity"
source: variables/specificHumidityError
longName: "Specific Humidity Error"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have a unit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicholasesposito thanks, added unit for specificHumidity.

units: "kg kg-1"