# include <ohana.h>

# define DEFAULT_RADIUS  8.0    /* rough search radius, pixels */
# define DEFAULT_NPIX   100
# define CCD_NX 2048  /* CCD width -- not used, determined from header */
# define CCD_NY 4096  /* CCD height -- not used, determined from header  */
# define CCD_PC1_1 1  /* CCD orientation */
# define CCD_PC2_2 -1
# define CCD_PC1_2 0
# define CCD_PC2_1 0
# define CCD_DELT_X 1
# define CCD_DELT_Y -1 
# define NFIELD 1.5   /* search region */
# define MMIN 9.0     /* very saturated */

typedef struct {
  double X;
  double Y;
  double mag;
} Stars;

typedef struct {
  char      ctype[16];
  double    crval1, crpix1, cdelt1;
  double    crval2, crpix2, cdelt2;
  double    pc1_1, pc1_2;
  double    pc2_1, pc2_2;
} Coords;

static char GSCFILE[] = "./GSCregions.tbl";
static char GSC_DIR[] = "./gsc";

void   args                PROTO((int *, char **));
void   rargs               PROTO((int *, char **));
void   alter_header        PROTO((char *, char **, int, double, double, double, double, double, double, double, double, int));
void   ralter_header       PROTO((char *, char *, double, double, double, double, double, double, double, double, int));
void   delta               PROTO((Stars *, Stars *, int, int, double *, double *, double *, double *));
void   find_shift          PROTO((Stars *, Stars *, int, int, double, double, int *, double *, double *, double *));
Stars *get_stars           PROTO((char *, int *));
int    line_fit            PROTO((Stars *, Stars *, int, int, double, double, double, double, 
			          double *, double *, double *, double *, double *, double *, double *, double *));
void   ranges              PROTO((Stars *, Stars *, int, int, double *, double *, double *, double *, double, double));
void   stats               PROTO((char *, double *, double *, double *, double *, double));
double dms_to_deg          PROTO((char *, int));
void   extract_catalog     PROTO((char *, double **, double **, double **, int *));
Stars *get_catalog_stars   PROTO((double *, double *, double *, int, double, double, double, double, int *));
void   precess             PROTO((double *, double *, double, double));

extern double hypot PROTO((double, double));
/*  this seems to be a problem: is not included from math.h with the -ansi flag */

double RADIUS;
double ASEC_PIX;
int    FLIP;
int    ROTATE;
int    N2NUMBER;
int    NPIX;
int    FORCE;
int    DUMP;
double F_RA;
double F_DEC;
double NIM;

