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

Function "addcyclic": IndexError #575

Open
YixinNJU opened this issue May 28, 2023 · 2 comments
Open

Function "addcyclic": IndexError #575

YixinNJU opened this issue May 28, 2023 · 2 comments
Milestone

Comments

@YixinNJU
Copy link

YixinNJU commented May 28, 2023

Hi, I am using "addcyclic" function and encounter the Index Error. Error details are:

IndexError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11852/1134487354.py in
6 m.drawmeridians(np.arange(0.,360.,90.),linewidth=0.4,color='gray',labels=[True,True,True,True])
7 #在Py3.7下使用basemap==1.2.0,在循环填白addcyclic时可能会报错
----> 8 psi_p1,lon1=addcyclic(np.array(psi_p),np.array(lon))
9 lonsn, latsn = np.meshgrid(lon1, lat)
10 x_cyc,y_cyc=m(lonsn,latsn) #建立投影坐标映射

D:\AnacondaSoftware\lib\site-packages\mpl_toolkits\basemap_init_.py in addcyclic(*arr, **kwargs)
5101 return _addcyclic_lon(arr[-1])
5102 else:
-> 5103 return list(map(_addcyclic,arr[:-1])) + [_addcyclic_lon(arr[-1])]
5104
5105 def _choosecorners(width,height,**kwargs):

D:\AnacondaSoftware\lib\site-packages\mpl_toolkits\basemap_init_.py in _addcyclic(a)
5086 raise ValueError('The specified axis does not correspond to an '
5087 'array dimension.')
-> 5088 return npsel.concatenate((a,a[slicer]),axis=axis)
5089 def _addcyclic_lon(a):
5090 """addcyclic function for a single longitude array"""

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

The code is:
psi_p1,lon1=addcyclic(np.array(psi_p),np.array(lon))

Here is the variable psi_p: https://box.nju.edu.cn/f/64583aedd0c24eae909d/
lon: https://box.nju.edu.cn/f/a273d137b454468c8007/

Software and module versions are: Python 3.8.8, numpy 1.23.5, basemap: 1.2.2

I am wondering whether it is due to inconsistency of package version? Is it possible to fix the bug without reinstall python or modules due to interdependence of a lot of my other modules. Thanks a lot!!

@molinav
Copy link
Member

molinav commented Jun 4, 2023

Hi @YixinNJU! This error sounds like #555, which was solved for basemap release 1.3.5. Can you try upgrading to the latest basemap version (currently 1.3.7)? The version 1.2.2 is a bit outdated. The version 1.3.7 is available at conda-forge for Windows x64 (presumably your OS and architecture).

@YixinNJU
Copy link
Author

YixinNJU commented Jun 4, 2023

Hi @YixinNJU! This error sounds like #555, which was solved for basemap release 1.3.5. Can you try upgrading to the latest basemap version (currently 1.3.7)? The version 1.2.2 is a bit outdated. The version 1.3.7 is available at conda-forge for Windows x64 (presumably your OS and architecture).

Thank you for your reply! I upgraded basemap to 1.3.7 and re-import the module, the same Index Error still exists.

@molinav molinav added this to the v1.4.0 milestone Aug 23, 2023
@molinav molinav modified the milestones: v1.4.0, v1.5.0 Jan 9, 2024
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

No branches or pull requests

2 participants