Crps_util
Docstrings for the Crps_util class
3 minute read
Objects
crps_empirical()
crps_empirical.calc()
crps_empirical_loop()
crps_empirical_loop.calc()
crps_sonf_fixed()
crps_sonf_moving()
Python definitions used to aid in the calculation of Continuous Ranked Probability Score. Methods Overview -> crps_sonf_fixed(): Single obs neighbourhood forecast CRPS for fixed obs -> crps_song_moving(): Same as above for moving obs
crps_empirical()
def crps_empirical(sample, obs):
Calculates CRPS for a single observations against a sample of values.
This sample of values may be an ensemble of model forecasts or a model
neighbourhood. This is a comparison of a Heaviside function defined by
the observation value and an Empirical Distribution Function (EDF)
defined by the sample of values. This sample is sorted to create the
EDF.The calculation method is that outlined by Hersbach et al. (2000).
Each member of a supplied sample is weighted equally.
Args:
sample (array): Array of points (ensemble or neighbourhood)
obs (float): A single 'observation' value which to compare against
sample CDF.
Returns:
np.ndarray: A single CRPS value.
crps_empirical.calc()
def crps_empirical.calc(alpha, beta, p):
None
crps_empirical_loop()
def crps_empirical_loop(sample, obs):
Like crps_empirical, however a loop is used instead of numpy
boolean indexing. For large samples, will be slower but consume less
memory.
Args:
sample (array): Array of points (ensemble or neighbourhood)
obs (float): A single 'observation' value which to compare against
sample CDF.
Returns:
float: A single CRPS integral value.
crps_empirical_loop.calc()
def crps_empirical_loop.calc(alpha, beta, p):
None
crps_sonf_fixed()
def crps_sonf_fixed(mod_array, obs_lon, obs_lat, obs_var, obs_time, nh_radius, time_interp):
Single-observation neighbourhood forecast CRPS for a time series at a fixed observation location.
Handles the calculation of single-observation neighbourhood forecast CRPS for a time series at a fixed observation location.
Differs from crps_sonf_moving in that it only need calculate a model neighbourhood once.
Args:
mod_array (xr.DataArray): DataArray from a Model Dataset.
obs_lon (float): Longitude of fixed observation point.
obs_lat (float): Latitude of fixed observation point.
obs_var (np.ndarray): of floatArray of variable values, e.g time series.
obs_time (np.ndarray): of datetimeArray of times, corresponding to obs_var.
nh_radius (float): Neighbourhood radius in km.
time_interp (str): Type of time interpolation to use.
Returns:
Tuple[np.ndarray, np.ndarray, np.ndarray]: Array of CRPS values, array containing the number of model points used for
each CRPS value and an array of bools indicating where a model neighbourhood
contained land.
crps_sonf_moving()
def crps_sonf_moving(mod_array, obs_lon, obs_lat, obs_var, obs_time, nh_radius, time_interp):
Handles the calculation of single-observation neighbourhood forecast CRPS for a moving observation instrument.
Differs from crps_sonf_fixed in that latitude and longitude are arrays of locations. Mod_array must contain
dimensions x_dim, y_dim and t_dim and coordinates longitude, latitude, time.
Args:
mod_array (xr.DataArray): DataArray from a Model Dataset.
obs_lon (np.ndarray): Longitudes of fixed observation point.
obs_lat (np.ndarray): Latitudes of fixed observation point.
obs_var (np.ndarray): of floatArray of variable values, e.g time series.
obs_time: (np.ndarray): of datetimeArray of times, corresponding to obs_var.
nh_radius (float): Neighbourhood radius in km.
time_interp (str): Type of time interpolation to use.
Returns:
Tuple[np.ndarray, np.ndarray, np.ndarray]: Array of CRPS values,
Array containing the number of model points used for each CRPS value,
Array of bools indicating where a model neighbourhood contained land.
Feedback
Was this page helpful?
Glad to hear it!
Sorry to hear that. Please tell us how we can improve.
Last modified November 23, 2022: Updated docstrings from coast repo. (9daee18)