From 273e1767509759c8625456780ae423de5aad4fa7 Mon Sep 17 00:00:00 2001 From: billmills Date: Sun, 16 Jul 2023 12:29:26 -0400 Subject: [PATCH] less dumb variable identification --- wodpy/wodnc.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/wodpy/wodnc.py b/wodpy/wodnc.py index c7b29d4..0a1b3ca 100644 --- a/wodpy/wodnc.py +++ b/wodpy/wodnc.py @@ -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() @@ -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