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