-
Notifications
You must be signed in to change notification settings - Fork 1
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
WIP: fixed nc-bug, added dtype argument for monthly means, added quick fix… #14
Conversation
… in case no ValidDate is in attribute for nc
dlotter/arguments.py
Outdated
parser_plot.add_argument('--dataset', | ||
type=str, | ||
help='Set to DANRAmm if DANRA monthly means are used.', | ||
default='', | ||
required=False) |
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.
Either use default=None
(empty strings are a bit dangerous) or set the variable as store_true
so it can be used as a boolean flag instead.
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.
Indeed - should a similar change be added to --prefix and --postfix?
@@ -183,7 +185,8 @@ def plot_t2m(self, args:argparse.Namespace, data:xr.Dataset) -> None: | |||
colors='black', | |||
levels=contour_levels, | |||
linewidths=0.7, | |||
transform=self.data_crs) | |||
transform=self.data_crs, | |||
transform_first=True) |
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.
cool!
forecast = '1900-Jan-01 '+str(12+k)+':00:00' | ||
else: | ||
forecast = f.getncattr('ValidDate') | ||
|
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.
To prevent a clash when using many files, we could use a dummy starttime before the loop and use an iterator to update the forecasttime.
maybe something like:
dummy_time = dt.datetime(1900,1,1,0) | |
for k,f in enumerate(files_to_read): | |
f = nc.Dataset(files_to_read[k]) | |
if not 'ValidDate' in f.ncattrs(): | |
dummy_time+=dt.timedelta(minutes=k) | |
print('Warning: ValidDate not in attributes, setting date to {}'.format(dummy_time.strftime('%Y-%b-%d %H:%M:%S'))) | |
forecast = dummy_time.strftime('%Y-%b-%d %H:%M:%S') | |
else: | |
forecast = f.getncattr('ValidDate') |
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.
Beautiful, but using k makes the time increase in a strange sequence, I think just using 1 minute for each file is "cleaner"?
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 actually think we should give time as NaN
if it is not found in the attributes. That will be much cleaner for the user.
… in case no ValidDate is in attribute for nc.
This branch is developed to make dlotter work for DANRA monthly means.