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

Last change on this file since 201 was 201, checked in by Matthew Whiting, 18 years ago
  • New functionality added: ability to smooth a cube (in each individual spectrum) using a hanning filter before searching.
  • This comes with associated input parameters: flagSmooth and hanningWidth.
  • Hanning smoothing implemented via a new class that does the smoothing
  • Other minor changes:
    • changed the way getIAUName is called.
    • new colour names in mycpgplot
    • a << operator for the StatsContainer? class
    • more robust ProgressBar? functions
    • updated the Makefile.in
File size: 4.4 KB
Line 
1#ifndef UTILS_H
2#define UTILS_H
3
4#include <param.hh>
5#include <wcs.h>
6#include <string>
7
8// define the speed of light for WCS-related accessor functions
9const float C_kms = 299792.458;
10
11// MENU ROUTINES FOR DIGANOSTIC/TEST PROGRAMS
12std::string menu();
13std::string specMenu();
14std::string orionMenu();
15std::string imageMenu();
16std::string twoblMenu();
17
18int linear_regression(int num, float *x, float *y, int ilow, int ihigh,
19                      float &slope, float &errSlope,
20                      float &intercept, float &errIntercept, float &r);
21void zscale(long imagesize, float *image, float &z1, float &z2);
22void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal);
23template <class T> void swap(T &a, T &b){T t=a;a=b;b=t;};
24template <class T> void sort(T *arr, int begin, int end);
25template <class T1, class T2> void sort(T1 *arr, T2 *matchingArray,
26                                        int begin, int end);
27
28// STATISTICS-RELATED ROUTINES
29template <class T> void findMinMax(const T *array, const int size,
30                                   T &min, T &max);
31template <class T> float findMean(T *array, int size);
32template <class T> float findStddev(T *array, int size);
33template <class T> T findMedian(T *array, int size);
34template <class T> T findMADFM(T *array, int size);
35template <class T> void findMedianStats(T *array, int size,
36                                        T &median, T &madfm);
37template <class T> void findMedianStats(T *array, int size, bool *isGood,
38                                        T &median, T &madfm);
39template <class T> void findNormalStats(T *array, int size,
40                                        float &mean, float &stddev);
41template <class T> void findNormalStats(T *array, int size, bool *isGood,
42                     float &mean, float &stddev);
43
44void findTrimmedHistStats(float *array, const int size,
45                          float &tmean, float &tsigma);
46void getRandomSpectrum(int length, float *x, float *y);
47void getRandomSpectrum(int length, float *x, double *y);
48void getRandomSpectrum(int length, float mean, float sigma,
49                       float *x, double *y);
50void getRandomSpectrum(int length, float mean, float sigma,
51                       float *x, float *y);
52float getNormalRV();
53float getNormalRVtrunc();
54float getNormalRV(float mean, float sigma);
55void getSigmaFactors(int &numScales, float *factors);
56void getSigmaFactors2D(int &numScales, float *factors);
57void getSigmaFactors3D(int &numScales, float *factors);
58void getSigmaFactors1DNew(int &numScales);
59void getSigmaFactors2DNew(int &numScales);
60void getSigmaFactors3DNew(int &numScales);
61
62
63// PLOTTING ROUTINES
64extern "C" int  cpgtest();
65extern "C" int  cpgIsPS();
66extern "C" void cpgwedglog(const char* side, float disp, float width,
67                           float fg, float bg, const char *label);
68extern "C" void cpghistlog(int npts, float *data, float datamin,
69                           float datamax, int nbin, int pgflag);
70extern "C" void cpgcumul(int npts, float *data, float datamin,
71                         float datamax, int pgflag);
72void plotLine(const float slope, const float intercept);
73void lineOfEquality();
74void lineOfBestFit(int size, float *x, float *y);
75void lineOfBestFitPB(const int size, const float *x, const float *y);
76void plotVertLine(const float xval, const int colour, const int style);
77void plotVertLine(const float xval);
78void plotVertLine(const float xval, const int colour);
79void plotHorizLine(const float yval, const int colour, const int style);
80void plotHorizLine(const float yval);
81void plotHorizLine(const float yval, const int colour);
82void drawContours(const int size, const float *x, const float *y);
83void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par);
84
85// POSITION-RELATED ROUTINES
86string getIAUNameEQ(double ra, double dec, float equinox);
87string getIAUNameGAL(double ra, double dec);
88string decToDMS(double dec, string type);
89double dmsToDec(string dms);
90double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
91
92// WCS-RELATED ROUTINES
93int wcsToPixSingle(wcsprm *wcs, const double *world, double *pix);
94int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world);
95int wcsToPixMulti(wcsprm *wcs, const double *world,
96                  double *pix, const int npts);
97int pixToWCSMulti(wcsprm *wcs, const double *pix,
98                  double *world, const int npts);
99double pixelToVelocity(wcsprm *wcs, double &x, double &y,
100                       double &z, string velUnits);
101double coordToVel(wcsprm *wcs, const double coord, string outputUnits);
102double velToCoord(wcsprm *wcs, const float velocity, string outputUnits);
103
104// FILTER SMOOTHING ROUTINES
105void waveletSmooth(int dim,float *array, int arraySize, float sigma);
106void hanningSmooth(float *array, int arraySize, int hanningSize);
107void tophatSmooth(float *array, int arraySize, int width);
108
109#endif
Note: See TracBrowser for help on using the repository browser.