monocongo/climate_indices

Attribute error

Opened this issue · 5 comments

While running the code "python process_grid.py --index spi --time_series_type monthly --netcdf_precip ../example_inputs/ds.nc --var_name_precip pre --output_file_base ../results/cru --scales 1 --calibration_start_year 1999 --calibration_end_year 2000" in anaconda prompt in indices_env environment. I am getting: AttributeError: module 'climate_indices.indices' has no attribute 'spi_gamma'
Kindly help me to fix this problem

I'm unfamiliar with a script named process_grid.py -- where is that code?

Please follow up with the stack trace, as helpful error messages will be contained therein, leading to the problem.

I was following the YouTube tutorial from Nasa, there I got the code. But I think I was wrong all along. I have to use this python script in my Jupyter notebook to get work done, right? It would be really helpful if there is a video dedicated "how to calculate SPI?" as I am new to python.

The NASA video and tutorial use ancient versions of this code. Please re-install from the master branch -- I think you'll get much better results, though there may also be other issues where the NASA training is outdated. They didn't coordinate with me when they put together this training material, and as a result, several things are off and I have had to try to help numerous users like you before.

I will hopefully be able to put together an example notebook to explain how to use this package for new Python users like you @farheen2022 . The main idea is to get the precipitation timeseries data into a numpy array, then compute the corresponding index values using the indices.spi function. The overall main processing script just does that for an entire timeseries grid.

An example notebook would be very helpful in executing this code.
Though, I am able to get precipitation timeseries into Numpy array, I am not understanding why there are two files in the SPI code, one named as "netcdf_gamma" what is this for?" I was halfway through it to run the code but stuck where it was using that file "netcdf_gamma" from directory since I have only one file for precipitation ( by CRU).
Also what is the master branch from where I can re-install package?

Please install from the master branch of this repository.

  1. Clone the repository
  2. Change into the top-level directory
  3. python -m pip install .