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

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

A couple of additions and some minor changes:

  • New function to draw lines separating the BLANK and non-BLANK

pixels on a 2-D image -- in Utils/drawBlankEdges.cc. Also have a
front-end to it in the Cube:: class (in Cubes/cubes.cc)

  • Consolidated all the pgplot-related .c code in Utils into one file:

Utils/pgplot_related.c. Added new function, cpgtest(), to check if
there is a PGPlot device currently open.

  • Utilised this function in the plotting.cc functions.
  • Changed the calls to Detection::getIntegFlux and Detection::calcWCSparams

so that the FitsHeader? object is passed as a reference.

  • Other minor typos.
File size: 4.9 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
57extern "C" int  cpgtest();
58extern "C" void cpgwedglog(const char* side, float disp, float width, float fg, float bg, const char *label);
59extern "C" void cpghistlog(int npts, float *data, float datamin, float datamax, int nbin, int pgflag);
60extern "C" void cpgcumul(int npts, float *data, float datamin, float datamax, int pgflag);
61void plotLine(const float slope, const float intercept);
62void lineOfEquality();
63void lineOfBestFit(int size, float *x, float *y);
64void lineOfBestFitPB(const int size, const float *x, const float *y);
65void plotVertLine(const float xval, const int colour, const int style);
66void plotVertLine(const float xval);
67void plotVertLine(const float xval, const int colour);
68void plotHorizLine(const float yval, const int colour, const int style);
69void plotHorizLine(const float yval);
70void plotHorizLine(const float yval, const int colour);
71void drawContours(const int size, const float *x, const float *y);
72void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par);
73
74// POSITION-RELATED ROUTINES
75string getIAUNameEQ(double ra, double dec, float equinox);
76string getIAUNameGAL(double ra, double dec);
77string decToDMS(double dec, string type);
78double dmsToDec(string dms);
79double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
80
81// WCS-RELATED ROUTINES
82int wcsToPixSingle(wcsprm *wcs, const double *world, double *pix);
83int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world);
84int wcsToPixMulti(wcsprm *wcs, const double *world, double *pix, const int npts);
85int pixToWCSMulti(wcsprm *wcs, const double *pix, double *world, const int npts);
86double pixelToVelocity(wcsprm *wcs, double &x, double &y, double &z, string velUnits);
87double coordToVel(wcsprm *wcs, const double coord, string outputUnits);
88double velToCoord(wcsprm *wcs, const float velocity, string outputUnits);
89// double pixelToVelocity(FitsHeader &head, double &x, double &y, double &z);
90// int wcsToPixSingle(FitsHeader &head, const double *world, double *pix);
91// int pixToWCSSingle(FitsHeader &head, const double *pix, double *world);
92// int wcsToPixMulti(FitsHeader &head, const double *world, double *pix, const int npts);
93// int pixToWCSMulti(FitsHeader &head, const double *pix, double *world, const int npts);
94// double coordToVel(FitsHeader &head, const double coord, string outputUnits);
95// double velToCoord(FitsHeader &head, const float velocity, string outputUnits);
96
97// FILTER SMOOTHING ROUTINES
98void waveletSmooth(int dim,float *array, int arraySize, float sigma);
99void hanningSmooth(float *array, int arraySize, int hanningSize);
100void tophatSmooth(float *array, int arraySize, int width);
101
102#endif
Note: See TracBrowser for help on using the repository browser.