
	/* definitions for the "multipht" program */	


#define MAX_STAR  5000		/* max number stars total we can have */
#define MAX_IMAGE 500		/* max number of images we can have */
#define STRLEN    40		/* max length of star names and filters */
#define LINELEN   256
#define DEF_APER  -1		/* default aperture used for measurements */
                   			/*    note we use (aper-1) to access arrays */
                   			/*    so DEF_APER should start at 1, not 0 */
                   			/*    value of -1 means "use fwhm to pick aper" */
#define MAX_APER  10		/* max number of apertures a star may have */
#define LINELEN   256		/* max length of data lines */
#define NODATA    99.0		/* value assigned to a variable w/ no data */
#define PHT_POS   38		/* position in a .pht data line at which */
                    		/*    mag/err pairs begin */
#define PHT_LEN   15		/* length of a mag/err pair in chars */
#define AVG_TIME  0.10		/* fraction of an hour within which observations */
                      		/*    may be considered "simultaneous" */
#define MAXMATCH  20        /* Use the brightest MAXMATCH stars to determine */
                            /*    offset between images */

#define MJD(jd)  ((jd) - 2440000.0)

	/* parameters used to determine if stars match or not */
#define BIG       1.0e6			/* a number >> max number of rows, cols */
#define RADIUS      2.0			/* distance (in pixels) within which two */
                      			/*   stars count as 'matched' */
#define RAD2  (RADIUS*RADIUS)	/* square of the RADIUS distance */

	/* some flags which tell the program its function */
#define PRINT     1			
#define AUTO      2			/* don't ask for input from user */


	/* various flags for sorting */
#define BY_TIME   1			/* sort observations by time */
#define BY_NAME   2			/* sort by star primarily, by filter secondarily */
                   			/*    and by time tertially */

struct s_image {
	int index;				/* identifying index used in output routines */
	char name[STRLEN];
	char object[STRLEN];
	char filter[STRLEN];
	double exptime;
	double airmass;
	double ut;
	double mjd;
	int num_star;			/* number of stars in the image */
	struct s_star *stars;	/* array of stars in this image */
	int num_match;			/* # stars that match template image */
	int include;			/* if 1 include stars from this image; if 0 don't */
};

struct s_star {
	int image_id;				/* ID number on this star's image */
	int id;						/* ID number in set of all images' stars */
	struct s_image *image;
	double xc;
	double yc;
	double sky;
	double skysig;
	double peak;				/* peak value above sky, from .coo file */
	double fwhm;				/* fwhm of star, from .coo file */
	double sharp;				/* sharpness of star, from .coo file */
	double round;				/* roundness of star, from .coo file */
	int n_aper;					/* number of aperture mags measured */
	double mag[MAX_APER];
	double err[MAX_APER];
	int w3;						/* yes/no weight for this star, this image */
	double w4;					/* weight calculated from signal/noise */
	int saturated;				/* yes/no is this star saturated? */
};

	/* some structures used mostly for hashing stars, but also
	   for going through the total group of stars by ID number */

struct s_starp {
	struct s_star *star;
	struct s_starp *next;
};

struct s_hash {
	double xc, yc;
	int id;
	int num;					/* number of stars with this ID */
	struct s_starp *starp;		/* a linked list of stars with this ID */
	struct s_hash *next;		/* linked list of other stars with similar */
	                    		/*   hash values, but different positions */
	int include;				/* yes/no include star w/this ID in solution */
};

struct s_hashp {
	struct s_hash *hash;
	struct s_hashp *next;
};


	/* these are the heads of some important arrays/lists
	             image_arr: an array of all the images
	             star_list: a list of all the instances of the same star
	 */

struct s_image *image_arr;
struct s_hashp *star_list;

	/* some global variables */

int num_images;			/* total number of images */
int num_ids;			/* total number of unique stars */
int debug_flag;
int aper_rad[MAX_APER];		/* radii of apertures, in pixels */

	/* some global functions */
void print_star_hist( /* */ );
void print_image_hist( /* */ );
