Skip to content

Commit

Permalink
Update read module coordinate dimension manipulations to use new xarr…
Browse files Browse the repository at this point in the history
…ay index (#473)
  • Loading branch information
JessicaS11 committed Jan 5, 2024
1 parent fb28038 commit 93b0f1a
Showing 1 changed file with 12 additions and 16 deletions.
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

0 comments on commit 93b0f1a

Please sign in to comment.