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
213 stars 107 forks source link

order_vars Issue #389

Closed datigeofisica closed 1 year ago

datigeofisica commented 1 year ago

Hello, I'm using the last version of Icepyx (I upgraded today to 0.6.4, I've used the 0.6.3 until yesterday). The script has worked without problem until November 18th. For the last week I got the following errors:

-------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\geofisica\Desktop\Icepyx_NEW(22-11-10)\ScriptEstrazioneIcepyx2.3.py", line 180, in <module>
    region_a.order_vars.append(var_list=['lat_ph','lon_ph','h_ph', "geoid", "signal_conf_ph", "quality_ph"])
  File "C:\Users\geofisica\AppData\Local\Programs\Python\Python37\lib\site-packages\icepyx\core\variables.py", line 456, in append
    vgrp, allpaths = self.avail(options=True, internal=True)
  File "C:\Users\geofisica\AppData\Local\Programs\Python\Python37\lib\site-packages\icepyx\core\variables.py", line 125, in avail
    vgrp, paths = self.parse_var_list(self._avail)
  File "C:\Users\geofisica\AppData\Local\Programs\Python\Python37\lib\site-packages\icepyx\core\variables.py", line 222, in parse_var_list
    num = np.max([v.count("/") for v in varlist])
  File "<__array_function__ internals>", line 6, in amax
  File "C:\Users\geofisica\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\core\fromnumeric.py", line 2755, in amax
    keepdims=keepdims, initial=initial, where=where)
  File "C:\Users\geofisica\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\core\fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation maximum which has no identity
-----------------------------------------------------------------------------------------------------------

Trying to go deeper to this problem, I noticed that the problem occurs everytime that I try to launch the function order_vars. This has worked without any problems until that day (or at least I noticed it on November 18th, but I used it frequently the days before). When I go to check the script in the core of Icepyx, inside "variables.py", it seems that the "varlist" that should come from the download script gives always an empty array. This can be seen clearly using order_vars.avail() or order_vars.avail(options=True). Same thing with order_vars.wanted() and (the main problem) with order_vars.append. If you have any suggestion, I would like to try to solve this problem. Thank you for your time,

R.N.

JessicaS11 commented 1 year ago

Hello @datigeofisica! Thanks for reporting this issue. Could you please provide the first few lines of code you are using to set up your query object (i.e. everything up to region_a.order_vars.append(var_list=['lat_ph','lon_ph','h_ph', "geoid", "signal_conf_ph", "quality_ph"]))? This, combined with the information you've already provided, will allow me to try and reproduce the error. Thanks!

datigeofisica commented 1 year ago

Hello @JessicaS11, thank you for your answer! This is the script that we used until now: (MyUser and MyEmail are from our account) I think that these are the same lines of code suggested in the Accessing ICESat-2 Data Examples (https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html)

import icepyx as ipx import os import shutil short_name = 'ATL03' spatial_extent = [(9,44), (9,45), (10,45), (10,44), (9,44)] date_range = ['2019-01-01','2021-12-31'] region_a = ipx.Query(short_name, spatial_extent, date_range) region_a.avail_granules() earthdata_uid = 'MyUser' email = 'MyEmail@email.com' region_a.earthdata_login(earthdata_uid, email) region_a.order_vars.append(var_list=['lat_ph','lon_ph','h_ph'])

This script always worked until 18th of November. The last line of code can be wathever function of order_vars (i.e. append, avail or the others). I tried the script on all the computer that I have in our office and the script error is always the same. Thank you again,

R.N.

JessicaS11 commented 1 year ago

@rwegener2 this would be a great first issue to (1) see if it's still an issue and you can reproduce it (2) get to know the basics of icepyx. The notebook linked by the user has the updated syntax for the login step (everything else should be the same, and this should still run, it's just simpler now).

rwegener2 commented 1 year ago

Main diagnosis - seems to work in icepyx 0.7.0

This example seems to work in icepyx version 0.7.0. The updated code I used was:

import icepyx as ipx

# 1 - define search params
short_name = 'ATL03'
spatial_extent = [(9,44), (9,45), (10,45), (10,44), (9,44)]
date_range = ['2019-01-01','2021-12-31']
region_a = ipx.Query(short_name, spatial_extent, date_range)

# 2 - login
region_a.earthdata_login()

# 3 - add variables
region_a.order_vars.append(var_list=['lat_ph','lon_ph','h_ph'])

My metric for "it works" is that is that the last line (region_a.order_vars.append()) runs without error and that region_a.order_vars.wanted changes before and after running the last line.

Side comment: logging in with icepyx 0.6.4

I tried to reproduce this error with icepyx 0.6.4 and got blocked by being unable to sign in with my Earthdata credentials in that version. The environment I was using was a conda-produced Python 3.11.4 that had icepyx=0.6.4 installed. Running the .earthdata_login() function with my uid and username gave a JSONDecodeError. I can follow up with a full slacktrace in a separate issue, but since this is an issue with an older version of icepyx I didn't assume it was necessarily worth it to track this error down.

JessicaS11 commented 1 year ago

@datigeofisica We're unable to reproduce this error - please let us know if you're still experiencing any issues.