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 a few new metadata variables in tempo for QC and BC #1597

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
32 changes: 30 additions & 2 deletions src/compo/tempo_nc2ioda.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ def _read(self):
AttrData['sensor'] = ncd.getncattr('project')
AttrData['platform'] = ncd.getncattr('platform')

# coordinates and mask
# coordinates, mask and RT parameters for BC
lats = ncd.groups['geolocation'].variables['latitude'][:].ravel()
lons = ncd.groups['geolocation'].variables['longitude'][:].ravel()
sza = ncd.groups['geolocation'].variables['solar_zenith_angle'][:].ravel()
vza = ncd.groups['geolocation'].variables['viewing_zenith_angle'][:].ravel()
albedo = ncd.groups['support_data'].variables['albedo'][:].ravel()
qc_flag = ncd.groups['support_data'].variables['ground_pixel_quality_flag'][:]\
.ravel()
cld_fra = ncd.groups['support_data'].variables['eff_cloud_fraction'][:]\
Expand All @@ -110,6 +113,12 @@ def _read(self):
cld_fra.mask = False
cld_fra = np.ma.array(cld_fra, mask=mask)
qa_value = np.ma.array(qa_value, mask=mask)
sza.mask = False
sza = np.ma.array(sza, mask=mask)
vza.mask = False
vza = np.ma.array(vza, mask=mask)
albedo.mask = False
albedo = np.ma.array(albedo, mask=mask)

# adding ability to pre filter the data using the qa value
# and also perform thinning using random uniform draw
Expand Down Expand Up @@ -234,6 +243,9 @@ def _read(self):
print('flg: ', np.shape(flg))
print('qa_value: ', np.shape(qa_value))
print('cld_fra: ', np.shape(cld_fra))
print('sza: ', np.shape(sza))
print('vza: ', np.shape(vza))
print('albedo: ', np.shape(albedo))
print('qc_flag: ', np.shape(qc_flag))
print('obs: ', np.shape(obs))
print('err: ', np.shape(err))
Expand All @@ -247,6 +259,9 @@ def _read(self):
flg = np.ma.compressed(flg)
qa_value = np.ma.compressed(qa_value).astype('float32')
cld_fra = np.ma.compressed(cld_fra).astype('float32')
sza = np.ma.compressed(sza).astype('float32')
vza = np.ma.compressed(vza).astype('float32')
albedo = np.ma.compressed(albedo).astype('float32')
qc_flag = np.ma.compressed(qc_flag).astype('int32')
obs = np.ma.compressed(obs).astype('float32')
err = np.ma.compressed(err).astype('float32')
Expand All @@ -266,6 +281,9 @@ def _read(self):
print('flg: ', np.shape(flg))
print('qa_value: ', np.shape(qa_value))
print('cld_fra: ', np.shape(cld_fra))
print('sza: ', np.shape(sza))
print('vza: ', np.shape(vza))
print('albedo: ', np.shape(albedo))
print('qc_flag: ', np.shape(qc_flag))
print('obs: ', np.shape(obs))
print('err: ', np.shape(err))
Expand All @@ -278,6 +296,9 @@ def _read(self):
self.outdata[('longitude', 'MetaData')] = lons[flg]
self.outdata[('quality_assurance_value', 'MetaData')] = qa_value[flg]
self.outdata[('cloud_fraction', 'MetaData')] = cld_fra[flg]
self.outdata[('solar_zenith_angle', 'MetaData')] = sza[flg]
Copy link
Contributor

Choose a reason for hiding this comment

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

are these the right IODA names? I thought snake case was frowned upon?

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks @CoryMartin-NOAA ,, you are correct the name to use is:
solarZenithAngle

https://github.com/JCSDA-internal/ioda/blob/202aafb341afdd667562ded96447abb34199bf43/share/ioda/yaml/validation/ObsSpace.yaml#L955

note the first name in the list is the current standard with the other names ones that would be changed into the leading entry if the upgrader were run something like:

${JEDI_BUILD}/bin/ioda-upgrade-v2-to-v3.x ${ioda_v2} ${ioda_v3} ${JEDI_SRC}/ioda/share/ioda/yaml/validation/ObsSpace.yaml

self.outdata[('viewing_zenith_angle', 'MetaData')] = vza[flg]
self.outdata[('albedo', 'MetaData')] = albedo[flg]
self.outdata[('averagingKernel', 'RetrievalAncillaryData')] = avg_kernel[flg]
self.outdata[('pressureVertice', 'RetrievalAncillaryData')] = preslev[flg]
self.outdata[self.varDict[iodavar]['valKey']] = obs[flg]
Expand All @@ -294,6 +315,12 @@ def _read(self):
self.outdata[('quality_assurance_value', 'MetaData')], qa_value[flg]))
self.outdata[('cloud_fraction', 'MetaData')] = np.concatenate((
self.outdata[('cloud_fraction', 'MetaData')], cld_fra[flg]))
self.outdata[('solar_zenith_angle', 'MetaData')] = np.concatenate((
self.outdata[('solar_zenith_angle', 'MetaData')], sza[flg]))
self.outdata[('viewing_zenith_angle', 'MetaData')] = np.concatenate((
self.outdata[('viewing_zenith_angle', 'MetaData')], vza[flg]))
self.outdata[('albedo', 'MetaData')] = np.concatenate((
self.outdata[('albedo', 'MetaData')], albedo[flg]))
self.outdata[('averagingKernel', 'RetrievalAncillaryData')] = np.concatenate((
self.outdata[('averagingKernel', 'RetrievalAncillaryData')], avg_kernel[flg]))
self.outdata[('pressureVertice', 'RetrievalAncillaryData')] = np.concatenate((
Expand Down Expand Up @@ -367,6 +394,7 @@ def main():
optional.add_argument(
'-v3', '--version3',
action='store_true',
default=True,
help='Read V3 files and not V2 files')

args = parser.parse_args()
Expand All @@ -384,7 +412,7 @@ def main():
if args.column == "troposphere" or args.column == "stratosphere":

obsVar = {
var_name+'_'+args.column+'spheric_column': var_name+'Column'
var_name+'_'+args.column+'_column': var_name+'Column'
}

varDims = {
Expand Down