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-in module for ATL11 #398

Merged
merged 25 commits into from
Feb 17, 2023
Merged

update read-in module for ATL11 #398

merged 25 commits into from
Feb 17, 2023

Conversation

JessicaS11
Copy link
Member

The read-in module was not working for ATL11. This PR aims to remedy that.

@github-actions
Copy link

github-actions bot commented Jan 18, 2023

Binder 👈 Launch a binder notebook on this branch for commit 76576ae

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit 31594a9

Binder 👈 Launch a binder notebook on this branch for commit 79c4b7c

Binder 👈 Launch a binder notebook on this branch for commit 9226737

Binder 👈 Launch a binder notebook on this branch for commit 35088ba

Binder 👈 Launch a binder notebook on this branch for commit 191851f

Binder 👈 Launch a binder notebook on this branch for commit 5b2da3a

Binder 👈 Launch a binder notebook on this branch for commit 1b26978

Binder 👈 Launch a binder notebook on this branch for commit 8568fae

Binder 👈 Launch a binder notebook on this branch for commit 45540ce

Binder 👈 Launch a binder notebook on this branch for commit 03befa0

Binder 👈 Launch a binder notebook on this branch for commit dfaf2e9

Binder 👈 Launch a binder notebook on this branch for commit 775dba1

Binder 👈 Launch a binder notebook on this branch for commit bf6e632

@chris-picard
Copy link

chris-picard commented Jan 23, 2023

Hi Jessica, when trying to pull ATL11 using icepyx, I kept getting an error "pop from empty list":

#get a list of granule IDs for the available granules
region_a.avail_granules(ids=True) 

Which returned the error message:

IndexError                                Traceback (most recent call last)
/var/folders/d2/jjjzv8t95113nztdlt260q8r0000gn/T/ipykernel_14830/3270823387.py in <module>
      1 #get a list of granule IDs for the available granules
      2 print(region_a.CMRparams)
----> 3 region_a.avail_granules(ids=True)

~/opt/anaconda3/lib/python3.9/site-packages/icepyx/core/query.py in avail_granules(self, ids, cycles, tracks, s3urls)
    907         if ids or cycles or tracks or s3urls:
    908             # list of outputs in order of ids, cycles, tracks, s3urls
--> 909             return granules.gran_IDs(
    910                 self.granules.avail,
    911                 ids=ids,

~/opt/anaconda3/lib/python3.9/site-packages/icepyx/core/granules.py in gran_IDs(grans, ids, cycles, tracks, dates, s3urls)
    107                 AUX,
    108                 SFX,
--> 109             ) = rx.findall(producer_granule_id).pop()
    110             gran_cycles.append(CYCL)
    111             gran_tracks.append(TRK)

IndexError: pop from empty list

I ran this identical code for ATL06 and ATl12 without any issues. It seems like there is an issue with identifying the ID's of granules for ATL11. I have adjusted the spatial boundaries and maximized the temporal ones to make sure that I am getting enough data -- but there is still this error. Thoughts?

@JessicaS11 JessicaS11 linked an issue Jan 27, 2023 that may be closed by this pull request
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Jessica, sorry for the late review, just warming up after a long break. I've just left some minor comments for now from glancing through the code, will do a more thorough review once I set up my development environment properly on a new laptop :D

icepyx/core/read.py Show resolved Hide resolved
icepyx/core/read.py Show resolved Hide resolved
icepyx/core/read.py Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
Comment on lines +793 to +800
while wanted_groups_list:
# print(wanted_groups_list)
grp_path = wanted_groups_list[0]
wanted_groups_list = wanted_groups_list[1:]
ds = self._read_single_grp(file, grp_path)
is2ds, ds = Read._add_vars_to_ds(
is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this while loop code break on L796 once the wanted_groups_list variable is assigned a value? Or does it run to the end of the while-block first before breaking? Maybe I'm confusing Python with some other programming language...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it will either get to this version of the while loop from the elif on L743 (which ends with a return) or the L796 version of the while loop via the else on L775.

icepyx/core/read.py Outdated Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
icepyx/core/read.py Outdated Show resolved Hide resolved
JessicaS11 and others added 5 commits February 9, 2023 14:46
@JessicaS11
Copy link
Member Author

@weiji14 I think it's pretty close to being ready to merge!

@JessicaS11 JessicaS11 linked an issue Feb 14, 2023 that may be closed by this pull request
@JessicaS11 JessicaS11 requested a review from weiji14 February 14, 2023 21:07
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, reading ATL11 finally works in icepyx 🥲. So I tried downloading a sample file from https://n5eil01u.ecs.nsidc.org/ATLAS/ATL11.005/2022.03.27/ATL11_006305_0315_005_03.h5 and ran the following code in this atl11 branch:

import icepyx as ipx
import xarray as xr

# Read in ATL11
reader = ipx.Read(
    data_source=".",
    product="ATL11",
    filename_pattern="ATL{product:2}_{rgt:4}{orbitsegment:2}_{cycles:4}_{version:3}_{revision:2}.h5",
)
reader.vars.append(
    beam_list=["pt1", "pt2", "pt3"], var_list=["longitude", "latitude", "h_corr"]
)
ds: xr.Dataset = reader.load()
print(ds)

gives

<xarray.Dataset>
Dimensions:              (gran_idx: 1, cycle_number: 13, photon_idx: 5851,
                          pair_track: 3)
Coordinates:
  * gran_idx             (gran_idx) float64 1e+06
  * cycle_number         (cycle_number) float32 3.0 4.0 5.0 ... 13.0 14.0 15.0
  * photon_idx           (photon_idx) int64 0 1 2 3 4 ... 5847 5848 5849 5850
  * pair_track           (pair_track) <U3 'pt1' 'pt2' 'pt3'
    source_file          (gran_idx) <U29 './ATL11_006305_0315_005_03.h5'
    delta_time           (photon_idx, cycle_number) datetime64[ns] NaT ... 20...
    ref_pt               (photon_idx) float64 6.062e+05 6.062e+05 ... 6.112e+05
Data variables:
    atlas_sdp_gps_epoch  (gran_idx) datetime64[ns] 2018-01-01T00:00:18
    data_start_utc       (gran_idx) datetime64[ns] 2022-03-27T05:32:07.954158
    data_end_utc         (gran_idx) datetime64[ns] 2022-03-27T05:35:11.277237
    longitude            (pair_track, gran_idx, photon_idx) float64 154.3 ......
    latitude             (pair_track, gran_idx, photon_idx) float64 71.07 ......
    h_corr               (pair_track, gran_idx, photon_idx, cycle_number) float32 ...
    gt                   (gran_idx, pair_track) <U3 'pt1' 'pt2' 'pt3'
    rgt                  (pair_track, gran_idx, photon_idx) float64 nan ... 5...
Attributes: (12/24)
    data_product:             ATL11
    ATL06_xover_field_list:   ['delta_time', 'h_li', 'h_li_sigma', 'latitude'...
    L_search_AT:              60
    L_search_XT:              65
    N_coeffs:                 8
    N_poly_coeffs:            8
    ...                       ...
    seg_atc_spacing:          100
    seg_number_skip:          3.0
    seg_sigma_threshold_min:  0.05
    t_scale:                  31557600.0
    xy_scale:                 100.0
    beam_pair:                3

A couple of nitpicks:

  1. The cycle_number coordinate has a float32 dtype, but it should really just be uint8 if possible
  2. The gt data variable lists pair tracks 'pt1', 'pt2', 'pt3'. Should the data variable name be called 'pt' instead of 'gt' (ground track is for ATL06, pair track is for ATL11)?

Other than that, the filename_pattern of "ATL{product:2}_{rgt:4}{orbitsegment:2}_{cycles:4}_{version:3}_{revision:2}.h5" should probably be documented somewhere (at least in the docstring), and once that's done, it should be almost ready to merge!

@JessicaS11 JessicaS11 requested a review from weiji14 February 16, 2023 18:37
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks again @JessicaS11!

icepyx/core/read.py Outdated Show resolved Hide resolved
JessicaS11 and others added 3 commits February 17, 2023 14:42
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ATL11 granule ID empty list ipx.Read.load() not working with ATL09 beam profile names
3 participants