monocongo/climate_indices

On Calculating SPEI: ValueError: These variables cannot be found in this dataset: ['ppt']

Closed this issue · 2 comments

Report

I was trying to calculate the SPEI using the climate-indices package using input date from the Bureau of Meteorology Australia
I used this command

process_climate_indices --index spei --periodicity monthly --netcdf_precip ./bom_precip_1.nc --var_name_precip ppt --netcdf_pet ./bom_pet.nc --var_name_pet e0 --output_file_base ./bom --scales 3 --calibration_start_year 1980 --calibration_end_year 2020 --multiprocessing all

To Reproduce
Steps to reproduce the behavior:

  1. I have uploaded the input files https://drive.google.com/drive/folders/1zLlCAEDlPZ9xk5j0xEly1wCqWjWBY9Na?usp=share_link
  2. When I ran the code above in the terminal, I got the error below

2023-05-18 21:59:19 INFO Start time: 2023-05-18 21:59:19.022512 2023-05-18 21:59:20 INFO Computing 3-month SPEI/Pearson 2023-05-18 22:00:50 ERROR Failed to complete Traceback (most recent call last): File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/climate_indices/__main__.py", line 1775, in main _compute_write_index(kwrgs) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/climate_indices/__main__.py", line 1111, in _compute_write_index dataset = dataset.drop_vars(names=[var]) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/xarray/core/dataset.py", line 5095, in drop_vars self._assert_all_in_dataset(names) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/xarray/core/dataset.py", line 5063, in _assert_all_in_dataset raise ValueError( ValueError: These variables cannot be found in this dataset: ['ppt'] Traceback (most recent call last): File "/Users/24715447/anaconda3/envs/climate_process/bin/process_climate_indices", line 8, in <module> sys.exit(main()) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/climate_indices/__main__.py", line 1775, in main _compute_write_index(kwrgs) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/climate_indices/__main__.py", line 1111, in _compute_write_index dataset = dataset.drop_vars(names=[var]) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/xarray/core/dataset.py", line 5095, in drop_vars self._assert_all_in_dataset(names) File "/Users/24715447/anaconda3/envs/climate_process/lib/python3.9/site-packages/xarray/core/dataset.py", line 5063, in _assert_all_in_dataset raise ValueError( ValueError: These variables cannot be found in this dataset: ['ppt']

Expected behavior
I am not sure what I did wrong but I checked the dimensions of the file and it should be okay for processing. The precipitation input works for SPI. I encounter this problem only when running SPEI

I am using this computer

  • OS: Mac Ventura M2
  • Version: 13.3.1

Additional Information
I tried running the code in the example given (https://github.com/monocongo/example_climate_indices/) but I get the same error.

Any thoughts? Thank you.

I was able to resolve the issue by updating the main.py and utils.py. Some merge requests had not been updated in the current package installed in my computer.

Thanks so much for your follow-up on this issue, @xeimyname1 !