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

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

Major update to this branch, with all the edits to date.
Have added a new class FitsHeader?, to incorporate the wcsprm structs,
plus other header information such as units, beam size and so on...
Not quite working, but nearly there.

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 getIAUName(double ra, double dec, FitsHeader head);
74string getIAUNameEQ(double ra, double dec, float equinox);
75string getIAUNameGAL(double ra, double dec);
76string decToDMS(double dec, string type);
77double dmsToDec(string dms);
78double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
79
80// WCS-RELATED ROUTINES
81// double pixelToVelocity(wcsprm *wcs, double &x, double &y, double &z);
82// int wcsToPixSingle(wcsprm *wcs, const double *world, double *pix);
83// int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world);
84// int wcsToPixMulti(wcsprm *wcs, const double *world, double *pix, const int npts);
85// int pixToWCSMulti(wcsprm *wcs, const double *pix, double *world, const int npts);
86// float setVel_kms(wcsprm *wcs, const double coord);
87// double velToCoord(wcsprm *wcs, const float velocity);
88double pixelToVelocity(FitsHeader head, double &x, double &y, double &z);
89int wcsToPixSingle(FitsHeader head, const double *world, double *pix);
90int pixToWCSSingle(FitsHeader head, const double *pix, double *world);
91int wcsToPixMulti(FitsHeader head, const double *world, double *pix, const int npts);
92int pixToWCSMulti(FitsHeader head, const double *pix, double *world, const int npts);
93double coordToVel(FitsHeader head, const double coord);
94double velToCoord(FitsHeader head, const float velocity);
95
96// FILTER SMOOTHING ROUTINES
97void waveletSmooth(int dim,float *array, int arraySize, float sigma);
98void hanningSmooth(float *array, int arraySize, int hanningSize);
99void tophatSmooth(float *array, int arraySize, int width);
100
101#endif
Note: See TracBrowser for help on using the repository browser.