icesat2py / icepyx

Python tools for obtaining and working with ICESat-2 data
https://icepyx.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
207 stars 106 forks source link

ds = reader.load() #391

Closed 1kaiser closed 1 year ago

1kaiser commented 1 year ago

https://github.com/icesat2py/icepyx/blob/atmos/doc/source/example_notebooks/IS2_ATL09_workflow.ipynb

AttributeError                            Traceback (most recent call last)
[<ipython-input-36-2335148bbe01>](https://localhost:8080/#) in <module>
      3 warnings.filterwarnings('ignore')
      4 
----> 5 ds = reader.load()

2 frames
[/usr/local/lib/python3.8/dist-packages/icepyx/core/read.py](https://localhost:8080/#) in _add_vars_to_ds(is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict)
    409             import re
    410 
--> 411             gt_str = re.match(r"gt[1-3]['r','l']", grp_path).group()
    412             spot = is2ref.gt2spot(gt_str, is2ds.sc_orient.values[0])
    413             # add a test for the new function (called here)!

AttributeError: 'NoneType' object has no attribute 'group'
JessicaS11 commented 1 year ago

@rwegener2 I can't assign you yet since I just sent your org invite. I believe this issue is resolved, but confirming that would give you a good chance to go through the linked workflow notebook and get a sense for using icepyx to read in data.

1kaiser commented 1 year ago

mam now i use from colab with the data from earth data cloud

filename_1 = "/content/processed_ATL03_20200531180255_10110706_005_01.h5" #@param {type:"string"}
filename_2 = "/content/processed_ATL03_20200211111433_07140602_005_01.h5" #@param {type:"string"}
tr_1 = "gt1l" #@param ["gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"]
tr_2 = "gt1r" #@param ["gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"]
################################################################################
def get_height_lat_lon(filename, track_name):
  # Open the HDF5 file and extract data
  f = h5py.File(filename, 'r')
  h_ph_data = f['/'+str(track_name)+'/heights/h_ph']
  lat_ph_data = f['/'+str(track_name)+'/heights/lat_ph']
  lon_ph_data = f['/'+str(track_name)+'/heights/lon_ph']
  return h_ph_data, lat_ph_data, lon_ph_data
################################################################################
h_ph_data1, lat1, lon1 = get_height_lat_lon(filename_1, tr_1)
h_ph_data2, lat2, lon2 = get_height_lat_lon(filename_2, tr_2)

but thank yu for replying 🙏😁🥳✅

rwegener2 commented 1 year ago

I have re-run the linked notebook with icepyx version 0.7.0 and for me it runs fine through the line ds = reader.load(). The only changes I needed to make to the notebook for it to run through that point are:

Moving to the next line to extract a single profile it seems the variable names have changed. I changed the line profile = ds.sel(spot=1).isel(gran_idx=0) to profile = ds.sel(profile='profile_1').isel(gran_idx=0) and the plot then gets rendered nicely.

I suggest we update this line of the docs, but otherwise it appears that this example notebook is running smoothly.