/* include file for fits.c and fitsip.c */ #define FITS_HROWS 36 #define FITS_HCOLS 80 typedef char FITSRow[FITS_HCOLS]; typedef struct { /* following fields are cracked from the header for easy reference */ int bitpix; /* BITPIX -- MUST BE 16 FOR NOW */ int sw, sh; /* width/height, net pixels. NAXIS1 and NAXIS2 */ int sx, sy; /* starting X and Y, raw pixels. OFFSET1 and OFFSET2 */ int bx, by; /* binning. XFACTOR and YFACTOR */ int dur; /* exposure time, ms. EXPTIME is %.3f seconds */ FITSRow *var; /* malloced array of all unrecognized header lines */ int nvar; /* number of var[] */ char *image; /* malloced image data array of sw*sh*2 bytes */ } FImage; extern int writeFITS (int fd, FImage *fip, char *errmsg, int restore); extern int readFITS (int fd, FImage *fip, char *errmsg); extern int readFITSHeader (int fd, FImage *fip, char *errmsg); extern int writeSimpleFITS (int fd, char *pix, int w, int h, int x, int y, int restore); extern void timeStampFITS (FImage *fip, time_t t, char *comment); extern int getNAXIS (FImage *fip, int *n1p, int *n2p, char errmsg[]); extern void initFImage (FImage *fip); extern void resetFImage (FImage *fip); extern void setSimpleFITSHeader (FImage *fip); extern void setLogicalFITS (FImage *fip, char *name, int v, char *comment); extern void setIntFITS (FImage *fip, char *name, int v, char *comment); extern void setRealFITS (FImage *fip, char *name, double v, int sigdig, char *comment); extern void setCommentFITS (FImage *fip, char *name, char *comment); extern void setStringFITS(FImage *fip, char *name, char *string, char *comment); extern int getLogicalFITS (FImage *fip, char *name, int *vp); extern int getIntFITS (FImage *fip, char *name, int *vp); extern int getRealFITS (FImage *fip, char *name, double *vp); extern int getCommentFITS (FImage *fip, char *name, char *buf); extern int getStringFITS (FImage *fip, char *name, char *string); extern void addFImageVar (FImage *fip, FITSRow row); extern int delFImageVar (FImage *fip, char *name); extern int cpyFImageVar (FImage *dstfip, FImage *srcfip, char *name); typedef unsigned short CamPixel; /* type of pixel */ #define NCAMPIX (1<<(int)(8*sizeof(CamPixel))) /* number of unique CamPixels */ #define MAXCAMPIX (NCAMPIX-1) /* largest value in a CamPixel*/ typedef struct { CamPixel mean, median; /* mean and median pixel values */ CamPixel min, max; /* min and max pixel values */ int maxx, maxy; /* location of max pixel */ double sd; /* std deviation */ double sum, sum2; /* sum of pixels and sum of pixels squared */ int hist[NCAMPIX]; /* histogram */ } AOIStats; extern void flipImgCols (CamPixel *img, int w, int h); extern void flipImgRows (CamPixel *img, int w, int h); extern int align2FITS (FImage *fip1, char *image2, int *dxp, int *dyp); extern void alignAdd (FImage *fip1, char *image2, int dx, int dy); extern int cropFITS(FImage *fipin, FImage *fipout, int x, int y, int w, int h, char errmsg[]); extern void aoiStatsFITS (char *ip, int w, int x, int y, int nx, int ny, AOIStats *sp); extern int findStars (char *image, int w, int h, int **xa, int **ya, CamPixel **ba); /* how starStats uses its initial x/y */ typedef enum { SSHOW_BRIGHTWALK=1, SSHOW_MAXINAREA, SSHOW_HERE } SSHow; /* info to define parameters used when we look for a star */ typedef struct { int rsrch; /* max radius to search for brightest pixel */ int rAp; /* aperture radius. if 0, determine automatically */ SSHow how; /* how to establish brightest pixel */ } StarDfn; /* info to describe what we've learned about a "star" from starStats() */ typedef struct { int p; /* value of brightest pixel */ int bx, by; /* location of brightest pixel */ int Src; /* total counts due just to star in aperature */ double rmsSrc; /* rms error of Src */ int rAp; /* aperature radius */ int Sky; /* median value of noise annulus */ double rmsSky; /* rms of Sky */ /* following are based on the best gaussion fits in each dimension *after* * Sky has been subtracted off from all pixel values. Then, the x/ymax * have had Sky added back on so they can serve as pixel values. */ double x, y; /* location of centroid: 0 if centered on bx/by */ double xfwhm, yfwhm;/* full width at half max. FYI: sigma = fwhm/2.354 */ double xmax, ymax; /* gaussian peak (with Sky added back on) */ } StarStats; extern int starStats (CamPixel *image, int w, int h, StarDfn *sdp, int ix, int iy, StarStats *ssp, char errmsg[]); extern int starMag (StarStats *ref, StarStats *targt, double *mp, double *dmp); extern int fwhmFITS (char *im, int w, int h, double *hp, double *hsp, double *vp, double *vsp, char *msg); extern int setFWHMFITS (FImage *fip, char whynot[]);