#if !defined(COLLATE_H)
#define COLLATE_H

   /* 
    * this value denotes a "bad" magnitude measurement -- do not
    * include it in any computations.
    */
#define BAD_MAG        99.0

   /* 
    * there can be at most this many passbands defined in each file.
    * If more than 4, then the scheme of OR'ing all the quality_flag
    * bits from all the matched detections will overrun the 32-bit
    * integer used to hold the quality flag.  
    */
#define MAX_PASSBANDS  4

   /* filter names have at most this many characters */
#define FILTER_LENGTH  2

   /* we allow this many input files with detected star lists */
#define MAX_DETECTED_FILES    300

   /* each file name may be this long */
#define MAX_FILENAME_LEN      255

   /* default radius for two stars to match is 10 arcseconds */
#define MATCH_RADIUS    3.0


   /* multiply by this to convert degrees to radians */
#ifndef PI
#define PI 3.14159265359
#endif
#define DEGTORAD  (PI/180.0)


   /*
    * this structure contains information on detections in each
    * passband individually (i.e. before merging)
    */
typedef struct s_premerge {
   int id;              /* used for internal debugging only */
   double ra;           /* Right Ascension of star, J2000 */
   double dec;          /* Declination of star, J2000 */
   double jd;           /* Julian Date of midpoint of observation */
   double airmass;      /* Airmass of star during observation */
   char filter[FILTER_LENGTH+1];
   double mag;
   double magerr;

   /* stellar shape parameters */
   double fwhm;
   double sharp;
   double round;

   /* 
    * this flag is 0 if all is ok, contains OR'd bits to indicate
    * various possible sources of error (close to edge of image, etc.)
    */
   unsigned int quality_flag;
} S_PRE;


   /* 
    * this structure contains information on MERGED stars 
    */
typedef struct s_merged {
   int id;              /* used for internal debugging only */
   double ra;           /* Right Ascension of star, J2000 */
   double dec;          /* Declination of star, J2000 */
   double jd;           /* Julian Date of measurement */
   double airmass;      /* airmass at time of measurement */

   char filter[MAX_PASSBANDS][FILTER_LENGTH+1];   /* name of filter */

   /* instrumental magnitude of star in each passband */
   double mag[MAX_PASSBANDS];          

   /* estimated uncertainty in instrumental magnitude in each passband */
   double magerr[MAX_PASSBANDS];       

   /* the merged quality flag is the logical OR of the individual flags */
   unsigned int quality_flag;

} S_MERGED;


   /*
    * create/delete detected star (S_DET) structures
    */

void
spreFill(S_PRE *star, int id, char *filter, 
         double fwhm, double round, double sharp);



#endif   /* COLLATE_H */
