Changeset 2520
- Timestamp:
- Nov 29, 2004, 10:18:55 AM (22 years ago)
- Location:
- trunk/archive/scripts
- Files:
-
- 1 added
- 2 edited
-
phase2-alt.c (added)
-
phase2.c (modified) (5 diffs)
-
phase2.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/scripts/phase2.c
r2519 r2520 17 17 outroot = argv[2]; 18 18 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); 34 23 35 24 // identify camera (may be specified on command line) 36 25 if (cameraname == NULL) { 37 cameraname = pmCameraFromHeader ( headers.data[0]);26 cameraname = pmCameraFromHeader (psListGet (headers->list, 0)); 38 27 } 39 28 camerafile = psMetadataLookup (site, "CAMERA.%s", cameraname); … … 63 52 // Is EXTNAME invarient? (probably not; does not always exist) 64 53 54 /* This will work, but it is not efficient: 55 we should work with the extensions in sequence */ 65 56 for (i = 0; i < FPA[0].chips.n; i++) { 66 57 chip = FPA[0].chips.data[i]; 67 58 59 if (Base == CELL) { 60 f = psFitsMoveExtName(f, extname); 61 } 62 68 63 for (j = 0; j < chip[0].cells.n; j++) { 69 64 cell = chip[0].cells.data[j]; 70 65 66 if (Base == CELL) { 67 f = psFitsMoveExtName(f, extname); 68 } 69 70 /* these need to work with the psFits pointer correctly 71 71 bias = load_bias_image (recipe, cell[0].metadata, cell[0].extname); 72 72 dark = load_dark_image (recipe, cell[0].metadata, cell[0].extname); … … 74 74 badpix = load_badpix_image (recipe, cell[0].metadata, cell[0].extname); 75 75 fringe = load_fringe_image (recipe, cell[0].metadata, cell[0].extname); 76 */ 76 77 77 78 for (k = 0; k < cell[0].readouts.n; k++) { … … 79 80 80 81 // 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); 82 83 83 84 kernel = make_kernel (); … … 299 300 } 300 301 302 303 bool 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 314 bool 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 340 bool 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 2 2 3 3 sub 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"; 5 7 exit 2; 6 8 } … … 8 10 if (@ARGV != 4) { &usage; } 9 11 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); 11 14 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); 16 17 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); 18 21 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 20 24 21 $config = psMetadataReadFile (NULL, $configfile); 25 # load only the headers from the given file input a list of headers 26 @headers = psFITSReadHeaderSet ($input); 22 27 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); 30 32 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? 35 34 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); 36 38 39 ### now we work on individual readouts: 37 40 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 39 43 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); 43 46 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); 52 50 53 # convolution kernel is applied to:54 # - flat55 # - fringe56 # - 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) 57 55 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"); 82 58 $overscan = psImageSubsection ($image, $metaitem->data.void); 83 59 … … 88 64 $image_b = pmSubtractBias ($image, NULL, $overlist, PM_OVERSCAN_COLUMNS, $stats, 0, PM_FIT_NONE, $bias); 89 65 90 91 92 #######################93
Note:
See TracChangeset
for help on using the changeset viewer.
