-
Notifications
You must be signed in to change notification settings - Fork 443
Function for parsing WPC coded surface bulletins #1944
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
Conversation
|
How do I add a new text file to our staticdata folder and use I've tried adding my file to staticdata on my local repo, but when trying to use |
|
Above issue resolved by recreating the data registry with |
c0441f0 to
8f057be
Compare
8f057be to
9d08f87
Compare
| from .metar import * # noqa: F403 | ||
| from .nexrad import * # noqa: F403 | ||
| from .station_data import * # noqa: F403 | ||
| from .text import * # noqa: F403 |
Check notice
Code scanning / CodeQL
'import *' may pollute namespace
| """Test parser reading a WPC coded surface bulletin into a geodataframe.""" | ||
| # Get rows 17 and 47 from dataframe representing parsed text file | ||
| # Row 17 is a pressure center and row 47 is front | ||
| input_file = get_test_data('WPC_sfc_fronts_20210628_1800.txt') |
Check warning
Code scanning / CodeQL
File is not always closed
9d08f87 to
0f3b160
Compare
0f3b160 to
e26954f
Compare
1bfb415 to
976556e
Compare
|
Hrmm...also one other issue: We're currently optionally depending on Shapely, which is no burden since it comes in with the optional dependency on Cartopy. This would be harder to keep optional here. |
ce900bf to
7736950
Compare
dcamron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like how this is done, thanks y'all. Just some doc and testing thoughts, mostly.
|
@dcamron any thoughts on what to do with Shapely (e.g. depending on it or jumping through hoops)? |
|
Hmmm... Would it be more difficult than the cartopy machinery you've already put in place? Not to totally rebuild WPC parsing to be able to work without Shapely, but to just have it fail on run instead of import without it. I think realistically it would affect very few people negatively to fully depend on Shapely. It does feel a little conceptually gross if we've already done similar work to help out those very few people, and Shapely does feel ever so slightly heavier to jam into all of |
|
We could import Shapely inside the wpc parsing function since it's only used there. That seems pretty limited. We'd need to add some machinery to require shapely for the tests, which isn't scary. I'd say that's the way to go. |
This requires a year value potentially to be provided, though we try to look for one in the product header.
Users can easily convert to a GeoDataFrame if they need that functionality, but the DataFrame is already a dependency and is sufficient for our needs.
c282ceb to
89ef972
Compare
This avoids an import-time failure for MetPy if Shapely isn't installed.
89ef972 to
c53a328
Compare
As opposed to the "high res" product.
c53a328 to
45b01b5
Compare
dcamron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I think this is good to go in!
In response to issue #1153, the PR introduces a new function in the IO module for parsing WPC coded surface bulletins. Provided a path to a file, or a file-like object, the function returns a geopandas GeoDataFrame containing the data from the bulletin. Each row of the dataframe represents a pressure center or frontal boundary. The main use of this function is to provide support for the ability to plot surface analyses with MetPy.
Additionally, this PR includes a small change to
open_as_needed()in _tools.py. In order to get some WPC surface bulletins, I was usingurllib.request.urlopen("https://www.wpc.ncep.noaa.gov/basicwx/coded_srp.txt"), which returns an HTTPRequest object.open_as_needed()was throwing an error when trying to useseek(0)on that HTTPRequest object. Maybe there is a better solution than adding a try/except, so any additional feedback on that would be great.Checklist