source: branches/fitshead-branch/Utils/utils.hh @ 1441

Last change on this file since 1441 was 91, checked in by Matthew Whiting, 18 years ago

Completed re-write using the FitsHeader? class. Now runs quicker than code
on the trunk, and is able to deal with units properly, and is more adaptable.
Functions like conversion of coords to correct velocity units is taken care
of with FitsHeader? member functions, and the wcs/pix conversions all have
FitsHeader? member front-end functions, all defined in param.cc/hh.
The relevant functions in detection.cc need to have a FitsHeader? object passed,
which is possible due to Cube class having a FitsHeader? member.

File size: 4.7 KB
Line 
1#ifndef UTILS_H
2#define UTILS_H
3
4#include <param.hh>
5#include <wcs.h>
6#include <string>
7using std::string;
8
9// define the speed of light for WCS-related accessor functions
10const float C_kms = 299792.458;
11
12// Divide by the following correction factor to convert from MADFM to sigma estimator.
13const float correctionFactor = 0.6744888;
14// Multiply by the following correction factor to convert from trimmedSigma to sigma estimator.
15const double trimToNormal = 1.17036753077;
16
17// MENU ROUTINES FOR DIGANOSTIC/TEST PROGRAMS
18string menu();
19string specMenu();
20string orionMenu();
21string imageMenu();
22string twoblMenu();
23
24int linear_regression(int num, float *x, float *y, int ilow, int ihigh, float &slope, float &errSlope, float &intercept, float &errIntercept, float &r);
25void zscale(long imagesize, float *image, float &z1, float &z2);
26void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal);
27void swap(float &a, float &b);
28void sort(float *arr, int begin, int end);
29void sort(float *arr, float *matchingArray, int begin, int end);
30
31// STATISTICS-RELATED ROUTINES
32void findMinMax(const float *array, const int size, float &min, float &max);
33float findMean(float *&array, int size);
34float findStddev(float *&array, int size);
35float findMedian(float *&array, int size);
36float findMADFM(float *&array, int size);
37void findMedianStats(float *&array, int size, float &median, float &madfm);
38void findMedianStats(float *&array, long size, float &median, float &madfm);
39void findNormalStats(float *&array, int size, float &mean, float &sig);
40void findTrimmedHistStats(float *array, const int size, float &tmean, float &tsigma);
41void getRandomSpectrum(int length, float *x, float *y);
42void getRandomSpectrum(int length, float *x, double *y);
43void getRandomSpectrum(int length, float mean, float sigma, float *x, double *y);
44void getRandomSpectrum(int length, float mean, float sigma, float *x, float *y);
45float getNormalRV();
46float getNormalRVtrunc();
47float getNormalRV(float mean, float sigma);
48void getSigmaFactors(int &numScales, float *factors);
49void getSigmaFactors2D(int &numScales, float *factors);
50void getSigmaFactors3D(int &numScales, float *factors);
51void getSigmaFactors1DNew(int &numScales);
52void getSigmaFactors2DNew(int &numScales);
53void getSigmaFactors3DNew(int &numScales);
54
55
56// PLOTTING ROUTINES
57void cpgwedglog(const char* side, float disp, float width, float fg, float bg, const char *label);
58void cpghistlog(int npts, float *data, float datamin, float datamax, int nbin, int pgflag);
59void cpgcumul(int npts, float *data, float datamin, float datamax, int pgflag);
60void plotLine(const float slope, const float intercept);
61void lineOfEquality();
62void lineOfBestFit(int size, float *x, float *y);
63void lineOfBestFitPB(const int size, const float *x, const float *y);
64void plotVertLine(const float xval, const int colour, const int style);
65void plotVertLine(const float xval);
66void plotVertLine(const float xval, const int colour);
67void plotHorizLine(const float yval, const int colour, const int style);
68void plotHorizLine(const float yval);
69void plotHorizLine(const float yval, const int colour);
70void drawContours(const int size, const float *x, const float *y);
71
72// POSITION-RELATED ROUTINES
73string getIAUNameEQ(double ra, double dec, float equinox);
74string getIAUNameGAL(double ra, double dec);
75string decToDMS(double dec, string type);
76double dmsToDec(string dms);
77double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
78
79// WCS-RELATED ROUTINES
80int wcsToPixSingle(wcsprm *wcs, const double *world, double *pix);
81int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world);
82int wcsToPixMulti(wcsprm *wcs, const double *world, double *pix, const int npts);
83int pixToWCSMulti(wcsprm *wcs, const double *pix, double *world, const int npts);
84double pixelToVelocity(wcsprm *wcs, double &x, double &y, double &z, string velUnits);
85double coordToVel(wcsprm *wcs, const double coord, string outputUnits);
86double velToCoord(wcsprm *wcs, const float velocity, string outputUnits);
87// double pixelToVelocity(FitsHeader &head, double &x, double &y, double &z);
88// int wcsToPixSingle(FitsHeader &head, const double *world, double *pix);
89// int pixToWCSSingle(FitsHeader &head, const double *pix, double *world);
90// int wcsToPixMulti(FitsHeader &head, const double *world, double *pix, const int npts);
91// int pixToWCSMulti(FitsHeader &head, const double *pix, double *world, const int npts);
92// double coordToVel(FitsHeader &head, const double coord, string outputUnits);
93// double velToCoord(FitsHeader &head, const float velocity, string outputUnits);
94
95// FILTER SMOOTHING ROUTINES
96void waveletSmooth(int dim,float *array, int arraySize, float sigma);
97void hanningSmooth(float *array, int arraySize, int hanningSize);
98void tophatSmooth(float *array, int arraySize, int width);
99
100#endif
Note: See TracBrowser for help on using the repository browser.