timcera / tsgettoolbox

Command line script and Python package to get weather and hydrologic time-series from Internet services.
BSD 3-Clause "New" or "Revised" License
18 stars 3 forks source link

Not downloading GLDAS data #6

Closed mishranurag closed 4 years ago

mishranurag commented 4 years ago

I tried following command

df = tsgettoolbox.ldas(xindex=1031, yindex=360,
                           variable='GLDAS:GLDAS_NOAH025_3H.001:precip')

And got following error

Traceback (most recent call last):

File "<ipython-input-46-be91ad9ffc6c>", line 3, in <module>
    variable='GLDAS:GLDAS_NOAH025_3H.001:precip')

File "C:\ProgramData\Anaconda3\lib\site-packages\tstoolbox\tsutils.py", line 858, in onCall
  validator_func[valid](funcname, argname, nargs, nvar, vlen)

File "C:\ProgramData\Anaconda3\lib\site-packages\tstoolbox\tsutils.py", line 788, in _vrange
  if nargs[1] is None:

IndexError: list index out of range
timcera commented 4 years ago

Fixed in 55e7b9c52c39a0ddd3c4710b54a2b9420b446a10 and published to PyPI as version 20.42.11.22.

The LDAS folks moved things around a bit. Fixed tsgettoolbox operation and documentation to match the new LDAS variable strings.

There are now three different GLDAS2:GLDAS_NOAH025_3H_v2.1 precipitation time series.

GLDAS2:GLDAS_NOAH025_3H_v2.1:Rainf_f_tavg = Total precipitation rate GLDAS2:GLDAS_NOAH025_3H_v2.1:Rainf_tavg = Rain precipitation rate GLDAS2:GLDAS_NOAH025_3H_v2.1:Snowf_tavg = Snow precipitation rate

I suspect "Total precipitation rate" is what you want - it might be rain + snow.

df = tsgettoolbox.ldas(lat=45, 
                       lon=-100, 
                       variable='GLDAS2:GLDAS_NOAH025_3H_v2.1:Rainf_f_tavg', 
                       startDate='2000-01-01', 
                       endDate='2001-01-01')
df.head()                             
                           Rainf_f_tavg:kg/m2/s
Datetime:UTC                                   
2000-01-04 12:00:00+00:00          1.280000e-05
2000-01-04 15:00:00+00:00          1.400000e-06
2000-01-04 18:00:00+00:00          1.600000e-06
2000-01-04 21:00:00+00:00          7.000000e-07
2000-01-05 00:00:00+00:00          1.299000e-04

Also, LDAS is now requireing a "startDate=..." and "endDate=...". Used to just return period of record if you left them off.

I also cleaned up the documentation. Right now you can only use 'xindex/yindex' for the NLDAS grid.

mishranurag commented 4 years ago

Thanks for fixing this. I was thinking of showcasing the usefulness of this script in my weekly BASINS group post in LinkedIn and it wasn't working at that time.