source: trunk/src/Utils/utils.hh @ 275

Last change on this file since 275 was 275, checked in by Matthew Whiting, 17 years ago

Many changes -- almost a week's worth!

  • Major change is to enable spatial smoothing. This incorporated:
    • A new class GaussSmooth? (in eponymous files) to implement this.
    • New parameters concerning setup of Gaussian.
    • New Cube functions to do the smoothing and searching: smoothCube() and smoothNSearch() (the latter not used, but still in the file).
  • Some changes to the statistical calculations:
    • Cube::setCubeStats() now re-worked to be clearer. Smoothed data dealt with directly. setupFDR() now has a switching function to go before it.
    • Improved the way the stats are written to the results file, with new functions.
    • new functions to StatsContainer?: scaleNoise and sigmaToMADFM
    • a new findAllStats() function to return all four statistical parameters, which is made use of by the StatsContainer? calculate() functions.

Other changes include:

  • Lutz_detect now does not check for the minsize criterion.
  • New function Param::makeBlankMask() to make a mask array.
  • FitsHeader? now has a bpaKeyword member
  • Fixed drawContours() function so that it can deal with data outside box.
  • Added new files to Makefile.in
  • Hanning class now has a define(int) function. Definition moved out of the constructor.
  • In the map plots, each object is now marked by the peak location, not the centre.
  • Documentation somewhat updated (bit still to do for smoothing, especially statistics)
  • Other minor changes, including comments.
File size: 3.5 KB
Line 
1#ifndef UTILS_H
2#define UTILS_H
3
4#include <wcs.h>
5#include <string>
6
7struct wcsprm; // just foreshadow this.
8
9// define the speed of light for WCS-related accessor functions
10const float C_kms = 299792.458;
11
12int linear_regression(int num, float *x, float *y, int ilow, int ihigh,
13                      float &slope, float &errSlope,
14                      float &intercept, float &errIntercept, float &r);
15void zscale(long imagesize, float *image, float &z1, float &z2);
16void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal);
17template <class T> void sort(T *arr, int begin, int end);
18template <class T1, class T2> void sort(T1 *arr, T2 *matchingArray,
19                                        int begin, int end);
20
21// STATISTICS-RELATED ROUTINES
22template <class T> T absval(T value);
23template <class T> void findMinMax(const T *array, const int size,
24                                   T &min, T &max);
25template <class T> float findMean(T *array, int size);
26template <class T> float findStddev(T *array, int size);
27template <class T> T findMedian(T *array, int size);
28template <class T> T findMADFM(T *array, int size);
29template <class T> void findMedianStats(T *array, int size,
30                                        T &median, T &madfm);
31template <class T> void findMedianStats(T *array, int size, bool *isGood,
32                                        T &median, T &madfm);
33template <class T> void findNormalStats(T *array, int size,
34                                        float &mean, float &stddev);
35template <class T> void findNormalStats(T *array, int size, bool *isGood,
36                                        float &mean, float &stddev);
37template <class T> void findAllStats(T *array, int size,
38                                     float &mean, float &stddev,
39                                     T &median, T &madfm);
40template <class T> void findAllStats(T *array, int size, bool *mask,
41                                     float &mean, float &stddev,
42                                     T &median, T &madfm);
43
44
45//--------------------
46// PLOTTING ROUTINES
47//--------------------
48// The following are in plottingUtilities.cc
49//
50void plotLine(const float slope, const float intercept);
51void lineOfEquality();
52void lineOfBestFit(int size, float *x, float *y);
53void lineOfBestFitPB(const int size, const float *x, const float *y);
54void plotVertLine(const float xval, const int colour, const int style);
55void plotVertLine(const float xval);
56void plotVertLine(const float xval, const int colour);
57void plotHorizLine(const float yval, const int colour, const int style);
58void plotHorizLine(const float yval);
59void plotHorizLine(const float yval, const int colour);
60void drawContours(const int size, const float *x, const float *y);
61
62// POSITION-RELATED ROUTINES
63std::string getIAUNameEQ(double ra, double dec, float equinox);
64std::string getIAUNameGAL(double ra, double dec);
65std::string decToDMS(double dec, std::string type);
66double dmsToDec(std::string dms);
67double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
68
69// WCS-RELATED ROUTINES
70int wcsToPixSingle(struct wcsprm *wcs, const double *world, double *pix);
71int pixToWCSSingle(struct wcsprm *wcs, const double *pix, double *world);
72int wcsToPixMulti(struct wcsprm *wcs, const double *world,
73                  double *pix, const int npts);
74int pixToWCSMulti(struct wcsprm *wcs, const double *pix,
75                  double *world, const int npts);
76double pixelToVelocity(struct wcsprm *wcs, double &x, double &y,
77                       double &z, std::string velUnits);
78double coordToVel(struct wcsprm *wcs, const double coord, std::string outputUnits);
79double velToCoord(struct wcsprm *wcs, const float velocity, std::string outputUnits);
80
81// FILTER SMOOTHING ROUTINES
82void waveletSmooth(int dim,float *array, int arraySize, float sigma);
83void hanningSmooth(float *array, int arraySize, int hanningSize);
84void tophatSmooth(float *array, int arraySize, int width);
85
86#endif
Note: See TracBrowser for help on using the repository browser.