-
Notifications
You must be signed in to change notification settings - Fork 131
feat(wind): Bias correct wind speeds based on scaling to a known average #405
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
base: master
Are you sure you want to change the base?
Changes from 8 commits
e7af2b4
1d4442d
daa5877
4b020d7
4abf434
f9ecafa
606850e
f1e154e
e28eba1
1405b16
de38bec
bdb4f8e
f9f4d77
fc33325
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,14 +31,15 @@ def get_features( | |
| tmpdir=None, | ||
| monthly_requests=False, | ||
| concurrent_requests=False, | ||
| **parameter_updates, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use this for internal methods, but it's much more readable and gives a better docs/api reference if we avoid this general kwargs handling
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, we don't know at cutout creation time or in the prepare doc-string, which of these parameters exist, since they are datasets module specific. So, I don't think there is much i can do about this here. |
||
| ): | ||
| """ | ||
| Load the feature data for a given module. | ||
|
|
||
| This get the data for a set of features from a module. All modules | ||
| in `atlite.datasets` are allowed. | ||
| """ | ||
| parameters = cutout.data.attrs | ||
| parameters = cutout.data.attrs | parameter_updates | ||
| lock = SerializableLock() | ||
| datasets = [] | ||
| get_data = datamodules[module].get_data | ||
|
|
@@ -58,7 +59,7 @@ def get_features( | |
|
|
||
| datasets = compute(*datasets) | ||
|
|
||
| ds = xr.merge(datasets, compat="equals") | ||
| ds = xr.merge([da for da in datasets if da is not None], compat="equals") | ||
| for v in ds: | ||
| da = ds[v] | ||
| da.attrs["module"] = module | ||
|
|
@@ -140,6 +141,7 @@ def cutout_prepare( | |
| dask_kwargs=None, | ||
| monthly_requests=False, | ||
| concurrent_requests=False, | ||
| **parameter_updates, | ||
| ): | ||
| """ | ||
| Prepare all or a selection of features in a cutout. | ||
|
|
@@ -185,6 +187,8 @@ def cutout_prepare( | |
| concurrent_requests : bool, optional | ||
| If True, the monthly data requests are posted concurrently. | ||
| Only has an effect if `monthly_requests` is True. The default is False. | ||
| **parameter_updates | ||
| Updates of creation parameters | ||
|
|
||
| Returns | ||
| ------- | ||
|
|
@@ -224,19 +228,27 @@ def cutout_prepare( | |
| data_format=data_format, | ||
| monthly_requests=monthly_requests, | ||
| concurrent_requests=concurrent_requests, | ||
| **parameter_updates, | ||
| ) | ||
| new_features = set(da.attrs["feature"] for da in ds.data_vars.values()) | ||
| if not new_features: | ||
| logger.warning("No new features prepared") | ||
| return | ||
| attrs = non_bool_dict( | ||
| cutout.data.attrs | ||
| | ds.attrs | ||
| | dict(prepared_features=list(prepared | new_features)) | ||
| | parameter_updates | ||
| ) | ||
| prepared |= set(missing_features) | ||
|
|
||
| cutout.data.attrs.update(dict(prepared_features=list(prepared))) | ||
| attrs = non_bool_dict(cutout.data.attrs) | ||
| attrs.update(ds.attrs) | ||
|
|
||
| # Add optional compression to the newly prepared features | ||
| if compression: | ||
| for v in missing_vars: | ||
| ds[v].encoding.update(compression) | ||
| for da in ds.data_vars.values(): | ||
| da.encoding.update(compression) | ||
|
|
||
| ds = cutout.data.merge(ds[missing_vars.values]).assign_attrs(**attrs) | ||
| ds = cutout.data.merge( | ||
| ds[missing_vars.loc[list(new_features)].values] | ||
| ).assign_attrs(attrs) | ||
|
|
||
| # write data to tmp file, copy it to original data, this is much safer | ||
| # than appending variables | ||
|
|
||
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.
The check if
apply_windspeed_bias_correctionactually does something should be done here and not within the method. If it's called it should do/ raise something or should not even be called.