-
Notifications
You must be signed in to change notification settings - Fork 416
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
Change defaults for parse_metar_file
#1327
Comments
My opinion is that you need more granularity here to also specify the day, so to get things right when parsing archived METARs around the first of the month. |
So I couple with @akrherz as I have run into this issue quite a bit and think we may need to add in hour as well. Here is some code that would work to alleviate the problem, but with the need to have year, month, day, and hour, then we might as well make the input be a date time object. from datetime import datetime, timedelta
import numpy as np
file_day = 31
file_hour = 23
file_minute = 50
known_date = datetime(2020, 2, 1, 0)
try:
file_date = datetime(known_date.year, known_date.month, file_day, file_hour, file_minute)
except:
file_date = datetime(known_date.year, known_date.month-1, file_day, file_hour, file_minute)
if np.abs(known_date - file_date) > timedelta(hours=1):
if month == 1:
file_date = datetime(known_date.year-1, 12, file_day, file_hour, file_minute)
else:
file_date = datetime(known_date.year, known_date.month-1, file_day, file_hour, file_minute)
print(known_date)
print(file_date) Output:
|
Only on days ending with the letter 'y'. Likely preaching to the choir here, but there's craziness on the noaaport feed, mostly international METARs
|
Right now, the signature of
parse_metar_file
is:This can create some confusion:
parse_metar_file(filename, year=2020, month=1)
)parse_metar_file
are not going to use the current year/month, but the year/month when MetPy was imported.So we should change this to default to
None
, and then check forNone
and convert that to the appropriate values.The text was updated successfully, but these errors were encountered: