From a5a46720bd65ccf35792a3d0223bd30f2a3adc63 Mon Sep 17 00:00:00 2001 From: Jeff Klenzing Date: Mon, 2 Oct 2023 11:37:30 -0400 Subject: [PATCH 1/4] STY: update clean routine --- pysatNASA/instruments/methods/general.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pysatNASA/instruments/methods/general.py b/pysatNASA/instruments/methods/general.py index 8dee2bbe..26dc293f 100644 --- a/pysatNASA/instruments/methods/general.py +++ b/pysatNASA/instruments/methods/general.py @@ -51,9 +51,14 @@ def init(self, module, name): return -def clean(self): +def clean(self, skip_names=None): """Clean data to the specified level. + Parameters + ---------- + skip_names : list of str + List of names to skip for cleaning. (default=None) + Note ---- Basic cleaning to replace fill values with NaN @@ -62,21 +67,20 @@ def clean(self): # Get a list of coords for the data if self.pandas_format: - coords = [self.data.index.name] + skip_key = [self.data.index.name] else: - coords = [key for key in self.data.coords.keys()] + skip_key = [key for key in self.data.coords.keys()] + + if skip_names: + # Add additional variable names to skip + for key in skip_names: + skip_key.append(key) for key in self.variables: # Check for symmetric dims # Indicates transformation matrix, xarray cannot broadcast - if self.pandas_format: - # True by default - unique_dims = True - else: - # Check for multiple dims - unique_dims = len(self[key].dims) == len(np.unique(self[key].dims)) # Skip over the coordinates when cleaning - if key not in coords and unique_dims: + if key not in skip_key: fill = self.meta[key, self.meta.labels.fill_val] # Replace fill with nan From c8a27a6226e3f39b1c17cca3e2643a27c59769c2 Mon Sep 17 00:00:00 2001 From: Jeff Klenzing Date: Mon, 2 Oct 2023 11:42:31 -0400 Subject: [PATCH 2/4] STY: apply to insitu kp --- pysatNASA/instruments/maven_insitu.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pysatNASA/instruments/maven_insitu.py b/pysatNASA/instruments/maven_insitu.py index dda55d99..229bdf78 100644 --- a/pysatNASA/instruments/maven_insitu.py +++ b/pysatNASA/instruments/maven_insitu.py @@ -61,7 +61,9 @@ # Use default clean -clean = mm_nasa.clean +clean = functools.partial(mm_nasa.clean, + skip_names=['Rotation_matrix_IAU_MARS_MAVEN_MSO', + 'Rotation_matrix_SPACECRAFT_MAVEN_MSO']) # ---------------------------------------------------------------------------- From 857d8483bc6f40a1c86386c8853895f7e2700085 Mon Sep 17 00:00:00 2001 From: Jeff Klenzing Date: Mon, 2 Oct 2023 13:08:36 -0400 Subject: [PATCH 3/4] DOC: update comments --- pysatNASA/instruments/methods/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysatNASA/instruments/methods/general.py b/pysatNASA/instruments/methods/general.py index 26dc293f..16326279 100644 --- a/pysatNASA/instruments/methods/general.py +++ b/pysatNASA/instruments/methods/general.py @@ -65,7 +65,7 @@ def clean(self, skip_names=None): """ - # Get a list of coords for the data + # Get a list of coords for the data. These should be skipped for cleaning. if self.pandas_format: skip_key = [self.data.index.name] else: From 7ba9ffbdf8202da1b70ac932cbf9980f22c42a02 Mon Sep 17 00:00:00 2001 From: Jeff Klenzing Date: Mon, 2 Oct 2023 13:11:11 -0400 Subject: [PATCH 4/4] BUG: fix test dates --- pysatNASA/instruments/maven_sep.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pysatNASA/instruments/maven_sep.py b/pysatNASA/instruments/maven_sep.py index 3ce0ca4b..53deca1a 100644 --- a/pysatNASA/instruments/maven_sep.py +++ b/pysatNASA/instruments/maven_sep.py @@ -23,9 +23,10 @@ :: import pysat - insitu = pysat.Instrument(platform='maven', name='sep', inst_id = 's1') + insitu = pysat.Instrument(platform='maven', name='sep', inst_id='s1') insitu.download(dt.datetime(2020, 1, 1), dt.datetime(2020, 1, 31)) - insitu.load(2020, 1, use_header = True) + insitu.load(2020, 1, use_header=True) + """ import datetime as dt @@ -49,7 +50,7 @@ # ---------------------------------------------------------------------------- # Instrument test attributes -_test_dates = {'': {'': dt.datetime(2020, 1, 1)}} +_test_dates = {id: {'': dt.datetime(2020, 1, 1)} for id in inst_ids.keys()} # ---------------------------------------------------------------------------- # Instrument methods