Note
Go to the end to download the full example code.
Calculate Resource grid#
Example of using PyWAsP to calculate a resource grid
Prepare TopographyMap#
First, we need to prepare the topography map. This is done by reading the elevation and roughness maps and creating a TopographyMap object.
import numpy as np
import windkit as wk
import pywasp as pw
ssl = wk.load_tutorial_data("serra_santa_luzia")
topo_map = pw.wasp.TopographyMap(ssl.elev, ssl.rgh)
Define output locations#
Second, we need to define the output locations. This is done by creating a dataset with the coordinates of the output locations.
Calculate resource grid#
Finally, we can calculate the resource grid. This is done by calling the predict_wwc function. This function takes the output locations, the boundary conditions, and the topography map as input. The output is a weibull wind climate dataset at the output locations.
wwc = pw.wasp.predict_wwc(ssl.bwc, topo_map, output_locs)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/pywasp/wasp/meso_climate.py:351: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge([ds_baro, ds_stab])
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/spatial.py:1087: UserWarning: Clipping bbox including marging is outside the bounds of the dataset to clip!
warnings.warn(
/home/neil/DTU/repos/pywasp/modules/windkit/windkit/spatial/_interpolation.py:495: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
ds = xr.merge(results)
Plot the mean wind speed#
We can plot the mean wind speed to see the result.
wwc["wspd"].plot()
![height = 50 [m], crs = 0](../_images/sphx_glr_resource_grid_001.png)
Total running time of the script: (0 minutes 3.612 seconds)