DT Climate Energy Offshore use case
Project description
DT CLIMATE - ENERGY OFFSHORE USE CASE
This is a python package used in the Destination Earth: Digital Twin of Climate simulations project to produce a set of statistics in support of offshore wind farm siting and long term operations. It includes functions for calculating monhtly mean climatologies, monhtly extreme climatologies (includes interannual variability), monhtly weather window climatologies (frequency of suitable conditions to exist)
Installation
After installing the dependencies: Xarray, Dask, Distributed, Matplotlib, Cartopy, and, Numpy
The package can be installed using
pip install EnergyOffshore
Usage
Import using
from EnergyOffshore import EnergyOffshore_analysis_and_visualization as EO
which allows using functions as EO.function_name(function_inputs)
API content
The package includes the following functions
FUNCTIONS
compute_climatologies(data, config)
Compute monthly climatologies and save them to netcdf files.
Input:
-------
config: dict, loaded from the configuration.yml file and including
the names of the desired variables under the key {'var_exceed'}
and their desired exceedance values. Climatological output
will be saved under the directory defined by 'data_path' key.
data: dict of xr.DataArrays (time,lat,lon). The xr.DataArrays are the daily exceedance
statistics of a given variable (1-24 if based on hourly data, 0-1 if based on daily data).
The dict entries are names like 'var_name_exceed_limit' e.g. ws10_exceed_21 for 10 m wind
exceeding 21 m/s.
Output:
-------
This function does not return any variables, but instead will save monthly statistics to annual files
under the directory defined in configuration yml file by the 'data_path' key.
compute_extreme_climatology(var, quantiles=[0.05, 0.5, 0.95])
Calculate interannual extemes for each month assuming
that input array is monthly data
Input:
------
var: xr.DataArray (time, lat, lon), timeseries of data at any sub-monthly frequency.
quantiles: List or Array (default=[0.05,0.5,0.95]), specifying the quantiles of interannual variability [0-1]
Output:
-------
var_out: xarray.DataArray (month,lat,lon,quantile), output climatology with quantiles specifying the range of interannual variability
compute_weather_windows(suitable_conditions, windows=[3, 5, 7])
Determine how likely it is that in a given month
one will find a weather window (user defined criteria)
Input:
----------
suitable_conditions: xr.DataArray [time,lat,lon], mask [0 or 1]
of suitable conditions that match user
defined criteria (float)
windows: list or numpy.array, weather window lengths in days (int)
Output:
----------
weather_window: xarray.DataArray (month,lat,lon,window), mean monthly likelihood [0-1]
of being within the user defined criteria (i.e. not exceeding the criteria)
load_data(config)
Load data give the config dictionary
Input:
------
config: dict, loaded from the configuration.yml file and including
the names of the desired variables under the key {'var_exceed'}
and their desired exceedance values.
Output:
-------
data: dict of xr.DataArrays (time,lat,lon). The xr.DataArrays are the daily exceedance
statistics of a given variable (1-24 if based on hourly data, 0-1 if based on daily data).
The dict entries are names like 'var_name_exceed_limit' e.g. ws10_exceed_21 for 10 m wind
exceeding 21 m/s.
plot_climatology(climatology, weather_windows, config, plot_name='DT_climate_threshold_exceedance_with_weather_windows.png', plot_windows=True, proj=None, extent=Non
e, levels=None)
Plot the climatological frequencies of 'suitable conditions' on a map with/without weather windows
using matplotlib and cartopy.
Input:
-------
climatology: xr.DataArray [time,lat,lon], mean climatology of a given 'suitable condition'
weather_windows: xarray.DataArray (month,lat,lon,window), mean monthly likelihood [0-1]
of being within the user defined criteria (i.e. not exceeding the criteria)
plot_name: str, define the name of the plot (including the path)
plot_windows: boolean, whether to include weather_window contours on the map (default=True)
proj: cartopy map projection (default=None), if not given NearSidePespective centered on
northern Europe will be used.
extent: list or array [lon_min,lon_max,lat_min,lat_max] (default=None),
if not None will be used to clip the extent of the map (no effect if None)
Output:
-------
Does not return variables, but produces a figure in user defined location (plot_name)
plot_climatology_at_location(climatology, extreme_climatology, areas, plot_name)
Make a climatological plot of given variable at a location.
Input:
------
climatology: xr.DataArray [time,lat,lon], mean climatology of a given 'suitable condition'
extreme_climatology: xr.DataArray [time,lat,lon,quantile],
interannual extreme climatology of a given 'suitable condition'.
Quantiles are assumed to include [0.05,0.5,0.95].
areas: dict, {area: {'name':'long_name_of_the_area'
'lon_slice':[lon_min,lon_max]
'lat_slice':[lat_min,lat_max]
}}
plot_name: str, define the name of the plot (including the path)
Output:
-------
Does not return variables, but produces a figure in user defined location (plot_name)
preprocess(ds)
Preprocess a dataset checking for variable 'valid_time' and drop it if found
Input:
------
ds: xarray.Dataset
Output:
-------
ds: xarray.Dataset without the variable 'valid_time'
verify_climatology_at_location(climatologies, extreme_climatologies, areas, plot_name)
Produce a climatology comparing the model output to reanalysis
Input:
------
climatologies: dict of xr.DataArray [time,lat,lon], mean climatologies of a given 'suitable condition'.
dict entries are the different conditions for a given model.
extreme_climatologies: dict xr.DataArray [time,lat,lon,quantile],
interannual extreme climatology of a given 'suitable condition'.
Quantiles are assumed to include [0.05,0.5,0.95].
dict entries are the different conditions for a given model.
areas: dict, {area: {'name':'long_name_of_the_area'
'lon_slice':[lon_min,lon_max]
'lat_slice':[lat_min,lat_max]
}}.
Climatologies will be averaged over these areas.
plot_name: str, define the name of the plot (including the path)
Output:
-------
Does not return variables, but produces a figure in user defined location (plot_name)\
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file energyoffshore-0.2.7.tar.gz
.
File metadata
- Download URL: energyoffshore-0.2.7.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b2e4ffcfc0eef97e4fc856517e4cd62d97fe24dd2c4653923f586b6467ad744 |
|
MD5 | 55b57f87a032490b57bce109726746ee |
|
BLAKE2b-256 | faf7a776ee23486dedcd2ff1619fc3aac3b08f6a12bebb9f3e3d4844cf98aaef |
File details
Details for the file energyoffshore-0.2.7-py3-none-any.whl
.
File metadata
- Download URL: energyoffshore-0.2.7-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c64f3a05abbbd63c79d89f890132dd1257ed454cd145d93d57c54ba285267322 |
|
MD5 | bcfdc540f2571341a2bcb1849e7fb54a |
|
BLAKE2b-256 | 0c83b2b1fa3e633972cc19f6f14b2871436d90fdcc4cb01ef6c8355fb2f6fc3f |