/* CATPARAMS - Set or modify catalog header */ #include "focas1.h" #define CATTYPE 4 catparams (catalog, image, arfl, satr, magfst, rfca, thrln0, thrln1, skyhw, minarea, sig, filter, transform, psffile, classrules) char *catalog, *image, *arfl, *filter, *transform, *psffile, *classrules; float *satr, *magfst, *rfca, *thrln0, *thrln1, *skyhw, *sig; int *minarea; { FILE *fd; int i, j, nx, ny; char str[80]; long oldsz, szcathdr (); struct objrec ob; /* Initialize a new catalog. */ if (access (catalog, 0)) { cattype = CATTYPE; setcathdr (); cfd = catopen (catalog, 1); fclose (cfd); } /* Open the catalog for modification. */ cfd = catopen (catalog, 2); oldsz = szcathdr (); /* If an image is specified open the image and set other parameters. */ if (strlen(image) && strcmp(image, sp.ptfl)) { strncpy (sp.ptfl, image, SZ_FNAME); imopen (sp.ptfl, &pthdr, 0); strncpy (sp.pltnm, pthdr.object, 32); strncpy (sp.pltepoch, pthdr.date, 32); strncpy (sp.observer, pthdr.observer, 24); strncpy (sp.origin, pthdr.origin, 24); sp.xs = pthdr.crpix1; sp.ys = pthdr.crpix2; sp.kpts = pthdr.naxis1; sp.kscan = pthdr.naxis2; if (!strlen(sp.arfl)) sprintf (sp.arfl, "%s.ar", sp.ptfl); } /* Set general parameters. */ sp.satr = *satr; if (sp.magfst != *magfst) { fseek (cfd, oldsz, 0); chmag (*magfst); sp.magfst = *magfst; } sp.rfca = *rfca; sp.thrln0 = *thrln0; sp.thrln1 = *thrln1; sp.skyhw = *skyhw; sp.minarea = *minarea; sp.sig = *sig; if (strlen(arfl)) strncpy (sp.arfl, arfl, 11); /* Set detection filter. */ if (strcmp (filter, "default") == 0) { sp.pflags &= ~FLTR; sp.fx = 1; sp.fy = 1; dfltr[0][0] = 1.; } else if (strcmp (filter, "builtin") == 0) { sp.pflags |= FLTR; sp.fx = sp.fy = 5; dfltr[0][0] = 0.; dfltr[0][1] = 1.; dfltr[0][2] = 2.; dfltr[0][3] = 1.; dfltr[0][4] = 0.; dfltr[1][0] = 1.; dfltr[1][1] = 2.; dfltr[1][2] = 3.; dfltr[1][3] = 2.; dfltr[1][4] = 1.; dfltr[2][0] = 2.; dfltr[2][1] = 3.; dfltr[2][2] = 4.; dfltr[2][3] = 3.; dfltr[2][4] = 2.; dfltr[3][0] = 1.; dfltr[3][1] = 2.; dfltr[3][2] = 3.; dfltr[3][3] = 2.; dfltr[3][4] = 1.; dfltr[4][0] = 0.; dfltr[4][1] = 1.; dfltr[4][2] = 2.; dfltr[4][3] = 1.; dfltr[4][4] = 0.; } else if (strlen(filter)) { sp.pflags &= ~FLTR; if ((fd = fopen (filter, "r")) == NULL) printf (" Can't read file %s\n", filter); else { fscanf (fd, "%d%d", &nx, &ny); if ((nx < 1) || (nx > NXFLT) || (ny < 1) || (ny > NYFLT)) fprintf (stderr, " Error in detection filter dimensions %d %d\n", nx, ny); else { for (i = 0; i < ny; i++) for (j = 0; j < nx; j++) fscanf (fd, "%hf", &dfltr[i][j]); fclose (fd); sp.fx = nx; sp.fy = ny; } } } /* Set coordinate transformation. */ if (strcmp(transform, "default") == 0) { for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) sp.xfrm[i][j] = 0.; sp.xfrm[0][0] = sp.xfrm[1][1] = sp.xfrm[2][2] = 1.; fseek (cfd, oldsz, 0); setflat (0, 0., 0., 0., 0.); chcoords (); } else if (strlen(transform)) { if ((fd = fopen (transform, "r")) == NULL) printf (" Can't read file %s\n", transform); else { for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) fscanf (fd, "%lf", &sp.xfrm[i][j]); fclose (fd); fseek (cfd, oldsz, 0); setflat (0, 0., 0., 0., 0.); chcoords (); } } /* Set PSF. */ if (strlen(psffile)) { if ((fd = fopen (psffile, "r")) == NULL) printf (" Can't read file %s\n", psffile); else { fscanf (fd, "%d%d", &nx, &ny); if ((nx < 1) || (nx > NXMAX) || (ny < 1) || (ny > NYMAX)) fprintf (stderr, " Error in template dimensions %d %d\n", nx, ny); for (i = 0; i < ny; i++) for (j = 0; j < nx; j++) fscanf (fd, "%hf", &template[i][j]); fclose (fd); sp.nx = nx; sp.ny = ny; } } /* Set classification rules. */ if (strcmp (classrules, "default") == 0) { crules[0].mag1 = -100.; crules[0].mag2 = 100.; crules[0].scl1 =.1; crules[0].scl2 = 0.6; crules[0].frc1 = 0.; crules[0].frc2 = 1.; strcpy (crules[0].class, "n"); crules[1].mag1 = -100.; crules[1].mag2 = 100.; crules[1].scl1 =.61; crules[1].scl2 = 1.2; crules[1].frc1 = 0.; crules[1].frc2 = 1.; strcpy (crules[1].class, "s"); crules[2].mag1 = -100.; crules[2].mag2 = 100.; crules[2].scl1 = 1.21; crules[2].scl2 = 10.0; crules[2].frc1 = 0.; crules[2].frc2 = 0.24; strcpy (crules[2].class, "sf"); crules[3].mag1 = -100.; crules[3].mag2 = 100.; crules[3].scl1 = 1.21; crules[3].scl2 = 10.0; crules[3].frc1 = 0.25; crules[3].frc2 = 1.; strcpy (crules[3].class, "g"); crules[4].mag1 = -100.; crules[4].mag2 = 100.; crules[4].scl1 = 10.01; crules[4].scl2 = 100.; crules[4].frc1 = 0.; crules[4].frc2 = 1.; strcpy (crules[4].class, "d"); fseek (cfd, oldsz, 0); chclass (); } else if (strlen(classrules)) { if ((fd = fopen (classrules, "r")) == NULL) printf (" Can't read file %s\n", crules); else { for (sp.nrules = 0; sp.nrules < NRULES; sp.nrules++) { fscanf (fd, "%hf", &crules[sp.nrules].mag1); fscanf (fd, "%hf", &crules[sp.nrules].mag2); fscanf (fd, "%hf", &crules[sp.nrules].scl1); fscanf (fd, "%hf", &crules[sp.nrules].scl2); fscanf (fd, "%hf", &crules[sp.nrules].frc1); fscanf (fd, "%hf", &crules[sp.nrules].frc2); fscanf (fd, "%5s", crules[sp.nrules].class); if (feof (fd)) break; } fclose (fd); fseek (cfd, oldsz, 0); chclass (); } } wtcathdr (cfd, 0); fclose (cfd); }