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

BUG: MAVEN general clean routine fix #208

Merged
merged 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion pysatNASA/instruments/maven_insitu_kp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])


# ----------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions pysatNASA/instruments/maven_sep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 15 additions & 11 deletions pysatNASA/instruments/methods/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,36 @@ 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

"""

# 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:
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
Expand Down