IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 70


Ignore:
Timestamp:
May 8, 2003, 3:19:39 AM (23 years ago)
Author:
eugene
Message:

megacam updates

Location:
trunk/Ohana/src
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/imregister/base/ConfigCamera.c

    r3 r70  
    1616  ScanConfig (config, "NCCD", "%d", 1, &Nccd);
    1717  ALLOCATE (ccds, char *, Nccd);
     18  ALLOCATE (ccdn, char *, Nccd);
    1819
    1920  for (i = 0; i < Nccd; i++) {
     
    2324    ccds[i] = strcreate (ID);
    2425  }
     26
     27  for (i = 0; i < Nccd; i++) {
     28    sprintf (ID, "%02d", i);
     29    ccdn[i] = strcreate (ID);
     30  }
    2531}
    2632
    27 int MatchCCDName (Header *header) {
     33int MatchCCDNameHeader (Header *header) {
    2834
    2935  int i;
     
    4955}
    5056
     57int MatchCCDName (char *ID) {
     58
     59  int i;
     60
     61  /* compare as number if ID is a complete number (ie, 00 equiv to 0, but 00b not equiv to 0b */
     62  for (i = 0; i < Nccd; i++) {
     63    if (strnumcmp (ccds[i], ID)) {
     64      return (i);
     65    }
     66  }
     67 
     68  fprintf (stderr, "warning: ccd %s not found in camera config file\n", ID);
     69  return (-1);
     70}
     71
  • trunk/Ohana/src/imregister/base/ConfigInit.c

    r29 r70  
    5555  WarnConfig (config, "CAMERA-KEYWORD",              "%s", 0, CameraKeyword);
    5656
     57  ScanConfig (config, "CAMERA",                      "%s", 0, Camera);
     58  ScanConfig (config, "SEEING_REF_CCD",              "%s", 0, SeeingREFCCD);
     59
    5760  /* optional values */
    5861  ScanConfig (config, "RA-DDD-KEYWORD",              "%s", 0, RADecDegKeyword);
  • trunk/Ohana/src/imregister/base/sort.c

    r3 r70  
    6767  }
    6868}
     69
     70void sortstr (char **S, int *X, int N) {
     71
     72  int l,j,ir,i;
     73  char *tmpS;
     74  int tmpX;
     75 
     76  if (N < 2) return;
     77  l = N >> 1;
     78  ir = N - 1;
     79  for (;;) {
     80    if (l > 0) {
     81      l--;
     82      tmpS = S[l];
     83      tmpX = X[l];
     84    } else {
     85      tmpS = S[ir];
     86      S[ir] = S[0];
     87      tmpX = X[ir];
     88      X[ir] = X[0];
     89      if (--ir == 0) {
     90        S[0] = tmpS;
     91        X[0] = tmpX;
     92        return;
     93      }
     94    }
     95    i = l;
     96    j = (l << 1) + 1;
     97    while (j <= ir) {
     98      if (j < ir && (strcmp(S[j], S[j+1]) < 0)) j++;
     99      if (strcmp(tmpS, S[j]) < 0) {
     100        S[i] = S[j];
     101        X[i] = X[j];
     102        j += (i=j) + 1;
     103      }
     104      else j = ir + 1;
     105    }
     106    S[i] = tmpS;
     107    X[i] = tmpX;
     108  }
     109}
     110
     111void sortpair (int *X, int *Y, int N) {
     112
     113  int l,j,ir,i;
     114  int tX, tY;
     115 
     116  if (N < 2) return;
     117  l = N >> 1;
     118  ir = N - 1;
     119  for (;;) {
     120    if (l > 0) {
     121      l--;
     122      tX = X[l];
     123      tY = Y[l];
     124    } else {
     125      tX = X[ir];
     126      X[ir] = X[0];
     127      tY = Y[ir];
     128      Y[ir] = Y[0];
     129      if (--ir == 0) {
     130        X[0] = tX;
     131        Y[0] = tY;
     132        return;
     133      }
     134    }
     135    i = l;
     136    j = (l << 1) + 1;
     137    while (j <= ir) {
     138      if (j < ir && X[j] < X[j+1]) j++;
     139      if (tX < X[j]) {
     140        X[i] = X[j];
     141        Y[i] = Y[j];
     142        j += (i=j) + 1;
     143      }
     144      else j = ir + 1;
     145    }
     146    X[i] = tX;
     147    Y[i] = tY;
     148  }
     149}
     150
  • trunk/Ohana/src/imregister/detrend/args.detsearch.c

    r62 r70  
    301301    }
    302302  }
     303  /*
    303304  if ((base.Type != T_DARK) && base.ExptimeSelect) {
    304305    fprintf (stderr, "ERROR: exptime invalid with type %s\n", typename[base.Type]);
    305306    exit (1);
    306307  }
     308  */
    307309  if (output.Select && !base.TimeSelect) {
    308310    fprintf (stderr, "ERROR: selection missing time\n");
  • trunk/Ohana/src/imregister/detrend/output.c

    r21 r70  
    180180int PrintSubset (DetReg *detdata, Match *match, int Nmatch) {
    181181 
    182   char *dBPath, *typestr, *filtstr;
     182  char *dBPath, *typestr, *filtstr, filename[128];
    183183  char *timestr, *modestr, *ccdstr, ccdinfo[16], ccdformat[16];
    184184  int i, j, Nc;
     
    218218
    219219    /* output mode (Select vs List) */
     220    if (output.Chipname && criteria[0].CCDSelect && detdata[i].mode == M_MEF) {
     221      snprintf (filename, 128, "%s[%s]", detdata[i].filename, ccds[criteria[0].CCD]);
     222    } else {
     223      strcpy (filename, detdata[i].filename);
     224    }
     225
    220226    if (output.Select) {
    221       fprintf (stdout, "%s/%s\n", dBPath, detdata[i].filename);
     227      fprintf (stdout, "%s/%s\n", dBPath, filename);
    222228    } else {
    223229      fprintf (stdout, "%-40s = %19s %7s %6s %6s %s %2d %2d %6.1f  %20s\n",
    224                detdata[i].filename, timestr, modestr, typestr, filtstr, ccdstr,
     230               filename, timestr, modestr, typestr, filtstr, ccdstr,
    225231               detdata[i].Nentry, detdata[i].Norder, detdata[i].exptime, detdata[i].label);
    226232    }
  • trunk/Ohana/src/imregister/detrend/recipe.c

    r3 r70  
    3939      }
    4040      if (!strcasecmp (RecipeType[i], "flat") ||
     41          !strcasecmp (RecipeType[i], "scatter") ||
    4142          !strcasecmp (RecipeType[i], "fringe") ||
     43          !strcasecmp (RecipeType[i], "frpts") ||
    4244          !strcasecmp (RecipeType[i], "modes")) {
    4345        crit[Ns].FilterSelect = TRUE;
     
    4648        crit[Ns].CCDSelect = FALSE;
    4749      }
     50      /*     
    4851      if (!strcasecmp (RecipeType[i], "dark")) {
    49         crit[Ns].ExptimeSelect = TRUE;
    50       }
     52      crit[Ns].ExptimeSelect = TRUE;
     53      }
     54      */
    5155      Ns ++;
    5256    }
  • trunk/Ohana/src/imregister/imreg/args.imregister.c

    r3 r70  
    22# include "imreg.h"
    33
    4 /* args is now greatly simplified from the rsh-fork version */
    54int args (int argc, char **argv) {
    65
     
    2524  /* all imregister programs are implicitly modifying the db */
    2625  output.modify = TRUE;
     26  IMSORT = FALSE;
    2727
    2828  if (strstr (argv[0], "imregister") != (char *) NULL) {
     
    4545      exit (1);
    4646    }
     47    IMSORT = TRUE;
    4748    return (TRUE);
    4849  }
    4950  if (strstr (argv[0], "imstatreg") != (char *) NULL) {
     51
     52    char *path, *file;
     53
     54    CLIENT = TRUE;
     55
     56    /* set up name to lockfile */
     57    path = pathname (ImageDB);
     58    file = filebasename (ImageDB);
     59    ALLOCATE (PIDFILE, char, strlen (path) + strlen (file) + 10);
     60    sprintf (PIDFILE, "%s/.%s.pid", path, file);
     61
     62    /* check for daemon mode */
     63    if (N = get_argument (argc, argv, "-daemon")) {
     64      remove_argument (N, &argc, argv);
     65      CLIENT = FALSE;
     66
     67      /* special daemon options */
     68      if (get_argument (argc, argv, "-kill"))   KillProcess (PIDFILE);
     69      if (get_argument (argc, argv, "-status")) StatusProcess (PIDFILE);
     70
     71      if (argc != 1) {
     72        fprintf (stderr, "ERROR: Usage: imstatreg\n");
     73        exit (1);
     74      }
     75      return (TRUE);
     76    }
     77
    5078    if (argc != 4) {
    5179      fprintf (stderr, "ERROR: Usage: imstatreg (fits) (stats) (sdat) [-split] [-noreg]\n");
     80      fprintf (stderr, "       or:    imstatreg -daemon\n");
    5281      exit (1);
    5382    }
  • trunk/Ohana/src/imregister/imreg/args.imsearch.c

    r64 r70  
    7979    }
    8080    if (criteria.CCD == -1) {
    81       fprintf (stderr, "ERROR: ccd %s choice out not found in camera config\n", argv[N]);
    82       exit (1);
    83     }
    84 
     81      fprintf (stderr, "ERROR: ccd %s choice not found in camera config\n", argv[N]);
     82      exit (1);
     83    }
     84
     85    remove_argument (N, &argc, argv);
     86    criteria.CCDSelect = TRUE;
     87  }
     88  /* select CCD seq number */
     89  if (N = get_argument (argc, argv, "-ccdn")) {
     90    remove_argument (N, &argc, argv);
     91    criteria.CCD = atoi (argv[N]);
    8592    remove_argument (N, &argc, argv);
    8693    criteria.CCDSelect = TRUE;
     
    172179
    173180  /*** command-line options which modify behavior (delete, modify, newpath, mef2split split2mef */
    174   output.delete = output.modify = FALSE;
    175   output.modify_path = output.modify_dist = FALSE;
    176   output.mef2split = output.split2mef = FALSE;
     181  output.delete = FALSE;
     182  output.modify = FALSE;
     183  output.modify_path = FALSE;
     184  output.modify_dist = FALSE;
     185  output.mef2split = FALSE;
     186  output.split2mef = FALSE;
     187  output.unique = FALSE;
    177188
    178189  if (N = get_argument (argc, argv, "-delete")) {
    179190    remove_argument (N, &argc, argv);
    180191    output.delete = TRUE;
     192  }
     193
     194  if (N = get_argument (argc, argv, "-unique")) {
     195    remove_argument (N, &argc, argv);
     196    output.unique = TRUE;
    181197  }
    182198
  • trunk/Ohana/src/imregister/imreg/db.c

    r4 r70  
    33
    44/* variables which describe the db */
    5 char *dBFile;
     5char *dBFile = (char *) NULL;
    66FILE *f;
    77Header header;
     
    1414int dbstate = LCK_UNLOCK;
    1515
     16int set_db (char *filename) {
     17
     18  /* be careful: don't change db without closing old db */
     19  dBFile = filename;
     20  return (TRUE);
     21}
     22
    1623RegImage *get_images (int *N) {
    1724  *N = Nimage;
     
    2330  int Nbytes;
    2431
     32  /* assign pointers to new data block */
    2533  free (image);
     34  Nimage = Nnew;
     35  image = new;
    2636
     37  /* update header, table structures */
    2738  fits_modify (table.header, "NAXIS2", "%d", 1, Nnew);
    2839  table.header[0].Naxis[1] = Nnew;
    2940  Nbytes = fits_matrix_size (table.header);
    3041
    31   Nimage = Nnew;
    32   image = new;
    33   REALLOCATE (image, RegImage, Nbytes);
     42  /* add padding space to buffer */
     43  REALLOCATE ((char *) image, char, Nbytes);
    3444  table.buffer = (char *) image;
     45  table.size = Nbytes;
     46
    3547  return (TRUE);
    3648}
     
    4153
    4254  lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT;
    43   dBFile = ImageDB; /* loaded in ConfigInit */
     55
     56  if (dBFile == (char *) NULL) {
     57    fprintf (stderr, "ERROR: db file is not set\n");
     58    exit (1);
     59  }
    4460
    4561  /* lock database (soft) */
     
    166182
    167183
     184int close_lock_db () {
     185  close (f);
     186  return (TRUE);
     187
     188
    168189int escape (int mode, char *message) {
    169190 
  • trunk/Ohana/src/imregister/imreg/delete.c

    r3 r70  
    1010  image = get_images (&Nimage);
    1111
    12   ALLOCATE (keep, int, Nimage);
     12  ALLOCATE (keep, int, MAX (Nimage, 1));
    1313  for (i = 0; i < Nimage; i++) keep[i] = TRUE;
     14  fprintf (stderr, "total of %d images\n", Nimage);
    1415
    1516  Nbad = 0;
     
    2021    Nbad ++;
    2122  }
     23  fprintf (stderr, "delete %d images\n", Nbad);
    2224
    2325  Nsubset = Nimage - Nbad;
    24   ALLOCATE (subset, RegImage, Nsubset);
     26  ALLOCATE (subset, RegImage, MAX (1, Nsubset));
     27  fprintf (stderr, "keeping %d images\n", Nsubset);
    2528  for (j = i = 0; i < Nimage; i++) {
    2629    if (!keep[i]) continue;
  • trunk/Ohana/src/imregister/imreg/iminfo.c

    r19 r70  
    5757  if (SingleIsSplit && (image[0].mode == MODE_SINGLE)) {
    5858    image[0].mode = MODE_SPLIT;
    59     image[0].ccd  = MatchCCDName (&header);
     59    image[0].ccd  = MatchCCDNameHeader (&header);
    6060  }
    6161  /* is there a better way to id a 'split' image? */
  • trunk/Ohana/src/imregister/imreg/modify.c

    r26 r70  
    6868    }
    6969
     70    if (output.modify_filter) {
     71      strncpy (image[i].filter, output.filter, 31);
     72    }
     73
     74    if (output.modify_type) {
     75      image[i].type = output.type;
     76    }
     77
    7078  }
    7179
  • trunk/Ohana/src/imregister/imreg/output.c

    r29 r70  
    173173}
    174174
    175 void DumpCADCTable (char *filename, RegImage *image, int *match, int Nmatch) {
    176  
    177   int i, obsid;
    178   char *datestr, *line, hdrname[99];
    179   unsigned long tsecond;
    180   Header header, theader;
    181   Matrix matrix;
    182   FTable table;
    183   RegImage *subset;
    184 
    185   /* create primary header */
    186   fits_init_header (&header);   
    187   header.extend = TRUE;
    188   fits_create_header (&header);
    189   fits_create_matrix (&header, &matrix);
    190   fits_print (&header, "NEXTEND", "%d", 1, 1);
    191  
    192   /* create table header */
    193   fits_create_table_header (&theader, "TABLE", "CADC_RAW_IMAGES");
    194      
    195   /* add current date/time to header */
    196   str_to_time ("now", &tsecond);
    197   datestr = sec_to_date (tsecond);
    198   fits_modify (&header,  "DATE", "%s", 1, datestr);
    199   fits_modify (&theader, "DATE", "%s", 1, datestr);
    200 
    201   /* define table layout */
    202   fits_define_table_column (&theader, "A99",   "FILENAME",     "filename in db",        "",                              1.0, 0.0);
    203   fits_define_table_column (&theader, "A99",   "HDR_FILENAME", "filename in db",        "",                              1.0, 0.0);
    204   fits_define_table_column (&theader, "I10",   "OBSID",        "image ID number",        "pixels",                         1.0, 0.0);
    205   fits_define_table_column (&theader, "F5.2",  "OBS_IQ",       "image quality",        "pixels",                         1.0, 0.0);
    206   fits_define_table_column (&theader, "F9.3",  "OBS_BG_VAL",   "background level",     "counts / pixel",                 1.0, 0.0);
    207 
    208   /* define TNULL, TNVAL values */
    209   fits_modify (&theader, "TNULL1",  "%s", 1, "NULL");  /* FILENAME     */
    210   fits_modify (&theader, "TNULL2",  "%s", 1, "NULL");  /* HDR_FILENAME */
    211   fits_modify (&theader, "TNULL3",  "%s", 1, "0");     /* OBSID        */
    212   fits_modify (&theader, "TNULL4",  "%s", 1, "NaN");   /* OBS_IQ       */
    213   fits_modify (&theader, "TNULL5",  "%s", 1, "NaN");   /* OBS_BG_VAL   */
    214 
    215   fits_modify (&theader, "TNVAL1",  "%s", 1, "NA");    /* FILENAME     */
    216   fits_modify (&theader, "TNVAL2",  "%s", 1, "NA");    /* HDR_FILENAME */
    217   fits_modify (&theader, "TNVAL3",  "%s", 1, "-1");    /* OBSID        */
    218   fits_modify (&theader, "TNVAL4",  "%s", 1, "Inf");   /* OBS_IQ       */
    219   fits_modify (&theader, "TNVAL5",  "%s", 1, "Inf");   /* OBS_BG_VAL   */
    220 
    221   /* create table, add data values */
    222   fits_create_table (&theader, &table);
    223  
    224   /* add data to table */
    225   for (i = 0; i < Nmatch; i++) {
    226     subset = &image[match[i]];
    227 
    228     /* filename: NNNNNNx.fits or NNNNNNxNN.fits */
    229     /* OBSID & HDR_FILENAME are derived from FILENAME */
    230     obsid = atoi (subset[0].filename);
    231     if (obsid < 400000) fprintf (stderr, "warning: derived obsid < 400000\n");
    232     sprintf (hdrname, "%s.hdr", subset[0].filename);
    233 
    234     line = fits_table_print (&table, subset[0].filename, hdrname, obsid, (subset[0].fwhm*ARCSEC_PIXEL), subset[0].sky);
    235 
    236     fits_add_rows (&table, line, 1, strlen(line));
    237     free (line);
    238   }
    239 
    240   fits_write_header  (filename, &header);
    241   fits_write_matrix  (filename, &matrix);
    242   fits_write_Theader (filename, &theader);
    243   fits_write_table   (filename, &table);
    244   exit (0);
    245 }
    246 
    247175/* Select, TimeMode are global */
    248176int PrintSubset (RegImage *image, int *match, int Nmatch) {
     
    250178  char ccdstr[64]; 
    251179  int i, j;
    252   char *pmode, *ptype, *timestr;
     180  char *pmode, *ptype, *timestr, *root, *path;
    253181
    254182  /* print the selected entries */
     
    283211
    284212    if (PTstyle) {
    285       /* this is somewhat poor: I have predefined a subset of value, and I can't guarantee that 'filter' has no spaces */
    286       fprintf (stdout, "%s/%s %s %s %s\n", image[i].pathname, image[i].filename, image[i].filename, ccdstr, pmode);
     213      root = filerootname (image[i].filename);
     214
     215      /* do i want ccdstr? add a dot? 654321o.ccd00.ext */
     216      if (image[i].mode == MODE_MEF) {
     217        fprintf (stdout, "%s/%s %s/%s%02d %s %s\n", image[i].pathname, image[i].filename, root, root, image[i].ccd, ccdstr, pmode);
     218      }
     219
     220      if (image[i].mode == MODE_SPLIT) {
     221        path = basename (image[i].pathname);
     222        fprintf (stdout, "%s/%s %s/%s %s %s\n", image[i].pathname, image[i].filename, path, root, ccdstr, "SPLIT");
     223      }
     224
     225      if ((image[i].mode == MODE_SINGLE) || (image[i].mode == MODE_CUBE)) {
     226        fprintf (stdout, "%s/%s %s 0 %s\n", image[i].pathname, image[i].filename, root, pmode);
     227      }
    287228    } else {
    288229      /* this is somewhat poor: I have predefined a subset of value, and I can't guarantee that 'filter' has no spaces */
  • trunk/Ohana/src/imregister/src/imregister.c

    r3 r70  
    11# include "imregister.h"
    22# include "imreg.h"
    3 static char *version = "imregister $Revision: 3.0 $";
     3static char *version = "imregister $Revision: 3.1 $";
    44
    55int main (int argc, char **argv) {
     
    4242  }
    4343
     44  set_db (ImageDB);
     45
    4446  if (!NoReg) {
    4547    status = load_db ();
     
    5052  }
    5153
     54  if (IMSORT) SubmitImages (image);
    5255  fprintf (stderr, "SUCCESS: registered %s\n", argv[1]);
    5356  exit (0);
  • trunk/Ohana/src/imregister/src/imregtable.c

    r4 r70  
    11# include "imregister.h"
    22# include "imreg.h"
    3 static char *version = "imregtable $Revision: 3.1 $";
     3static char *version = "imregtable $Revision: 3.2 $";
    44
    55int main (int argc, char **argv) {
     
    3838  ConvertStruct ((char *) image, sizeof (RegImage), Nimage, "regimage");
    3939
     40  set_db (ImageDB);
     41
    4042  status = load_db ();
    4143  if (!status) {
  • trunk/Ohana/src/imregister/src/imsearch.c

    r3 r70  
    11# include "imregister.h"
    22# include "imreg.h"
    3 static char *version = "imsearch $Revision: 3.0 $";
     3static char *version = "imsearch $Revision: 3.1 $";
    44
    55int main (int argc, char **argv) {
     
    1111  args (argc, argv);
    1212
     13  set_db (ImageDB);
     14
    1315  status = load_db ();
    1416  if (!status) {
     
    1921 
    2022  match = match_criteria (&Nmatch);
     23  match = unique_entries (match, &Nmatch);
    2124
    2225  if (output.modify) ModifySubset (match, Nmatch);
  • trunk/Ohana/src/imregister/src/imstatreg.c

    r65 r70  
    11# include "imregister.h"
    22# include "imreg.h"
    3 static char *version = "imstatreg $Revision: 3.1 $";
     3static char *version = "imstatreg $Revision: 3.2 $";
    44
    55int main (int argc, char **argv) {
    66 
    7   FILE *f;
    87  RegImage *image;
    98  float *dtime;
    10   int i, Nentry, Nslice, *match, Nmatch, status;
     9  int i, *match, Nmatch, status, child;
     10  char *TempDB, *LogFile;
    1111
    1212  get_version (argc, argv, version);
    1313  args (argc, argv);
    14   image = iminfo (argv[1]);
    1514
    16   /* if images is MEF or SPLIT/SINGLE, load stats file */
    17   /* get stats file (has sky, bias, etc) */
    18   switch (image[0].mode) {
    19   case MODE_MEF:
    20   case MODE_SPLIT:
    21     f = fopen (argv[2], "r");
    22     if (f == (FILE *) NULL) {
    23       fprintf (stderr, "ERROR: can't open file.stats\n");
     15  if (CLIENT) imregclient (argv[1], argv[2], argv[3]);
     16
     17  ALLOCATE (TempDB, char, strlen (ImageDB) + 10);
     18  sprintf (TempDB, "%s.bfr", ImageDB);
     19
     20  SetSignals ();
     21
     22  if (child = fork ()) {
     23    if (child == -1) {
     24      fprintf (stderr, "error forking imstatreg -daemon \n");
    2425      exit (1);
    2526    }
    26     fscanf (f, "%f %f", &image[0].sky, &image[0].bias);
    27     fclose (f);
    28     image[0].fwhm = get_fwhm (argv[3]);
    29     Nentry = 1;
    30     break;
    31   case MODE_SINGLE:
    32     f = fopen (argv[2], "r");
    33     if (f == (FILE *) NULL) {
    34       fprintf (stderr, "ERROR: can't open file.stats\n");
    35       exit (1);
    36     }
    37     status = fscanf (f, "%d %f %f", &image[0].ccd, &image[0].sky, &image[0].fwhm);
    38     fclose (f);
    39     Nentry = 1;
    40     break;
    41   case MODE_CUBE:
    42     f = fopen (argv[2], "r");
    43     if (f == (FILE *) NULL) {
    44       fprintf (stderr, "ERROR: can't open file.stats\n");
    45       exit (1);
    46     }
    47     status = 3;
    48     Nslice = image[0].ccd;
    49     Nentry = Nslice + 1;
    50     REALLOCATE (image, RegImage, Nentry);
    51     dtime = (float *)&image[0].junk[0];
    52     for (i = 0; i < Nentry; i++) {
    53       image[i] = image[0];
    54       status = fscanf (f, "%d %f %f", &image[i].ccd, &image[i].sky, &image[i].fwhm);
    55       if (image[i].ccd == Nslice) continue;
    56       image[i].obstime += *dtime*image[i].ccd;
    57     }
    58     fclose (f);
    59     Nentry = i;
    60     break;
    61   }
    62   if (NoReg) dump_data (image, Nentry);
    63 
    64   status = load_db ();
    65   if (!status) {
    66     fprintf (stderr, "ERROR: database does not yet exist\n");
    67     close_db ();
    68     exit (1);
     27    fprintf (stderr, "starting imstatreg, logging to %s\n", LogFile);
     28    exit (0);
    6929  }
    7030
    71   match = match_images (image, Nentry, &Nmatch);
    72   if (!Nmatch) {
    73     close_db ();
    74     fprintf (stderr, "ERROR: no matched images found\n");
    75     fprintf (stderr, "image: %s %s (%d) %s (%d)\n", image[0].filename, sec_to_date (image[0].obstime), image[0].obstime, ccds[image[0].ccd], image[0].ccd);
    76     exit (2);
     31  /* child process, check for process */
     32  ConfigPID (PIDFILE);
     33
     34  /* redirect stderr, stdout to logfile */
     35  ALLOCATE (LogFile, char, strlen (ImageDB) + 10);
     36  sprintf (LogFile, "%s.log", ImageDB);
     37  tmpfd = freopen (LogFile, "w", stderr);
     38  if (tmpfd == (FILE *) NULL)
     39    fprintf (LogFile, "can't open log file %s, writing to stderr\n", LogFile);
     40  else
     41    stderr = tmpfd;
     42  tmpfd = freopen (LogFile, "w", stdout);
     43  if (tmpfd == (FILE *) NULL)
     44    fprintf (LogFile, "can't open log file %s, writing to stderr\n", LogFile);
     45  else
     46    stdout = tmpfd;
     47
     48    /* start loop */
     49  while (1) {
     50
     51    fflush (stderr);
     52    fflush (stdout);
     53    set_db (TempDB);
     54    status = load_db ();
     55    if (!status) {
     56      fprintf (stderr, "temporary database is empty\n");
     57      close_db (); sleep (60); continue;
     58    }
     59    image = get_images (&Nentry);
     60    close_lock_db (); /* file closed, hardlock on temp db remains */
     61     
     62    set_db (ImageDB);
     63    status = load_db ();
     64    if (!status) {
     65      fprintf (stderr, "database is empty\n");
     66      close_db (); sleep (60); continue;
     67    }
     68     
     69    match = match_images (image, Nentry, &Nmatch);
     70    if (!Nmatch) {
     71      close_db ();
     72      fprintf (stderr, "ERROR: no matched images found\n");
     73      fprintf (stderr, "image: %s %s (%d) %s (%d)\n", image[0].filename, sec_to_date (image[0].obstime), image[0].obstime, ccds[image[0].ccd], image[0].ccd);
     74      exit (2);
     75    }
     76    update_db (match, Nmatch);
     77     
     78    /* clear temp db hardlock */
     79    unlink (TempDB);
     80    clearlockfile2 (TempDB, -1, LCK_HARD, &status);
     81    sleep (60);
    7782  }
    78 
    79   update_db (match, Nmatch);
    80 
    81   fprintf (stdout, "SUCCESS\n");
    82   exit (0);
    8383}
    8484
     85
  • trunk/Ohana/src/perl/src/ckimregdb

    r40 r70  
    1414
    1515# test for current camera?
     16
     17system ("gconfig CAMERA");
     18exit;
    1619
    1720$start = $ARGV[0];
  • trunk/Ohana/src/perl/src/dads.detrend

    r60 r70  
    55$DO_DEFRINGE = 0;
    66$DO_DEMODE   = 0;
    7 
    8 if (@ARGV != 3) { die "USAGE: dads.detrend (input) (outbase) (level)\n" }
     7$config = "";
     8if ($ENV{'PTOLEMY'}) { $config = "-c $ENV{'PTOLEMY'}"; }
     9$tmpenv = `mktemp /tmp/elixir.XXXXXX`; chop ($tmpenv);
     10
     11@opt = ();
     12@tARGV = ();
     13for (; @ARGV > 0; ) {
     14    if ($ARGV[0] eq "-c") {
     15        $config = "-c $ARGV[1]";
     16        shift; shift; next;
     17    }
     18    if ($ARGV[0] eq "-C") {
     19        push @opt, "-C $ARGV[1]";
     20        shift; shift; next;
     21    }
     22    if ($ARGV[0] eq "-D") {
     23        push @opt, "-D $ARGV[1] $ARGV[2]";
     24        shift; shift; shift; next;
     25    }
     26    if ($ARGV[0] eq "-cleanup") {
     27        $CLEANUP = 0;
     28        shift; next;
     29    }
     30    @tARGV = (@tARGV, $ARGV[0]);
     31    shift;
     32}
     33@ARGV = @tARGV;
     34
     35$config = join (" ", $config, @opt);
     36$status = system ("gconfig -raw $config > $tmpenv");
     37if ($status) { &escape ("error in elixir configuration: gconfig fails"); }
     38$ENV{'PTOLEMY'} = "$tmpenv";
     39
     40if (@ARGV != 3) { &escape ("USAGE: dads.detrend (input) (outbase) (level) [-cleanup] [elixir options]"); }
    941
    1042$input  = $ARGV[0];   # input : /path/path/654321o.fits
     
    1547$level = "\U$level\E";
    1648if (($level ne "PERFECT") && ($level ne "BEST") && ($level ne "RAW")) {
    17     die "ERROR: invalid entry for (level)\n";
     49    &escape ("ERROR: invalid entry for (level)");
    1850}
    1951$close = "";
     
    2153
    2254# check for input file (must be MEF)
    23 if (! -e $input) { die "ERROR: input file not found\n"; }
     55if (! -e $input) { &escape ("ERROR: input file not found"); }
    2456
    2557# for raw distribution, simply use fhtool to split the files:
    2658if ($level eq "RAW") {
    2759    system ("rmdir $outdir");
    28     if ($?) { die "ERROR: can't remove target directory for fhtool\n"; }
     60    if ($?) { &escape ("ERROR: can't remove target directory for fhtool"); }
    2961    system ("fhtool $input $outdir");
    30     if ($?) { die "ERROR: failure in fhtool\n"; }
     62    if ($?) { &goodbye ("ERROR: failure in fhtool"); }
    3163    print STDOUT "SUCCESS: finished with dads.detrend\n";
    32     exit 0;
     64    &goodbye;
    3365}
    3466
     
    3668if (! -d $outdir) {
    3769    system ("mkdir -p $outdir");
    38     if ($?) { die "ERROR: can't create output directory\n"; }
     70    if ($?) { &goodbye ("ERROR: can't create output directory"); }
    3971}
    4072
    4173# load ccd config information
    42 @ccdn   = split (" ", `cameraconfig -ccdn`); if ($?) { die "ERROR in cameraconfig\n"; }
    43 @ccds   = split (" ", `cameraconfig -ccds`); if ($?) { die "ERROR in cameraconfig\n"; }
     74@ccdn   = split (" ", `cameraconfig -ccdn`); if ($?) { &goodbye ("ERROR in cameraconfig"); }
     75@ccds   = split (" ", `cameraconfig -ccds`); if ($?) { &goodbye ("ERROR in cameraconfig"); }
    4476
    4577# load abstracted keywords
    4678($typekwd, $filtkwd, $exptkwd) = split (" ", `gconfig IMAGETYPE-KEYWORD FILTER-KEYWORD EXPTIME-KEYWORD`);
    47 if ($?) { die "ERROR: config system missing keyword abstractions\n"; }
     79if ($?) { &goodbye ("ERROR: config system missing keyword abstractions"); }
    4880
    4981# extract keyword values:
    5082($junk, $type, $exptime, $filtvalue) = split (" ", `echo $input | fields $typekwd $exptkwd $filtkwd`);
    51 if ($?) { die "ERROR: failure reading header keywords (1)\n"; }
     83if ($?) { &goodbye ("ERROR: failure reading header keywords (1)"); }
    5284
    5385# check for valid imagetype & filter
    54 if ($type ne "OBJECT") { die "ERROR: $input: wrong image type\n"; }
     86if ($type ne "OBJECT") { &goodbye ("ERROR: $input: wrong image type"); }
    5587$filter = `filtnames $filtvalue`; chop $filter;
    56 if ($?) { die "ERROR: filter not found\n"; }
     88if ($?) { &goodbye ("ERROR: filter not found"); }
    5789
    5890# check recipe file for detrend types & cutoff exptime values
    5991$recipefile = `gconfig DETREND_RECIPES`; chop $recipefile;
    6092($detypes, $cutoffs) = split (" ", `gconfig -c $recipefile $filter`);
    61 if ($?) { die "ERROR: failure to get detrend recipes\n"; }
     93if ($?) { &goodbye ("ERROR: failure to get detrend recipes"); }
    6294@detypes = split (",", $detypes);
    6395@cutoffs = split (",", $cutoffs);
     
    81113# check the GEOMETRY:
    82114($tmp, $bin1, $bin2, $raster) = split (" ", `echo $input | fields CCDBIN1 CCDBIN2 RASTER`);
    83 if ($?) { die "ERROR: failure reading header keywords (2)\n"; }
    84 
    85 if ($bin1 != 1) { die "ERROR: $input: binned image\n"; }
    86 if ($bin2 != 1) { die "ERROR: $input: binned image\n"; }
    87 if ($raster ne "FULL") { die "ERROR: $input: sub-rastered image\n"; }
     115if ($?) { &goodbye ("ERROR: failure reading header keywords (2)"); }
     116
     117if ($bin1 != 1) { &goodbye ("ERROR: $input: binned image"); }
     118if ($bin2 != 1) { &goodbye ("ERROR: $input: binned image"); }
     119if ($raster ne "FULL") { &goodbye ("ERROR: $input: sub-rastered image"); }
    88120
    89121# print a summary of the processing
     
    158190    if ($status) { &escape ("ERROR: problem running flatten on $input, $ccds[$i]"); }
    159191}
     192
    160193
    161194# we need files containing detlist, demlist, deflist:
     
    183216    }
    184217    close (FILE);
     218    if (!$DO_DEMODE) { $demlist = $detlist; }
    185219}
    186220
     
    195229}
    196230
    197 &cleanup;
    198 print STDOUT "SUCCESS: finished with dads.detrend\n";
    199 exit 0;
    200 
    201 sub escape {
    202     # cleanup temporary files:
    203 
    204     &cleanup;
    205     die "$_[0]\n";
    206     exit 1;
    207 }
     231&goodbye ("SUCCESS: finished with dads.detrend");
     232
     233########################################################################
    208234
    209235sub cleanup {
     
    211237    if (!$CLEANUP) { return; }
    212238
     239    unlink $tmpenv;
    213240    # detlist, demlist, deflist
    214241    foreach $name (@detlist) {
     
    246273
    247274sub goodbye {
    248     die "@_\n";
    249 }
    250 
     275    &cleanup;
     276    print STDERR "@_\n";
     277    exit 0;
     278}
     279
     280sub escape {
     281    &cleanup;
     282    print STDERR "@_\n";
     283    exit 1;
     284}
  • trunk/Ohana/src/perl/src/defringe

    r54 r70  
    1414@ARGV = @tARGV;
    1515
    16 if (@ARGV != 2) { &escape ("ERROR: USAGE: defringe (inlist) (outlist) [-close]"); }
     16if (@ARGV != 2) { &escape ("USAGE: defringe (inlist) (outlist) [-close]"); }
    1717
    1818# load config info
    1919$confdir = `gconfig CONFDIR`; chop $confdir;
    20 if ($?) { &escape ("ERROR: config failure"); }
     20if ($?) { &escape ("config failure"); }
    2121$script = "$confdir/mana/fringe.pro";
    2222
     
    2626@ccds   = split (" ", `cameraconfig -ccds`);
    2727$Nccd   = @ccds;
     28$dbmode = `gconfig DETREND-DB-MODE`; chop $dbmode;
    2829
    2930# find fringe-point file
    3031$frpts  = `detsearch -quiet -image $input[0] $ccds[0] split -type frpts`; chop $frpts;
    31 if ($?) { &escape ("ERROR: can't get fringe points for image"); }
     32if ($?) { &escape ("can't get fringe points for image"); }
    3233
    3334# temporary files
     
    4647    # measure fringe amplitude of input image
    4748    vsystem ("getfringe $input[$i] $ccds[$i]  $frpts 1 >> $imstats");
    48     if ($?) { die "ERROR: failure to measure fringe amplitude\n"; }
     49    if ($?) { die "failure to measure fringe amplitude\n"; }
    4950
    5051    # find fringe master frames
    51     $fringe[$i] = `detsearch -quiet $close -image $input[$i] $ccds[$i] split -type fringe`; chop $fringe[$i];
    52     if ($?) { &escape ("ERROR: can't find fringe master for $input[$i]"); }
     52    $file = `detsearch -quiet $close -image $input[$i] $ccds[$i] split -type fringe`; chop $file;
     53    if ($?) { &escape ("can't find fringe master for $input[$i]"); }
     54    $fringe[$i] = $file;
     55    if ($dbmode eq "MEF") { $fringe[$i] = "$file\[$ccds[$i]\]"; }
    5356
    5457    # get fringe master stats
    55     ($name, $C0, $C1, $SKY, $RNG) = split (" ", `echo $fringe[$i] | fields FRNG_C0 FRNG_C1 FRNG_SKY FRNG_RNG`);
     58    if ($dbmode eq "MEF") {
     59        ($name, $C0, $C1, $SKY, $RNG) = split (" ", `echo $file | fields -x $i FRNG_C0 FRNG_C1 FRNG_SKY FRNG_RNG`);
     60    } else {
     61        ($name, $C0, $C1, $SKY, $RNG) = split (" ", `echo $file | fields FRNG_C0 FRNG_C1 FRNG_SKY FRNG_RNG`);
     62    }
    5663    print FILE "$C0 $C1 $SKY $RNG\n";
     64    print STDERR "$C0 $C1 $SKY $RNG\n";
    5765
    5866    # check on output directory
     
    6573# convert image stats to optimal image parameters
    6674vsystem ("fr.frstats -applyfit $imstats $frstats $fitpars");
    67 if ($?) { &escape ("ERROR: can't assign DISPLAY"); }
     75if ($?) { &escape ("failure in fr.frstats"); }
    6876@fitpars = `cat $fitpars`;
    6977
     
    97105
    98106    vsystem ("imcombred $parfile");
    99     if ($?) { &escape ("ERROR: failure running imcombred"); }
     107    if ($?) { &escape ("failure running imcombred"); }
    100108}
    101109
    102 exit 0;
    103 
    104 foreach $name (@temp) { unlink ($name); }
    105 print STDERR "SUCCESS\n";
    106 exit 0;
     110&goodbye;
    107111
    108112########
     
    119123    if (! -e $dir) {
    120124        system ("mkdir -p $dir");
    121         if ($?) { die "ERROR: can't create output directory $dir\n"; }
     125        if ($?) { die "can't create output directory $dir\n"; }
    122126    }
    123127}
     
    155159sub escape {
    156160    $message = $_[0];
     161    die "$message\n";
    157162    foreach $name (@temp) {
    158163        unlink ($name);
     
    161166}
    162167
     168sub goodbye {
     169    foreach $name (@temp) { unlink ($name); }
     170    exit 0;
     171}
  • trunk/Ohana/src/perl/src/detflips

    r50 r70  
    11#!/usr/bin/env perl
     2
     3# grab the command line options [-C config] [-c configfile]
     4$config = "";
     5@tARGV = ();
     6while (@ARGV) {
     7    if ($ARGV[0] eq "-C") {
     8        $config = "$config -C $ARGV[1]";
     9        shift; shift; next;
     10    }
     11    if ($ARGV[0] eq "-c") {
     12        $config = "$config -c $ARGV[1]";
     13        shift; shift; next;
     14    }
     15    push @tARGV, $ARGV[0];
     16    shift;
     17}
     18@ARGV = @tARGV;
    219
    320if (@ARGV != 3) { die "ERROR: USAGE: detflips (inlist) (output) (type)\n" }
     
    1936$temp2 = `mktemp /tmp/\@detflips.XXXXXX`; chop $temp2;
    2037
    21 if ($type eq "BIAS")   { $paramkey = "FLIPS_PARAM_DARK";   $detype = "bias";    }
    22 if ($type eq "DARK")   { $paramkey = "FLIPS_PARAM_DARK";   $detype = "dark";    }
    23 if ($type eq "FLAT")   { $paramkey = "FLIPS_PARAM_FLAT";   $detype = "skyflat"; }
    24 if ($type eq "FRINGE") { $paramkey = "FLIPS_PARAM_FRINGE"; $detype = "fringe";  }
     38if ($type eq "BIAS")    { $paramkey = "FLIPS_PARAM_DARK";   $detype = "bias";    }
     39if ($type eq "DARK")    { $paramkey = "FLIPS_PARAM_DARK";   $detype = "dark";    }
     40if ($type eq "FLAT")    { $paramkey = "FLIPS_PARAM_FLAT";   $detype = "skyflat"; }
     41if ($type eq "FRINGE")  { $paramkey = "FLIPS_PARAM_FRINGE"; $detype = "fringe";  }
     42if ($type eq "STACK")   { $paramkey = "FLIPS_PARAM_STACK";  $detype = "science";  }
    2543
    2644if ($paramkey eq "")  {
     
    2947}
    3048
    31 $paramfile = `gconfig $paramkey`; chop $paramfile;
     49$paramfile = `gconfig $config $paramkey`; chop $paramfile;
     50if ($?) { die "ERROR: missing parameter file $paramkey from config\n"; }
     51
    3252open (FILE, "$paramfile");
    3353@params = <FILE>;
    3454close (FILE);
    3555
    36 print STDERR "using: $paramfile\n";
     56print STDERR "detflips parameter file: $paramfile\n";
    3757
    3858foreach $line (@params) {
  • trunk/Ohana/src/perl/src/elixir.photreport

    r17 r70  
    1515$ENV{'DISPLAY'} = $xdisp;
    1616
    17 @filter = ("B", "V", "R", "I");
    18 # @filter = ("B");
     17# select filters
     18@filter = split (" ", `filtnames list`);
    1919
    20 # this should come fron the config system
    2120$logdir   = `gconfig LOGDIR`;   chop $logdir;
    2221$confdir  = `gconfig CONFDIR`;  chop $confdir;
  • trunk/Ohana/src/perl/src/elixir.postrun

    r44 r70  
    202202
    203203        $refs = `gconfig REFSDIR`; chop $refs;
    204         $stds = "$refs/landolt/new";
     204        $stds = "$refs/standards";
    205205   
    206206        # insert standards in photometry database
    207207        foreach $filter (@filter) {
    208             vsystem ("addrefs -replace -v $stds/Landolt92$filter.fix $filter\_L92");
    209             vsystem ("addrefs -replace -v $stds/Landolt92$filter.hq  $filter\_L92_HQ");
     208#           vsystem ("addrefs -replace -v $stds/Landolt92$filter.fix $filter\_L92");       
     209#           vsystem ("addrefs -replace -v $stds/Landolt92$filter.hq  $filter\_L92_HQ");
     210
     211            @words = split (" ", `filtnames $filter -cal`);
     212            if ($words[1] == 0) { next; }
     213            $photref = $words[2];
     214            vsystem ("addrefs -replace -v $stds/$photref.dat $photref");
    210215        }
    211216
     
    546551    # global variables
    547552    # add this from the filter configuration system, eventually
    548     @filter = ("B", "V", "R", "I");
     553    @filter = split (" ", `filtnames list`);
    549554
    550555    @def_state = ("camera",    "off",
  • trunk/Ohana/src/perl/src/flatten.flips

    r50 r70  
    77$quiet = 0;
    88$close = "";
     9$config = "";
    910@tARGV = ();
    1011for (; @ARGV > 0; ) {
     12    if ($ARGV[0] eq "-C") {
     13        $config = "-C $ARGV[1]";
     14        shift; shift; next;
     15    }
     16    if ($ARGV[0] eq "-c") {
     17        $config = "-c $ARGV[1]";
     18        shift; shift; next;
     19    }
     20    if ($ARGV[0] eq "-D") {
     21        $config = "-D $ARGV[1] $ARGV[2]";
     22        shift; shift; shift; next;
     23    }
    1124    if ($ARGV[0] eq "-fast") {
    1225        $fast = 1;
     
    5063
    5164# find the appropriate detrend images (need to fix output name for MEF - option?)
    52 $flat=`detsearch -chipname -quiet -image $input $ccd $mode -type flat $close`; chop ($flat);
     65$flat=`detsearch $config -chipname -quiet -image $input $ccd $mode -type flat $close`; chop ($flat);
    5366if ($?) { die "ERROR: can't get flat for image\n"; }
    5467
    5568if (!$fast) {
    56     $bias=`detsearch -chipname -quiet -image $input $ccd $mode -type bias $close`; chop ($bias);
     69    $bias=`detsearch $config -chipname -quiet -image $input $ccd $mode -type bias $close`; chop ($bias);
    5770    if ($?) { die "ERROR: can't get bias for image\n"; }
    5871
    59     $dark=`detsearch -chipname -quiet -image $input $ccd $mode -type dark $close`; chop ($dark);
     72    $dark=`detsearch $config -chipname -quiet -image $input $ccd $mode -type dark $close`; chop ($dark);
    6073    if ($?) { die "ERROR: can't get dark for image\n"; }
    6174}
     
    6477$mask = "none";
    6578if ($use_mask) {
    66     $mask=`detsearch -chipname -quiet -image $input $ccd $mode -type mask $close`; chop ($mask);
     79    $mask=`detsearch $config -chipname -quiet -image $input $ccd $mode -type mask $close`; chop ($mask);
    6780    if ($?) { die "ERROR: can't get mask for image\n"; }
    6881}
    6982
    7083# abstracted keywords
    71 $ccdkeyword  = `gconfig -q CCDNUM-KEYWORD`;    chop ($ccdkeyword);
    72 $darkword    = `gconfig -q DARKTIME-FUNCTION`; chop ($darkword);
    73 $exptimeword = `gconfig -q EXPTIME-KEYWORD`;   chop ($exptimeword);
     84$ccdkeyword  = `gconfig $config CCDNUM-KEYWORD`;    chop ($ccdkeyword);
     85$darkword    = `gconfig $config DARKTIME-FUNCTION`; chop ($darkword);
     86$exptimeword = `gconfig $config EXPTIME-KEYWORD`;   chop ($exptimeword);
    7487
    7588# find the appropriate fringe frame & coords file
     
    8093    die "ERROR: -fringe not yet available in flatten.flips\n";
    8194
    82     $filterword  = `gconfig -q FILTER-KEYWORD`;    chop ($filterword);
     95    $filterword  = `gconfig $config FILTER-KEYWORD`;    chop ($filterword);
    8396
    8497    # check the FILTER and EXPTIME, include fringe correction?:
     
    87100
    88101    # recipe file defines detrend types & cutoff exptime values
    89     $recipefile = `gconfig DETREND_RECIPES`; chop $recipefile;
     102    $recipefile = `gconfig $config DETREND_RECIPES`; chop $recipefile;
    90103    ($detypes, $cutoffs) = split (" ", `gconfig -c $recipefile $filter`);
    91104    if ($?) { die "ERROR: failure to get detrend recipes\n"; }
     
    104117    # grab necessary detrend files
    105118    if ($use_fringe) {
    106         $fringe = `detsearch -chipname -quiet -image $input $ccd $mode -type fringe $close`; chop ($fringe);
     119        $fringe = `detsearch $config -chipname -quiet -image $input $ccd $mode -type fringe $close`; chop ($fringe);
    107120        if ($?) { die "ERROR: can't get fringe for image\n"; }
    108121
    109         $frpts  = `detsearch -chipname -quiet -image $input $ccd $mode -type frpts $close`;
     122        $frpts  = `detsearch $config -chipname -quiet -image $input $ccd $mode -type frpts $close`;
    110123        if ($?) { die "ERROR: can't get fringe points for image\n"; }
    111124    }
     
    118131    ($junk, $t1) = split (" ", `echo $input    | fields $exptimeword`);
    119132    ($name, $t2) = split (" ", `echo $darkfile | fields $exptimeword`);
     133    print STDERR "darktime: $input, $t1; $darkfile, $t2\n";
    120134    $darkfactor = `darktime.$darkword $t1 $t2`; chop ($darkfactor);
    121135    if ($?) { die "ERROR: failure to get darkfactor $t1 $t2\n"; }
     
    123137
    124138# load FLIPS parameter file, fill in missing words:
    125 $paramfile = `gconfig FLIPS_IMRED_PARAM`; chop $paramfile;
    126 if ($?) { die "ERROR: missing FLIPS_IMRED_PARAM in config\n"; }
     139$paramfile = `gconfig $config FLIPS_PARAM_IMRED`; chop $paramfile;
     140if ($?) { die "ERROR: missing FLIPS_PARAM_IMRED in config\n"; }
    127141open (FILE, "$paramfile");
    128142@params = <FILE>;
  • trunk/Ohana/src/perl/src/fr.defringe

    r50 r70  
    3131# load flips parameter file
    3232$paramfile = `gconfig FLIPS_PARAM_DEFRINGE`; chop $paramfile;
     33if ($?) { die "ERROR: missing FLIPS_PARAM_DEFRINGE in config\n"; }
     34
    3335open (FILE, "$paramfile");
    3436@rawpars = <FILE>;
     
    6668}
    6769
    68 foreach $name (@temp) { unlink ($name); }
    69 print STDERR "SUCCESS\n";
    70 exit 0;
     70&goodbye;
    7171
    7272########################################################
     
    124124    die "$message\n";
    125125}
     126
     127sub goodbye {
     128    foreach $name (@temp) { unlink ($name); }
     129    print STDERR "SUCCESS\n";
     130    exit 0;
     131}
     132
     133
  • trunk/Ohana/src/perl/src/fr.select

    r57 r70  
    121121
    122122open (LIST, ">$output");
    123 for ($i = 0; $i < @good; $i++) {
    124     print LIST "$good[$i]\n";
    125 }
     123# write output to Nccd list files
     124# keep a random sample of roughly 40 images:
     125$Nselect = @good;
     126for ($i = 0; $i < $Nselect; $i++) {
     127    if (rand ($Nselect) < 40) {
     128        print LIST "$good[$i]\n";
     129    }
     130}
    126131close (LIST);
    127 print STDERR "SUCCESS\n";
     132print STDERR "SUCCESS\n\n";
    128133exit 0;
    129134
  • trunk/Ohana/src/perl/src/fr.smooth

    r45 r70  
    2222$Nccd   = @ccds;
    2323
     24$CCDKEYWORD = `gconfig CCDNUM-KEYWORD`; chop $CCDKEYWORD;
     25$dbmode = `gconfig DETREND-DB-MODE`; chop $dbmode;
    2426@frstats = `cat $frstats`;
    2527for ($i = 0; $i < @frstats; $i++) {
     
    3335# unbin and insert header keywords
    3436open (MANA, "|mana --norc");
     37print MANA "list kernel\n";
     38print MANA "  0.025\n";
     39print MANA "  0.100\n";
     40print MANA "  0.025\n";
     41print MANA "  0.100\n";
     42print MANA "  0.500\n";
     43print MANA "  0.100\n";
     44print MANA "  0.025\n";
     45print MANA "  0.100\n";
     46print MANA "  0.025\n";
     47print MANA "end\n";
    3548print MANA "macro go\n";
    3649print MANA " rd a $infile\n";
    3750print MANA " rebin a A -$binning\n";
    38 print MANA " rd mask $mask\n";
     51print MANA " \$CCDKEYWORD = $CCDKEYWORD\n";
     52if ($dbmode eq "MEF") {
     53    print MANA " rd mask $mask -n $ccds[$ccd]\n";
     54} else {
     55    print MANA " rd mask $mask\n";
     56}
    3957print MANA " keyword A NAXIS1 nx1\n";
    4058print MANA " keyword A NAXIS2 ny1\n";
     
    4361print MANA " delete a\n";
    4462print MANA " extract A a 0 0 \$nx1 \$ny1 0 0 \$nx2 \$ny2\n";
     63print MANA " kern a kernel \n";
    4564print MANA " set b = a*mask + $Fs*not(mask)\n";
    4665
     
    6887print MANA " keyword b COMMENT  -ws \"Elixir:fr.smooth version $version\"\n";
    6988print MANA " keyword b COMMENT  -ws \"Elixir Fringe Frame\"\n";
     89print MANA " keyword b COMMENT  -ws \"Elixir smoothing: 3x3 kernel (1): 0.025, 0.100, 0.025\"\n";
     90print MANA " keyword b COMMENT  -ws \"Elixir smoothing: 3x3 kernel (2): 0.100, 0.500, 0.100\"\n";
     91print MANA " keyword b COMMENT  -ws \"Elixir smoothing: 3x3 kernel (3): 0.025, 0.100, 0.025\"\n";
    7092
    7193print MANA " wd b $outfile\n";
     
    7395
    7496print MANA "end\n";
     97print MANA "macro list go\n";
    7598print MANA "go\n";
    7699print MANA "exit 1\n";
  • trunk/Ohana/src/perl/src/getfringe

    r50 r70  
    2828
    2929# find input parameter file
    30 $paramfile = `gconfig FLIPS_IMSTAT_PARAM`; chop $paramfile;
    31 if ($?) { &escape ("params not in config system"); }
     30$paramfile = `gconfig FLIPS_PARAM_IMSTAT`; chop $paramfile;
     31if ($?) { &escape ("paramfile FLIPS_PARAM_IMSTAT not in config system"); }
    3232
    3333# fill in missing keywords
     
    8989print STDOUT "$input $sky $fringe $dfringe\n";
    9090
    91 # cleanup
    92 unlink $temp1;
    93 unlink $temp2;
    94 unlink $temp3;
    95 exit 0;
     91&goodbye;
    9692
    9793########
     
    116112    die "$message\n";
    117113}
     114
     115sub goodbye {
     116    foreach $name (@temp) { unlink ($name); }
     117    exit 0;
     118}
     119
     120
  • trunk/Ohana/src/perl/src/imclean.cfht

    r17 r70  
    11#!/usr/bin/env perl
     2
     3$config = "";
     4@tARGV = ();
     5for (; @ARGV > 0; ) {
     6    if ($ARGV[0] eq "-C") {
     7        $config = "-C $ARGV[1]";
     8        shift; shift; next;
     9    }
     10    if ($ARGV[0] eq "-c") {
     11        $config = "-c $ARGV[1]";
     12        shift; shift; next;
     13    }
     14    if ($ARGV[0] eq "-D") {
     15        $config = "-D $ARGV[1] $ARGV[2]";
     16        shift; shift; shift; next;
     17    }
     18    @tARGV = (@tARGV, $ARGV[0]);
     19    shift;
     20}
     21@ARGV = @tARGV;
     22
     23if (@ARGV < 3) {
     24    print STDERR "ERROR: USAGE: USAGE: imclean.cfht (fits) (obj) (cmp) [option]\n";
     25    print STDERR "  corrects for errors with CD1_1, CRPIX1 on 12k for 51400 < MJD < 51540\n";
     26    print STDERR "  also determines and inserts the photcode for the image\n";
     27    exit 2;
     28}
     29
     30# input image must already be in SPLIT mode
     31
     32# determine the photcode of this image:
     33$photcode=`photcode $config -quiet $ARGV[0] 0 split`; chop $photcode;
     34if ($?) { die "ERROR: cannot find photcode\n"; }
     35
     36# check if we need to correct the WCS terms (only CFH12K)
     37($name, $id, $mjd) = split (" ", `echo $ARGV[0] | fields IMAGEID MJD-OBS`);
     38
     39$fix="";
     40if (($mjd > 51400) && ($mjd < 51540) && (($id == 2) || ($id == 6))) {
     41    $line = `echo $ARGV[0] | fields CD1_1 CRPIX1 NAXIS1`;
     42    ($name, $cd11, $crpix1, $nx) = split (" ", $line, 4);
     43    $crpix1 = $nx - $crpix1;
     44    $cd11 = -$cd11;
     45    $fix = "-key CD1_1 %f $cd11  -key CRPIX1 %f $crpix1";
     46}
     47
     48vsystem ("imclean $config @ARGV -p $photcode $fix");
     49
     50exit 0;
     51
     52############
    253
    354sub vsystem {
     
    1263}
    1364
    14 if (@ARGV < 3) {
    15     print STDERR "ERROR: USAGE: USAGE: imclean.cfht (fits) (obj) (cmp) [option]\n";
    16     print STDERR "  corrects for errors with CD1_1, CRPIX1 on 12k for 51400 < MJD < 51540\n";
    17     print STDERR "  also determines and inserts the photcode for the image\n";
    18     exit 2;
    19 }
    20 
    21 # input image must already be in SPLIT mode
    22 # determine the photcode of this image:
    23 $photcode=`photcode -quiet $ARGV[0] 0 split`;
    24 if ($?) {
    25     print STDERR "ERROR: cannot find photcode\n";
    26     exit 1;
    27 }
    28 chop ($photcode);
    29 
    30 # check if we need to correct the WCS terms
    31 $line = `echo $ARGV[0] | fields IMAGEID MJD-OBS`;
    32 chop ($line);
    33 ($name, $id, $mjd) = split (" ", $line);
    34 $fix="";
    35 
    36 print STDERR "mjd $mjd, $id $id\n";
    37 if (($mjd > 51400) && ($mjd < 51540) && (($id == 2) || ($id == 6))) {
    38     $line = `echo $ARGV[0] | fields CD1_1 CRPIX1 NAXIS1`;
    39     ($name, $cd11, $crpix1, $nx) = split (" ", $line, 4);
    40     $crpix1 = $nx - $crpix1;
    41     $cd11 = -$cd11;
    42     $fix = "-key CD1_1 %f $cd11  -key CRPIX1 %f $crpix1";
    43 }
    44 
    45 vsystem ("imclean @ARGV -p $photcode $fix");
    46 
    47 exit 0;
    48 
  • trunk/Ohana/src/perl/src/imstatqso

    r33 r70  
    2727$line = `echo $ARGV[0] | fields $ccdkeyword`;
    2828($tmp, $ccd) = split (" ", $line);
     29
     30if ($ccd =~ m|amp|) {
     31    # convert to equivalent ccd
     32    ($n) = $ccd =~ m|amp(\d*)|;
     33    $ccd = sprintf "ccd%02d", $n/2;
     34}
    2935
    3036if ($ccd ne $refccd) {
  • trunk/Ohana/src/perl/src/mkfringe

    r51 r70  
    955955    @list = load_config ();
    956956   
     957    # create directory for fhtool to work in
     958    $links = mkfiles ("links");
     959    if (! -e $links) { mkdir ($links); }
     960
    957961    # create namelist for those with appropriate status
    958962    foreach $confline (@list) {
     
    982986
    983987        if ($DBmode eq "MEF") {
     988            # empty link directory:
     989            system ("rm -f $links/*.fits");
     990
    984991            # make links
    985992            foreach $ccd (@ccds) {
     
    991998            # mef, register
    992999            $mef = mknames ("mef", $confline);
     1000            system ("rm -f $mef");
     1001
    9931002            vsystem ("fhtool -P $links $mef");
    9941003            if ($status) { $success = 0; }
     
    25412550        }
    25422551       
    2543         if ($value eq "-C") {
     2552        if ($value eq "-D") {
    25442553            push @opt, $value;
    25452554            $value = shift @argv;
     
    26002609    if ($?) { &escape ("error with elixir camera configuration"); }
    26012610
    2602     # desired types:
    2603     @type = ('fringe', 'fringe');
    2604     @filt = ('I',      'Z');
     2611    # get list of valid filters from lookup table
     2612    @filters = split (" ", `filtnames list`);
     2613    if ($?) { &escape ("error with elixir filter configuration"); }
     2614
     2615    # recipe file defines detrend types & cutoff exptime values
     2616    $recipefile = `gconfig DETREND_RECIPES`; chop $recipefile;
     2617    if ($?) { &escape ("missing DETREND_RECIPES in configuration"); }
     2618
     2619    @filt = ();
     2620    foreach $filter (@filters) {
     2621        ($detypes) = split (" ", `gconfig -c $recipefile $filter`);
     2622        if ($?) { die "ERROR: missing detrend recipe for $filter\n"; }
     2623
     2624        @detypes = split (",", $detypes);
     2625        for ($i = 0; $i < @detypes; $i++) {
     2626            if ($detypes[$i] eq "fringe") {
     2627                push @filt, $filter;
     2628                push @type, "fringe";
     2629                last;
     2630            }
     2631        }
     2632    }
    26052633
    26062634    $CGI = `gconfig CGIBIN`; chop ($CGI);
  • trunk/Ohana/src/perl/src/mktrans

    r17 r70  
    66$stop  = $ARGV[1];
    77
    8 @photcodes = ("B", "V", "R", "I", "Z");
     8@photcodes = split (" ", `filtnames list`);
    99
    1010foreach $code (@photcodes) {
  • trunk/Ohana/src/perl/src/mktreport

    r17 r70  
    66$stop  = $ARGV[1];
    77
    8 @photcodes = ("B", "V", "R", "I");
     8@photcodes = split (" ", `filtnames list`);
    99
    1010@list = `transearch -offset`;
  • trunk/Ohana/src/perl/src/normalize

    r55 r70  
    11#!/usr/bin/env perl
    22
    3 $revline = "\$Revision: 1.3 $?";
     3$revline = "\$Revision: 1.4 $?";
    44($version) = $revline =~ m|\$Revision:\s*(\S*)|;
    55
     
    4848$ccdword = `gconfig -q CCDNUM-KEYWORD`; chop ($ccdword);
    4949$typeword = `gconfig -q IMAGETYPE-KEYWORD`; chop ($typeword);
     50$dbmode = `gconfig -q DETREND-DB-MODE`; chop ($dbmode);
    5051
    5152# choose appropriate type
     
    151152    print MANA "echo 'starting normalize'\n";
    152153    print MANA "rd a $input\n";
    153     print STDERR "mask: $mask\n";
     154    print MANA "\$CCDKEYWORD = $ccdword\n";
     155    print MANA "keyword a $ccdword ccd\n";
    154156    if ($mask eq "none") {
    155157        print MANA "set b = a / $refmode\n";
    156158    } else {
    157         print MANA "rd c $mask\n";
     159        if ($dbmode eq "MEF") {
     160            print MANA "rd c $mask -n \$ccd\n";
     161        } else {
     162            print MANA "rd c $mask\n";
     163        }
    158164        print MANA "set b = (a / $refmode) * c\n";
    159165    }
  • trunk/Ohana/src/shell/src/checkdisks

    r31 r70  
    11#!/bin/csh -f
    22
    3 set disks="/data/elixir /data/elixir3 /data/koa /data/milo /data/elixir2 /data/kiawe /data/noni /data/ulu /data/hau /data/naupaka"
     3set disks="/data/elixir /data/milo /data/elixir3 /data/koa /data/elixir2 /data/kiawe /data/noni /data/ulu /data/hau /data/naupaka"
    44
    55df $disks
  • trunk/Ohana/src/shell/src/el_plots

    r16 r70  
    77# check that camera is ok:
    88set camera=`gconfig CAMERA.CURRENT`
     9set datdir=`gconfig DATDIR`
    910if ($camera == "cfh12k") goto valid;
    1011if ($camera == "cfhtir") goto valid;
     12if ($camera == "megacam") goto valid;
    1113
    1214if ("$1" == "init") then
     
    5153 endif
    5254
    53  cp /data/milo/elixir/plots/seeing_night.png /apps/www/www.cfht.hawaii.edu/Instruments/Elixir/seeing/archive/seeing_$2.png
     55 cp $datdir/plot/seeing_night.png /apps/www/www.cfht.hawaii.edu/Instruments/Elixir/seeing/archive/seeing_$2.png
    5456 exit 0;
    5557
  • trunk/Ohana/src/shell/src/elixir.fork

    r16 r70  
    2727
    2828# set logdir for various logging
    29 set logdir=`gconfig LOGDIR`
    30 if ($status) then
    31  echo "error with elixir configurations: missing LOGDIR, using /tmp"
     29# set logdir=`gconfig LOGDIR`
     30# if ($status) then
     31#  echo "error with elixir configurations: missing LOGDIR, using /tmp"
     32# endif
     33
     34set logdir = "$HOME/elixir"
     35if (! -e $logdir) then
     36  mkdir $logdir
     37  if ($status) then
     38    echo "error with elixir configurations: missing LOGDIR, using /tmp"
     39    set logdir = "/tmp"
     40  endif
    3241endif
    3342
  • trunk/Ohana/src/shell/src/elixir.launch

    r48 r70  
    88set run    = `gconfig RUNID.CURRENT`;
    99set camera = `gconfig CAMERA.CURRENT`;
     10set logdir = `gconfig LOGDIR`;
    1011
    1112if ($1 == "mkdetrend") then
    1213    switch ($camera)
    1314     case cfh12k:
    14 #     case megacam:
     15     case megacam:
    1516      echo "starting mkdetrend"
    16       mkdetrend auto run -run $run -camera $camera >>& /data/milo/elixir/log/mkdetrend.log &
     17      mkdetrend auto run -run $run -camera $camera >>& $logdir/mkdetrend.log &
    1718      breaksw;
    1819
     
    2930     case megacam:
    3031      echo "starting elixir imstats"
    31       elixir -restart -D mode imstats -D CAMERA $camera -D RUNID $run >>& /data/milo/elixir/log/imstats.log &
     32      elixir -restart -D mode imstats -D CAMERA $camera -D RUNID $run >>& $logdir/imstats.log &
    3233      breaksw;
    3334
    3435     case cfhtir:
    3536      echo "starting elixir irstats"
    36       elixir -restart -D mode irstats -D CAMERA $camera -D RUNID $run >>& /data/milo/elixir/log/imstats.log &
     37      elixir -restart -D mode irstats -D CAMERA $camera -D RUNID $run >>& $logdir/imstats.log &
    3738      breaksw;
    3839
     
    4647
    4748if ($1 == "sextract") then
    48     exit 0;
    49 
    5049    switch ($camera)
    5150     case cfh12k:
    52 #     case megacam:
     51     case megacam:
    5352      echo "starting elixir sextract"
    54       elixir -restart -D mode sextract -D CAMERA $camera -D RUNID $run >>& /data/milo/elixir/log/sextract.log &
     53      elixir -restart -D mode sextract -D CAMERA $camera -D RUNID $run >>& $logdir/sextract.log &
    5554      breaksw;
    5655
  • trunk/Ohana/src/shell/src/getfocus

    r49 r70  
    135135set i = 1
    136136while ($i <= $#ccds)
    137  $ccdnum = $ccdn[$i]
    138  $ccdnam = $ccns[$i]
     137 echo $i $ccds
     138 set ccdnum = $ccdn[$i]
     139 set ccdnam = $ccds[$i]
    139140 echo "split $fdir/$name.fits $ccdnam $temp.$ccdnum.fits" >> $temp.pro
     141 @ i++
    140142end
    141143mana --norc --only $script $temp.pro
  • trunk/Ohana/src/shell/src/getseeing

    r49 r70  
    6666if ($mef) then
    6767 set Nextend = `echo $file | fields NEXTEND | awk '{print $2}'`
    68  if ($Nextend > 50) set ccd = amp26
    69  echo "subraster.mef   $file $ccd $temp.fits $temp.stats" > $temp.pro
     68 set tccd = $ccd
     69 if ($Nextend > 50) set tccd = amp26
     70 echo "subraster.mef   $file $tccd $temp.fits $temp.stats" > $temp.pro
    7071else
    7172 echo "subraster.split $file $ccd $temp.fits $temp.stats" > $temp.pro
  • trunk/Ohana/src/shell/src/gosexphot

    r16 r70  
    1515    if ("$3" == "-shallow") then
    1616        set name="gosexshallow.sex"
     17    endif
     18    if ("$3" == "-deep") then
     19        set name="gosexdeep.sex"
    1720    endif
    1821endif
  • trunk/Ohana/src/shell/src/sp_phot

    r16 r70  
    1313# run this process on 'druid' instead of 'ohia'?
    1414
    15 set PROCNAME=sp_phot
    16 set MAXTIME=300
     15set DBMACHINE = `gconfig DBMACHINE`
     16set PROCNAME  = sp_phot
     17set MAXTIME   = 300
    1718
    1819set args=""
     
    103104
    104105# use the tycho data only to do astrometry
    105 rsh -n milo gastro -D CATDIR $TYCHO $SMPDIR/$root.smp
     106rsh -n $DBMACHINE gastro -D CATDIR $TYCHO $SMPDIR/$root.smp
    106107# if ($status) goto cleanup;
    107108
    108 rsh -n milo addspphot -cal TYCHO_V TYCHO_B $SMPDIR/$root.smp
    109 # rsh -n milo addstar -cal TYCHO_V TYCHO_B $SMPDIR/$root.smp
     109rsh -n $DBMACHINE addspphot -image -cal TYCHO_V TYCHO_B $SMPDIR/$root.smp
    110110# if ($status) goto cleanup;
    111111
  • trunk/Ohana/src/shell/src/sp_plots

    r32 r70  
    77# find the appropriate script file
    88set confdir=`gconfig CONFDIR`
     9set datdir=`gconfig DATDIR`
    910set script="$confdir/mana/skyprobe"
    1011set xhost=`gconfig XHOST`
     
    4647 endif
    4748
    48  cp /data/milo/elixir/plots/skyprobe_night.png /apps/www/www.cfht.hawaii.edu/Instruments/Skyprobe/archive/mcal_$2.png
     49 cp $datdir/plots/skyprobe_night.png /apps/www/www.cfht.hawaii.edu/Instruments/Skyprobe/archive/mcal_$2.png
    4950 exit 0;
    5051
Note: See TracChangeset for help on using the changeset viewer.