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

Remove obsolate subsetting in Calc.load #284

Merged
merged 1 commit into from
Jun 12, 2018
Merged
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
36 changes: 1 addition & 35 deletions aospy/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,38 +621,8 @@ def _load_from_tar(self, dtype_out_time, dtype_out_vert=False):
)
return ds[self.name]

def _get_data_subset(self, data, region=False, time=False,
vert=False, lat=False, lon=False):
"""Subset the data array to the specified time/level/lat/lon, etc."""
if region:
raise NotImplementedError
if np.any(time):
data = data[time]
if 'monthly_from_' in self.dtype_in_time:
data = np.mean(data, axis=0)[np.newaxis, :]
if np.any(vert):
if self.dtype_in_vert == internal_names.ETA_STR:
data = data[{PFULL_STR: vert}] # flake8: noqa
else:
if np.max(self.model.level) > 1e4:
# Convert from Pa to hPa.
lev_hpa = self.model.level*1e-2
else:
lev_hpa = self.model.level
level_index = np.where(lev_hpa == self.level)
if 'ts' in self.dtype_out_time:
data = np.squeeze(data[:, level_index])
else:
data = np.squeeze(data[level_index])
if np.any(lat):
raise NotImplementedError
if np.any(lon):
raise NotImplementedError
return data

def load(self, dtype_out_time, dtype_out_vert=False, region=False,
time=False, vert=False, lat=False, lon=False, plot_units=False,
mask_unphysical=False):
plot_units=False, mask_unphysical=False):
"""Load the data from the object if possible or from disk."""
msg = ("Loading data from disk for object={0}, dtype_out_time={1}, "
"dtype_out_vert={2}, and region="
Expand All @@ -670,10 +640,6 @@ def load(self, dtype_out_time, dtype_out_vert=False, region=False,
data = self._load_from_tar(dtype_out_time, dtype_out_vert)
# Copy the array to self.data_out for ease of future access.
self._update_data_out(data, dtype_out_time)
# Subset the array and convert units as desired.
if any((time, vert, lat, lon)):
data = self._get_data_subset(data, region=False, time=time,
vert=vert, lat=lat, lon=lon)
# Apply desired plotting/cleanup methods.
if mask_unphysical:
data = self.var.mask_unphysical(data)
Expand Down