2.3.13. vacumm.misc.stats – Statistiques spéciales

2.3.13.2. Content

Statistical tools

class StatAccum(tall=False, tavail=None, tmean=None, tstd=None, smax=None, smin=None, tbias=None, trms=None, tcrms=None, tcorr=None, shist=None, tcount=None, sall=False, savail=None, smean=None, sstd=None, tmax=None, tmin=None, sbias=None, srms=None, scrms=None, scorr=None, thist=None, scount=None, bins=None, restart_file=None, restart=False, withtime=None)[source]

Bases: object

Statistics accumulator

Generic params:
  • t/sall: Perform all the statistics by default.
  • withtime, optional: Input does not contain a time dimension.
Single:
  • tcount/scount: Number of observations taken into account
  • tavail/savail: Percentage of available observations
  • tmean/smean: Temporal (t) / Spatial (s) average
  • tstd/sstd: Temporal (t) / Spatial (s) std
Dual:
  • tall: Perform all the following statistics by default.
  • tbias/sbias: Temporal (t) / Spatial (s) bias
  • trms/srms: Temporal (t) / Spatial (s) RMS
  • tcrms/scrms: Temporal (t) / Spatial (s) centered RMS
  • tcorr/scorr: Temporal (t) / Spatial (s) Correlation
Example:
>>> sa = StatAccum(tbias=True, srms=True)
>>> sa += ssta1, sstb1
>>> sa += ssta2, sstb2
>>> tbias = sa.get_tbias()
>>> srms = sa.get_srms()
all_stats = ('mean', 'std', 'hist', 'min', 'max', 'bias', 'rms', 'crms', 'corr', 'avail', 'count')
append(*items)[source]

Append data to the accumulator

default_restart_file = 'stataccum_restart.nc'
dual_stats = ('bias', 'rms', 'crms', 'corr', 'avail', 'count')
dump(restart_file=None)[source]

Dump the current instance to a netcdf file

get_savail(**kwargs)[source]

Get the spatial availability

get_sbias(**kwargs)[source]

Get the spatial bias

get_scorr(**kwargs)[source]

Get the spatial correlation

get_scount(**kwargs)[source]

Get the spatial count

get_scrms(**kwargs)[source]

Get the spatial centered RMS difference

get_shist(**kwargs)[source]

Get the spatial histogram

get_smean(**kwargs)[source]

Get the spatial standard deviation

get_srms(**kwargs)[source]

Get the spatial absolute RMS difference

get_sstats(**kwargs)[source]

Get all spatial statistics as a dictionary

get_sstd(**kwargs)[source]

Get the spatial mean

get_stats()[source]

Get all statistics as dict

get_tavail(**kwargs)[source]

Get the temporal availability

get_tbias(**kwargs)[source]

Get the temporal bias

get_tcorr(**kwargs)[source]

Get the temporal correlation

get_tcount(**kwargs)[source]

Get the temporal count

get_tcrms(**kwargs)[source]

Get the temporal centered RMS difference

get_thist(**kwargs)[source]

Get the temporal histogram

get_tmean(**kwargs)[source]

Get the temporal standard deviation

get_trms(**kwargs)[source]

Get the temporal absolute RMS difference

get_tstats(**kwargs)[source]

Get all temporal statistics as a dictionary

get_tstd(**kwargs)[source]

Get the temporal mean

isempty()[source]
load(restart_file=None, iterindex=None, nowtime=None)[source]

Load the current instance from a netcdf file

Params:
  • restart_file, optional: Netcdf restart file.
  • iterindex, optional: If given, the restart file is not loaded if iterindex is greater or equal to the file’s iterindex attribute.
  • nowtime, optional: If given, the restart file is not loaded if nowtime is greater or equal to the file’s lasttime attribute.
single_stats = ('mean', 'std', 'hist', 'min', 'max')
exception StatAccumError[source]

Bases: vacumm.VACUMMError

args
message
corr_proba(r, ndata, ndataset=2, dof=False)[source]

Probability of rejecting correlations

  • r: Correlation coefficient
  • ndata: Number of records use for correlations
  • ndataset, optional: Number of datasets (1 for autocorrelations, else 2) [default: 2]

Todo

This must be rewritten using scipy.stats

ensrank(obs, ens, gethist=False, getnrz=False, centered=False)[source]

Compute the rank of a reference (observations) in an ensemble

If nens is the size of the ensemble, the rank may go from 0 to nens.

  • obs, (…): Observation array
  • ens, (nens,…): Ensemble array
  • getrank, optional: If True, return also the rank histogram
  • getnrz, optional: If True, return also non recovery zones
  • centered, optional: Center the ensemble data on the observations before computing the rank
qtmax(var, qt=95.0)[source]

Get max using quantiles

This is useful for very asymmetic distributions

Params:
  • var: A numeric array.
  • qt, optional: Percentile used to define max
qtmin(var, qt=5.0)[source]

Get min max using quantiles

This is useful for very asymmetic distributions

Params:
  • var: A numeric array.
  • qt, optional: Percentile used to define min
qtminmax(var, qt=5.0)[source]

Get min and max using quantiles

This is useful for very asymmetic distributions

Params:
  • var: A numeric array.

  • qt, optional: Percentile used to define min and max

    • Single number: qt -> [qt, 100-qt]
    • Two elements: used directly.