Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time_pos index needs to be cast to int as of numpy 1.13. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

time_pos index needs to be cast to int as of numpy 1.13. #5

wants to merge 1 commit into from

Conversation

stochtastic
Copy link

Minor bugfix to address a problem I had with output_to_netcdf() using a clean Anaconda environment, reproducible via:

conda create -n GHCNpy python=2.7
source activate GHCNpy
conda install -c conda-forge geopy
conda install numpy netCDF4 requests matplotlib basemap
git clone https://github.com/jjrennie/GHCNpy.git
cd GHCNpy/
python setup.py install
python test.py

Testing output_to_netcdf(),

import ghcnpy as gp
gp.output_to_netcdf("USW00024233")

yields the following error from numpy:

('\nOUTPUTTING TO netCDF: ', 'USW00024233', '.nc')
('\nGETTING DATA FOR STATION: ', 'USW00024233')

GRABBING LATEST STATION METADATA FILE
Traceback (most recent call last):
  File "test_GHCNpy.py", line 2, in <module>
      gp.output_to_netcdf("USW00024233")
        File "/home/ar/Dropbox/Work/Projects/NXPhase/GHCNpy/ghcnpy/iotools.py", line 523, in output_to_netcdf
            ghcnd_data[time_pos,element_counter] = float(ghcnd_contents[counter][char:char+5]) / divisor
            IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Simple fix applied here is to cast time_pos to int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant