IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2520


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

new versions of phase2 scripts

Location:
trunk/archive/scripts
Files:
1 added
2 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}
  • trunk/archive/scripts/phase2.pl

    r2519 r2520  
    22
    33sub usage {
    4     print STDERR "USAGE: phase2.pl\n";
     4    # input is foo.fits
     5    # outputs are outroot.im.fits (image) outroot.ob.fits (object list), outroot.log, etc
     6    print STDERR "USAGE: phase2 (input) (outroot)\n";
    57    exit 2;
    68}
     
    810if (@ARGV != 4) { &usage; }
    911
    10 # phase2.pl has extensive intelligence about data sources
     12# base file needs to be hardwired, from environment, or based on program name
     13$base   = psMetadataParseConfig (NULL, basefile, FALSE); 
    1114
    12 # input: filename.fits
    13 # output: flattened image: filename.f.fits? filename.flt? (chosen externally?)
    14 # output: extracted stars: filename.p.tbl
    15 # output: constructed kernel: filename.k.fits
     15# probably defined in the base file?
     16$site   = psMetadataParseConfig (NULL, sitefile, FALSE); 
    1617
    17 # determine camera from image or externally?
     18# this should be optionally specified as part of the command-line options
     19# alternatively, this should be derived from the input file header data
     20$camera = psMetadataParseConfig (NULL, camerafile, FALSE);
    1821
    19 # load configuration information:
     22# we need a way to define an optional alternative recipe
     23$recipe = psMetadataParseConfig (NULL, recipefile, FALSE);  # defined in the camera file
    2024
    21 $config = psMetadataReadFile (NULL, $configfile);
     25# load only the headers from the given file input a list of headers
     26@headers = psFITSReadHeaderSet ($input);
    2227
    23 # check image:
    24 # is it a FITS image?
    25 # find camera
    26 # find mode:
    27 #  one cell per extension
    28 #  one chip per extension
    29 #  one FPA per extension
     28# check the validity of the given set of headers based on expectactions for this camera
     29# ** where does camera come from?
     30# ** how do we do this if the camera is derived from the header info?
     31$status = pmCameraValidateHeaders ($headers, $camera);
    3032
    31 @chips = getChips ($input);
    32 foreach $chip () {
    33     @cells = getCells ($input, $chip);
    34 }
     33# this gets a bit tenuous: what do we do with the collection? 
    3534
     35# construct a complete, empty (ie, no pixel data) FPA structure for this camera / header set
     36# we need to construct the output container.  is it big enough to fit in memory?  assume so?
     37$FPA = pmFPAfromHeader ($headers, $camera);
    3638
     39### now we work on individual readouts:
    3740
    38 # construct kernel
     41# we have the FPA, already validated
     42# as part of the FPA, we have access to a specified READOUT and we know the corresponding EXTNAME
    3943
    40 # load bias
    41 # load dark
    42 # apply bias and dark
     44# load in the complete readout:
     45$image    = psImageReadSection (NULL, 0, 0, 0, 0, 0, $extname, $Nreadout, $input);
    4346
    44 # all possible detrend operations
    45 #   - bias
    46 #   - dark
    47 #   - trim
    48 #   - mask bad pixels (astrometry independent)
    49 #   - mask artifacts (astrometry dependent)
    50 #   - flatten
    51 #   - fringe correct
     47# load in the complete corresponding bias image (this should be done once per cell)
     48# in this form, we are implying that the bias image is guaranteed to have the corresponding EXTNAME
     49$bias     = psImageReadSection (NULL, 0, 0, 0, 0, 0, $extname, 0, $biasname);
    5250
    53 # convolution kernel is applied to:
    54 #   - flat
    55 #   - fringe
    56 #   - bias?
     51# overscan options:
     52# - overscan is defined by the recipe (BIAS.OVERSCAN has form [Xs,Xe:Ys:Ye])
     53# - overscan is defined by the header (BIAS.OVERSCAN has value BIASSEC)
     54# - overscan is not used (BIAS.OVERSCAN has value NONE)
    5755
    58 #
    59 
    60 
    61 $out = pmSubtractBias ($in, $fit);
    62 
    63 
    64 ##### example: single chip, single cell, single readout:
    65 
    66 # input filename: $input
    67 
    68 # bias recipe:
    69 #   bias image: filename
    70 #   overscan: header BIASSE
    71 
    72 # bias subtraction options:
    73 # - use a bias image?
    74 # -
    75 
    76 
    77 
    78 $image    = psImageReadSection (NULL, 0, 0, 0, 0, 0, $extname, -1, $input);
    79 $metadata = psMetadataReadHeader (NULL, $extname, -1, $input);
    80 
    81 $metaitem = psMetadataLookup ($metadata, "BIASSEC");
     56# bias section from header:
     57$ = psMetadataLookup ($readout->metadata, "BIASSEC");
    8258$overscan = psImageSubsection ($image, $metaitem->data.void);
    8359
     
    8864$image_b = pmSubtractBias ($image, NULL, $overlist, PM_OVERSCAN_COLUMNS, $stats, 0, PM_FIT_NONE, $bias);
    8965
    90 
    91 
    92 #######################
    93 
Note: See TracChangeset for help on using the changeset viewer.