Events (s2stools.events)
Finding events in the forecasts and creating composites.
ssw_composite = EventComposite(data, "path/to/eventlists*.json", descr="Sudden Warmings", model="ecmwf")
Class
- class s2stools.events.EventComposite(data, events, descr, model)
- __init__(data, events, descr, model)
Composite class
Generate an instance my_composite of the class EventComposite and analyse the composite data using instance my_composite.comp.
- Parameters:
data (xr.Dataset) – dataset with appropriate dimensions (reftime, leadtime, hc_year, number, …)
events ((str or list)) – if str, then define the path, e.g., json/s2s_events/MODEL/ssw/* (model will automatically replaced by self.model) if list then of format [{fc: {reftime: None, hc_year: None, number: None}, days_since_init: None}, {…}]
descr (str) – event description, e.g., used for plot titles
model (str) – model name, e.g., ecmwf or ukmo
Examples
>>> ssw_composite = EventComposite(data, "path/to/eventlists*.json", descr="sudden warmings", model="ecmwf") >>> ssw_composite <s2stools.events.EventComposite> of 182 events of type 'sudden warmings'. --> see composite dataset using my_event_composite.comp >>> ssw_composite.comp <xarray.Dataset> Dimensions: (lagtime: 73, longitude: 2, latitude: 1, i: 182) Coordinates: * lagtime (lagtime) timedelta64[ns] -36 days -35 days ... 35 days 36 days * longitude (longitude) float32 -180.0 -177.5 * latitude (latitude) float32 60.0 number (i) int64 0 3 4 5 6 8 10 3 8 10 ... 39 40 42 43 44 45 46 47 48 49 reftime (i) datetime64[ns] 2017-11-16 2017-11-16 ... 2017-11-20 hc_year (i) int64 -20 -20 -20 -20 -20 -20 -20 -19 -19 ... 0 0 0 0 0 0 0 0 validtime (i, lagtime) datetime64[ns] NaT NaT NaT NaT ... NaT NaT NaT NaT leadtime (i) timedelta64[ns] 11 days 11 days 10 days ... 19 days 16 days * i (i) int64 0 1 2 3 4 5 6 7 8 ... 174 175 176 177 178 179 180 181 Data variables: u (i, latitude, longitude, lagtime) float32 dask.array<chunksize=(1, 1, 2, 73), meta=np.ndarray>
- comp = None
Access the composite dataset using my_event_composite.comp
- data = None
Obtain the original feded data using my_event_composite.data
- descr = ''
Access the composite description using my_event_composite.descr
Functions
- s2stools.events.bootstrap_extr_prob(population, sample_size, dsi_slice, threshold, alpha=0.05, n_bootstrap_samples=1000)
Bootstrapping forecasts to compute mean and confidence interval for probability that NAM is below threshold.
- Parameters:
population (DataArray) – dimensions ‘fc’ and ‘days_since_init’
sample_size (int) – size of one sample that is bootstrapped
dsi_slice (int) – at which ‘days_since_init’ to start to bootstrap
threshold (int) – NAM below which threshold?
alpha (float, optional) – alpha-level for confidence interval. Defaults to 0.05.
n_bootstrap_samples (int, optional) – times to repeat drawing samples from the population. Defaults to 1_000.
- Returns:
(mean, (CI_bottom, CI_top))
- Return type:
(float, (float, float))
- s2stools.events.extreme_predictors(data_comp)
Compute the fraction of events with nam1000 below 0, -3 and above +3.
- Parameters:
data_comp (xr.Dataset) – Dataset that contains variable nam1000 and dimensions “days_since_event” and “i”.
- Returns:
Dataset with dimension “days_since_event”
- Return type:
xr.Dataset
- s2stools.events.find_ssw(u60_10hPa, buffer_start=10, buffer_end=10, require_westwind_start=10) list
Find Sudden Stratospheric Warmings in S2S forecast.
- Parameters:
u60_10hPa (xr.DataArray) – zonal wind at 60N 10hPa, requires dimensions reftime, hc_year, number
buffer_start (int) – When are events allowed to happen the earliest?
buffer_end (int) – When are events allowed to happen the latest?
require_westwind_start (int) – How many days should u60 start positive?
- Return type:
list
See also
s2stools.events._composite_from_eventlist()Warning
There could have been a major SSW before the start of the forecast. In that case, the first zero-crossing in the forecast might actually not be a real SSW. In the future, it would be nice to append the reanalysis ahead of the forecast to check the preceding vortex evolution.
- s2stools.events.ssw_compendium_event_dates(column='ERA-Interim')
Read html table from SSW compendium
Butler et al. 2017 A sudden stratospheric warming compendium https://doi.org/10.5194/essd-9-63-2017
- Parameters:
column (str) – Indicating the different datasets, see website for available options. Defaults to ‘ERA-Interim’.
- Returns:
dates – Sudden Warming dates
- Return type:
pd.Series