Changeset 6421 for trunk/doc/modules/CameraImages.tex
- Timestamp:
- Feb 10, 2006, 3:25:23 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/doc/modules/CameraImages.tex (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/modules/CameraImages.tex
r6019 r6421 129 129 \begin{verbatim} 130 130 typedef struct { 131 // Position on the cell132 int col0; // Offset from the left of cell.133 int row0; // Offset from the bottom of cell.134 int colBins; // Amount of binning in x-dimension and parity (from sign)135 int rowBins; // Amount of binning in y-dimension and parity (from sign)136 131 // Information 132 psMetadata *analysis; // Readout-level analysis metadata 133 pmCell *parent; // Parent cell 134 // Data 137 135 psImage *image; // Imaging area of readout 138 136 psImage *mask; // Mask for image 139 137 psImage *weight; // Weight for image 140 138 psList *bias; // List of bias section (sub-)images 141 psMetadata *analysis; // Readout-level analysis metadata142 pmCell *parent; // Parent cell143 139 } pmReadout; 144 140 \end{verbatim} … … 146 142 The constructor for \code{pmReadout} shall be: 147 143 \begin{verbatim} 148 pmReadout *pmReadoutAlloc(pmCell *cell); 149 \end{verbatim} 150 The constructor shall make an empty \code{pmReadout}. If the parent 151 \code{cell} is not \code{NULL}, the \code{parent} link is made and the 152 readout shall be placed in the parent's array of \code{readouts}. The 153 metadata containers shall be allocated. All other pointers in the 154 structure shall be initialized to \code{NULL}. 144 pmReadout *pmReadoutAlloc(void); 145 \end{verbatim} 146 The constructor shall make an empty \code{pmReadout}. The metadata 147 container and the \code{bias} list shall be allocated. All other 148 pointers in the structure shall be initialized to \code{NULL}. 155 149 156 150 \subsubsection{A Cell} … … 177 171 \begin{verbatim} 178 172 typedef struct { 179 // Offset specifying position on chip180 int col0; // Offset from the left of chip.181 int row0; // Offset from the bottom of chip.182 173 // Astrometric transformations 183 174 psPlaneTransform* toChip; // Transformations from cell to chip coordinates … … 186 177 // Information 187 178 psMetadata *concepts; // Cache for PS concepts 188 psMetadata *camera; // Camera information179 psMetadata *camera; // Camera information 189 180 psMetadata *analysis; // Cell-level analysis metadata 181 bool process; // Do we want to process? 182 bool exists; // Does the data exist? 183 // Levels 190 184 psArray *readouts; // The readouts (referred to by number) 191 185 pmChip *parent; // Parent chip 192 bool valid; // Do we bother about reading and working with this cell? 193 p_pmHDU *hdu; // FITS data 186 // Sources 187 pmFile *imageSource; // Image file on disk 188 pmFile *maskSource; // Mask file on disk 189 pmFile *weightSource; // Weight file on disk 194 190 } pmCell; 195 191 \end{verbatim} … … 197 193 The constructor for \code{pmCell} shall be: 198 194 \begin{verbatim} 199 pmCell *pmCellAlloc(pmChip *chip, psMetadata *cameraData, psString name); 200 \end{verbatim} 201 The constructor shall make an empty \code{pmCell}. If the parent 202 \code{chip} is not \code{NULL}, the \code{parent} link is made and the 203 cell shall be placed in the parent's array of \code{cells}. The 195 pmCell *pmCellAlloc(psMetadata *cameraData, psString name); 196 \end{verbatim} 197 The constructor shall make an empty \code{pmCell}. The 204 198 \code{readouts} array shall be allocated with a zero size, and the 205 199 metadata containers constructed. The cell's \code{camera} pointer 206 shall be set to the provided \code{cameraData}, and the \code{name} 207 shall be used to set \code{CELL.NAME} in the \code{concepts}. All 208 other pointers in the structure shall be initialized to \code{NULL}. 200 shall be set to the provided \code{cameraData}, the \code{exists} 201 boolean shall be set to \code{false}, the \code{process} boolean shall 202 be set to \code{true}, and the \code{name} shall be used to set 203 \code{CELL.NAME} in the \code{concepts}. All other pointers in the 204 structure shall be initialized to \code{NULL}. 205 206 \tbd{The astrometric transformations will likely disappear into the 207 analysis metadata in the future.} 209 208 210 209 \subsubsection{A Chip} … … 224 223 \begin{verbatim} 225 224 typedef struct { 226 // Offset specifying position on focal plane227 int col0; // Offset from the left of FPA.228 int row0; // Offset from the bottom of FPA.229 225 // Astrometric transformations 230 226 psPlaneTransform* toFPA; // Transformation from chip to FPA coordinates … … 233 229 psMetadata *concepts; // Cache for PS concepts 234 230 psMetadata *analysis; // Chip-level analysis metadata 231 bool process; // Do we want to process? 232 bool exists; // Does the data exist? 233 // Levels 235 234 psArray *cells; // The cells (referred to by name) 236 235 pmFPA *parent; // Parent FPA 237 bool valid; // Do we bother about reading and working with this chip? 238 p_pmHDU *hdu; // FITS data 236 // Sources 237 pmFile *imageSource; // Image file on disk 238 pmFile *maskSource; // Mask file on disk 239 pmFile *weightSource; // Weight file on disk 239 240 } pmChip; 240 241 \end{verbatim} … … 242 243 The constructor for \code{pmChip} shall be: 243 244 \begin{verbatim} 244 pmChip *pmChipAlloc(pmFPA *fpa, psString name); 245 \end{verbatim} 246 The constructor shall make an empty \code{pmChip}. If the parent 247 \code{fpa} is not NULL, the \code{parent} link is made and the chip 248 shall be placed in the parent's array of \code{chips}. The 249 \code{cells} array shall be allocated with a zero size, and the 250 metadata containers constructed. The \code{name} shall be used to set 251 \code{CHIP.NAME} in the \code{concepts}. All other pointers in the 252 structure shall be initialized to \code{NULL}. 245 pmChip *pmChipAlloc(psString name); 246 \end{verbatim} 247 The constructor shall make an empty \code{pmChip}. The \code{cells} 248 array shall be allocated with a zero size, the metadata containers 249 constructed, the \code{exists} boolean shall be set to \code{false}, 250 the \code{process} boolean shall be set to \code{true}, andhe 251 \code{name} shall be used to set \code{CHIP.NAME} in the 252 \code{concepts}. All other pointers in the structure shall be 253 initialized to \code{NULL}. 254 255 \tbd{The astrometric transformations will likely disappear into the 256 analysis metadata in the future.} 253 257 254 258 \subsubsection{A Focal Plane} … … 278 282 psMetadata *analysis; // FPA-level analysis metadata 279 283 const psMetadata *camera; // Camera configuration 284 // Levels 280 285 psArray *chips; // The chips 281 p_pmHDU *hdu; // FITS data 282 psMetadata *phu; // Primary Header 286 // Sources 287 pmFile *imageSource; // Image file on disk 288 pmFile *maskSource; // Mask file on disk 289 pmFile *weightSource; // Weight file on disk 283 290 } pmFPA; 284 291 \end{verbatim} … … 289 296 \end{verbatim} 290 297 The constructor shall make an empty \code{pmFPA}. The \code{chips} 291 array shall be allocated with a zero size, the \code{camera} and 292 \code{db} pointers set to the values provided, and the \code{concepts} 293 metadata constructed. All other pointers in the structure shall be 294 initialized to \code{NULL}. 295 298 array shall be allocated with a zero size, the \code{camera} pointer 299 set to the value provided, and the \code{concepts} metadata 300 constructed. All other pointers in the structure shall be initialized 301 to \code{NULL}. 302 303 \tbd{The astrometric transformations will likely disappear into the 304 analysis metadata in the future.} 305 306 \subsubsection{Disk files} 307 308 Each of the levels in the hierarchy have a place to hold a 309 \code{pmFile}, which is the representation of a FITS file and ``header 310 data unit'': 311 \begin{datatype} 312 typedef struct { 313 const char *filename; // Name of file 314 psFits *fits; // FITS file 315 psMetadata *phu; // Primary extension 316 const char *extname; // Extension name, or NULL 317 psMetadata *header; // The FITS header, or NULL if primary 318 psArray *images; // The pixel data 319 psDB *database; // Database handle for concepts 320 } pmFile; 321 \end{datatype} 322 323 324 \subsubsection{Links between levels} 325 326 We provide functions to attach readouts, cells and chips with their 327 parents: 328 \begin{prototype} 329 bool pmReadoutParent(pmReadout *readout, pmCell *cell); 330 bool pmCellParent(pmCell *cell, pmChip *chip); 331 bool pmChipParent(pmChip *chip, pmFPA *fpa); 332 \end{prototype} 333 In the case of \code{pmReadoutParent}, the function shall set the 334 \code{parent} pointer for the \code{readout} to \code{cell}, and add 335 the \code{readout} to the array of \code{readouts} in the \code{cell}. 336 The other cases are similar. \textit{Note that, in order to avoid 337 infinite loops when freeing, the reference counter should \textbf{not} 338 be incremented when attaching to the \code{parent} pointer, and the 339 deallocators should \textbf{not} free the parent.} 340 341 The following functions remove all levels below that specified: 342 \begin{prototype} 343 void pmCellFreeReadouts(pmCell *cell); 344 void pmChipFreeCells(pmChip *chip); 345 void pmFPAFreeChips(pmFPA *fpa); 346 \end{prototype} 296 347 297 348 The inclusion of hierarchical links pointing both down (via the … … 299 350 For this reason, we specify a utility function to manage the 300 351 collection of upward-pointing links: 301 \begin{ verbatim}302 bool pmFPACheck Parents(pmFPA *fpa);303 \end{ verbatim}352 \begin{prototype} 353 bool pmFPACheckLinks(pmFPA *fpa); 354 \end{prototype} 304 355 This function checks the validity of the \code{parent} links in the 305 FPA hierarchy. If a \code{parent} link is not set (or not set 306 correctly), it is corrected, and the function shall return 307 \code{false}. If all the \code{parent} pointers were correct, the 308 function shall return \code{true}. 309 310 311 Each of the levels in the hierarchy have a place to hold a 312 \code{p_pmHDU}, which is the disk representation of the image: 313 \begin{datatype} 314 typedef struct { 315 const char *extname; // Extension name, if it corresponds to this level 316 psMetadata *header; // The FITS header, if it corresponds to this level 317 psArray *images; // The pixel data, if it corresponds to this level 318 psArray *masks; // The mask data, if it corresponds to this level 319 psArray *weights; // The weight data, if it corresponds to this level 320 } p_pmHDU; 321 \end{datatype} 356 FPA hierarchy. If any \code{parent} link in the (entire) hierarchy is 357 not set (or not set correctly), it is corrected, and the function 358 shall return \code{false}. If all the \code{parent} pointers were 359 correct, the function shall return \code{true}. 360 322 361 323 362 \subsection{Detector Coordinate Transformations} 363 364 \tbd{The implementation of this section may change slightly if the 365 coordinate transformations in the focal plane hierarchy are pushed 366 into the metadata --- the math shouldn't change, just how the values 367 are accessed.} 324 368 325 369 \begin{figure} … … 380 424 381 425 \begin{prototype} 382 pmFPA *pmFPAConstruct(const psMetadata *camera, psDB *db); 426 pmFPA *pmFPAConstruct(const psMetadata *camera); 427 bool pmFPADatabase(pmFPA *fpa, psDB *db); 383 428 bool pmFPARead(pmFPA *fpa, psFits *fits); 429 bool pmFPAWrite(psFits *fits, pmFPA *fpa); 384 430 \end{prototype} 385 431 386 432 \code{pmFPAConstruct} shall construct a focal plane hierarchy from a 387 \code{camera} configuration. A \code{db} handle is also provided so 388 that may be set in the \code{pmFPA}. The resultant \code{pmFPA} and 389 its lower-down components shall be ready for to read a FITS file into 390 it by setting the \code{extname} pointers at the appropriate levels to 391 the appropriate FITS extension name. 433 \code{camera} configuration. The resultant \code{pmFPA} and its 434 lower-down components shall be ready for to read a FITS file into it 435 by setting \code{filename} and \code{extname} in the \code{file} 436 pointers at the appropriate levels. 437 438 \code{pmFPADatabase} shall set the \code{database} of the \code{file} 439 pointers within the hierarchy to the supplied \code{db}. 392 440 393 441 \code{pmFPARead} shall read a \code{fits} file (the contents of which 394 442 are described by the previous \code{camera} configuration) into an 395 extant \code{fpa}. This involves reading the headers and pixels, as 396 well as ingesting all the concepts. 443 extant \code{fpa}, for those components which don't already 444 \code{exist} and are marked to be \code{process}ed. This involves 445 reading the headers and pixels into the \code{pmFile}, ingesting all 446 the concepts for that level, and making subimages for the 447 \code{readout->image} (from \code{CELL.TRIMSEC}) and 448 \code{readout->bias} (from \code{CELL.BIASSEC}). 449 450 \code{pmFPAWrite} shall write those elements focal plane hierarchy 451 (\code{fpa}) that \code{exist} and are marked to be \code{process}ed 452 to the specified \code{fits} file, returning \code{true} upon success 453 and \code{false} otherwise. If the provided \code{fits} file is 454 \code{NULL}, the information within the \code{pmFile *image} 455 components is used for the output. The \code{fpa} should contain 456 sufficient information with which to write the FITS images. 457 458 \subsubsection{Mask and weight input/output} 459 460 We carry mask and weight images, since these are useful for downstream 461 processing. A mask value of zero for a pixel shall indicate that the 462 pixel is not suspect. The weight images shall be the variance (the 463 square of the standard deviation). 464 465 We desire to access the mask and weight images without specifying a 466 particular file name. We introduce the \code{SUPPLEMENTARY} metadata 467 entry in the camera configuration file, which allows identification of 468 the location for the mask and weight images, based on the value of 469 some of the ``concepts'': 470 471 \begin{verbatim} 472 # How to get the supplementary stuff: mask and weight 473 SUPPLEMENTARY METADATA 474 MASK.SOURCE STR FILE # Source type for mask: EXT | FILE 475 MASK.NAME STR {FPA.NAME}_mask.fits # Name for mask extension or filename 476 WEIGHT.SOURCE STR EXT # Source type for weight: EXT | FILE 477 WEIGHT.NAME STR {CELL.NAME}_weight.fits # Name for weight extension or filename 478 END 479 \end{verbatim} 480 481 How the mask (or weight) image is stored is specified by the 482 \code{MASK.SOURCE} (or \code{WEIGHT.SOURCE}) keyword. The images may 483 be stored either in the same file as the pixels with a different 484 extension name (\code{EXT}), or they may be stored in a different file 485 with the same extension name (\code{FILE}). The name of the file or 486 extension is specified by the \code{MASK.NAME} (or \code{WEIGHT.NAME}) 487 keyword, with strings within curly brackets interpreted as concepts 488 that must be evaluated and replaced. 489 490 \begin{prototype} 491 pmFPAReadMask(pmFPA *fpa, psFits *fits); 492 pmFPAWriteMask(psFits *fits, pmFPA *fpa); 493 pmFPAReadWeight(pmFPA *fpa, psFits *fits); 494 pmFPAWriteWeight(psFits *fits, pmFPA *fpa); 495 \end{prototype} 496 497 \code{pmFPAReadMask} and \code{pmFPAReadWeight} are very similar to 498 \code{pmFPARead}, except that they shall read the \code{mask} and 499 \code{weight} elements (respectively) of the \code{pmReadout}s 500 comprising the \code{fpa}. 501 502 \code{pmFPAWriteMask} and \code{pmFPAWriteWeight} is very similar to 503 \code{pmFPAWrite}, but it shall write the \code{mask} and 504 \code{weight} elements (respectively) of the \code{pmReadout}s 505 comprising the \code{fpa}. 506 507 We also provide functions to generate the mask and weight images: 508 \begin{prototype} 509 bool pmCellDetectorMask(pmCell *cell); 510 bool pmCellDetectorWeight(pmCell *cell); 511 \end{prototype} 512 513 \code{pmCellPhotonMask} shall set the mask pixels based on the 514 \code{CELL.SATURATION} and \code{CELL.BAD} concepts. 515 \code{pmCellPhotonWeight} shall set the weight image based on the 516 photon statistics using the \code{CELL.GAIN} and \code{CELL.READNOISE} 517 concepts. 518 519 \subsection{Iteration} 520 521 Often we will desire to perform a function on all cells in the focal 522 plane, or all chips, etc. Since this is a common operation, we 523 provide an iterator that performs the mind numbing part: 524 525 \begin{datatype} 526 typedef bool (*pmFPAIterateFunc)(pmFPA *fpa, pmChip *chip, pmCell *cell); 527 \end{datatype} 528 \begin{prototype} 529 bool pmFPAIterate(pmFPA *fpa, bool doCells, pmFPAIterateFunc func); 530 \end{prototype} 531 532 \code{pmFPAIterate} shall iterate through all chips (that \code{exist} 533 and are marked to be \code{process}ed) in the \code{fpa}, and if 534 \code{doCells} is \code{true}, all cells (that \code{exist} and are 535 marked to be \code{process}ed) in those chips. For each, the function 536 shall call the iterator function, \code{func}. 537 538 539 \subsection{Selecting elements of the hierarchy for processing} 397 540 398 541 \begin{prototype} … … 401 544 \end{prototype} 402 545 403 These functions are provided to set the \code{ valid} booleans within546 These functions are provided to set the \code{process} booleans within 404 547 an \code{fpa} so that only certain chips within the FITS file are read 405 548 in. … … 418 561 have \code{valid} set to \code{true}. 419 562 420 \tbd{make these functions richer: select by extention, extname, cell, 421 options to invalidate all / validate all, etc} 563 \tbd{Provide a richer set of functions: select by extension, extname, 564 cell, options to invalidate all / validate all, etc} 565 566 567 \subsection{Mosaicking} 422 568 423 569 \begin{prototype} 424 570 bool pmFPAMorph(pmFPA *toFPA, pmFPA *fromFPA, bool positionDependent, int chipNum, int cellNum); 425 571 \end{prototype} 426 427 572 \code{pmFPAMorph} shall morph the \code{fromFPA} focal plane hierarchy 428 573 to the \code{toFPA} focal plane hierarchy. This allows us to write … … 447 592 suitable error message, in which case it shall return \code{false}. 448 593 449 \begin{prototype} 450 bool pmFPAWrite(psFits *fits, pmFPA *fpa); 451 \end{prototype} 452 453 \code{pmFPAWrite} shall write the focal plane hierarchy, \code{fpa}, 454 to the specified \code{fits} file, returning \code{true} upon success 455 and \code{false} otherwise. The \code{fpa} should contain sufficient 456 information with which to write the FITS images. 457 458 \begin{prototype} 459 pmFPAWriteMask(psFits *fits, pmFPA *fpa); 460 \end{prototype} 461 462 \code{pmFPAWriteMask} is very similar to \code{pmFPAWrite}, but it 463 shall write the \code{mask} elements of the \code{pmReadout}s 464 comprising the \code{fpa}. 465 466 \begin{prototype} 467 pmFPAWriteWeight(psFits *fits, pmFPA *fpa); 468 \end{prototype} 469 470 \code{pmFPAWriteWeight} is very similar to \code{pmFPAWrite}, but it 471 shall write the \code{weight} elements of the \code{pmReadout}s 472 comprising the \code{fpa}. 594 \tbd{Don't code pmFPAMorph --- it's tricky, and maybe unnecessary.} 595 596 \begin{prototype} 597 int pmChipMosaic(pmChip *chip, int xBinChip, int yBinChip); 598 \end{prototype} 599 600 \code{pmChipMosaic} shall mosaic the cells within the provided 601 \code{chip}. The mosaicking shall take into account the offsets of 602 the cells on the chip (\code{CELL.X0,CELL.Y0}), the cell binning 603 (\code{CELL.XBIN,CELL.YBIN}) and the desired (absolute, i.e., relative 604 to the physical pixels) binning level (\code{xBinChip,yBinChip}). The 605 component cells and readouts shall be replaced with a single cell and 606 readout containing the mosaic. \code{file} pointers within the 607 hierarchy and the concepts shall be updated. 608 473 609 474 610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note:
See TracChangeset
for help on using the changeset viewer.
