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

Last change on this file since 188 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
RevLine 
[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
9const float C_kms = 299792.458;
10
[146]11// Divide by the following correction factor to convert from
12//   MADFM to sigma estimator.
[3]13const float correctionFactor = 0.6744888;
[146]14// Multiply by the following correction factor to convert from
15//   trimmedSigma to sigma estimator.
[70]16const double trimToNormal = 1.17036753077;
[3]17
[56]18// MENU ROUTINES FOR DIGANOSTIC/TEST PROGRAMS
[146]19std::string menu();
20std::string specMenu();
21std::string orionMenu();
22std::string imageMenu();
23std::string twoblMenu();
[3]24
[146]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);
[3]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);
[56]33
34// STATISTICS-RELATED ROUTINES
[70]35void findMinMax(const float *array, const int size, float &min, float &max);
[53]36float findMean(float *&array, int size);
[78]37float findStddev(float *&array, int size);
[53]38float findMedian(float *&array, int size);
39float findMADFM(float *&array, int size);
[3]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);
[146]43void findTrimmedHistStats(float *array, const int size,
44                          float &tmean, float &tsigma);
[3]45void getRandomSpectrum(int length, float *x, float *y);
46void getRandomSpectrum(int length, float *x, double *y);
[146]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);
[3]51float getNormalRV();
[70]52float getNormalRVtrunc();
[3]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
[56]61
62// PLOTTING ROUTINES
[129]63extern "C" int  cpgtest();
[146]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);
[56]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);
[129]81void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par);
[3]82
[56]83// POSITION-RELATED ROUTINES
[3]84string getIAUNameEQ(double ra, double dec, float equinox);
85string getIAUNameGAL(double ra, double dec);
[38]86string decToDMS(double dec, string type);
[3]87double dmsToDec(string dms);
88double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
89
[56]90// WCS-RELATED ROUTINES
[3]91int wcsToPixSingle(wcsprm *wcs, const double *world, double *pix);
92int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world);
[146]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);
[103]99double coordToVel(wcsprm *wcs, const double coord, string outputUnits);
100double velToCoord(wcsprm *wcs, const float velocity, string outputUnits);
[3]101
[56]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);
[3]106
107#endif
Note: See TracBrowser for help on using the repository browser.