monocongo / climate_indices

Climate indices for drought monitoring
https://monocongo.github.io/climate_indices/
Other
353 stars 167 forks source link

Attribute error #506

Open farheen2022 opened 1 year ago

farheen2022 commented 1 year ago

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

monocongo commented 1 year ago

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.

farheen2022 commented 1 year ago

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.

monocongo commented 1 year ago

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.

farheen2022 commented 1 year ago

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?

monocongo commented 1 year ago

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 .