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

Search string for one hour precip fails. Lots of corner cases #156

Closed
scollis opened this issue Jan 15, 2023 · 5 comments · Fixed by #158
Closed

Search string for one hour precip fails. Lots of corner cases #156

scollis opened this issue Jan 15, 2023 · 5 comments · Fixed by #158

Comments

@scollis
Copy link

scollis commented Jan 15, 2023

In order to get the 1 hour precip from HRRR you need to brute force.
See this notebook.
https://github.com/scollis/notebooks/blob/master/Herbie_Chicago_precip.ipynb

Need to update the examples to include this brute force method and show an example with Fast Herbie.

I may have time to get to this during this week.

@blaylockbk
Copy link
Owner

Thanks for pointing this out. Yeah, I wish you could just use searchString="ACPC:surface" to get both hourly and total precip, but cfgrib has a limitation reading both from a grib file (ecmwf/cfgrib#187).

I found what the problem is here...that regex searchString won't match these because of the zero:

:APCP:surface:10-11 hour acc fcst
:APCP:surface:20-21 hour acc fcst
:APCP:surface:30-31 hour acc fcst
:APCP:surface:40-41 hour acc fcst

(I never tried requesting precip data at that long lead time, so I'm glad you found this). I'll figure out what the right regex should be; the docs need to be updated.

@scollis
Copy link
Author

scollis commented Jan 16, 2023

Or we can use my brute force technique. It is an example of how to construct a query which has complex rules.

nfcst = 47
for i in range(nfcst):
    if i != nfcst -1:
        qstr = qstr +  f':APCP:surface:{i}-{i+1} h*|'
    else:
        qstr = qstr +  f':APCP:surface:{i}-{i+1} h*)'

@blaylockbk
Copy link
Owner

Using

searchString=":APCP:surface:[1-9].*-[1-9].*"

(with .* instead of *) almost does the trick.

Old Search String doesn't capture all cases
image

New Search String almost captures everything
image

@blaylockbk
Copy link
Owner

(If ChatGTP was online, I'd ask it to figure out the right search string) 😂

@blaylockbk
Copy link
Owner

The brute force method is a good example I'll add to the docs for complex cases.

There's probably a cleaner regex for this, but this captures all 1-hr accumulated precip

:APCP:surface:(?:0-1|[1-9].*-\d+) hour acc fcst

image

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

Successfully merging a pull request may close this issue.

2 participants