sharppy / SHARPpy

Sounding/Hodograph Analysis and Research Program in Python
https://sharppy.github.io/SHARPpy/index.html
Other
221 stars 110 forks source link

TypeError: only integer scalar arrays can be converted to a scalar index #165

Open kenpryor67 opened 5 years ago

kenpryor67 commented 5 years ago

Hello all: I have been running SHARPpy successfully on my Windows PC with Python2.7 since I installed the module back in 2017. The GUI still works very well, however, a problem recently occurred with the SHARPpy tutorial Jupyter notebook in "Step 3: Making a Profile object":

TypeError: only integer scalar arrays can be converted to a scalar index

This appears to be related to the function call in line 27: 27 pres, hght, tmpc, dwpc, wdir, wspd = parseSPC(spc_file)

in parseSPC(spc_file) 19 full_data = '\n'.join(data[start_idx : finish_idx][:]) The complete output from that section is in the attached PDF. If you know of a quick work-around for this issue until I can install SHARPpy with Python3.6, I would greatly appreciate it. SHARPpy has been instrumental in my research and product development activities in NOAA and at UMBC since I started using the module back in 2017! Thanks in advance for your help, Ken [SHARPpy_basics_Ottawa_0927.pdf](https://github.com/sharppy/SHARPpy/files/3116982/SHARPpy_basics_Ottawa_0927.pdf)
wblumberg commented 5 years ago

Hi Ken! I saw your email about this, but just now getting to this. I'm glad you're still using SHARPpy and it has been so helpful to your work. I remember coming across this error a while back, but I don't quite remember what the fix was. The error you posted makes me think that the variables start_idx and finish_idx are not integers like the program is expecting. They are probably arrays that contain the indexes that the program wants to strip out the data. I would add in some print statements in the function to check this and modify the code to fix it.

Still trying to get the 3.6 version out, but hit a big bump in the development road and haven't been able to recover from it just yet. Recently moved up to NASA Goddard, so I'm down the street from you now. Not sure when I'll get to visit the NOAA building again, but I'll let you know if I do!

Greg

kenpryor67 commented 5 years ago

Greg, Great to hear from you, and congratulations on your move and new career opportunity with NASA. Thanks for the suggestion. Yes, I did solve this problem by converting the variables "start_idx" and "finish_idx" into array elements "start_idx[0]" and "finish_idx[0]":

put it all together for StringIO

full_data = '\n'.join(data[start_idx[0] : finish_idx[0]][:])
sound_data = StringIO( full_data )

The process now runs correctly and produces great profile images. SHARPpy has been instrumental in my analysis of the pre-convective environment surrounding the 24 September 2001 College Park, MD tornado (see attached notebook). I have also recently modified the params.py script to include calculation of my Microburst Windspeed Potential Index (MWPI) for two layers (listed as MBURST1 and MBURST2) in the attached sounding window excerpts, and in the full profile generated by the notebook.

Thanks again for all your help. Please send me your NASA email address when you have a chance.

Ken

params_mburst.pdf

CGS_1800_sdg Fig5new

SHARPpy_basics_torn_092401.pdf