tethys-ts / tethysts

Apache License 2.0
2 stars 2 forks source link

Issues with hdf5tools has no attribute 'combine_hdf5' #82

Closed aspe98 closed 1 year ago

aspe98 commented 1 year ago

Hello,

I am a masters student at University of Canterbury and I would like to use the tethys package to obtain climate data from the Moana Backbone model. Prior to this, I had created a new Jupyter Notebook environment (called tethys_new) and ipykernel to isolate the packages and avoid conflict.

I have the station ID and dataset ID of interest:

dataset_id = 'ff28976e766f2320b1404eaa'
station_id = '0c58fa18828c819f551900f2'

However, when following the documentation I am encountering a few issues. The first is using the hdftools module.

Here is my script with reproducible errors:

from tethysts import Tethys
import numpy

# Issue 1: hdf5tools has no attribute 'combine_hdf5'
# Obtain dataset information
ts = Tethys()
datasets = ts.datasets

# set parameters 
my_dataset = [d for d in datasets if (d['parameter'] == 'precipitation') and
                                     (d['product_code'] == 'Moana backbone model')]

# obtain dataset id 
dataset_id = my_dataset[0]["dataset_id"]

# find stations from dataset id
stations = ts.get_stations(dataset_id)

# set station id of interest
my_station = [s for s in stations if (s['station_id'] == "0c58fa18828c819f551900f2")][0]

# Obtain results 
dataset_id = 'ff28976e766f2320b1404eaa'
station_id = '0c58fa18828c819f551900f2'
results = ts.get_results(dataset_id, station_id)

And the error message I receive is:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[9], line 4
      2 dataset_id = 'ff28976e766f2320b1404eaa'
      3 station_id = '0c58fa18828c819f551900f2'
----> 4 results = ts.get_results(dataset_id, station_id)
      6 results

File C:\Program Files\Anaconda3\envs\tethys_new\lib\site-packages\tethysts\main.py:550, in Tethys.get_results(self, dataset_id, station_ids, geometry, lat, lon, from_date, to_date, from_mod_date, to_mod_date, version_date, heights, bands, squeeze_dims, output_path, compression, threads)
    547 xr.backends.file_manager.FILE_CACHE.clear()
    549 ## combine results
--> 550 xr3 = results_concat(results_list, output_path=output_path, from_date=from_date, to_date=to_date, from_mod_date=from_mod_date, to_mod_date=to_mod_date, compression=compression)
    552 ## Convert to new version
    553 attrs = xr3.attrs.copy()

File C:\Program Files\Anaconda3\envs\tethys_new\lib\site-packages\tethysts\utils.py:767, in results_concat(results_list, output_path, from_date, to_date, from_mod_date, to_mod_date, compression)
    764 else:
    765     temp_path = output_path + '.temp'
--> 767 hdf5tools.combine_hdf5(results_list, temp_path, compression='zstd')
    769 xr3 = xr.open_dataset(temp_path, engine='h5netcdf', cache=False)
    770 xr3 = result_filters(xr3, from_date, to_date, from_mod_date, to_mod_date)

AttributeError: module 'hdf5tools' has no attribute 'combine_hdf5'

I suspect this may be something to do with the version of hdf5. I am using hdf5tools version 0.1.11. Is there a specific version that is used that would make it compatible?

Please note I am relatively new to Python so please excuse my limited understanding in the nature of the errors or the package itself. Any help is greatly appreciated!

mullenkamp commented 1 year ago

Hi,

I'm glad you're giving tethys a try. Try to make sure your tethysts python package is up-to-date. If you're using conda then: conda install tethysts=4.5.11

Your hdf5tools version is the latest one, so that's not the issue.

Let me know if this fixes your issue.

Take care

aspe98 commented 1 year ago

Hi mullenkamp,

Thank you for the quick response! Following your advice, I see that this is indeed the issue as I was using version 4.5.0 previously.

And thank you for your answer to my previous response as well! Apologies for not creating a new issue when needed - I created the github account specifically to ask for help on this package but will remember for future queries!

Many thanks again.

mullenkamp commented 1 year ago

Absolutely no problem. It's good that you've created a github account to use the github issues system. It's a good way of getting help and it allows others to help themselves if other ask the same question.