source: tags/release-1.0.5/src/Utils/utils.hh @ 1455

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

A few new things:

  • Made a mycpgplot.hh file, to keep PGPlot-related constants (enum types)

in a standard namespace (so one can do cpgsci(RED) rather than cpgsci(2)...).
Incorporated this into all code that uses pgplot.

  • Improved the outputting of the number of detected objects in the search

functions. Now shows how many have been detected, before they are merged
into the list.

  • Fixed a bug in columns.cc that was incorrectly updating the precision for

negative velocities.

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