Skip to content

Commit

Permalink
Merge pull request #36 from BillMills/post-meeting
Browse files Browse the repository at this point in the history
identifying level variables in netcdf
  • Loading branch information
bkatiemills authored Jul 16, 2023
2 parents 04adfe9 + 488b212 commit df12c77
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions wodpy/wodnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def ncasts(self):
def variables(self):
return self.rootgrp.variables

def dimensions(self):
return self.rootgrp.dimensions

def attributes(self):
return self.rootgrp.ncattrs()

Expand Down Expand Up @@ -124,15 +127,9 @@ def is_level_data(self, data_key):
returns true if data_key looks like per level data
'''

if data_key in self.r.variables():
try:
if len(self.r.variables()[data_key]) != self.r.ncasts():
return True
else:
return False
except:
logging.warning(data_key + ' neither profile metadata nor level data.')
return False
if data_key + '_obs' in self.r.dimensions():
# per level data should have a *_obs dimension
return True
else:
logging.warning(data_key + ' not found in this dataset.')
return False
Expand Down

0 comments on commit df12c77

Please sign in to comment.