IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 29, 2004, 10:18:55 AM (22 years ago)
Author:
eugene
Message:

new versions of phase2 scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/phase2.c

    r2519 r2520  
    1717  outroot = argv[2];
    1818
    19   // define command-line options
    20   cameraname = NULL;
    21   cameraname = getargs ("-camera");  // pseudo-code, not a valid API
    22   recipefile = NULL;
    23   recipefile = getargs ("-recipe");  // pseudo-code, not a valid API
    24 
    25   // base file needs to be hardwired, from environment, or based on program name
    26   base   = psMetadataParseConfig (NULL, basefile, FALSE); 
    27 
    28   // load site-specific information (such as database servers, etc)
    29   sitefile = psMetadataLookup (base, "SITE");
    30   site   = psMetadataParseConfig (NULL, sitefile, FALSE); 
    31 
    32   // load only the headers from the given file input a list of headers
    33   headers = psFITSReadHeaderSet (input);
     19  fits = psFitsAlloc (input);
     20
     21  // load only the headers from the given file
     22  headers = psFitsReadHeaderSet (fits);
    3423 
    3524  // identify camera (may be specified on command line)
    3625  if (cameraname == NULL) {
    37     cameraname = pmCameraFromHeader (headers.data[0]);
     26    cameraname = pmCameraFromHeader (psListGet (headers->list, 0));
    3827  }
    3928  camerafile = psMetadataLookup (site, "CAMERA.%s", cameraname);
     
    6352  // Is EXTNAME invarient?  (probably not; does not always exist)
    6453
     54  /* This will work, but it is not efficient:
     55     we should work with the extensions in sequence */
    6556  for (i = 0; i < FPA[0].chips.n; i++) {
    6657    chip = FPA[0].chips.data[i];
    6758
     59    if (Base == CELL) {
     60      f = psFitsMoveExtName(f, extname);
     61    }
     62   
    6863    for (j = 0; j < chip[0].cells.n; j++) {
    6964      cell = chip[0].cells.data[j];
    7065
     66      if (Base == CELL) {
     67        f = psFitsMoveExtName(f, extname);
     68      }
     69
     70      /* these need to work with the psFits pointer correctly
    7171      bias = load_bias_image (recipe, cell[0].metadata, cell[0].extname);
    7272      dark = load_dark_image (recipe, cell[0].metadata, cell[0].extname);
     
    7474      badpix = load_badpix_image (recipe, cell[0].metadata, cell[0].extname);
    7575      fringe = load_fringe_image (recipe, cell[0].metadata, cell[0].extname);
     76      */
    7677
    7778      for (k = 0; k < cell[0].readouts.n; k++) {
     
    7980
    8081        // load the specific readout pixels.  put this in a function? 
    81         readout[0].image = psImageReadSection (NULL, 0, 0, 0, 0, 0, cell[0].extname, k, input);
     82        status = pmReadoutLoad (fits, cell, k);
    8283
    8384        kernel = make_kernel ();
     
    299300}
    300301
     302
     303bool pmConfigLoadBasic (psMetadata **site, psMetadata **base) {
     304
     305  // base file needs to be hardwired, from environment, or based on program name
     306  base   = psMetadataParseConfig (NULL, basefile, FALSE); 
     307
     308  // load site-specific information (such as database servers, etc)
     309  sitefile = psMetadataLookup (base, "SITE");
     310  site   = psMetadataParseConfig (NULL, sitefile, FALSE); 
     311
     312}
     313
     314bool pmConfigLoadCamera (psMetadata **camera, psMetadata *site, psMetadata *header) {
     315 
     316  if (site == NULL) return (FALSE);
     317
     318  // identify camera (may be specified on command line)
     319  cameraname = getargs ("-camera");  // pseudo-code, not a valid API
     320
     321  // if there is no source for camera info, fail
     322  if ((cameraname == NULL) && (header == NULL)) {
     323    return (FALSE);
     324  }
     325
     326  // try to determine camera from header
     327  if (cameraname == NULL) {
     328    cameraname = pmCameraFromHeader (header);
     329  }
     330
     331  // find appropriate camera definition file
     332  camerafile = psMetadataLookup (site, "CAMERA.%s", cameraname);
     333
     334  // load the camera details for the specific camera
     335  *camera = psMetadataParseConfig (NULL, camerafile, FALSE);
     336
     337  return (TRUE);
     338}
     339
     340bool pmConfigLoadRecipe (psMetadata **recipe, psMetadata *camera, char *script) {
     341
     342  char recipename[64];
     343
     344  if (site   == NULL) return (FALSE);
     345  if (camera == NULL) return (FALSE);
     346
     347  // define command-line options
     348  recipefile = getargs ("-recipe");  // pseudo-code, not a valid API
     349
     350  // recipefile is defined in the camera metadata, if not specified on command line
     351  if (recipefile == NULL) {
     352    sprintf (recipename, "RECIPE.%s", script);
     353
     354    // option 1: recipe is in the camera definition
     355    recipefile = psMetadataLookup (camera, recipename);
     356
     357    // option 2: recipe is in the metadata database (equiv to a detrend file)
     358    // this option requires a different API (header data, etc)
     359    recipefile = DetrendDatabaseLookup (recipename, site, camera, header);
     360  }
     361
     362  *recipe = psMetadataParseConfig (NULL, recipefile, FALSE); 
     363  return (TRUE);
     364}
Note: See TracChangeset for help on using the changeset viewer.