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

Update read module coordinate dimension manipulations to use new xarray index #473

Merged
merged 15 commits into from
Nov 27, 2023
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
28 changes: 12 additions & 16 deletions icepyx/core/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class Read:

# ----------------------------------------------------------------------
# Constructors

def __init__(
self,
data_source=None, # DevNote: Make this a required arg when catalog is removed
Expand All @@ -336,7 +336,7 @@ def __init__(
"The `catalog` argument has been deprecated and intake is no longer supported. "
"Please use the `data_source` argument to specify your dataset instead."
)

if data_source is None:
raise ValueError("data_source is a required arguemnt")
# Raise warnings for deprecated arguments
Expand Down Expand Up @@ -457,7 +457,7 @@ def vars(self):
if not hasattr(self, "_read_vars"):
self._read_vars = Variables(path=self.filelist[0])
return self._read_vars

@property
def filelist(self):
"""
Expand Down Expand Up @@ -591,22 +591,18 @@ def _add_vars_to_ds(is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict):
.assign_coords(
{
spot_dim_name: (spot_dim_name, [spot]),
"delta_time": ("delta_time", photon_ids),
"photon_idx": ("delta_time", photon_ids),
}
)
.assign({spot_var_name: (("gran_idx", spot_dim_name), [[track_str]])})
.rename_dims({"delta_time": "photon_idx"})
.rename({"delta_time": "photon_idx"})
# .set_index("photon_idx")
.swap_dims({"delta_time": "photon_idx"})
)

# handle cases where the delta time is 2d due to multiple cycles in that group
if spot_dim_name == "pair_track" and np.ndim(hold_delta_times) > 1:
ds = ds.assign_coords(
{"delta_time": (("photon_idx", "cycle_number"), hold_delta_times)}
)
else:
ds = ds.assign_coords({"delta_time": ("photon_idx", hold_delta_times)})

# for ATL11
if "ref_pt" in ds.coords:
Expand Down Expand Up @@ -721,15 +717,15 @@ def load(self):

if not self.vars.wanted:
raise AttributeError(
'No variables listed in self.vars.wanted. Please use the Variables class '
'via self.vars to search for desired variables to read and self.vars.append(...) '
'to add variables to the wanted variables list.'
"No variables listed in self.vars.wanted. Please use the Variables class "
"via self.vars to search for desired variables to read and self.vars.append(...) "
"to add variables to the wanted variables list."
)

# Append the minimum variables needed for icepyx to merge the datasets
# Skip products which do not contain required variables
if self.product not in ['ATL14', 'ATL15', 'ATL23']:
var_list=[
if self.product not in ["ATL14", "ATL15", "ATL23"]:
var_list = [
"sc_orient",
"atlas_sdp_gps_epoch",
"cycle_number",
Expand All @@ -743,7 +739,7 @@ def load(self):
var_list.remove("sc_orient")

self.vars.append(defaults=False, var_list=var_list)

try:
groups_list = list_of_dict_vals(self.vars.wanted)
except AttributeError:
Expand Down