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

Provide return value for download and plot #28

Open
wxguy opened this issue Sep 13, 2024 · 3 comments
Open

Provide return value for download and plot #28

wxguy opened this issue Sep 13, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@wxguy
Copy link

wxguy commented Sep 13, 2024

With the current implementation of sounderpy, it is not possible to know if the data downloaded is successful or not. I tried following simple example as reorted in #27 and only changed different time (ahead of current time):-

import sounderpy as spy

data = spy.get_obs_data("vomm", "2024", "09", "13", "12")
spy.build_sounding(data, save=True, filename="sample.png")

This has resulted in following error:

File "/home/sundar/miniconda3/envs/vatavar/lib/python3.11/site-packages/sounderpy/sounderpy.py", line 845, in get_obs_data
    sounding_params(clean_data).print_vals()
  File "/home/sundar/miniconda3/envs/vatavar/lib/python3.11/site-packages/sounderpy/calc.py", line 572, in print_vals
    thermo = self.calc()[1]
             ^^^^^^^^^^^
  File "/home/sundar/miniconda3/envs/vatavar/lib/python3.11/site-packages/sounderpy/calc.py", line 94, in calc
    general['sfc_pressure']  = (p[0].m*(1-(0.0065*(general['elevation']))/(T[0].m+(0.0065*(general['elevation']))+273.15))**-5.257)*units.hPa
                                ~^^^
  File "/home/sundar/miniconda3/envs/vatavar/lib/python3.11/site-packages/pint/facets/numpy/quantity.py", line 257, in __getitem__
    return type(self)(self._magnitude[key], self._units)
                      ~~~~~~~~~~~~~~~^^^^^
IndexError: index 0 is out of bounds for axis 0 with size 0

I think it is due to the fact that cleaning is done as part of the download function. It would be better to separate this clean function and provide api access to user to check if data is downloaded first and then clean the data.

@kylejgillett
Copy link
Owner

kylejgillett commented Sep 13, 2024

Hi again @wxguy,

Here the data did download, noted by the fact that the data is being run through the calc.py module.

Allowing the ability to load in just the 'dirty data' before 'cleaning' is a good idea though. I have an idea on how to do this without disrupting the current API too much.

I will plan to include this in the next upcoming release.

I will close this issue after its been implemented.

@kylejgillett kylejgillett self-assigned this Sep 13, 2024
@kylejgillett kylejgillett added the bug Something isn't working label Sep 13, 2024
@wxguy
Copy link
Author

wxguy commented Sep 13, 2024

Here the data did download

I am pretty sure it did not. I placed a download request ahead of current time in UTC. For example, if I provide similar request through browser with following url:-

https://weather.uwyo.edu/cgi-bin/sounding?region=seasia&TYPE=TEXT%3ARAW&YEAR=3024&MONTH=12&FROM=1312&TO=1312&STNM=vomm

will return this message.

Sorry, unable to generate 43279 VOMM Madras Observations at 12Z 13 Dec 2024

In the above case, the response is 200, which is also considered as successful.

@kylejgillett
Copy link
Owner

Where the calc.py module comes into play in spy.get_obs_data() is after the download was completed. As such, the code would never have made it to the line sounding_params(clean_data).print_vals(), that references the calc.py module, if the data wasn't downloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants