climpred.classes.PerfectModelEnsemble.smooth#
- PerfectModelEnsemble.smooth(smooth_kws: str | Dict[str, int] | None = None, how: str = 'mean', drop: bool = False, **xesmf_kwargs: str)#
Smooth in space and/or aggregate in time in
PredictionEnsemble.- Parameters:
smooth_kws – Dictionary to specify the dims to smooth compatible with
spatial_smoothing_xesmf()ortemporal_smoothing(). Shortcut for Goddard et al. [2013]goddard2013. Defaults toNone.how – how to smooth temporally. From Choose from
["mean", "sum"]. Defaults to"mean".drop – If
Trueand"lead"is insmooth_kws, subsample the smoothed rolling windows to non-overlapping windows (everyn-th lead, wherenis the smoothing length). For example,smooth({"lead": 3}, drop=True)on a forecast with leads1..10yields leads"1-3", "4-6", "7-9"instead of the default overlapping"1-3", "2-4", ..., "8-10". Defaults toFalse.**xesmf_kwargs – kwargs passed to
spatial_smoothing_xesmf()
Examples
>>> PerfectModelEnsemble.get_initialized().lead.size 20 >>> PerfectModelEnsemble.smooth( ... {"lead": 4}, how="sum" ... ).get_initialized().lead.size 17
>>> HindcastEnsemble_3D.smooth({"lon": 1, "lat": 1}) <climpred.HindcastEnsemble> Initialized: SST (init, lead, lat, lon) float32 123kB -0.3236 -0.3161 ... 0.0 0.0 Uninitialized: None Observations: SST (time, lat, lon) float32 13kB 0.002937 0.001561 ... 0.0 0.0
smoothsimultaneously aggregates spatially listening tolonandlatand temporally listening toleadortime.>>> HindcastEnsemble_3D.smooth( ... {"lead": 2, "lat": 5, "lon": 4} ... ).get_initialized().coords Coordinates: * init (init) object 512B 1954-01-01 00:00:00 ... 2017-01-01 00:00:00 * lead (lead) int32 36B 1 2 3 4 5 6 7 8 9 * lat (lat) float64 16B -9.75 -4.75 * lon (lon) float64 32B 250.8 254.8 258.8 262.8 valid_time (lead, init) object 5kB 1955-01-01 00:00:00 ... 2026-01-01 00... >>> HindcastEnsemble_3D.smooth("goddard2013").get_initialized().coords Coordinates: * init (init) object 512B 1954-01-01 00:00:00 ... 2017-01-01 00:00:00 * lead (lead) int32 28B 1 2 3 4 5 6 7 * lat (lat) float64 16B -9.75 -4.75 * lon (lon) float64 32B 250.8 255.8 260.8 265.8 valid_time (lead, init) object 4kB 1955-01-01 00:00:00 ... 2024-01-01 00...