Gridpp 0.6.0
A post-processing library for gridded weather forecasts
Enumerations | Classes
gridpp Namespace Reference

Typedefs

Short-hand notation for vectors of different dimensions sizes

typedef std::vector< float > vec
 
typedef std::vector< vecvec2
 
typedef std::vector< vec2vec3
 
typedef std::vector< int > ivec
 
typedef std::vector< ivecivec2
 
typedef std::vector< ivec2ivec3
 
typedef std::vector< double > dvec
 
typedef std::vector< dvecdvec2
 

Functions

Data assimilation methods

Functions that merge observations with a background field

vec2 optimal_interpolation (const Grid &bgrid, const vec2 &background, const Points &points, const vec &pobs, const vec &pratios, const vec &pbackground, const StructureFunction &structure, int max_points, bool allow_extrapolation=true)
 Optimal interpolation for a deterministic gridded field. More...
 
vec optimal_interpolation (const Points &bpoints, const vec &background, const Points &points, const vec &pobs, const vec &pratios, const vec &pbackground, const StructureFunction &structure, int max_points, bool allow_extrapolation=true)
 Optimal interpolation for a deterministic vector of points. More...
 
vec2 optimal_interpolation_full (const Grid &bgrid, const vec2 &background, const vec2 &bvariance, const Points &points, const vec &obs, const vec &obs_variance, const vec &background_at_points, const vec &bvariance_at_points, const StructureFunction &structure, int max_points, vec2 &analysis_variance, bool allow_extrapolation=true)
 Optimal interpolation for a deterministic gridded field including analysis variance. More...
 
vec optimal_interpolation_full (const Points &bpoints, const vec &background, const vec &bvariance, const Points &points, const vec &obs, const vec &obs_variance, const vec &background_at_points, const vec &bvariance_at_points, const StructureFunction &structure, int max_points, vec &analysis_sigmas, bool allow_extrapolation=true)
 Optimal interpolation for a deterministic vector of points including analysis variance. More...
 
vec3 optimal_interpolation_ensi (const Grid &bgrid, const vec3 &background, const Points &points, const vec &pobs, const vec &psigmas, const vec2 &pbackground, const StructureFunction &structure, int max_points, bool allow_extrapolation=true)
 Optimal interpolation using a structure function based on an ensemble See Lussana et al 2019 (DOI: 10.1002/qj.3646) More...
 
vec2 optimal_interpolation_ensi (const Points &bpoints, const vec2 &background, const Points &points, const vec &pobs, const vec &psigmas, const vec2 &pbackground, const StructureFunction &structure, int max_points, bool allow_extrapolation=true)
 
vec2 local_distribution_correction (const Grid &bgrid, const vec2 &background, const Points &points, const vec &pobs, const vec &pbackground, const StructureFunction &structure, float min_quantile, float max_quantile, int min_points=0)
 Correction of a gridded field ensuring the distribution of values nearby match that of observations. More...
 
vec2 local_distribution_correction (const Grid &bgrid, const vec2 &background, const Points &points, const vec2 &pobs, const vec2 &pbackground, const StructureFunction &structure, float min_quantile, float max_quantile, int min_points=0)
 Version with multiple number of timesteps. More...
 
vec2 fill (const Grid &igrid, const vec2 &input, const Points &points, const vec &radii, float value, bool outside)
 Fill in values inside or outside a set of circles (useful for masking) More...
 
vec2 doping_square (const Grid &igrid, const vec2 &background, const Points &points, const vec &observations, const ivec &halfwidths, float max_elev_diff=gridpp::MV)
 Insert observations into gridded field using a square box. More...
 
vec2 doping_circle (const Grid &igrid, const vec2 &background, const Points &points, const vec &observations, const vec &radii, float max_elev_diff=gridpp::MV)
 Insert observations into gridded field using a circle. More...
 
Distributions

Functions that extract values from probability distributions

vec gamma_inv (const vec &levels, const vec &shape, const vec &scale)
 
Spatial neighbourhood filters

Functions that apply neighbourhood filters on a gridded field

vec2 neighbourhood (const vec2 &input, int halfwidth, Statistic statistic)
 Spatial neighbourhood filter, computing a statistic for a sliding square window. More...
 
vec2 neighbourhood (const vec3 &input, int halfwidth, Statistic statistic)
 Spatial neighbourhood filter for an ensemble of fields. More...
 
vec2 neighbourhood_quantile (const vec2 &input, float quantile, int halfwidth)
 Computes a quantile in a sliding square neighbourhood. More...
 
vec2 neighbourhood_quantile (const vec3 &input, float quantile, int halfwidth)
 Computes a quantile in a sliding square neighbourhood for an ensemble of fields. More...
 
vec2 neighbourhood_quantile_fast (const vec2 &input, float quantile, int halfwidth, const vec &thresholds)
 Fast and approximate neighbourhood quantile. More...
 
vec2 neighbourhood_quantile_fast (const vec3 &input, float quantile, int halfwidth, const vec &thresholds)
 Fast and approximate neighbourhood quantile for ensemble of fields. More...
 
vec2 neighbourhood_quantile_fast (const vec2 &input, const vec2 &quantile, int halfwidth, const vec &thresholds)
 Fast and approximate neighbourhood quantile, with spatially varying quantile. More...
 
vec2 neighbourhood_quantile_fast (const vec3 &input, const vec2 &quantile, int halfwidth, const vec &thresholds)
 Fast and approximate neighbourhood quantile for ensemble of fields, with spatially varying quantile. More...
 
vec2 neighbourhood_brute_force (const vec2 &input, int halfwidth, Statistic statistic)
 Spatial neighbourhood filter without any shortcuts. More...
 
vec2 neighbourhood_brute_force (const vec3 &input, int halfwidth, Statistic statistic)
 Spatial neighbourhood filter without any shortcuts. More...
 
vec get_neighbourhood_thresholds (const vec2 &input, int num_thresholds)
 Calculate appropriate approximation thresholds for neighbourhood quantile. More...
 
vec get_neighbourhood_thresholds (const vec3 &input, int num_thresholds)
 Calculate appropriate approximation thresholds for neighbourhood quantile based on an * ensemble. More...
 
vec2 neighbourhood_ens (const vec3 &input, int halfwidth, Statistic statistic)
 Deprecated: Compute neighbourhood statistic on ensemble field. More...
 
vec2 neighbourhood_quantile_ens (const vec3 &input, float quantile, int halfwidth)
 Deprecated: Compute neighbourhood quantiles on ensemble field. More...
 
vec2 neighbourhood_quantile_ens_fast (const vec3 &input, float quantile, int radius, const vec &thresholds)
 Deprecated: Compute neighbourhood quantiles fast on ensemble field. More...
 
Calibration methods

Functions that apply statistical methods to data

vec quantile_mapping_curve (const vec &ref, const vec &fcst, vec &output_fcst, vec quantiles=vec())
 Create quantile mapping calibration curve. More...
 
vec metric_optimizer_curve (const vec &ref, const vec &fcst, const vec &thresholds, Metric metric, vec &output_fcst)
 Create calibration curve that optimizes a metric. More...
 
float apply_curve (float fcst, const vec &curve_ref, const vec &curve_fcst, Extrapolation policy_below, Extrapolation policy_above)
 Apply arbitrary calibration curve to a single value. More...
 
vec apply_curve (const vec &fcst, const vec &curve_ref, const vec &curve_fcst, Extrapolation policy_below, Extrapolation policy_above)
 Apply arbitrary calibration curve to 1D forecasts. More...
 
vec2 apply_curve (const vec2 &fcst, const vec &curve_ref, const vec &curve_fcst, Extrapolation policy_below, Extrapolation policy_above)
 Apply arbitrary calibration curve to 2D forecasts. More...
 
vec2 apply_curve (const vec2 &fcst, const vec3 &curve_ref, const vec3 &curve_fcst, Extrapolation policy_below, Extrapolation policy_above)
 Apply arbitrary calibration curve to 2D forecasts with spatially varying QQ map. More...
 
vec monotonize_curve (vec curve_ref, vec curve_fcst, vec &output_fcst)
 Ensure calibration curve is monotonic, by removing points. More...
 
float get_optimal_threshold (const vec &ref, const vec &fcst, float threshold, Metric metric)
 
float calc_score (float a, float b, float c, float d, Metric metric)
 
float calc_score (const vec &ref, const vec &fcst, float threshold, Metric metric)
 
float calc_score (const vec &ref, const vec &fcst, float threshold, float fthreshold, Metric metric)
 
Downscaling methods

Functions that interpolate data from one grid to another

vec2 downscaling (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues, Downscaler downscaler)
 Generic downscaler for simple methods that don't use information other than the grids. More...
 
vec3 downscaling (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues, Downscaler downscaler)
 
vec downscaling (const Grid &igrid, const Points &opoints, const vec2 &ivalues, Downscaler downscaler)
 
vec2 downscaling (const Grid &igrid, const Points &opoints, const vec3 &ivalues, Downscaler downscaler)
 
vec2 nearest (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues)
 Nearest neighbour dowscaling grid to grid. More...
 
vec3 nearest (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues)
 
vec nearest (const Grid &igrid, const Points &opoints, const vec2 &ivalues)
 Nearest neighbour dowscaling grid to point. More...
 
vec2 nearest (const Grid &igrid, const Points &opoints, const vec3 &ivalues)
 
vec nearest (const Points &ipoints, const Points &opoints, const vec &ivalues)
 Nearest neighbour dowscaling point to point. More...
 
vec2 nearest (const Points &ipoints, const Points &opoints, const vec2 &ivalues)
 
vec2 nearest (const Points &ipoints, const Grid &ogrid, const vec &ivalues)
 Nearest neighbour dowscaling point to grid. More...
 
vec3 nearest (const Points &ipoints, const Grid &ogrid, const vec2 &ivalues)
 
vec2 downscale_probability (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues, const vec2 &threshold, const ComparisonOperator &comparison_operator)
 Nearest neighbour downscaling grid to grid and probability in one. More...
 
vec2 mask_threshold_downscale_consensus (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues_true, const vec3 &ivalues_false, const vec3 &theshold_values, const vec2 &threshold, const ComparisonOperator &comparison_operator, const Statistic &statistic)
 Nearest neighbour downscaling grid to grid and threshold and consensus in one. More...
 
vec2 bilinear (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues)
 Bilinear downscaling grid to grid. More...
 
vec3 bilinear (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues)
 
vec bilinear (const Grid &igrid, const Points &opoints, const vec2 &ivalues)
 Bilinear downscaling grid to points. More...
 
vec2 bilinear (const Grid &igrid, const Points &opoints, const vec3 &ivalues)
 
vec2 simple_gradient (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues, float elev_gradient, Downscaler downscaler=Nearest)
 
vec3 simple_gradient (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues, float elev_gradient, Downscaler downscaler=Nearest)
 
vec simple_gradient (const Grid &igrid, const Points &opoints, const vec2 &ivalues, float elev_gradient, Downscaler downscaler=Nearest)
 
vec2 simple_gradient (const Grid &igrid, const Points &opoints, const vec3 &ivalues, float elev_gradient, Downscaler downscaler=Nearest)
 
vec2 full_gradient (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues, const vec2 &elev_gradient, const vec2 &laf_gradient=vec2(), Downscaler downscaler=Nearest)
 Compute Downscale. More...
 
vec3 full_gradient (const Grid &igrid, const Grid &ogrid, const vec3 &ivalues, const vec3 &elev_gradient, const vec3 &laf_gradient, Downscaler downscaler=Nearest)
 
vec full_gradient (const Grid &igrid, const Points &opoints, const vec2 &ivalues, const vec2 &elev_gradient, const vec2 &laf_gradient, Downscaler downscaler=Nearest)
 
vec2 full_gradient (const Grid &igrid, const Points &opoints, const vec3 &ivalues, const vec3 &elev_gradient, const vec3 &laf_gradient, Downscaler downscaler=Nearest)
 
vec3 full_gradient_debug (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues, const vec2 &elev_gradient, const vec2 &laf_gradient=vec2(), Downscaler downscaler=Nearest)
 
vec2 smart (const Grid &igrid, const Grid &ogrid, const vec2 &ivalues, int num, const StructureFunction &structure)
 Smart neighbour downscaling grid to grid. More...
 
Grid calculations

Functions that calculate statistics on a grid

vec count (const Grid &grid, const Points &points, float radius)
 For each point, counts the number of gridpoints within the radius. More...
 
vec2 count (const Grid &igrid, const Grid &ogrid, float radius)
 For each gridpoint, counts the number of gridpoints within the radius. More...
 
vec2 count (const Points &points, const Grid &grid, float radius)
 For each gridpoint, counts the number of points within the radius. More...
 
vec count (const Points &ipoints, const Points &opoints, float radius)
 For each point, counts the number of points within the radius. More...
 
vec distance (const Grid &grid, const Points &points, int num=1)
 For each point, calculates the distance to nearest gridpoint. More...
 
vec2 distance (const Grid &igrid, const Grid &ogrid, int num=1)
 For each output gridpoint, calculate the distance to nearest input gridpoint. More...
 
vec2 distance (const Points &points, const Grid &grid, int num=1)
 For each gridpoint, calculates the distance to nearest point. More...
 
vec distance (const Points &ipoints, const Points &opoint, int num=1)
 For each output point, calculates the distance to nearest input point. More...
 
vec2 fill_missing (const vec2 &values)
 Fill in missing values based on nearby values. More...
 
vec2 gridding (const Grid &grid, const Points &points, const vec &values, float radius, int min_num, Statistic statistic)
 Aggregate points onto a grid. More...
 
vec2 gridding_nearest (const Grid &grid, const Points &points, const vec &values, int min_num, gridpp::Statistic statistic)
 Assign each point to nearest neighbour in grid and aggregate values. More...
 
Diagnosing meteorological variables

Functions that diagnose a meteorological variable based on other variables

float dewpoint (float temperature, float relative_humidity)
 Calculate dewpoint temperature from temperature and relative humidity. More...
 
vec dewpoint (const vec &temperature, const vec &relative_humidity)
 Vector version of dewpoint calculation. More...
 
float pressure (float ielev, float oelev, float ipressure, float itemperature=288.15)
 Calculate pressure at a new elevation. More...
 
vec pressure (const vec &ielev, const vec &oelev, const vec &ipressure, const vec &itemperature)
 Calculate Vector version of pressure calculation. More...
 
float sea_level_pressure (float ps, float altitude, float temperature, float rh=gridpp::MV, float dewpoint=gridpp::MV)
 Convert Surface Pressure to Sea Level Pressure. More...
 
vec sea_level_pressure (const vec &ps, const vec &altitude, const vec &temperature, const vec &rh, const vec &dewpoint)
 Vector version of Convert Surface Pressure to Sea Level Pressure. More...
 
float qnh (float pressure, float altitude)
 Diagnose QNH from pressure and altitude. More...
 
vec qnh (const vec &pressure, const vec &altitude)
 Vector version of QNH calculation. More...
 
float relative_humidity (float temperature, float dewpoint)
 Calculate relative humidity from temperature and dewpoint temperature. More...
 
vec relative_humidity (const vec &temperature, const vec &dewpoint)
 Vector version of relative humidity calculation. More...
 
float wetbulb (float temperature, float pressure, float relative_humidity)
 Calculate wetbulb temperature from temperature, pressure, and relative humidity. More...
 
vec wetbulb (const vec &temperature, const vec &pressure, const vec &relative_humidity)
 Vector version of wetbulb calculation. More...
 
float wind_speed (float xwind, float ywind)
 Diagnose wind speed from its components. More...
 
vec wind_speed (const vec &xwind, const vec &ywind)
 Vector version of wind speed calculation. More...
 
float wind_direction (float xwind, float ywind)
 Diagnose wind direction from its components. More...
 
vec wind_direction (const vec &xwind, const vec &ywind)
 Vector version of wind direction calculation. More...
 
OpenMP settings

Functions that configure OpenMP

void set_omp_threads (int num)
 Set the number of OpenMP threads to use. More...
 
int get_omp_threads ()
 Get the number of OpenMP threads currently set. More...
 
void initialize_omp ()
 Sets the number of OpenMP threads to 1 if OMP_NUM_THREADS undefined. More...
 

Variables

Constants

Functions that assimilate observations onto a gridded background

static const float MV = NAN
 Missing value indicator. More...
 
static const float MV_CML = -999
 Missing value indicator in gridpp command-line tool. More...
 
static const float pi = 3.14159265
 Mathematical constant pi. More...
 
static const double radius_earth = 6.378137e6
 Radius of the earth [m]. More...
 
static const float lapse_rate =0.0065
 Constant Lapse Rate moist air standard atmosphere [K/m]. More...
 
static const float standard_surface_temperature = 288.15
 Temperature at surface in standard atmosphere [K]. More...
 
static const float gravit = 9.80665
 Gravitational acceleration [m/s^2]. More...
 
static const float molar_mass = 0.0289644
 Molar Mass of Dry Air [kg/mol]. More...
 
static const float gas_constant_mol = 8.31447
 Universal Gas Constant [kg*m^2*s^-2/(K*mol)]. More...
 
static const float gas_constant_si = 287.05
 Universal Gas Constant [J/(kg*K)]. More...
 

Enumerations

enum  ComparisonOperator { Lt = 0, Leq = 10, Gt = 20, Geq = 30 }
 Types of comparison operators. More...
 
enum  CoordinateType { Geodetic = 0, Cartesian = 1 }
 Types of coordinates for position of points. More...
 
enum  CorrectionType { Qq = 0, Multiplicative = 10, Additive = 20 }
 Method for statistical correction. More...
 
enum  Downscaler { Nearest = 0, Bilinear = 1 }
 Types of simple downscaling methods. More...
 
enum  Extrapolation {
  OneToOne = 0, MeanSlope = 10, NearestSlope = 20, Zero = 30,
  Unchanged = 40
}
 Methods for extrapolating outside a curve. More...
 
enum  GradientType { MinMax = 0, LinearRegression = 10 }
 Types of methods to calculate the gradient. More...
 
enum  Metric {
  Ets = 0, Ts = 1, Kss = 20, Pc = 30,
  Bias = 40, Hss = 50
}
 Binary verification metrics. More...
 
enum  Statistic {
  Mean = 0, Min = 10, Median = 20, Max = 30,
  Quantile = 40, Std = 50, Variance = 60, Sum = 70,
  Count = 80, Unknown = -1
}
 Statistical operations to reduce a vector to a scalar. More...
 

Classes

class  BarnesStructure
 Simple structure function based on distance, elevation, and land area fraction. More...
 
class  BoxCox
 
class  CressmanStructure
 Simple structure function based on distance, elevation, and land area fraction. More...
 
class  CrossValidation
 
class  Gamma
 
class  Grid
 Represents a 2D grid of locations and their metadata. More...
 
class  Identity
 
class  KDTree
 Helper class for Grid and Points. More...
 
class  Log
 
class  MultipleStructure
 
class  not_implemented_exception
 
class  Point
 Represents a single point in some coordinate system. More...
 
class  Points
 Represents a vector of locations and their metadata. More...
 
class  StructureFunction
 Covariance structure function. More...
 
class  Transform
 

Utilities


Helper functions

static int _debug_level = 0
 
void set_debug_level (int level)
 Set the verbosity of debug messages. More...
 
int get_debug_level ()
 Get the currently set level of debug messages. More...
 
Statistic get_statistic (std::string name)
 Convert name of a statistic enum. More...
 
std::string version ()
 The gridpp version. More...
 
double clock ()
 
void debug (std::string string)
 
void warning (std::string string)
 
void error (std::string string)
 
void future_deprecation_warning (std::string function, std::string other="")
 
bool is_valid (float value)
 
float calc_statistic (const vec &array, Statistic statistic)
 
float calc_quantile (const vec &array, float quantile)
 
vec calc_statistic (const vec2 &array, Statistic statistic)
 
vec calc_quantile (const vec2 &array, float quantile=MV)
 
vec2 calc_quantile (const vec3 &array, const vec2 &quantile)
 Compute quantile with 2D varying quantile. More...
 
int num_missing_values (const vec2 &iArray)
 
int get_lower_index (float iX, const vec &iValues)
 Find the index in a vector that is equal or just below a value. More...
 
int get_upper_index (float iX, const vec &iValues)
 Find the index in a vector that is equal or just above a value. More...
 
float interpolate (float x, const vec &iX, const vec &iY)
 Piecewise linear interpolation If x is outside the range of iX, then the min/max value of iY is used. More...
 
ivec2 init_ivec2 (int Y, int X, int value)
 Initialize a vector of size Y, X, with a given value. More...
 
vec2 init_vec2 (int Y, int X, float value=MV)
 
ivec3 init_ivec3 (int Y, int X, int E, int value)
 Initialize a vector of size Y, X, E, with a given value. More...
 
vec3 init_vec3 (int Y, int X, int E, float value=MV)
 
vec calc_even_quantiles (const vec &values, int num)
 Get reasonably spaced quantiles from a vector of values, ignoring duplicate values but including the first number after duplicated values. More...
 
vec2 calc_gradient (const vec2 &base, const vec2 &values, GradientType gradient_type, int halfwidth, int min_num=2, float min_range=gridpp::MV, float default_gradient=0)
 Computes gradients based on values in neighbourhood. More...
 
vec2 neighbourhood_search (const vec2 &array, const vec2 &search_array, int halfwidth, float search_target_min, float search_target_max, float search_delta, const ivec2 &apply_array=ivec2())
 Find suitable value in neighbourhood based on a search criteria. More...
 
vec2 window (const vec2 &array, int length, gridpp::Statistic statistic, bool before=false, bool keep_missing=false, bool missing_edges=true)
 Compute window statistics. More...
 
bool compatible_size (const Grid &grid, const vec2 &v)
 Check if the grid is the same size as the 2D vector. More...
 
bool compatible_size (const Grid &grid, const vec3 &v)
 
bool compatible_size (const Points &points, const vec &v)
 
bool compatible_size (const Points &points, const vec2 &v)
 
bool compatible_size (const vec2 &a, const vec2 &b)
 
bool compatible_size (const vec2 &a, const vec3 &b)
 
bool compatible_size (const vec3 &a, const vec3 &b)
 
bool point_in_rectangle (const Point &A, const Point &B, const Point &C, const Point &D, const Point &m)
 Checks if a point is located inside a rectangle formed by 4 points. More...
 

SWIG testing functions


Functions for testing the SWIG interface.

Not useful for any other purpose.

static const float swig_default_value = -1
 Default value used to fill array in SWIG testing functions. More...
 
float * test_array (float *v, int n)
 Special function whose presense is needed for SWIG. More...
 
float test_vec_input (const vec &input)
 Testing function for 1D input vector. More...
 
int test_ivec_input (const ivec &input)
 Testing function for 1D input vector. More...
 
float test_vec2_input (const vec2 &input)
 Testing function for 2D input vector. More...
 
float test_vec3_input (const vec3 &input)
 Testing function for 3D input vector. More...
 
vec test_vec_output ()
 Testing function for 1D output vector. More...
 
ivec test_ivec_output ()
 
vec2 test_vec2_output ()
 Testing function for 2D output vector. More...
 
ivec2 test_ivec2_output ()
 
vec3 test_vec3_output ()
 Testing function for 3D output vector. More...
 
ivec3 test_ivec3_output ()
 
float test_vec_argout (vec &distances)
 Testing function for 1D vector treated as output. More...
 
float test_vec2_argout (vec2 &distances)
 Testing function for 2D vector treated as output. More...
 
void test_not_implemented_exception ()
 

Typedef Documentation

◆ dvec

typedef std::vector<double> gridpp::dvec

◆ dvec2

typedef std::vector<dvec> gridpp::dvec2

◆ ivec

typedef std::vector<int> gridpp::ivec

◆ ivec2

typedef std::vector<ivec> gridpp::ivec2

◆ ivec3

typedef std::vector<ivec2> gridpp::ivec3

◆ vec

typedef std::vector<float> gridpp::vec

◆ vec2

typedef std::vector<vec> gridpp::vec2

◆ vec3

typedef std::vector<vec2> gridpp::vec3

Enumeration Type Documentation

◆ ComparisonOperator

Types of comparison operators.

Enumerator
Lt 

Lower than, <.

Leq 

Lower or equal than, <=.

Gt 

Greater than, >

Geq 

Greater or equal than, >=.

◆ CoordinateType

Types of coordinates for position of points.

Enumerator
Geodetic 

Latitude and longitude.

Cartesian 

X and Y.

◆ CorrectionType

Method for statistical correction.

Enumerator
Qq 

Quantile mapping.

Multiplicative 

Multiplicative.

Additive 

Additive.

◆ Downscaler

Types of simple downscaling methods.

Enumerator
Nearest 
Bilinear 

◆ Extrapolation

Methods for extrapolating outside a curve.

Enumerator
OneToOne 

Continue past the end-points using a slope of 1.

MeanSlope 

Continue past the end-points using the mean slope of the curve.

NearestSlope 

Continue past the end-points using the slope of the two lowermost or uppermost points in the curve.

Zero 

Continue past the end-points using a slope of 0.

Unchanged 

Keep values the way they were.

◆ GradientType

Types of methods to calculate the gradient.

Enumerator
MinMax 
LinearRegression 

◆ Metric

Binary verification metrics.

Enumerator
Ets 

Equitable threat score.

Ts 

Threat score.

Kss 

Hannsen-Kuiper skill score.

Pc 

Proportion correct.

Bias 

Bias.

Hss 

Heidke skill score.

◆ Statistic

Statistical operations to reduce a vector to a scalar.

Enumerator
Mean 

Mean of values.

Min 

Minimum of values.

Median 

Mean of values.

Max 

Maximum of values.

Quantile 

A quantile from values.

Std 

Standard deviation of values.

Variance 

Population variance of values.

Sum 

Sum of values.

Count 

Count of values.

Unknown 

Unknown statistic.

Function Documentation

◆ apply_curve() [1/4]

float gridpp::apply_curve ( float  fcst,
const vec curve_ref,
const vec curve_fcst,
gridpp::Extrapolation  policy_below,
gridpp::Extrapolation  policy_above 
)

Apply arbitrary calibration curve to a single value.

Parameters
fcstinput forecast
curve_refReference quantiles
curve_fcstForecast quantiles
policy_belowExtrapolation policy below curve
policy_aboveExtrapolation policy above curve
Returns
Calibrated forecasts

◆ apply_curve() [2/4]

vec gridpp::apply_curve ( const vec fcst,
const vec curve_ref,
const vec curve_fcst,
gridpp::Extrapolation  policy_below,
gridpp::Extrapolation  policy_above 
)

Apply arbitrary calibration curve to 1D forecasts.

Parameters
fcst1D vector of forecast values
curve_refReference quantiles
curve_fcstForecast quantiles
policy_belowExtrapolation policy below curve
policy_aboveExtrapolation policy above curve
Returns
Calibrated forecasts

◆ apply_curve() [3/4]

vec2 gridpp::apply_curve ( const vec2 fcst,
const vec curve_ref,
const vec curve_fcst,
gridpp::Extrapolation  policy_below,
gridpp::Extrapolation  policy_above 
)

Apply arbitrary calibration curve to 2D forecasts.

Parameters
fcst2D grid of forecast values
curve_refReference quantiles
curve_fcstForecast quantiles
policy_belowExtrapolation policy below curve
policy_aboveExtrapolation policy above curve
Returns
Calibrated forecasts

◆ apply_curve() [4/4]

vec2 gridpp::apply_curve ( const vec2 fcst,
const vec3 curve_ref,
const vec3 curve_fcst,
gridpp::Extrapolation  policy_below,
gridpp::Extrapolation  policy_above 
)

Apply arbitrary calibration curve to 2D forecasts with spatially varying QQ map.

Parameters
fcst2D grid of forecast values
curve_refReference quantiles (Y, X, Q)
curve_fcstForecast quantiles (Y, X, Q)
policy_belowExtrapolation policy below curve
policy_aboveExtrapolation policy above curve
Returns
Calibrated forecasts

◆ bilinear() [1/4]

vec2 gridpp::bilinear ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues 
)

Bilinear downscaling grid to grid.

Parameters
igridInput grid
ogridOutput grid to downscale to
ivalues2D vector of values on the input grid
Returns
Values on the output grid

◆ bilinear() [2/4]

vec3 gridpp::bilinear ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues 
)

◆ bilinear() [3/4]

vec gridpp::bilinear ( const Grid igrid,
const Points opoints,
const vec2 ivalues 
)

Bilinear downscaling grid to points.

Parameters
igridInput grid
ogridOutput points to downscale to
ivalues2D vector of values on the input grid
Returns
Values for the output points

◆ bilinear() [4/4]

vec2 gridpp::bilinear ( const Grid igrid,
const Points opoints,
const vec3 ivalues 
)

◆ calc_even_quantiles()

vec gridpp::calc_even_quantiles ( const vec values,
int  num 
)

Get reasonably spaced quantiles from a vector of values, ignoring duplicate values but including the first number after duplicated values.

Include the lowest and highest values.

Parameters
valuesvector of values (unsorted, and no invalid values)
numnumber of thresholds to get

◆ calc_gradient()

vec2 gridpp::calc_gradient ( const vec2 base,
const vec2 values,
GradientType  gradient_type,
int  halfwidth,
int  min_num = 2,
float  min_range = gridpp::MV,
float  default_gradient = 0 
)

Computes gradients based on values in neighbourhood.

Parameters
gridGrid
baseDependent variable. Missing values are not used.
valuesIndependent variable. Missing values are not used.
radiusNeighbourhood radius in number of gridpoints
min_nimMinimum number of points required to compute gradient
min_rangeMinimum range of base to compute gradient
default_gradientUse this gradient if minimum number is not met

◆ calc_quantile() [1/3]

float gridpp::calc_quantile ( const vec array,
float  quantile 
)

◆ calc_quantile() [2/3]

vec gridpp::calc_quantile ( const vec2 array,
float  quantile = MV 
)

◆ calc_quantile() [3/3]

vec2 gridpp::calc_quantile ( const vec3 array,
const vec2 quantile 
)

Compute quantile with 2D varying quantile.

Parameters
arrayInput array with dimensions (T, Y, X)
quantileQuantile array with dimensions (Y, X)
Returns
Extracted quantile with dimensions (Y, X)

◆ calc_score() [1/3]

float gridpp::calc_score ( float  a,
float  b,
float  c,
float  d,
gridpp::Metric  metric 
)

◆ calc_score() [2/3]

float gridpp::calc_score ( const vec ref,
const vec fcst,
float  threshold,
gridpp::Metric  metric 
)

◆ calc_score() [3/3]

float gridpp::calc_score ( const vec ref,
const vec fcst,
float  threshold,
float  fthreshold,
gridpp::Metric  metric 
)

◆ calc_statistic() [1/2]

float gridpp::calc_statistic ( const vec array,
gridpp::Statistic  statistic 
)

◆ calc_statistic() [2/2]

vec gridpp::calc_statistic ( const vec2 array,
gridpp::Statistic  statistic 
)

◆ clock()

double gridpp::clock ( )

◆ compatible_size() [1/7]

bool gridpp::compatible_size ( const Grid grid,
const vec2 v 
)

Check if the grid is the same size as the 2D vector.

If True, they are compatible, if false they are incompatible

◆ compatible_size() [2/7]

bool gridpp::compatible_size ( const Grid grid,
const vec3 v 
)

◆ compatible_size() [3/7]

bool gridpp::compatible_size ( const Points points,
const vec v 
)

◆ compatible_size() [4/7]

bool gridpp::compatible_size ( const Points points,
const vec2 v 
)

◆ compatible_size() [5/7]

bool gridpp::compatible_size ( const vec2 a,
const vec2 b 
)

◆ compatible_size() [6/7]

bool gridpp::compatible_size ( const vec2 a,
const vec3 b 
)

◆ compatible_size() [7/7]

bool gridpp::compatible_size ( const vec3 a,
const vec3 b 
)

◆ count() [1/4]

vec gridpp::count ( const Grid grid,
const Points points,
float  radius 
)

For each point, counts the number of gridpoints within the radius.

Parameters
gridGrid
pointsPoints
radiusRadius [m]
Returns
Number of gridpoints

◆ count() [2/4]

vec2 gridpp::count ( const Grid igrid,
const Grid ogrid,
float  radius 
)

For each gridpoint, counts the number of gridpoints within the radius.

Parameters
igridInput grid
ogridOutput grid
radiusRadius [m]
Returns
Number of gridpoints

◆ count() [3/4]

vec2 gridpp::count ( const Points points,
const Grid grid,
float  radius 
)

For each gridpoint, counts the number of points within the radius.

Parameters
gridGrid
pointsPoints
radiusRadius [m]
Returns
Number of points

◆ count() [4/4]

vec gridpp::count ( const Points ipoints,
const Points opoints,
float  radius 
)

For each point, counts the number of points within the radius.

Parameters
ipointsInput points
opointsOutput points
radiusRadius [m]
Returns
Number of points

◆ debug()

void gridpp::debug ( std::string  string)

◆ dewpoint() [1/2]

float gridpp::dewpoint ( float  temperature,
float  relative_humidity 
)

Calculate dewpoint temperature from temperature and relative humidity.

Parameters
temperatureTemperature [K]
relative_humidityRelative humidity [1]
Returns
Dewpoint temperature [K]

◆ dewpoint() [2/2]

vec gridpp::dewpoint ( const vec temperature,
const vec relative_humidity 
)

Vector version of dewpoint calculation.

Parameters
temperatureTemperatures [K]
relative_humidityRelative humidities [1]
Returns
Dewpoint temperatures [K]

◆ distance() [1/4]

vec gridpp::distance ( const Grid grid,
const Points points,
int  num = 1 
)

For each point, calculates the distance to nearest gridpoint.

Parameters
gridGrid
pointsPoints
numNumber of points
Returns
Distance [m] to nearest gridpoint for each point

◆ distance() [2/4]

vec2 gridpp::distance ( const Grid igrid,
const Grid ogrid,
int  num = 1 
)

For each output gridpoint, calculate the distance to nearest input gridpoint.

Parameters
gridGrid
ogridOutput grid
numNumber of points
Returns
Distance [m] to nearest gridpoint for each gridpoint

◆ distance() [3/4]

vec2 gridpp::distance ( const Points points,
const Grid grid,
int  num = 1 
)

For each gridpoint, calculates the distance to nearest point.

Parameters
pointsPoints
gridGrid
numNumber of points
Returns
Distance [m] to nearest gridpoint for each point

◆ distance() [4/4]

vec gridpp::distance ( const Points ipoints,
const Points opoint,
int  num = 1 
)

For each output point, calculates the distance to nearest input point.

Parameters
ipointsInput points
opointsOutput points
numNumber of points
Returns
Distance [m] to nearest point for each point

◆ doping_circle()

vec2 gridpp::doping_circle ( const Grid igrid,
const vec2 background,
const Points points,
const vec observations,
const vec radii,
float  max_elev_diff = gridpp::MV 
)

Insert observations into gridded field using a circle.

Parameters
gridGrid
backgroundDeterministic values with dimensions Y, X
pointsPoints representing observations
observationsVector of observations
radiiRadius of circle where observations are inserted for each point [m]
max_elev_diffOnly insert where elevation difference between grid and point is less than this value

◆ doping_square()

vec2 gridpp::doping_square ( const Grid igrid,
const vec2 background,
const Points points,
const vec observations,
const ivec halfwidths,
float  max_elev_diff = gridpp::MV 
)

Insert observations into gridded field using a square box.

Parameters
gridGrid
backgroundDeterministic values with dimensions Y, X
pointsPoints representing observations
observationsVector of observations
halfwidthsHalf width of square (in number of grid points) where observations are inserted for each point
max_elev_diffOnly insert where elevation difference between grid and point is less than this value

◆ downscale_probability()

vec2 gridpp::downscale_probability ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues,
const vec2 threshold,
const ComparisonOperator comparison_operator 
)

Nearest neighbour downscaling grid to grid and probability in one.

Parameters
igridInput grid
ogridOutput grid to downscale to
ivalues3D vector of values on the input grid (Y, X, E)
threshold2D vector of threshold values
comparison_operatorlower than, lower or equal than, greater than, great or equal than
Returns
Values on the output grid

◆ downscaling() [1/4]

vec2 gridpp::downscaling ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues,
Downscaler  downscaler 
)

Generic downscaler for simple methods that don't use information other than the grids.

Parameters
igridInput grid
ogridOutput grid to downscale to
ivalues2D vector of values on the input grid
downscalerDownscaling method
Returns
Values on the output grid

◆ downscaling() [2/4]

vec3 gridpp::downscaling ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues,
Downscaler  downscaler 
)

◆ downscaling() [3/4]

vec gridpp::downscaling ( const Grid igrid,
const Points opoints,
const vec2 ivalues,
Downscaler  downscaler 
)

◆ downscaling() [4/4]

vec2 gridpp::downscaling ( const Grid igrid,
const Points opoints,
const vec3 ivalues,
Downscaler  downscaler 
)

◆ error()

void gridpp::error ( std::string  string)

◆ fill()

vec2 gridpp::fill ( const Grid igrid,
const vec2 input,
const Points points,
const vec radii,
float  value,
bool  outside 
)

Fill in values inside or outside a set of circles (useful for masking)

Parameters
inputDeterministic values with dimensions Y, X
radiiCircle radii for each point
valueFill in this value
outsideif True, fill outside circles, if False, fill inside circles

◆ fill_missing()

vec2 gridpp::fill_missing ( const vec2 values)

Fill in missing values based on nearby values.

Parameters
values2D array of values
Returns
2D array of values without any missing values

◆ full_gradient() [1/4]

vec2 gridpp::full_gradient ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues,
const vec2 elev_gradient,
const vec2 laf_gradient = vec2(),
Downscaler  downscaler = Nearest 
)

Compute Downscale.

Parameters
igridinput grid
ogridoutput grid
ivaluesvalues from igrid
elev_gradientelevation gradient
laf_gradientland area fraction gradient

◆ full_gradient() [2/4]

vec3 gridpp::full_gradient ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues,
const vec3 elev_gradient,
const vec3 laf_gradient,
Downscaler  downscaler = Nearest 
)

◆ full_gradient() [3/4]

vec gridpp::full_gradient ( const Grid igrid,
const Points opoints,
const vec2 ivalues,
const vec2 elev_gradient,
const vec2 laf_gradient,
Downscaler  downscaler = Nearest 
)

◆ full_gradient() [4/4]

vec2 gridpp::full_gradient ( const Grid igrid,
const Points opoints,
const vec3 ivalues,
const vec3 elev_gradient,
const vec3 laf_gradient,
Downscaler  downscaler = Nearest 
)

◆ full_gradient_debug()

vec3 gridpp::full_gradient_debug ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues,
const vec2 elev_gradient,
const vec2 laf_gradient = vec2(),
Downscaler  downscaler = Nearest 
)

◆ future_deprecation_warning()

void gridpp::future_deprecation_warning ( std::string  function,
std::string  other = "" 
)

◆ gamma_inv()

vec gridpp::gamma_inv ( const vec levels,
const vec shape,
const vec scale 
)
Parameters
shapeShape parameter of gamma distribution
scaleScale parameter of gamma distribution
levelsQuantile levels to retrieve

◆ get_debug_level()

int gridpp::get_debug_level ( )

Get the currently set level of debug messages.

◆ get_lower_index()

int gridpp::get_lower_index ( float  iX,
const vec iValues 
)

Find the index in a vector that is equal or just below a value.

Parameters
iXLookup value
iValuesLookup vector. Must be sorted.
Returns
The index into iValues that is equal or just below iX

◆ get_neighbourhood_thresholds() [1/2]

vec gridpp::get_neighbourhood_thresholds ( const vec2 input,
int  num_thresholds 
)

Calculate appropriate approximation thresholds for neighbourhood quantile.

Parameters
input2D (Y, X) array of values
num_thresholdsNumber of thresholds

◆ get_neighbourhood_thresholds() [2/2]

vec gridpp::get_neighbourhood_thresholds ( const vec3 input,
int  num_thresholds 
)

Calculate appropriate approximation thresholds for neighbourhood quantile based on an * ensemble.

Parameters
input3D (Y, X, T) array of values
num_thresholdsNumber of thresholds

◆ get_omp_threads()

int gridpp::get_omp_threads ( )

Get the number of OpenMP threads currently set.

◆ get_optimal_threshold()

float gridpp::get_optimal_threshold ( const vec ref,
const vec fcst,
float  threshold,
gridpp::Metric  metric 
)

◆ get_statistic()

gridpp::Statistic gridpp::get_statistic ( std::string  name)

Convert name of a statistic enum.

◆ get_upper_index()

int gridpp::get_upper_index ( float  iX,
const vec iValues 
)

Find the index in a vector that is equal or just above a value.

Parameters
iXLookup value
iValuesLookup vector. Must be sorted.
Returns
The index into iValues that is equal or just above iX

◆ gridding()

vec2 gridpp::gridding ( const Grid grid,
const Points points,
const vec values,
float  radius,
int  min_num,
gridpp::Statistic  statistic 
)

Aggregate points onto a grid.

Writes MV where there are not enough observations.

Parameters
gridGrid to aggregate to
pointsPoints with values
valuesValues at points
radiusCircle radius for aggregate points [m]
min_numMinimum number of points in radius to create a value
statisticStatistic to compute on points within radius

◆ gridding_nearest()

vec2 gridpp::gridding_nearest ( const Grid grid,
const Points points,
const vec values,
int  min_num,
gridpp::Statistic  statistic 
)

Assign each point to nearest neighbour in grid and aggregate values.

Writes MV where there are not enough observations.

Parameters
gridGrid to aggregate to
pointsPoints with values
valuesValues at points
min_numMinimum number of points in a gridpoint to create a value
statisticStatistic to compute on points within gridpoint

◆ init_ivec2()

ivec2 gridpp::init_ivec2 ( int  Y,
int  X,
int  value 
)

Initialize a vector of size Y, X, with a given value.

◆ init_ivec3()

ivec3 gridpp::init_ivec3 ( int  Y,
int  X,
int  E,
int  value 
)

Initialize a vector of size Y, X, E, with a given value.

◆ init_vec2()

vec2 gridpp::init_vec2 ( int  Y,
int  X,
float  value = MV 
)

◆ init_vec3()

vec3 gridpp::init_vec3 ( int  Y,
int  X,
int  E,
float  value = MV 
)

◆ initialize_omp()

void gridpp::initialize_omp ( )

Sets the number of OpenMP threads to 1 if OMP_NUM_THREADS undefined.

◆ interpolate()

float gridpp::interpolate ( float  x,
const vec iX,
const vec iY 
)

Piecewise linear interpolation If x is outside the range of iX, then the min/max value of iY is used.

If there are multiple identical x values, then the average of the y values at each end of the x-interval that is constant is used. The exception is if the constant interval is on one (only) of the edges of the interpolation curve. In that case, the y-value at the end of the interval further away from the boundary of the curve is used.

Parameters
xInterpolation to this point
iXVector of x-axis values. Vector must be sorted.
iYVector of y-axis values corresponding to iX.
Returns
Y value corresponding to x

◆ is_valid()

bool gridpp::is_valid ( float  value)

◆ local_distribution_correction() [1/2]

vec2 gridpp::local_distribution_correction ( const Grid bgrid,
const vec2 background,
const Points points,
const vec pobs,
const vec pbackground,
const StructureFunction structure,
float  min_quantile,
float  max_quantile,
int  min_points = 0 
)

Correction of a gridded field ensuring the distribution of values nearby match that of observations.

This is an experimental method.

Parameters
bgridgrid corresponding to input
background2D field of background values (Y, X)
pointsobservation points
pobsvector of observations
pbackgroundvector of background values at points
structurestructure function specifying correlation between points
min_quantiletruncate quantile map below this quantile
max_quantiletruncate quantile map above this quantile
max_pointsmaximum number of points used within localization radius (not used at moment)

◆ local_distribution_correction() [2/2]

vec2 gridpp::local_distribution_correction ( const Grid bgrid,
const vec2 background,
const Points points,
const vec2 pobs,
const vec2 pbackground,
const StructureFunction structure,
float  min_quantile,
float  max_quantile,
int  min_points = 0 
)

Version with multiple number of timesteps.

Pool all observations across time in when computing the calibration curve.

Parameters
bgridgrid corresponding to input
background2D field of background values (Y, X)
pointsobservation points
pobs2D vector of observations with dimensions (T, N)
pbackgroundvector of background values at points with dimensions (T, N)
structurestructure function specifying correlation between points
min_quantiletruncate quantile map below this quantile
max_quantiletruncate quantile map above this quantile
max_pointsmaximum number of points used within localization radius (not used at moment)

◆ mask_threshold_downscale_consensus()

vec2 gridpp::mask_threshold_downscale_consensus ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues_true,
const vec3 ivalues_false,
const vec3 theshold_values,
const vec2 threshold,
const ComparisonOperator comparison_operator,
const Statistic statistic 
)

Nearest neighbour downscaling grid to grid and threshold and consensus in one.

Parameters
igridInput grid
ogridOutput grid to downscale to
ivalues_true3D vector of values on the input grid (Y, X, E)
ivalues_false3D vector of values on the input grid (Y, X, E)
threshold_values3D vector of values (Y, X, E), which defines the mask array for ivalues after applying the theshold
threshold2D vector of threshold values
comparison_operatorlower than, lower or equal than, greater than, great or equal than
statisticstatistic to compute over the ensemble dimension
Returns
Values on the output grid

◆ metric_optimizer_curve()

vec gridpp::metric_optimizer_curve ( const vec ref,
const vec fcst,
const vec thresholds,
gridpp::Metric  metric,
vec output_fcst 
)

Create calibration curve that optimizes a metric.

Parameters
refReference values (observations)
fcstForecast values
thresholdsThresholds for computing optimal values for
metricA Metric to optimize for
Returns
Calibration curve

◆ monotonize_curve()

vec gridpp::monotonize_curve ( vec  curve_ref,
vec  curve_fcst,
vec output_fcst 
)

Ensure calibration curve is monotonic, by removing points.

Parameters
curve_refReference quantiles
curve_fcstForecast quantiles
output_fcstNew forecast quantiles
Returns
New reference quantiles

◆ nearest() [1/8]

vec2 gridpp::nearest ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues 
)

Nearest neighbour dowscaling grid to grid.

Parameters
igridInput grid
ogridOutput grid to downscale to
ivalues2D vector of values on the input grid
Returns
Values on the output grid

◆ nearest() [2/8]

vec3 gridpp::nearest ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues 
)

◆ nearest() [3/8]

vec gridpp::nearest ( const Grid igrid,
const Points opoints,
const vec2 ivalues 
)

Nearest neighbour dowscaling grid to point.

Parameters
igridInput grid
ogridOutput points to downscale to
ivalues2D vector of values on the input grid
Returns
Values for the output points

◆ nearest() [4/8]

vec2 gridpp::nearest ( const Grid igrid,
const Points opoints,
const vec3 ivalues 
)

◆ nearest() [5/8]

vec gridpp::nearest ( const Points ipoints,
const Points opoints,
const vec ivalues 
)

Nearest neighbour dowscaling point to point.

Parameters
ipointsInput points
opointsOutput points to downscale to
ivalues2D vector of values on the input grid
Returns
Values for the output points

◆ nearest() [6/8]

vec2 gridpp::nearest ( const Points ipoints,
const Points opoints,
const vec2 ivalues 
)

◆ nearest() [7/8]

vec2 gridpp::nearest ( const Points ipoints,
const Grid ogrid,
const vec ivalues 
)

Nearest neighbour dowscaling point to grid.

Parameters
ipointsInput points
ogridOutput points to downscale to
ivalues2D vector of values on the input grid
Returns
Values for the output points

◆ nearest() [8/8]

vec3 gridpp::nearest ( const Points ipoints,
const Grid ogrid,
const vec2 ivalues 
)

◆ neighbourhood() [1/2]

vec2 gridpp::neighbourhood ( const vec2 input,
int  halfwidth,
gridpp::Statistic  statistic 
)

Spatial neighbourhood filter, computing a statistic for a sliding square window.

Parameters
input2D grid of values
halfwidthFilter halfwidth in number of gridpoints
statisticStatistic to compute

◆ neighbourhood() [2/2]

vec2 gridpp::neighbourhood ( const vec3 input,
int  halfwidth,
gridpp::Statistic  statistic 
)

Spatial neighbourhood filter for an ensemble of fields.

Parameters
input3D grid of values with dimensions (Y, X, E)
halfwidthFilter halfwidth in number of gridpoints
statisticStatistic to compute

◆ neighbourhood_brute_force() [1/2]

vec2 gridpp::neighbourhood_brute_force ( const vec2 input,
int  halfwidth,
gridpp::Statistic  statistic 
)

Spatial neighbourhood filter without any shortcuts.

This is quite slow and is only useful for testing.

Parameters
input2D grid of values
halfwidthFilter halfwidth in number of gridpoints
operationone of min, mean, median, max

◆ neighbourhood_brute_force() [2/2]

vec2 gridpp::neighbourhood_brute_force ( const vec3 input,
int  halfwidth,
gridpp::Statistic  statistic 
)

Spatial neighbourhood filter without any shortcuts.

This is quite slow and is only useful for testing.

Parameters
input3D grid of values with dimensions (Y, X, E)
halfwidthFilter halfwidth in number of gridpoints
operationone of min, mean, median, max

◆ neighbourhood_ens()

vec2 gridpp::neighbourhood_ens ( const vec3 input,
int  halfwidth,
gridpp::Statistic  statistic 
)

Deprecated: Compute neighbourhood statistic on ensemble field.

Deprecated:
Use neighbourhood() function

◆ neighbourhood_quantile() [1/2]

vec2 gridpp::neighbourhood_quantile ( const vec2 input,
float  quantile,
int  halfwidth 
)

Computes a quantile in a sliding square neighbourhood.

Parameters
input2D grid of values
quantileQuantile to compute (between 0 and 1)
halfwidthFilter halfwidth in number of gridpoints

◆ neighbourhood_quantile() [2/2]

vec2 gridpp::neighbourhood_quantile ( const vec3 input,
float  quantile,
int  halfwidth 
)

Computes a quantile in a sliding square neighbourhood for an ensemble of fields.

Parameters
input3D grid of values with dimensions (Y, X, E)
quantileQuantile to compute (between 0 and 1)
halfwidthFilter halfwidth in number of gridpoints

◆ neighbourhood_quantile_ens()

vec2 gridpp::neighbourhood_quantile_ens ( const vec3 input,
float  quantile,
int  halfwidth 
)

Deprecated: Compute neighbourhood quantiles on ensemble field.

Deprecated:
Use neighbourhood_quantile() function

◆ neighbourhood_quantile_ens_fast()

vec2 gridpp::neighbourhood_quantile_ens_fast ( const vec3 input,
float  quantile,
int  radius,
const vec thresholds 
)

Deprecated: Compute neighbourhood quantiles fast on ensemble field.

Deprecated:
Use neighbourhood_quantile_fast() function

◆ neighbourhood_quantile_fast() [1/4]

vec2 gridpp::neighbourhood_quantile_fast ( const vec2 input,
float  quantile,
int  halfwidth,
const vec thresholds 
)

Fast and approximate neighbourhood quantile.

Parameters
input2D grid of values
quantileQuantile to compute (between 0 and 1)
halfwidthFilter halfwidth in number of gridpoints
thresholdsVector of thresholds to use to approximate value

◆ neighbourhood_quantile_fast() [2/4]

vec2 gridpp::neighbourhood_quantile_fast ( const vec3 input,
float  quantile,
int  halfwidth,
const vec thresholds 
)

Fast and approximate neighbourhood quantile for ensemble of fields.

Parameters
input3D grid of values with dimensions (Y, X, E)
quantileQuantile to compute (between 0 and 1)
halfwidthFilter halfwidth in number of gridpoints
thresholdsVector of thresholds to use to approximate value

◆ neighbourhood_quantile_fast() [3/4]

vec2 gridpp::neighbourhood_quantile_fast ( const vec2 input,
const vec2 quantile,
int  halfwidth,
const vec thresholds 
)

Fast and approximate neighbourhood quantile, with spatially varying quantile.

Parameters
input2D grid of values
quantile2D grid quantiles to compute (between 0 and 1)
halfwidthFilter halfwidth in number of gridpoints
thresholdsVector of thresholds to use to approximate value

◆ neighbourhood_quantile_fast() [4/4]

vec2 gridpp::neighbourhood_quantile_fast ( const vec3 input,
const vec2 quantile,
int  halfwidth,
const vec thresholds 
)

Fast and approximate neighbourhood quantile for ensemble of fields, with spatially varying quantile.

Parameters
input3D grid of values with dimensions (Y, X, E)
quantile2D grid quantiles to compute (between 0 and 1)
halfwidthFilter halfwidth in number of gridpoints
thresholdsVector of thresholds to use to approximate value

◆ neighbourhood_search()

vec2 gridpp::neighbourhood_search ( const vec2 array,
const vec2 search_array,
int  halfwidth,
float  search_target_min,
float  search_target_max,
float  search_delta,
const ivec2 apply_array = ivec2() 
)

Find suitable value in neighbourhood based on a search criteria.

If search value is within a criteria range, then the most suitable point is used. This is the nearest value of any point within the search_target range; or if no point fulfills this, the point with the highest search value.

Parameters
basebase values (e.g elevation)
valuesvalues to compute gradients for (e.g. temperatures)
gradient_typewhat gradient type to compute
halfwidthneighbourhood halfwidth to compute gradient for
min_numminimum number of valid points needed to compute gradient
min_rangeminimum range of base values to compute gradient (for LinearRegression, this is the standard deviation of values
default_gradientThe gradient to use when a gradient cannot be computed

◆ num_missing_values()

int gridpp::num_missing_values ( const vec2 iArray)

◆ optimal_interpolation() [1/2]

vec2 gridpp::optimal_interpolation ( const Grid bgrid,
const vec2 background,
const Points points,
const vec pobs,
const vec pratios,
const vec pbackground,
const StructureFunction structure,
int  max_points,
bool  allow_extrapolation = true 
)

Optimal interpolation for a deterministic gridded field.

Parameters
bgridGrid of background field
background2D field of background values
pointsPoints of observations
pobsVector of observations
pratiosVector of ratio of observation error variance to background variance
pbackgroundBackground with observation operator
structureStructure function
max_pointsMaximum number of observations to use inside localization zone; Use 0 to disable
allow_extrapolationAllow OI to extrapolate increments outside increments at observations

◆ optimal_interpolation() [2/2]

vec gridpp::optimal_interpolation ( const Points bpoints,
const vec background,
const Points points,
const vec pobs,
const vec pratios,
const vec pbackground,
const StructureFunction structure,
int  max_points,
bool  allow_extrapolation = true 
)

Optimal interpolation for a deterministic vector of points.

Parameters
bpointsPoints of background field
background1D field of background values
pointsPoints of observations
pobsVector of observations
pratiosVector of ratio of observation error variance to background variance
pbackgroundBackground with observation operator
structureStructure function
max_pointsMaximum number of observations to use inside localization zone; Use 0 to disable
allow_extrapolationAllow OI to extrapolate increments outside increments at observations

◆ optimal_interpolation_ensi() [1/2]

vec3 gridpp::optimal_interpolation_ensi ( const Grid bgrid,
const vec3 background,
const Points points,
const vec pobs,
const vec psigmas,
const vec2 pbackground,
const StructureFunction structure,
int  max_points,
bool  allow_extrapolation = true 
)

Optimal interpolation using a structure function based on an ensemble See Lussana et al 2019 (DOI: 10.1002/qj.3646)

Parameters
input3D field of background values (Y, X, E)
bgridgrid corresponding to input
pobsvector of observations
pcivector of ci values
pointsobservation points

◆ optimal_interpolation_ensi() [2/2]

vec2 gridpp::optimal_interpolation_ensi ( const Points bpoints,
const vec2 background,
const Points points,
const vec pobs,
const vec psigmas,
const vec2 pbackground,
const StructureFunction structure,
int  max_points,
bool  allow_extrapolation = true 
)

◆ optimal_interpolation_full() [1/2]

vec2 gridpp::optimal_interpolation_full ( const Grid bgrid,
const vec2 background,
const vec2 bvariance,
const Points points,
const vec obs,
const vec obs_variance,
const vec background_at_points,
const vec bvariance_at_points,
const StructureFunction structure,
int  max_points,
vec2 analysis_variance,
bool  allow_extrapolation = true 
)

Optimal interpolation for a deterministic gridded field including analysis variance.

Parameters
bgridGrid of background field
background2D field of background values
bvarianceVariance of background field
pointsPoints of observations
obsVector of observations
obs_varianceVariance of observations
background_at_pointsBackground interpolated to observation points
bvariance_at_pointsVariance of background interpolated to observation points
structureStructure function
max_pointsMaximum number of observations to use inside localization zone; Use 0 to disable
allow_extrapolationAllow OI to extrapolate increments outside increments at observations

◆ optimal_interpolation_full() [2/2]

vec gridpp::optimal_interpolation_full ( const Points bpoints,
const vec background,
const vec bvariance,
const Points points,
const vec obs,
const vec obs_variance,
const vec background_at_points,
const vec bvariance_at_points,
const StructureFunction structure,
int  max_points,
vec analysis_sigmas,
bool  allow_extrapolation = true 
)

Optimal interpolation for a deterministic vector of points including analysis variance.

Parameters
bpointsPoints of background field
background1D field of background values
bvarianceVariance of background field
pointsPoints of observations
obsVector of observations
obs_varianceVariance of observations
background_at_pointsBackground interpolated to observation points
bvariance_at_pointsVariance of background interpolated to observation points
structureStructure function
max_pointsMaximum number of observations to use inside localization zone; Use 0 to disable
allow_extrapolationAllow OI to extrapolate increments outside increments at observations

◆ point_in_rectangle()

bool gridpp::point_in_rectangle ( const Point A,
const Point B,
const Point C,
const Point D,
const Point m 
)

Checks if a point is located inside a rectangle formed by 4 points.

The 4 points must be provided in an order that draws out a rectangle (either clockwise or counter-clockwise)

Parameters
AA point in the rectangle
BA point in the rectangle
CA point in the rectangle
DA point in the rectangle
mThe point to test if it is inside
Returns
True if the point is inside, False otherwise

◆ pressure() [1/2]

float gridpp::pressure ( float  ielev,
float  oelev,
float  ipressure,
float  itemperature = 288.15 
)

Calculate pressure at a new elevation.

Parameters
ielevElevation at start point
oelevElevation at new point
ipressurePressure at start point
itemperatureTemperature at start point
Returns
Pressure at new point

◆ pressure() [2/2]

vec gridpp::pressure ( const vec ielev,
const vec oelev,
const vec ipressure,
const vec itemperature 
)

Calculate Vector version of pressure calculation.

Parameters
ielevElevations at start point
oelevElevations at new point
ipressurePressures at start point
itemperatureTemperatures at start point
Returns
Pressures at new points

◆ qnh() [1/2]

float gridpp::qnh ( float  pressure,
float  altitude 
)

Diagnose QNH from pressure and altitude.

Parameters
pressurePressure at point [pa]
altitudeAltitude of point [m]
Returns
QNH [pa]

◆ qnh() [2/2]

vec gridpp::qnh ( const vec pressure,
const vec altitude 
)

Vector version of QNH calculation.

Parameters
pressurePressures at points [pa]
altitudeAltitudes of points [m]
Returns
QNH [pa]

◆ quantile_mapping_curve()

vec gridpp::quantile_mapping_curve ( const vec ref,
const vec fcst,
vec output_fcst,
vec  quantiles = vec() 
)

Create quantile mapping calibration curve.

Parameters
refReference values (observations)
fcstForecast values
output_fcstOutput forecast quantiles
quantilesVector of quantiles to extract. If empty, use all values.
Returns
Output reference quantiles

◆ relative_humidity() [1/2]

float gridpp::relative_humidity ( float  temperature,
float  dewpoint 
)

Calculate relative humidity from temperature and dewpoint temperature.

Parameters
temperatureTemperature [K]
dewpointDewpoint temperature [K]
Returns
Relative humidity [1]

◆ relative_humidity() [2/2]

vec gridpp::relative_humidity ( const vec temperature,
const vec dewpoint 
)

Vector version of relative humidity calculation.

Parameters
temperatureTemperatures [K]
dewpointDewpoint temperatures [K]
Returns
Relative humidities [1]

◆ sea_level_pressure() [1/2]

float gridpp::sea_level_pressure ( float  ps,
float  altitude,
float  temperature,
float  rh = gridpp::MV,
float  dewpoint = gridpp::MV 
)

Convert Surface Pressure to Sea Level Pressure.

Parameters
psSurface pressure [pa]
altitudeStation altitude above sea level [m]
temperature2m temperature [K]
rh2m Relative humidity [1]
dewpoint2m Dewpoint Temperature at station [K]
Returns
Sea Level Pressure [pa]

◆ sea_level_pressure() [2/2]

vec gridpp::sea_level_pressure ( const vec ps,
const vec altitude,
const vec temperature,
const vec rh,
const vec dewpoint 
)

Vector version of Convert Surface Pressure to Sea Level Pressure.

Parameters
psSurface pressures [pa]
altitudeStation altitudes above sea level [m]
temperature2m temperatures [K]
rh2m Relative humidities [1]
dewpoint2m Dewpoint Temperatures at stations [K]
Returns
Sea Level Pressure [pa]

◆ set_debug_level()

void gridpp::set_debug_level ( int  level)

Set the verbosity of debug messages.

Use 0 for no messages.

◆ set_omp_threads()

void gridpp::set_omp_threads ( int  num)

Set the number of OpenMP threads to use.

Overrides OMP_NUM_THREAD env variable.

◆ simple_gradient() [1/4]

vec2 gridpp::simple_gradient ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues,
float  elev_gradient,
Downscaler  downscaler = Nearest 
)

◆ simple_gradient() [2/4]

vec3 gridpp::simple_gradient ( const Grid igrid,
const Grid ogrid,
const vec3 ivalues,
float  elev_gradient,
Downscaler  downscaler = Nearest 
)

◆ simple_gradient() [3/4]

vec gridpp::simple_gradient ( const Grid igrid,
const Points opoints,
const vec2 ivalues,
float  elev_gradient,
Downscaler  downscaler = Nearest 
)

◆ simple_gradient() [4/4]

vec2 gridpp::simple_gradient ( const Grid igrid,
const Points opoints,
const vec3 ivalues,
float  elev_gradient,
Downscaler  downscaler = Nearest 
)

◆ smart()

vec2 gridpp::smart ( const Grid igrid,
const Grid ogrid,
const vec2 ivalues,
int  num,
const StructureFunction structure 
)

Smart neighbour downscaling grid to grid.

Parameters
igridInput grid
ogridOutput points to downscale to
ivalues2D vector of values on the input grid
numNumber of neighbours to average
structureStructure function for determining similarity
Returns
Values for the output points

◆ test_array()

float * gridpp::test_array ( float *  v,
int  n 
)

Special function whose presense is needed for SWIG.

◆ test_ivec2_output()

ivec2 gridpp::test_ivec2_output ( )

◆ test_ivec3_output()

ivec3 gridpp::test_ivec3_output ( )

◆ test_ivec_input()

int gridpp::test_ivec_input ( const ivec input)

Testing function for 1D input vector.

◆ test_ivec_output()

ivec gridpp::test_ivec_output ( )

◆ test_not_implemented_exception()

void gridpp::test_not_implemented_exception ( )

◆ test_vec2_argout()

float gridpp::test_vec2_argout ( vec2 distances)

Testing function for 2D vector treated as output.

◆ test_vec2_input()

float gridpp::test_vec2_input ( const vec2 input)

Testing function for 2D input vector.

◆ test_vec2_output()

vec2 gridpp::test_vec2_output ( )

Testing function for 2D output vector.

◆ test_vec3_input()

float gridpp::test_vec3_input ( const vec3 input)

Testing function for 3D input vector.

◆ test_vec3_output()

vec3 gridpp::test_vec3_output ( )

Testing function for 3D output vector.

◆ test_vec_argout()

float gridpp::test_vec_argout ( vec distances)

Testing function for 1D vector treated as output.

◆ test_vec_input()

float gridpp::test_vec_input ( const vec input)

Testing function for 1D input vector.

◆ test_vec_output()

vec gridpp::test_vec_output ( )

Testing function for 1D output vector.

◆ version()

std::string gridpp::version ( )

The gridpp version.

Returns
The gridpp version

◆ warning()

void gridpp::warning ( std::string  string)

◆ wetbulb() [1/2]

float gridpp::wetbulb ( float  temperature,
float  pressure,
float  relative_humidity 
)

Calculate wetbulb temperature from temperature, pressure, and relative humidity.

Parameters
temperatureTemperature [K]
pressureAir pressure [pa]
Relativehumidity [1]
Returns
Wetbulb temperature [K]

◆ wetbulb() [2/2]

vec gridpp::wetbulb ( const vec temperature,
const vec pressure,
const vec relative_humidity 
)

Vector version of wetbulb calculation.

Parameters
temperatureTemperatures [K]
pressureAir pressures [pa]
Relativehumidities [1]
Returns
Wetbulb temperatures [K]

◆ wind_direction() [1/2]

float gridpp::wind_direction ( float  xwind,
float  ywind 
)

Diagnose wind direction from its components.

If both xwind and ywind are 0, then direction is 180

Parameters
xwindX-component of wind [any unit]
ywindY-component of wind [any unit]
Returns
Wind direction [degrees]

◆ wind_direction() [2/2]

vec gridpp::wind_direction ( const vec xwind,
const vec ywind 
)

Vector version of wind direction calculation.

Parameters
xwindX-components of wind [any unit]
ywindY-components of wind [any unit]
Returns
Wind direction [degrees]

◆ wind_speed() [1/2]

float gridpp::wind_speed ( float  xwind,
float  ywind 
)

Diagnose wind speed from its components.

Parameters
xwindX-component of wind [any unit]
ywindY-component of wind [any unit]
Returns
Wind speed [any unit]

◆ wind_speed() [2/2]

vec gridpp::wind_speed ( const vec xwind,
const vec ywind 
)

Vector version of wind speed calculation.

Parameters
xwindX-components of wind [any unit]
ywindY-components of wind [any unit]
Returns
Wind speeds [any unit]

◆ window()

vec2 gridpp::window ( const vec2 array,
int  length,
gridpp::Statistic  statistic,
bool  before = false,
bool  keep_missing = false,
bool  missing_edges = true 
)

Compute window statistics.

Parameters
arrayinput array with dimensions (case, time)
lengthwindow length in number of timesteps
statisticstatistic to apply to window
beforeif true, make the window end at the particular time. If false, centre it.
keep_missingif true, window value will be missing if one or more values in window are missing
missing_edgesif true put missing values at the edges, where window overshoots the edge

Variable Documentation

◆ _debug_level

int gridpp::_debug_level = 0
static

◆ gas_constant_mol

const float gridpp::gas_constant_mol = 8.31447
static

Universal Gas Constant [kg*m^2*s^-2/(K*mol)].

◆ gas_constant_si

const float gridpp::gas_constant_si = 287.05
static

Universal Gas Constant [J/(kg*K)].

◆ gravit

const float gridpp::gravit = 9.80665
static

Gravitational acceleration [m/s^2].

◆ lapse_rate

const float gridpp::lapse_rate =0.0065
static

Constant Lapse Rate moist air standard atmosphere [K/m].

◆ molar_mass

const float gridpp::molar_mass = 0.0289644
static

Molar Mass of Dry Air [kg/mol].

◆ MV

const float gridpp::MV = NAN
static

Missing value indicator.

◆ MV_CML

const float gridpp::MV_CML = -999
static

Missing value indicator in gridpp command-line tool.

◆ pi

const float gridpp::pi = 3.14159265
static

Mathematical constant pi.

◆ radius_earth

const double gridpp::radius_earth = 6.378137e6
static

Radius of the earth [m].

◆ standard_surface_temperature

const float gridpp::standard_surface_temperature = 288.15
static

Temperature at surface in standard atmosphere [K].

◆ swig_default_value

const float gridpp::swig_default_value = -1
static

Default value used to fill array in SWIG testing functions.

Not useful for any other purpose.