metrics.crpss
This class is for calculating the CRPSS (Continous Ranked Probability Skill Score) following the paper
of Goddard et al. (2012)
CRPSS Module
-
class metrics.crpss.Crpss(output='/tmp/crpss/output', output_plots='/tmp/crpss/plots', decadals='1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000', variable='tas', project='baseline0', product1='output', institute1='mpi-m', model='mpi-esm-lr', experiment='decadal', leadtimes='1, 2-9', observation='HadCrut', observation_ensemble='*', ensemblemembers='*', maskMissingValues=True, result_grid=False, cache='/tmp/crpss/cache', baseDir='./', timeFreq='mon', basic_output=True, bootstrapSwitch=False, bootstrap_number=2, leadtimes_mode='yearly', level=None, lonlatbox='', fieldmean=False, zonalmean=False, input_part='input1', colormap='goddard', observation_type='REANALYSIS', reanpath='', months=None)[source]
Class to calculate the CRPSS. Call method “analyze” to get results
Parameters: |
- output – Path where the results are saved
- output_plot – Path where the plots are saved
- decadals – a list with decadal experiments, i.e. [1960,1960,...,1995]
- variable – CMOR-Name of variable like ‘tas’ (Near Surface Temperature)
- project – CMOR-Name of the project like CMIP5 or BASELINE1
- product1 – CMOR-Parameter
- institute1 – CMOR-Name of the institute like MPI-M
- model – CMOR-Name of the used model like MPI-ESM-LR
- experiment – Experiment name like decs4e or historical
- leadtimes – Leadtimes to analyze, ie. 1,2-9
- observation – Observation or Reanalysis Experiment, HadCrut or ERA-Int or path to observation file
- ensemblemembers – Comma separated string of esemble members like ‘r1i1p1,r2i1p1,...’
- maskMissingValues – Boolean value. Whether you want to mask missing values or not
- result_grid – Griddescription of resultgrid like r72x36
- cache – Path for cachedir during analysis
- baseDir – Path of Class to find default files
- timeFreq – Timefrequency of the files, ie ‘mon’ or ‘day’
- basic_output – Boolean - If true only basic out is produced (CRPSS_ES and LESS).
- bootstrapSwitch – If you want calculating Significance using Bootstrap methods
- bootstrap_number – Number of Bootstrap runs
- leatimes_mode – ‘monthly’ or ‘yearly’ calculation
- level – For 3D-Files –> Select a single level
- lonlatbox – If you want to select a specific lonlat-Box
- fieldmean – Boolean - If you want to calculate field means
- zonalmean – Boolean - If you want to calculate zonal means
- input_part – String - Will be added to output path and cache file
- colormap – Matplotlib Colormap used for ploting
- observation_type – NOT USED ANYMORE!!!
- reanpath – NOT USED ANYMORE!!!
- months – Usefull if your analysing monthly and your experiment name has a month included
|
-
prepareInput()[source]
This method is to search and prepare the input files.
Integrated methods:
1. Searching files
2. Remapping
3. Selecting lonlatbox
4. Calculating fieldmean
5. Calculating zonalmean
The prepared files are stored in “self.inputRemapped” and “self.observationRemapped”
-
analyze()[source]
Main function to calculate the CRPSS after Goddard et al. (2012)
It also calculates the ESS and LESS after Kadow et al. (2015)
The following steps are performed:
- Temporal Smoothing
- Calculating ensemble means of hindcasts
- Calculating cross-validated means of ensemblemembers
- Calculating anomalies of hindcast and observations
- Removing conditional bias
- Calculating mean ensemble variance and reference STD
- Calculating climatological standard deviation
- Calculating CRPS for mean ensemble variance and for reference STD
- Calculating CRPSS
- Calculating Ensemble Spread Score (ESS) and Logarithmic ESS
- Plotting
-
removeConditionalBiasNew(hindcast, observations, ensembleMembers)[source]
Remove the conditional bias from the ensemble members. Following Murphy 1988 and Goddard et al. 2012
Parameters: |
- hindcast – dict of hindcast ensemble means
- observations – dict of observation anomalies
- ensembleMembers – dict of hindcast ensemble members
|
Returns: | dict of bias corrected ensemble members
|
-
_removeConditionalBias(hindcast, bias, ensembleMembers)[source]
This is the single process version of removeConditionalBias
-
getCrps(hindcast, observation, variances, tag)[source]
Calculates crpss for dictionarys after Gneiting and Raferty (2007)
Parameters: |
- hindcast – dict of anomaly conditional bias corrected hindcast
- observation – dict of anomaly observation
- variances – dict of Variances you want to test
- tag – name tag
|
Returns: | dict of crps
|
-
_calcCrps(hindcast, observation, variance, tag)[source]
Method calculates the CRPS after the formula by Gneiting and Raferty (2007).
Parameters: |
- hindcast – anomaly conditional bias corrected hindcast
- observation – anomaly observation
- variance – Variance or STD you want to test
- tag – name tag
|
Returns: | crps file
|
-
getCrpss(crps1, crps2, tag)[source]
Calculates the crpss out of two different crps dicts.
Parameters: |
- crps1 – dict
- crps2 – dict
- tag – name tag
|
Returns: | crpss filepath
|
-
getReferenceStd(hindcast, observation)[source]
Calculate Reference STD after Goddard et al. Calculates the Root Mean Squared Error between hindcast and observation
and standardizes by n-2
Parameters: |
- hindcast – dict of anomalies
- observation – dict of observation anomalies
|
Returns: | reference STD
|
-
bootstrap(crps, crpsRef, tag, crpss, bootstrap_number=500, plot_range=[-1, 1], colorbar='RdBu_r')[source]
Bootstrap function to calculate significance crosses for crpss and other metrics.
It also plots the fields with significance crosses
-
_multiBootstrap(crps, crpsRef, tag, crpss, i)[source]
Single process version used in crpss.bootstrap
-
_multiEnsspreadBootstrap(ensAnoms, anomalies, tempSmoothedObs, i)[source]
TODO: Not working!!!
-
bootstrapEnsembleSpreadscore(ensAnoms, anomalies, tempSmoothedObs, spreadscore, bootstrap_number, spreadscore_ln)[source]
Bootstrapping method for ESS and LESS
-
checkEnsembleError(ensList)[source]
Checks if enough ensemblemembers are selected for analysis
Crpss needs at least 2 ensemblemembers. And is only reasonable for more