geodat.stat

geodat.stat.cdf(data, **kwargs)[source]

Compute a histogram and the corresponding cumulative frequency polygon.

Parameters:
  • data (numpy 1d array) –
  • option (str) – currently accepts “hist” only

Keyword arguments currently are passed to numpy.histogram

Returns:mid values of bins and the cumulative frequencies
Return type:bins, cdf
geodat.stat.lat_weights(lats)[source]

Returns cos(lats)

Required as a weighting for calculating areas on a regular cartesian lat-lon grid in which meridians converge.

Parameters:lats (numpy ndarray) – in degree
Returns:numpy ndarray
geodat.stat.resample_xy(x, y, xnew, nx, ny, y_always_valid=True)[source]

Given paired values of (x,y), randomly sample a set of values for ynew given an array xnew such that the joint distribution of (xnew, ynew) resembles that of (x,y)

Parameters:
  • x (numpy 1d array) –
  • y (numpy 1d array) – shape should match x
  • xnew (numpy 1d array) –
  • nx (int) – the number of bins applied to x
  • ny (int) – the number of bins applied to y
  • y_always_valid (bool) – keep drawingn from the cdf until y is valid
Returns:

ynew – length = len(xnew)

Return type:

numpy 1d array

geodat.stat.runave(data, N, axis=0, step=None)[source]

Compute a smooth box-car running average and masked edge values using scipy.ndimage.filters.convolve1d

Parameters:
  • data (numpy array) –
  • N (int) – width of the box car
  • axis (int) – axis along which the average is computed (See scipy.ndimage.filters.convolve1d)
  • step (optional, int) – skips between the box car samples
Returns:

numpy masked array (same shape as data)

geodat.stat.skewness(data)[source]

Essentially the same as scipy.stats.skew or scipy.stats.mstats.skew depending on the input

Input:
data (numpy array or masked array)
Returns:numpy array or masked array
Fork me on GitHub