OPERA  1.0
Open source echelle spectrograph reduction pipeline
operaStats.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "operaError.h"
Include dependency graph for operaStats.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define M_PI   3.14159265358979323846264338327950288
#define ELEM_SWAP(a, b)   {register float t=(a);(a)=(b);(b)=t;}

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 xmax, float xmin)
 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.
void operaArrayIndexedMeanQuick (unsigned np, const float *array, const float *indexmask, unsigned nb, float *meanbin)
 This function ....
void operaArrayIndexedSigQuick (unsigned np, const float *array, const float *indexmask, unsigned nb, float *sigbin)
 This function ....
float operaArrayMeanQuick (unsigned np, const float *array)
 This function ....
float operaArrayWeightedMeanQuick (unsigned np, const float *array, const float *weigh)
 This function ....
float operaArraySigQuick (unsigned np, const float *array)
 This function ,,.
float operaArrayWeightedSigQuick (unsigned np, const float *array, const float *weigh)
 This function....
float operaArrayAvgSigClipQuick (unsigned np, const float *array, unsigned nsig)
 This function does an average sigma clip of an array.
float operaArrayMedianQuick (unsigned np, float *arr)
 Optimized inline function returning a median -- WARNING: DESTRUCTIVE -- the input is modified.
unsigned short operaArrayMedianQuickUSHORT (unsigned np, unsigned short *arr)
 Optimized inline function returning a median -- WARNING: DESTRUCTIVE -- the input is modified.

Define Documentation

#define ELEM_SWAP (   a,
 
)    {register float t=(a);(a)=(b);(b)=t;}
#define M_PI   3.14159265358979323846264338327950288

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
float operaArrayAvgSigClipQuick ( unsigned  np,
const float *  array,
unsigned  nsig 
) [inline]

This function does an average sigma clip of an array.

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

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
nsigis n unsigned that ..,
Returns:
float
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 operaArrayIndexedMeanQuick ( unsigned  np,
const float *  array,
const float *  indexmask,
unsigned  nb,
float *  meanbin 
) [inline]

This function ....

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

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
weighis a const float pointer that ..,
Returns:
float
void operaArrayIndexedSigQuick ( unsigned  np,
const float *  array,
const float *  indexmask,
unsigned  nb,
float *  sigbin 
) [inline]

This function ....

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

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
weighis a const float pointer that ..,
Returns:
float
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 operaArrayMeanQuick ( unsigned  np,
const float *  array 
) [inline]

This function ....

float operaArrayMeanQuick(unsigned np, const float *array)

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
Returns:
float
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 operaArrayMedianQuick ( unsigned  np,
float *  arr 
) [inline]

Optimized inline function returning a median -- WARNING: DESTRUCTIVE -- the input is modified.

inline float operaArrayMedianQuick(unsigned np, float *arr)

Parameters:
arr- the array to get median from
np- number of pixels
Returns:
median
unsigned short operaArrayMedianQuickUSHORT ( unsigned  np,
unsigned short *  arr 
) [inline]

Optimized inline function returning a median -- WARNING: DESTRUCTIVE -- the input is modified.

inline unsigned short operaArrayMedianQuickUSHORT(unsigned np, float *arr)

Parameters:
arr- the array to get median from
np- number of pixels
Returns:
unsigned short median
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 operaArraySigQuick ( unsigned  np,
const float *  array 
) [inline]

This function ,,.

float operaArraySigQuick(unsigned np, const float *array)

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
Returns:
float
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 operaArrayWeightedMeanQuick ( unsigned  np,
const float *  array,
const float *  weigh 
) [inline]

This function ....

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

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
weighis a const float pointer that ..,
Returns:
float
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
float operaArrayWeightedSigQuick ( unsigned  np,
const float *  array,
const float *  weigh 
) [inline]

This function....

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

Parameters:
npis an unsigned that ..,
arrayis a const float pointer that ..,
weighis a const float pointer that ..,
Returns:
float
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