OPERA  1.0
Open source echelle spectrograph reduction pipeline
operaStats.c File Reference

Statistics library. More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "libraries/operaStats.h"
Include dependency graph for operaStats.c:

Namespaces

namespace  operaStats

Functions

float operaArrayMean (unsigned np, const float *array)
 Calculate arithmetic mean of float array.
float operaArrayWeightedMean (unsigned np, const float *array, const float *weigh)
 Calculate weighted mean of float array.
float operaArrayAvgSigClip (unsigned np, const float *array, unsigned nsig)
 Calculate average of array clipped by nsig x sdtdev of original array.
float operaArraySig (unsigned np, const float *array)
 Calculate standard deviation around mean of array.
float operaArrayWeightedSig (unsigned np, const float *array, const float *weigh)
 Calculate weighted standard deviation of weighted mean of array.
float operaArrayMedian (unsigned np, const float *array)
 This function non-destructively finds the median of an array.
float operaArrayMedSig (unsigned np, const float *array, float median)
 Calculate median deviation of float array.
float operaArrayMaxValue (unsigned np, const float *array)
 Find maximum value of float array.
float operaArrayMinValue (unsigned np, const float *array)
 Find minimum value of float array.
void operaArrayHeapSort (unsigned np, float *arr)
 This function destructively heap sorts an array.
void operaArrayIndexSort (unsigned np, const float *array, unsigned *sindex)
 This function sorts a float array in increasing order using index association (doesn't change original array)
float operaUniformRand (float xcen, float xmin, float xmax)
 This function produces a random number with uniform distribution.
float operaGaussRand (float xcen, float sig)
 This function produces a random number with normal distribution.
unsigned operaCountPixels (unsigned np, const float *array, float minvalue, float maxvalue)
 Count number of elements in array lying between minvalue and maxvalue.

Variables

static int verbose = 0
 Statistics library.
static int debug = 0

Detailed Description

Statistics library.


Function Documentation

float operaArrayAvgSigClip ( unsigned  np,
const float *  array,
unsigned  nsig 
)

Calculate average of array clipped by nsig x sdtdev of original array.

float operaArrayAvgSigClip(unsigned np, const float *array, unsigned nsig)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
nsigis an unsigned for size for which data is clipped in sigma units
Returns:
float avgsigclip of array
void operaArrayHeapSort ( unsigned  np,
float *  arr 
)

This function destructively heap sorts an array.

void operaArrayHeapSort(unsigned np, float *arr)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
Returns:
void
void operaArrayIndexSort ( unsigned  np,
const float *  array,
unsigned *  sindex 
)

This function sorts a float array in increasing order using index association (doesn't change original array)

void operaArrayIndexSort(unsigned n, const float *x, unsigned *sindex)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
sindexis an unsigned pointer for the index association of the sorted array
Returns:
void
float operaArrayMaxValue ( unsigned  np,
const float *  array 
)

Find maximum value of float array.

float operaArrayMaxValue(unsigned np, const float *array)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
Returns:
float maximum value of array
float operaArrayMean ( unsigned  np,
const float *  array 
)

Calculate arithmetic mean of float array.

float operaArrayMean(unsigned np, const float *array)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
Returns:
float mean of array
float operaArrayMedian ( unsigned  np,
const float *  array 
)

This function non-destructively finds the median of an array.

float operaArrayMedian(unsigned np, const float *array)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
Returns:
float median of array
float operaArrayMedSig ( unsigned  np,
const float *  array,
float  median 
)

Calculate median deviation of float array.

float operaArrayMedSig(unsigned np, const float *array, float median)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
medianis a float input for the median of array
Returns:
float median deviation of array

Here is the call graph for this function:

float operaArrayMinValue ( unsigned  np,
const float *  array 
)

Find minimum value of float array.

float operaArrayMinValue(unsigned np, const float *array)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
Returns:
float minimum value of array
float operaArraySig ( unsigned  np,
const float *  array 
)

Calculate standard deviation around mean of array.

float operaArraySig(unsigned np, const float *array)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
Returns:
float sigma
float operaArrayWeightedMean ( unsigned  np,
const float *  array,
const float *  weigh 
)

Calculate weighted mean of float array.

float operaArrayWeightedMean(unsigned np, const float *array, const float *weigh)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
weighis a float pointer with weights
Returns:
float mean of array
float operaArrayWeightedSig ( unsigned  np,
const float *  array,
const float *  weigh 
)

Calculate weighted standard deviation of weighted mean of array.

float operaArrayWeightedSig(unsigned np, const float *array, const float *weigh)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
weighis a float pointer with weights
Returns:
float weighted sigma
unsigned operaCountPixels ( unsigned  np,
const float *  array,
float  minvalue,
float  maxvalue 
)

Count number of elements in array lying between minvalue and maxvalue.

operaCountPixels(unsigned np, const float *array, float minvalue, float maxvalue)

Parameters:
npis an unsigned for the number of elements in array
arrayis a float pointer with data
minvalueis a float for the minimum value to count an element
maxvalueis a float for the maximum value to count an element
Returns:
unsigned number of elements
float operaGaussRand ( float  xcen,
float  sig 
)

This function produces a random number with normal distribution.

float operaGaussRand(float xcen, float sig)

Note:
For better randomness initialize srandom(time(NULL)) prior to call this function
Parameters:
xcenis a float to define the center of the distribution
sigis a float to define the spread of the distribution (symmetric)
Returns:
float random number
float operaUniformRand ( float  xcen,
float  xmin,
float  xmax 
)

This function produces a random number with uniform distribution.

float operaUniformRand(float xcen, float xmax, float xmin)

Note:
For better randomness initialize srandom(time(NULL)) prior to call this function
Parameters:
xcenis a float for the center of the distribution
xminis a float to define the lower limit of the distribution (rand > xcen - xmin)
xmaxis a float to define the higher limit of the distribution (rand < xcen + xmax)
Returns:
float random number