Skip to content

Commit

Permalink
STY: update clean routine
Browse files Browse the repository at this point in the history
  • Loading branch information
jklenzing committed Oct 2, 2023
1 parent 8474d74 commit a5a4672
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pysatNASA/instruments/methods/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a5a4672

Please sign in to comment.