sharppy / SHARPpy

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

boolean index did not match indexed array #253

Closed michaelselfwx closed 3 months ago

michaelselfwx commented 3 months ago

Hi SHARPpy team!

I have recently launched a weather balloon and have collected lots of good data from it. Last year I was able to fix the data into the SPC format for the program and create a nice skew-t from it. This year, I was plagued with the following error on both my windows and linux installation of sharppy...

Exception: boolean index did not match indexed array along dimension 0; dimension is 4252 but corresponding boolean dimension is 4184

Well, this is embarrassing. SHARPpy broke. This is probably due to an issue with one of the data source servers, but if it keeps happening, send the detailed information to the developers.

Detailed Information: SHARPpy v1.4.0 Andover Crash time: 2024-03-24 22:18:18.292161 Traceback (most recent call last): File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\runsharp\full_gui.py", line 136, in doCrasher ret = func(*args, kwargs) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\runsharp\full_gui.py", line 1001, in openFile self.picker.skewApp(filename=l) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\runsharp\full_gui.py", line 767, in skewApp self.skew.addProfileCollection(prof_collection, check_integrity=self.strictQC) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\sharppy\viz\SPCWindow.py", line 857, in addProfileCollection exit_code = self.testDataIntegrity(prof_col.getHighlightedProf()) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\sharppy\sharptab\prof_collection.py", line 145, in getHighlightedProf self._profs[self._highlight][self._prof_idx] = self._target_type.copy(cur_prof) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\sharppy\sharptab\profile.py", line 184, in copy new_prof = cls(new_kwargs) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\sharppy\sharptab\profile.py", line 544, in init super(ConvectiveProfile, self).init(**kwargs) File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\sharppy\sharptab\profile.py", line 336, in init self.vtmp[self.dwpc.mask[idx]] = self.tmpc[self.dwpc.mask[idx]] # Masking any virtual temperature File "C:\Users\micha\anaconda3\envs\venv\lib\site-packages\numpy\ma\core.py", line 3228, in getitem dout = self.data[indx] IndexError: boolean index did not match indexed array along dimension 0; dimension is 4252 but corresponding boolean dimension is 4184

This error occurs right when I select the .txt file with the sonde data.

The empty skew-t shows but there is no lines drawn or calculations made on the bottom.

Versioning Information (please complete the following information):

collin-volk commented 3 months ago

Could you add the file you are trying to plot? Without that, it's going to be hard to recreate/debug the issue.

michaelselfwx commented 3 months ago

Could you add the file you are trying to plot? Without that, it's going to be hard to recreate/debug the issue.

Sorry about that! Here it is, thank you! SP24-spcWBL.txt

collin-volk commented 3 months ago

So looking at the data, I figured out a few issues. First, and the main cause of the error you were seeing, is all the lines where there are -9999.0. If you notice on SPC data (https://www.spc.noaa.gov/exper/soundings/24032512_OBS/MPX.txt for example), they only have -9999.0 for wind speed and direction on most lines (the one exception being the first line which also has it for temperature and dewpoint. In your data, you have -9999 set for the pressure on the first 25 lines, and then towards the end of your file you have numerous lines where just the dewpoint is -9999. I removed every line that had a -9999 and was able to load your file in SHARPpy (after a slight delay due to its large size).

This brought me to the second issue with your data. There are lines with duplicate or decreasing height as the pressure decreases (I was able to find a large chunk at the start of the file, but apparently there are more somewhere else in the file). SHARPpy will warn you about this, but will still let you load the file.

Long story short, you just have to do a little cleanup on your data and you should be good to go!

michaelselfwx commented 3 months ago

I took out the -9999 temp/humidity/pressure data but I am still getting the error: IndexError: boolean index did not match indexed array along dimension 0; dimension is 4186 but corresponding boolean dimension is 4184

Here is my updated text file. SP24-spcWBL#3.txt

collin-volk commented 3 months ago

You have two lines in that file with a temperature of -273 which is absolute 0, which presumably get thrown out by SHARPpy causing the difference between 4186 and 4184 being reported. Removing those two lines makes the program work.

michaelselfwx commented 3 months ago

Thank you so much! It finally worked and I got a great skew-T.