-
Notifications
You must be signed in to change notification settings - Fork 131
wave energy converters and new wind and wave data modules #475
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 2 commits
5f87745
20045e1
ffb156d
2b0380e
dcffaef
3383ebc
7b6872f
335a67c
1b7efd7
7067490
3f0c0df
7aaae50
a1a2aaa
963896d
76f94fd
5f6cfe2
39eefe6
ba748f4
f2acfc4
1de851d
83ae74a
669ad8e
400b591
4a3e2a2
c76e86c
124a9d2
66a2d65
9cb7ff7
58d0a2c
a63d82c
0c50fa9
d53fdd6
0c0b726
5cc55a8
8b4ae18
9b7cae6
b06dfd3
0363202
270951b
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 |
|---|---|---|
|
|
@@ -27,3 +27,4 @@ paper | |
| # Ignore IDE project files | ||
| .idea/ | ||
| .vscode | ||
| .vs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| from atlite.resource import ( | ||
| get_cspinstallationconfig, | ||
| get_solarpanelconfig, | ||
| get_wecgeneratorconfig, | ||
| get_windturbineconfig, | ||
| windturbine_smooth, | ||
| ) | ||
|
|
@@ -653,6 +654,67 @@ def wind( | |
| ) | ||
|
|
||
|
|
||
| # #wave | ||
| def convert_wave(ds, wec_type): | ||
| power_matrix = pd.DataFrame.from_dict(wec_type["Power_Matrix"]) | ||
|
Contributor
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. You should have a docstring here |
||
|
|
||
| max_pow = power_matrix.to_numpy().max() | ||
|
|
||
| Hs = np.ceil(ds["wave_height"] * 2) / 2 | ||
| Tp = np.ceil(ds["wave_period"] * 2) / 2 | ||
|
|
||
| Hs_list = Hs.to_numpy().flatten().tolist() | ||
| Tp_list = Tp.to_numpy().flatten().tolist() | ||
|
|
||
| # empty list for result | ||
| power_list = [] | ||
| cases = len(Hs_list) | ||
| count = 0 | ||
|
|
||
| # for loop to loop through Hs and Tp pairs and get the power output and capacity factor | ||
| for Hs_ind, Tp_ind in zip(Hs_list, Tp_list): | ||
| if count % 1000000 == 0: | ||
| print(f"Case {count} of {cases}: {count / cases * 100} %") | ||
|
|
||
| if np.isnan(Hs_ind) or np.isnan(Tp_ind): | ||
| power_list.append(0) | ||
| elif Hs_ind > 10 or Tp_ind > 18: | ||
|
Contributor
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. These are cut-outs, I assume. Should they not be specified in the power matrices? Or, rather, they look to be outside the matrices, so we'd get cf NaN values, which we can fill with zeros later. That way, it doesn't cause a silent error if in future a power matrix is added that has non-zero values above these thresholds.
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. You are correct they indicate the older limits of power conversion. It is true that they are already specified in the matrices so this power filter can be erased from this section. |
||
| power_list.append(0) | ||
| else: | ||
| generated_power = power_matrix.loc[Hs_ind, Tp_ind] | ||
| power_list.append(generated_power / max_pow) | ||
| count += 1 | ||
|
|
||
| # results list to numpy array | ||
| power_list_np = np.array(power_list) | ||
|
|
||
| power_list_np = power_list_np.reshape(Hs.shape) | ||
|
Contributor
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. This approach is quite inefficient for combining two matrices of data. We want to vectorise operations where possible. I have an idea how to achieve this which I'll test locally and then come back to you. |
||
|
|
||
| da = xr.DataArray( | ||
| power_list_np, coords=Hs.coords, dims=Hs.dims, name="Power generated" | ||
| ) | ||
| da.attrs["units"] = "kWh/kWp" | ||
| da = da.rename("specific generation") | ||
| da = da.fillna(0) | ||
|
|
||
| return da | ||
|
|
||
|
|
||
| def wave(cutout, wec_type, **params): | ||
|
lmezilis marked this conversation as resolved.
Outdated
|
||
| """ | ||
| Generate wave generation time series | ||
|
|
||
| evaluates the significant wave height (Hs) and wave peak period (Tp) | ||
|
Contributor
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. Since |
||
| and assesses the power output with the chosen power matrix for each time step and grid cell | ||
| """ | ||
| if isinstance(wec_type, (str, Path)): | ||
| wec_type = get_wecgeneratorconfig(wec_type) | ||
|
|
||
| return cutout.convert_and_aggregate( | ||
| convert_func=convert_wave, wec_type=wec_type, **params | ||
| ) | ||
|
|
||
|
|
||
| # irradiation | ||
| def convert_irradiation( | ||
| ds, | ||
|
|
||
|
Contributor
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. Since CERRA is available via the Climate Data Store, we should follow the same approach to data retrieval as with ERA5. You could probably just copy It might be best to drop this from this PR, though, and bring it in separately later. I can see a benefit to changing the features we bring in for wind since we can retrieve wind speed at various height/pressure levels from CDS, which would allow us to create a wind vertical profile (as we do with ERA5 data).
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. The problem with CERRA here is that there is a lot of preprocessing of data in order for atlite to be able to read it. I agree that it is best to review this later. Should I take an action on this or can you simply reject this file?
Contributor
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. The easiest is for you to simply delete this file (and reference to |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| """ | ||
| In order to create a CERRA cutout, the data must be manually downloaded from the Climate Data Store. | ||
| The variable used is "10m wind speed" and there is not a direction component in it. | ||
| This 10m wind speed was transformed into a 100m wind speed in order to follow the rest of atlite's processes. | ||
| """ | ||
|
|
||
| import logging | ||
|
|
||
| import numpy as np | ||
| import xarray as xr | ||
| from rasterio.warp import Resampling | ||
|
|
||
| from atlite.gis import regrid | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| crs = 4326 | ||
| dx = 0.05 | ||
| dy = 0.05 | ||
|
|
||
| features = {"wind": ["wnd100m", "roughness"]} | ||
|
|
||
|
|
||
| def as_slice(bounds, pad=True): | ||
| """ | ||
| Convert coordinate bounds to slice and pad by 0.01. | ||
| """ | ||
| if not isinstance(bounds, slice): | ||
| bounds = bounds + (-0.01, 0.01) | ||
| bounds = slice(*bounds) | ||
| return bounds | ||
|
|
||
|
|
||
| def get_data(cutout, feature, tmpdir, **creation_parameters): | ||
| """ | ||
| Retrieve data from a local CERRA dataset and process it. | ||
| """ | ||
| coords = cutout.coords | ||
|
|
||
| if "data_path" not in creation_parameters: | ||
| logger.error('Argument "data_path" not defined') | ||
| raise ValueError('Argument "data_path" not defined') | ||
| path = creation_parameters["data_path"] | ||
|
|
||
| ds = xr.open_dataset(path) | ||
|
|
||
| ds = ds.sel(x=as_slice(cutout.extent[:2]), y=as_slice(cutout.extent[2:])) | ||
| ds = ds.assign_coords(x=ds.x.astype(float).round(4), y=ds.y.astype(float).round(4)) | ||
|
|
||
| if (cutout.dx != dx) or (cutout.dy != dy): | ||
| ds = regrid(ds, coords["x"], coords["y"], resampling=Resampling.average) | ||
|
|
||
| if "sr" in ds: | ||
| ds = ds.rename({"sr": "roughness"}) | ||
|
|
||
| logger.info("Calculating 100 metre wind speed") | ||
| if "si10" in ds and "roughness" in ds: | ||
| ds["wnd100m"] = ( | ||
| ds["si10"] * (np.log(100 / ds["roughness"]) / np.log(10 / ds["roughness"])) | ||
| ).assign_attrs(units="m s**-1", long_name="100 metre wind speed") | ||
| ds = ds.drop_vars("si10") | ||
|
|
||
| ds = ds.assign_coords(x=ds.coords["x"], y=ds.coords["y"]) | ||
|
|
||
| logger.info("Resampling to 1H.") | ||
| ds = ds.resample(time="1h").interpolate("linear") | ||
|
|
||
| return ds |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ def nullcontext(): | |
|
|
||
| features = { | ||
| "height": ["height"], | ||
| "wind": ["wnd100m", "wnd_shear_exp", "wnd_azimuth", "roughness"], | ||
| "wind": ["wnd100m", "wnd_azimuth", "roughness"], | ||
|
Contributor
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. you probably didn't mean to delete
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. Yes I was working with an older version of atlite, this was accidental. |
||
| "influx": [ | ||
| "influx_toa", | ||
| "influx_direct", | ||
|
|
@@ -55,6 +55,8 @@ def nullcontext(): | |
| ], | ||
| "temperature": ["temperature", "soil temperature", "dewpoint temperature"], | ||
| "runoff": ["runoff"], | ||
| "wave_height": ["wave_height"], | ||
| "wave_period": ["wave_period"], | ||
|
Contributor
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. Collapse this into a
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. Correct, thank you. |
||
| } | ||
|
|
||
| static_features = {"height"} | ||
|
|
@@ -244,6 +246,53 @@ def sanitize_runoff(ds): | |
| return ds | ||
|
|
||
|
|
||
| def get_data_wave_height(retrieval_params): | ||
| """ | ||
| Get wave height data for given retrieval parameters. | ||
| """ | ||
| ds = retrieve_data( | ||
| variable=[ | ||
| "significant_height_of_combined_wind_waves_and_swell", | ||
| ], | ||
| **retrieval_params, | ||
| ) | ||
| ds = _rename_and_clean_coords(ds) | ||
| ds = ds.rename({"swh": "wave_height"}) | ||
|
|
||
| return ds | ||
|
|
||
|
|
||
| def sanitize_wave_height(ds): | ||
| """ | ||
| Sanitize retrieved wave height data. | ||
| """ | ||
| ds["wave_height"] = ds["wave_height"].clip(min=0.0) | ||
| return ds | ||
|
|
||
|
|
||
| def get_data_wave_period(retrieval_params): | ||
| """ | ||
| Get wave period data for given retrieval parameters. | ||
| """ | ||
| ds = retrieve_data( | ||
| variable=["peak_wave_period"], | ||
| **retrieval_params, | ||
| ) | ||
|
|
||
| ds = _rename_and_clean_coords(ds) | ||
| ds = ds.rename({"pp1d": "wave_period"}) | ||
|
|
||
| return ds | ||
|
|
||
|
|
||
| def sanitize_wave_period(ds): | ||
| """ | ||
| Sanitize retrieved wave period data. | ||
| """ | ||
| ds["wave_period"] = ds["wave_period"].clip(min=0.0) | ||
| return ds | ||
|
|
||
|
|
||
| def get_data_height(retrieval_params): | ||
| """ | ||
| Get height data for given retrieval parameters. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,108 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import numpy as np | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import xarray as xr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from rasterio.warp import Resampling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from atlite.gis import regrid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crs = 4326 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dx = 0.0625 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dy = 0.04 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| features = {"wave_height": ["wave_height"], "wave_period": ["wave_period"]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. This is unused, I suggest you change it to allow you to use it later on
Suggested change
Then, you can get rid of the very simple |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _rename_and_clean_coords(ds): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Rename 'longitude' and 'latitude' columns to 'x' and 'y' and fix roundings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Optionally (add_lon_lat, default:True) preserves latitude and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| longitude columns as 'lat' and 'lon'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. you mention this option in the docstring but it isn't in the method signature. Do you want to include this option or not?
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. this option was not necessary for the mrel wave files. I eventually renamed the dimentions in the last part of the script. I would say that the function "_rename_and_clean_coords" can be deleted here. do you think we should include this option? EDIT: I saw the rest of the comments now, I will include the function and try to make it as similar to era5 as possible. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.rename({"longitude": "x", "latitude": "y"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.assign_coords( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x=np.round(ds.x.astype(float), 5), y=np.round(ds.y.astype(float), 5) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def get_data_wave_height(ds): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.rename({"hs": "wave_height"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. No need, this renaming is happening in the main function now ( |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds["wave_height"] = ds["wave_height"].clip(min=0.0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def get_data_wave_period(ds): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.rename({"tp": "wave_period"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. No need, this renaming is happening in the main function now ( |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ds["wave_period"] = (1 / ds["wave_period"]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. It's always better to rely on version history to recover lines of code you no longer need, rather than commenting them out. So, feel free to delete all your commented out lines!
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. Yes, sorry for this, I thought I did that for every file but forgot this one. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds["wave_period"] = ds["wave_period"].clip(min=0.0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. Keep the process the same as in
Contributor
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. EDIT: you don't actually need these
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. you are correct, I was working with these files a long time ago, figuring out how which functions I need, will correct this! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def as_slice(bounds, pad=True): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Convert coordinate bounds to slice and pad by 0.01. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not isinstance(bounds, slice): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bounds = bounds + (-0.01, 0.01) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bounds = slice(*bounds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return bounds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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.
Suggested change
Then, below, use This (a) explicitly uses your |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def get_data(cutout, feature, tmpdir, **creation_parameters): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| coords = cutout.coords | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "data_path" not in creation_parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger.error('Argument "data_path" not defined') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise ValueError('Argument "data_path" not defined') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path = creation_parameters["data_path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = xr.open_dataset(path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "longitude" in ds and "latitude" in ds: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.rename({"longitude": "x", "latitude": "y"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.sel(x=as_slice(cutout.extent[:2]), y=as_slice(cutout.extent[2:])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.assign_coords(x=ds.x.astype(float).round(4), y=ds.y.astype(float).round(4)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. You have some repetition here w.r.t. However, since you only have one dataset from the start, you could call |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (cutout.dx != dx) or (cutout.dy != dy): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = regrid(ds, coords["x"], coords["y"], resampling=Resampling.average) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. Move this to |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # coords = cutout.coords | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # if "data_path" not in creation_parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # logger.error('Argument "data_path" not defined') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # return None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # path = creation_parameters["data_path"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # logger.info(f"Opening dataset from {path}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ds = xr.open_dataset(path, chunks=cutout.chunks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ds = _rename_and_clean_coords(ds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. delete |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables = ds.data_vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for var in variables: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if var not in ["hs", "tp"]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = ds.drop_vars(var) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ds = ds.sel(x=as_slice(cutout.extent[:2]), y=as_slice(cutout.extent[2:])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # if (cutout.dx != dx) or (cutout.dy != dy): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ds = regrid(ds, coords["x"], coords["y"], resampling=Resampling.average) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger.info("Obtaining wave data.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = get_data_wave_height(ds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ds = get_data_wave_period(ds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ds = ds.assign_coords(x=ds.coords["x"], y=ds.coords["y"]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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.
Suggested change
See my suggestion above on how to make this work by updating the
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. Thank you very much for this suggestion. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
It's generally best to add these pointers to your own "global" gitignore, rather than to every project you work on. That way, it never accidentally slips in without you realising it!