Changeset 2504 for trunk/doc/modules/ModulesSDRS.tex
- Timestamp:
- Nov 26, 2004, 3:48:49 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/modules/ModulesSDRS.tex (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/modules/ModulesSDRS.tex
r2335 r2504 1 %%% $Id: ModulesSDRS.tex,v 1.2 1 2004-11-11 04:01:43 price Exp $1 %%% $Id: ModulesSDRS.tex,v 1.22 2004-11-27 01:48:49 eugene Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 4 4 % basic document variables 5 \title{Pan-STARRS Image Processing Pipeline Modules}5 \title{Pan-STARRS PS-1 Image Processing Pipeline Modules} 6 6 \subtitle{Supplementary Design Requirements} 7 7 \shorttitle{Modules SDRS} … … 11 11 \project{Pan-STARRS Image Processing Pipeline} 12 12 \organization{Institute for Astronomy} 13 \version{0 1}13 \version{02} 14 14 \docnumber{PSDC-430-012} 15 15 … … 34 34 35 35 \DocumentsInternal 36 PSCD- 130-001 & PS-1 Design Reference Mission \\ \hline37 PS CD-430-004 & Pan-STARRSIPP C Code Conventions \\ \hline38 PS CD-430-005 & Pan-STARRS IPP SRS\\ \hline39 PS CD-430-006 & Pan-STARRS IPP ADD\\ \hline40 PS CD-430-008 & Pan-STARRS IPP Architecture SDR \\36 PSCD-230-001 & PS-1 Design Reference Mission \\ \hline 37 PSDC-430-004 & Pan-STARRS PS-1 IPP C Code Conventions \\ \hline 38 PSDC-430-005 & Pan-STARRS PS-1 IPP Software Requirements Specification \\ \hline 39 PSDC-430-006 & Pan-STARRS PS-1 IPP Algorithm Design Document \\ \hline 40 PSDC-430-011 & Pan-STARRS PS-1 IPP System/Subsystem Design Description \\ \hline 41 41 \DocumentsExternal 42 42 Posix Standard & Open Group Based Specifications Issue 6, IEEE Std 1003.1, 2003 \\ … … 52 52 53 53 This document describes the Pan-STARRS Image Processing Pipeline (IPP) 54 image processing modules. The modules use the functionality of the 55 \PS{} Library (PSLib) to perform more complex tasks. They will 56 eventually be tied together, employing a script written in a 57 high-level language to form a ``processing stage''. Modules will be 58 constructed to support each of the required processing stages, and are 59 listed in this document according to the particular processing stage 60 for which they will primarily be used. 54 data analysis Modules. The Modules use the functionality of the 55 Pan-STARRS Library (PSLib) to perform more complex tasks, especially 56 tasks which require assumptions of astronomical analysis or the data 57 organization. Within the IPP, the Modules are tied together into 58 programs which perform complete data analysis tasks (an ``analysis 59 stage''). The modules may be tied together within a C framework or 60 using a high-level scripting language. Bindings of the Modules are 61 made available to the scripting language using the program SWIG. 61 62 62 63 In order to preserve name space, globally-visible structures and 63 functions shall be prefixed with \code{pm}, for ``\PS{} Modules''. 64 64 functions shall be prefixed with \code{pm}, for ``Pan-STARRS 65 Modules''. 66 67 \section{Runtime Configuration Data} 68 69 PSLib defines a \code{psMetadata} structure which can carry labeled 70 data of arbirtary types. The associated functions implemented by 71 PSLib consist of tools to manipulate and extract data from 72 \code{psMetadata} collections. Within PSLib, the \code{psMetadata} 73 stucture is used to carry the data from a FITS header. In addition, 74 functions are available to fill a \code{psMetadata} collection from a 75 text-based configuration file using a particular syntax, and to fill a 76 \code{psMetadata} collection from a properly formatted XML document. 77 78 In the IPP Modules, we use \code{psMetadata} collections to carry 79 run-time configuration data used by the data analysis modules. Below, 80 in the discussion of the various modules, this configuration 81 information is defined by specifying the name of the data item of 82 interest, the conceptual meaning of that data item, and the allowed 83 values for the data item. In this section, we discuss top-level 84 concepts related to the configuration information, including the 85 sources of the run-time configuration data and special 86 operations used to extract information from the configuration system. 87 88 \subsection{Configuration Data Sources} 89 90 All modules need to load some configuration information defining 91 parameters which may be configured at run-time. Some module require 92 only a basic amount of information, while others require configuration 93 information defining the camera or details of an analysis (the {\it 94 recipe}). We define three utility functions to load these files from 95 standard locations, with optional command-line override values. 96 97 \begin{verbatim} 98 bool pmConfigLoadSite (psMetadata **site, int *argc, char **argv); 99 bool pmConfigLoadCamera (psMetadata **camera, psMetadata *site, psMetadata *header, int *argc, char **argv); 100 bool pmConfigLoadRecipe (psMetadata **recipe, psMetadata *camera, int *argc, char **argv, char *script); 101 \end{verbatim} 102 103 \code{pmConfigLoadSite} loads basic configuration information from a 104 general configuration file. By default, this file has the name 105 \code{~/.ipprc} in the user's home directory. This file may be 106 overridden on the command line with the optional flag \code{-site 107 (file)}. 108 109 % eventually, we should define the complete sequence: 110 % $FOO, ~/.foorc, /prefix/config/foorc 111 112 \code{pmConfigLoadCamera} loads camera configuration information from 113 a file which depends on the camera of interest. In some cases, the 114 camera may be determined from the header of an image currently in 115 hand. In other cases, the camera must be specified without reference 116 to a file. This function attempts to determine the appropriate camera 117 configuration file by examining, in order, the command-line options, 118 the header data, and the site configuration data. The camera config 119 file may be specified on the command line with the option 120 \code{-camera (file)}. If this does not exist, the 121 \code{pmConfigLoadCamera} examines the provided header to determine 122 the camera by using the function \code{pmCameraFromHeader} (defined 123 below). If this fails, the function attempts to determine the camera 124 from the provided site config data, looking for the keyword 125 \code{CAMERA} in the site config data. The camera name is used to 126 select the camera configuration file, defined in the site 127 configuration file with the keyword \code{CAMERA.name}, where 128 \code{name} is substituted with the name of the camera. 129 130 \code{pmConfigLoadRecipe} loads the recipe configuration information 131 from a file which depends on the camera of interest and the particular 132 analysis task. The camera configuration file must define recipe files 133 for each of the analysis tasks of interest. The function attempts to 134 load the recipe file using the keyword \code{RECIPE.name}, where 135 \code{name} is substituted with the name of the analysis task, for 136 example \code{PHASE2}. The choice of the recipe file may be 137 overridden on the command line with the option \code{-recipe (file)}. 138 139 \subsection{Indirect Configuration Data} 140 141 Some configuration data is not provided directly by the configuration 142 files. Instead, the configuration system provides a mechanism to 143 define indirect references to configuration data. Three indirect 144 configuration data sources are currently defined: data from a FITS 145 header, data from the Metadata Database, and data from the Pan-STARRS 146 Status Server. The configuration data may specify that a certain 147 value is provided by one of these mechanisms. 148 149 In order to specify that the configuration data should be derived from 150 a FITS header, the data value is given in the form: \code{HD:KEYWORD}, 151 where \code{KEYWORD} specifies the keyword to be used in search the 152 FITS header. 153 154 If the data is to be extracted from the Metadata Database, the data 155 value is given in the form: \code{MD:TABLE,FIELD,KEY}. In this case, 156 \code{TABLE} specifies the Metadata Database table to be used to find 157 the value, \code{FIELD} specifies the field in that table to be used, 158 and \code{KEY} specifies the value of the primary key which gives the 159 value of interest. 160 161 If the data is to be extracted from the Status Server, the data value 162 is given in the form: \code{SS:PATH}. In this case, \code{PATH} 163 specifies the Status Server path to the data value of interest. 164 165 {\bf \it note that the Metadata Database and Status Server 166 interactions require us to define the APIs for these interactions. 167 These two methods are not available until the MD and SS APIs are 168 defined.} 169 170 As an example, consider the definition of the data region of an image. 171 This value is frequenty represented in the FITS header with the 172 keyword \code{DATASEC}. However, in some cameras, this value may not 173 be defined, or another value may be used. We must be able to flexibly 174 define both the appropriate keyword, or the actual value, if known. 175 These two cases may be written as follows, using the configuration 176 file format parsed by \code{psMetadataParseConfig}: 177 \begin{verbatim} 178 DATA.REGION STR [1:100,2:400] 179 DATA.REGION STR HD:DATASEC 180 \end{verbatim} 181 In the first case, the data provided in the configuration file is the 182 data of interest. (\code{[1:100,2:400]}). In the second case, the 183 three-character code \code{HD:} specifies that the value of interest 184 may be determined by searching for the value associated with the 185 header keyword \code{DATASEC}. 186 187 We provide utilities functions to extract this type of potentially 188 indirect configuration information. We provide four functions 189 returning four data types. The first three return the value from the 190 appropriate location assuming the data type to be \code{char*}, 191 \code{psS32}, and \code{psF64}. The fourth version searches for a 192 string which is passed to the function \code{psRegionFromString} 193 before being returned as a \code{psRegion} pointer. 194 195 \begin{verbatim} 196 psSTR pmConfigLookupSTR (psMetadata *config, psMetadata *header, char *name); 197 psS32 pmConfigLookupS32 (psMetadata *config, psMetadata *header, char *name); 198 psF64 pmConfigLookupF64 (psMetadata *config, psMetadata *header, char *name); 199 psRegion *pmConfigLookupRegion (psMetadata *config, psMetadata *header, char *name); 200 \end{verbatim} 201 202 \section{Camera Data Organization \& Camera Geometry} 203 204 We require several utility functions to define the geometry of the 205 detectors in a camera and to specify the organization of the camera 206 data in real FITS images. The camera data organization is defined in 207 a set of \code{psMetadata} structures, and may be stored on disk in 208 the file format parsed by \code{psMetadataParseConfig}. 209 210 PSLib defines a hierarchy of data structures related to the 211 organization of the pixels in a camera. These structures, starting 212 from the top level, follow the sequence \code{psFPA}, \code{psChip}, 213 \code{psCell}, \code{psReadout}, \code{psImage}. Each lower level 214 structure is carried as an array in the higher level. The containers 215 as defined by PSLib include functions which specify the astrometric 216 relationships between these levels, and provide a single 217 \code{psMetadata} container pointer for each level. In this section, 218 we define the type of metadata is stored in these metadata containers 219 and how the image headers are parse to define the data hierarchy in 220 memory. 221 222 \subsection{Camera Config Data \& the {\tt psFPA}} 223 224 A relevant collection of metadata is the externally supplied camera 225 definition metadata loaded with the function 226 \code{pmConfigLoadCamera}. This metadata defines the expected layout 227 of a specific camera along with information detailing how to interpret 228 the headers for an image from that camera. The camera metadata 229 consists of keyword / value pairs which are relevant to the entire 230 camera, and a set of metadata collections specified for each cell. 231 This top-level metadata is added to the \code{psFPA} with the name 232 'CAMERA.LAYOUT'. For example: 233 \begin{verbatim} 234 fpa->metadata = psMetadataAdd (fpa->metadata, PS_LIST_TAIL, "CAMERA", PS_META_META, "camera", camera); 235 \end{verbatim} 236 The specific cell-level entries are also placed on the correpsonding 237 \code{psCell} elements. These entries are added to the metadata with 238 the name 'CELL': 239 \begin{verbatim} 240 cell->metadata = psMetadataAdd (cell->metadata, PS_LIST_TAIL, "CELL", PS_META_META, "cell", cellMD); 241 \end{verbatim} 242 243 \subsection{FITS File Data Representations} 244 245 Within the FITS data representation, there are various choices which 246 can and have been made for the placement of the pixels in a data file. 247 In the simplest case, the camera consists of a single chip consisting 248 of a single cell always read with a single readout. In this case, the 249 image data could be written as part of the primary data unit. In a 250 more complex case with multiple chips and multiple cells, the data may 251 be organized in various ways. The data may be distributed into 252 multiple files or in multiple FITS data extensions. A single camera 253 image may be written as a collection of files for individual chips 254 with separate extensions for each cell (CFH12K.split, GPC). Another 255 camera may write a single file with multiple extensions for each cell 256 (Megacam.raw), or multiple extensions per chip, which each cell 257 representing portions of the chip image (Megacam.splice, CFHT-IR). 258 259 In all of these representations, there are only two principal 260 distinctions in how the pixel data is stored. Either a single data 261 block (a single FITS image) represents only a single cell, or it 262 represents a collection of cells. This affects the way in which an 263 image is read in, the way the header is associated with a level of the 264 data hierarchy, and the way in which the header keywords are 265 interpretted to define the layout of the pixels in the cell. We 266 distinguish these two cases as 'cell-based' and 'chip-based' layout. 267 268 The FITS headers are attached to the \code{psFPA} data hierarchy by 269 adding them to the \code{psMetadata} entries for the appropriate data 270 level. Each of the data levels \code{psFPA}, \code{psChip}, and 271 \code{psCell} have \code{metadata} elements to store relevant metadata 272 of any type. A FITS header metadata collection may be added to one of 273 these metadata collections using the metadata name 'HEADER': 274 \begin{verbatim} 275 fpa->metadata = psMetadataAdd (fpa->metadata, PS_LIST_TAIL, "HEADER", PS_META_META, "header", header); 276 \end{verbatim} 277 278 In 'cell-based' layout, the headers are attached to the corresponding 279 \code{psCell} element. In 'chip-based' layout, the headers are 280 attached to the \code{psChip} element. This difference is natural 281 since a 'cell-based' data file has one FITS extension, and therefore 282 one FITS header, for each \code{cell}. Conversely, in a 'chip-based' 283 data file, there is one extension per chip, and therefore multiple 284 cells for each FITS header, but only one chip for each FITS header. 285 286 \subsection{Determine the Camera from the Primary Header} 287 288 \begin{verbatim} 289 char *pmCameraFromHeader (psFitsHeader *header, psMetadata *rules); 290 \end{verbatim} 291 292 This function examines a primary header unit (\code{header}) and 293 determines the camera which provided the data. The rules which 294 identify the camera are defined as a \code{psMetadata} structure 295 containing one element for each known camera. These are generally to 296 be provided as part of the site configuration information. The 297 elements of this \code{psMetadata} container are in turn 298 \code{psMetadata} containers consisting of the expected header 299 keywords and their required values. The function 300 \code{pmCameraFromHeader} tests each of the defined cameras in 301 succession. For each camera, it searches for each of the given 302 keywords and compares the value with the value expected. If the 303 keyword does not exist, or if the keyword has the wrong value, the 304 camera is rejected. The name of first camera which matches the header 305 is returned as an allocated string. If no match is found, the 306 returned value must be \code{UNKNOWN}. This condition may be treated 307 by calling functions as either an error or only a warning. If an 308 error is encountered in parsing the metadata containers, then 309 \code{NULL} is returned. An example of the metadata keyword / value 310 pairs is given below (note that this uses an undefined metadata config 311 file representation \code{METADATA}): 312 313 \begin{verbatim} 314 CFH12K.MEF METADATA 315 TELESCOP STR CFHT 316 INSTRUME STR CFH12K 317 EXTEND BOOL T 318 NEXTEND S32 12 319 END 320 321 CFH12K.SPLIT METADATA 322 TELESCOP STR CFHT 323 INSTRUME STR CFH12K 324 EXTEND BOOL F 325 END 326 \end{verbatim} 327 328 \begin{figure} 329 \begin{center} 330 \psfig{file=CameraHierarchy,width=5.0in} 331 \caption{Camera Data and Metadata Hierarchy\label{CameraHierarchy}} 332 \end{center} 333 \end{figure} 334 335 \subsection{Validate the Header set \& Construct the FPA} 336 337 \begin{verbatim} 338 bool pmCameraValidateHeaders (psMetadata *headers, psMetadata *camera); 339 psFPA *pmFPAfromHeader (psMetadata *headers, psMetadata *camera); 340 \end{verbatim} 341 342 These funtions examine the collection of \code{headers} and compare 343 them with the camera definitions in the metadata structure 344 \code{camera}. One function (\code{pmFPAfromHeader}) uses the header 345 set and camera definition file to construct a \code{psFPA} with all 346 \code{psChip} and \code{psCell} entries allocated, but without any 347 \code{psReadout} or pixel data. The other function validates the 348 header set against the camera definition, but does not actually 349 construct the \code{psFPA}. 350 351 The camera definition metadata collection defines the relationship 352 between chips, cells, and the FITS extensions. An example of the data 353 needed by \code{pmCameraValidateHeaders} and \code{pmFPAfromHeader} is 354 given below for several types of cameras in the form of a metadata 355 config file. 356 357 \begin{verbatim} 358 MEGACAM.RAW METADATA 359 NCELL S32 72 360 CELL.FMT STR CELL.%02d 361 EXT.TYPE STR CELL 362 EXT.KEY STR EXTNAME 363 PHU STR FPA 364 # 365 # EXT.KEY CHIP 366 CELL.00 CELL amp00 CHIP.00 367 CELL.01 CELL amp01 CHIP.00 368 CELL.02 CELL amp02 CHIP.01 369 CELL.03 CELL amp03 CHIP.01 370 ... 371 END 372 373 MEGACAM.SPLICE METADATA 374 NCELL S32 36 375 CELL.FMT STR CELL.%02d 376 EXT.TYPE STR CHIP 377 EXT.KEY STR EXTNAME 378 PHU STR FPA 379 # 380 # EXT.KEY CHIP 381 CELL.00 CELL ccd00 CHIP.00 382 CELL.01 CELL ccd00 CHIP.00 383 CELL.02 CELL ccd01 CHIP.01 384 CELL.03 CELL ccd01 CHIP.01 385 ... 386 END 387 388 CFH12K.SPLIT METADATA 389 NCELL S32 12 390 CELL.FMT STR CELL.%02d 391 EXT.TYPE STR CELL 392 EXT.KEY STR EXTNAME 393 PHU STR NONE 394 # 395 # EXT.KEY CHIP 396 CELL.00 CELL chip00 CHIP.00 397 CELL.01 CELL chip01 CHIP.01 398 CELL.02 CELL chip02 CHIP.02 399 ... 400 END 401 402 GPC.RAW METADATA 403 NCELL S32 4096 404 CELL.FMT STR CELL.%04d 405 EXT.TYPE STR CELL 406 EXT.KEY STR EXTNAME 407 PHU STR CHIP 408 # 409 # EXT.KEY CHIP 410 CELL.0000 CELL amp00 CHIP.00 411 CELL.0001 CELL amp01 CHIP.00 412 CELL.0002 CELL amp02 CHIP.00 413 CELL.0003 CELL amp03 CHIP.00 414 ... 415 CELL.0065 CELL amp03 CHIP.01 416 CELL.0066 CELL amp03 CHIP.01 417 ... 418 END 419 \end{verbatim} 420 421 Among the important elements of the camera definition information are: 422 \begin{itemize} 423 \item \code{NCELL} - this defines the possible number of cells from this 424 camera. 425 \item \code{CELL.FMT} - this defines the format of the \code{CELL.nn} 426 keywords below in the metadata collection, one for each of the 427 \code{NCELL} values 428 \item \code{EXT.TYPE} - this defines the lowest data level 429 corresponding to a single FITS extension: \code{CELL} or 430 \code{CHIP}. In some cases, a single extension represents a chip, 431 and is subdivided into cells by header keywords specifying certain 432 regions. In other cases, a single extension represents only the 433 data from a single amplifier, ie, a cell. These two cases require 434 somewhat different handling. 435 \item \code{EXT.KEY} - this entry defines a header keyword which 436 allows the unique identification of a given header with one of the 437 cell or chip entries (depending on the value of \code{EXT.TYPE}). 438 \item \code{PHU} - this entry defines the meaning of the FITS file 439 primary header unit. 440 \end{itemize} 441 In addition to these generic parameters, the camera definition 442 metadata includes an entry for each cell giving specific values 443 required to define that cell. 444 445 Both functions \code{pmCameraValidateHeaders} and 446 \code{pmFPAfromHeader} must start with the set of headers and attempt 447 to identify the corresponding cell or chip. All available cells and 448 chips must be identified, and the cells corresponding to each chip 449 must be tracked. In the case of \code{pmCameraValidateHeaders}, the 450 function must only verify the headers contain valid extensions, 451 without allocating the correpsonding \code{psFPA}, while 452 \code{pmFPAfromHeader} must also allocate the \code{psFPA}, the 453 contained \code{psChip} arrays, and the correct number of 454 \code{psCell} arrays for each \code{psChip}. 455 456 These functions also add to the metadata containers for the chips and 457 cells, following the rules discussed above. Each \code{psCell} entry 458 should have the \code{CELL} metadata lines from above attached to the 459 \code{psCell.metadata} element as an additional metadata collection 460 with the name \code{CELL.LAYOUT}. The complete camera metadata 461 collection (including the cells), are attached to the 462 \code{psFPA.metadata} element with the name \code{CAMERA.LAYOUT}. The 463 image header data are also attached to metadata entries, at a level 464 which depends on the value of \code{EXT.TYPE} in the camera layout 465 data above. If the value is \code{CELL}, the header metadata 466 collections are attached to the \code{psCell.metadata} elements with 467 the name \code{HEADER}. If the value of \code{EXT.TYPE} is chip, the 468 header metadata is attached to the \code{psChip.metadata} element, 469 again with the name \code{HEADER}. 470 471 An image file may also have a primary header unit which is not 472 associated with a data block. This metadata block must also be added 473 to the data heirarchy so successive operations may update the metadata 474 as needed. The disposition of the primary header unit is defined by 475 the camera layout key \code{PHU}. If this has a value of \code{NONE}, 476 there is no primary header unit, or it should be ignored. If the 477 value is \code{FPR}, the primary header data is attached to the 478 \code{psFPA.metadata} element with the value PHU. Alternatively, if 479 it has the value \code{CHIP}, then the primary header metadata is 480 attached to the \code{psChip.metadata} element. 481 482 \subsection{Coordinate Transforms and Header Data} 483 \tbd{the algorithms for three functions in this section are not 484 well-defined. do not code yet}. 485 486 Astrometric and geometric information about an image from a camera may 487 be represented in a variety of ways. A crude representation of the 488 pixel geometry is specified in many image headers using the IRAF-style 489 region keywords \code{DATASEC}, \code{DETSEC}, etc. These keywords 490 are used to define the location of a single image's pixels in the 491 frame of the full mosaic of detectors in the assumption that the 492 mosaic can be represented as a single uniform grid of pixels. An 493 alternative set of keywords have been used in cases where multiple 494 cells are saved together in a single FITS image extension. More 495 sophisticated astrometric representations require elements to define 496 projections, scaling, distortion, etc. Several versions of header 497 keywords have been used to represent these astrometric 498 transformations. In this section, we define three functions to 499 interpret a collection of image headers and construct the appropriate 500 offset and/or astrometry parameters. 501 502 \begin{verbatim} 503 bool pmFPADefineOffsets (psFPA fpa); 504 bool pmFPADefineWCS (psFPA fpa); 505 bool pmFPADefineWCSfromOffsets (psFPA fpa); 506 \end{verbatim} 507 508 The first function takes a \code{psFPA} structure which has been 509 populated with header and camera configuration metadata in the 510 appropriate locations as discussed above. Using the information in 511 the camera config metadata and the headers, the function sets the 512 values for the elements \code{psChip.col0,row0}, 513 \code{psCell.col0,row0}, \code{psReadout.col0,row0}, 514 \code{psReadout.colParity,rowParity}, and 515 \code{psReadout.colBinning,rowBinning}. This information is 516 determined by examining the regions defined by the following names. 517 518 % how do we handle the CCDSUM keyword case? 519 \begin{verbatim} 520 psCell.metadata:CELL:CCDBIN1 $\rightarrow$ psReadout.colBins 521 psCell.metadata:CELL:CCDBIN2 $\rightarrow$ psReadout.rowBins 522 523 DETSEC from psCell.metadata:CELL:DETSEC 524 CCDSEC from psCell.metadata:CELL:CCDSEC 525 DATASEC from psCell.metadata:CELL:DATASEC 526 527 if (DETSEC.x0 > DETSEC.x1) then psReadout.colParity = -1 528 if (DETSEC.y0 > DETSEC.y1) then psReadout.rowParity = -1 529 \end{verbatim} 530 531 The second function examines the contents of the headers of the chips 532 and cells and constructs the collection of astrometric coordinate 533 transformations.. 534 535 The third function uses the offset information and the basic telescope 536 pointing information to construct a approximate guess at the 537 astrometric coefficients based on the detector geometry. 538 539 \begin{figure} 540 \begin{center} 541 \psfig{file=CameraLayout,width=5.5in} 542 \caption{Camera Pixel Layout\label{CameraLayout}} 543 \end{center} 544 \end{figure} 545 546 \begin{figure} 547 \begin{center} 548 \psfig{file=CameraRegionKeywords.ps,width=5.5in} 549 \caption{Camera Region Keyword Definitions\label{CameraRegionKeywords}} 550 \end{center} 551 \end{figure} 552 553 \subsection{Chip \& Cell from FITS File} 554 \tbd{the algorithm for the function in this section is not 555 well-defined. do not code yet}. 556 557 When loading data from disk, it is may be necessary to use the 558 information in the DATASEC and DETSEC entries to determine which part 559 of the image should be read. If the data is stored in a chip-based 560 format, then the data for each cell corresponds to only a fraction of 561 the pixels stored in a single image extension. We specify the 562 following function to perform the correct read of data from a FITS 563 file into the corresponding \code{psCell} entry respecting the 564 boundaries of the cells within chip-based images. 565 566 \begin{verbatim} 567 psReadout *pmReadoutLoad (psReadout *input, psFits *f, psCell *cell, int plane); 568 \end{verbatim} 65 569 66 570 \section{Phase 2} … … 76 580 \item Flat-field; 77 581 \item Mask bad pixels; 78 \item \tbd{Subtract the background;}582 \item Subtract the background; 79 583 \item \tbd{Mask cosmic rays;} 80 584 \item \tbd{Mask optical defects;} … … 358 862 image), the function shall generate an error. 359 863 360 361 362 \section{Calibration}363 364 The calibration module essentially consists of combining multiple365 images of a particular type in order to build up signal-to-noise. For366 this, we require a general purpose image combination module. We367 forsee this module as only acting upon data from the same detector,368 and so each input image will have the same noise characteristics.369 370 \begin{verbatim}371 typedef struct {372 psStats *stats; // Statistics to use in combining pixels373 unsigned int maskVal, // Mask pixels where mask & maskVal == 1374 float fracHigh; // Fraction of high pixels to throw375 float fracLow; // Fraction of low pixels to throw376 int nKeep; // Number of pixels to be sure to keep377 } pmCombineParams;378 379 psImage *380 pmReadoutCombine(psImage *output, // Output image, or NULL381 const psList *inputs, // List of input readouts382 pmCombineParams *params, // Combination parameters383 const psVector *zero, // Offsets to apply for each image384 const psVector *scale, // Scales to apply for each image385 bool applyZeroScale, // Are zero and scale for application, or only noise properties?386 float gain, // Gain in e/ADU387 float readnoise // Read noise in e388 );389 \end{verbatim}390 391 \code{pmReadoutCombine} combines input images pixel by pixel --- for392 each pixel of the output image, a stack of contributing input pixels393 is formed and combined. Several of its input parameters are lists or394 vectors, and if these are not all of the same length (or \code{NULL}),395 the module shall generate an error and return \code{NULL}.396 397 If the provided \code{output} is \code{NULL}, then the module shall398 allocate a new image of sufficient size for the input images. If the399 \code{output} image is non-\code{NULL} and is not of sufficient size400 for the combined image, the module shall generate an error and return401 \code{NULL}.402 403 If the \code{inputs} is \code{NULL}, the module shall generate an404 error and return \code{NULL}. Otherwise, the \code{inputs} shall be a405 list of \code{psReadout}s. The images contained within the406 \code{psReadout}s need not all be of the same size, but the module407 shall take into account the offsets (\code{col0,row0}) from the corner408 of the detector when comparing pixels, so that it is the same409 \textit{physical} pixels that are combined.410 411 The parameters used in the combination, including how the pixels are412 to be combined, and how the rejection is performed is contained within413 the \code{params}, which may not be \code{NULL} (otherwise the module414 shall generate an error and return \code{NULL}). We choose to use415 this structure instead of supplying the values separately in order to416 keep down the number of parameters to \code{pmReadoutCombine}; the417 \code{psCombineParams} may be recycled for subsequent calls to418 \code{pmReadoutCombine} since the values are not dependent upon the419 choice of inputs, but merely specify how the combination is to be420 performed.421 422 The particular statistic specified by \code{stats} shall be used to423 combine each stack of pixels from the input images. Only one of the424 statistics choices may be specified, otherwise the module shall425 generate an error and return \code{NULL}.426 427 If the \code{maskVal} is non-zero, then pixels in the \code{mask} of428 each \code{psReadout} in the \code{inputs} which satisfy the429 \code{maskVal} shall not have the corresponding pixels placed in the430 stack for combination.431 432 After masking, but before performing the combination, the highest433 \code{fracHigh} fraction and lowest \code{fracLow} fraction of pixels434 in the stack are immediately rejected, unless this would leave less435 than \code{nKeep} pixels in the stack, in which case no immediate436 rejection is performed.437 438 If the \code{zero} vector is non-\code{NULL} and \code{applyZeroScale}439 is \code{true}, then the appropriate values shall be added to the440 \code{inputs} before rejection is performed. If \code{zero} is441 non-\code{NULL} and \code{applyZeroScale} is false, then the values442 shall only be used in calculating the noise.443 444 If the \code{scale} vector is non-\code{NULL} and445 \code{applyZeroScale} is \code{true}, then the appropriate values446 shall multiply the \code{inputs} before rejection is performed. If447 \code{scale} is non-\code{NULL} and \code{applyZeroScale} is false,448 then the values shall only be used in calculating the noise.449 450 The purpose of \code{applyZeroScale} is to allow combination of fringe451 frames, where the frames have been deliberately sky-subtracted and452 rescaled (to get the fringes amplitudes running from -1 to 1), which453 actions should not be undone when combining, but yet it is desirable454 to provide the \code{zero} and \code{scale} values so that the correct455 noise properties are used in the combination.456 457 If the \code{gain} and \code{readnoise} are positive and non-negative458 (respectively), then these shall be used to provide weights for the459 combination using Poisson statistics.460 461 The \code{inputs, zero} and \code{scale} may be of S16, S32 and F32462 types, and must all be of the same type. The \code{output} shall be463 of the same type.464 465 \section{Camera Configutation Information}466 467 \tbd{these function are not yet ready for implementation. The APIs468 are fine but the algorithms need to be specified.}469 470 We require several utility functions to define the general layout of a471 camera and to relate the camera definition to the header in a given472 camera. This information may be passed to the modules by using the473 configuration files as parse by \code{psMetadataParseConfig}. These474 475 \begin{verbatim}476 char *pmCameraFromHeader (psFitsHeader *header);477 \end{verbatim}478 This function examines a primary header unit (\code{header}) and479 determines the camera which provided the data. \tbr{the rules for480 performing this analysis probably depend on the keywords such as481 INSTRUME and TELESCOP. Should this function be a script so we can482 easily add a new camera or should the rule set be defined by483 configuration information?}.484 485 \begin{verbatim}486 bool pmCameraValidateHeaders (psHash *headers, psMetadata *camera);487 \end{verbatim}488 This funtion examines the collection of \code{headers} and, based on489 the camera definitions in the metadata \code{camera}, determines if490 the header set is consistent with the specified camera.491 492 \begin{verbatim}493 psFPA *pmFPAfromHeader (psList *header, psMetadata *camera);494 \end{verbatim}495 This funtion uses the collection of \code{headers} and the camera496 definitions in the metadata \code{camera} to construct a complete497 \code{psFPA} structure which represents the data described by the498 collection of \code{headers}. The resulting \code{FPA} has all499 possible structure elements defined but no space for pixel data should500 be allocated.501 502 \section{Revision Change Log}503 \input{ChangeLogSDRS.tex}504 505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%506 \bibliographystyle{plain}507 \bibliography{panstarrs}508 509 \end{document}510 511 864 \subsection{Subtract sky} 512 513 \tbd{This is a simple sky subtraction routine. A more complicated514 routine will be specified in the future, following research into the515 best algorithm.}516 865 517 866 Given an input image, a polynomial or spline specifying the order of a 518 867 desired fit, a binning factor and statistics to use for the binning, 519 along with a clipping level, \code{p sPhase2SubtractSky} shall fit and868 along with a clipping level, \code{pmSubtractSky} shall fit and 520 869 subtract a model for the background of the image. The API shall be 521 870 the following: 522 871 \begin{verbatim} 523 psReadout *p sPhase2SubtractSky(psReadout *in, void *fitSpec, psFit fit, int binFactor, psStats *stats,524 float clipSD);872 psReadout *pmSubtractSky(psReadout *in, void *fitSpec, psFit fit, int binFactor, 873 psStats *stats, float clipSD); 525 874 \end{verbatim} 526 875 527 876 Note that the input image, \code{in}, shall be subtracted in-place. 528 877 The function shall return the subtracted image, and also update the 529 polynomial, chebyshev or spline specified by \code{fitSpec}, to hold878 polynomial, Chebyshev or spline specified by \code{fitSpec}, to hold 530 879 the coefficients used in the subtraction. 531 880 … … 560 909 561 910 911 \section{Calibration} 912 913 The calibration module essentially consists of combining multiple 914 images of a particular type in order to build up signal-to-noise. For 915 this, we require a general purpose image combination module. We 916 forsee this module as only acting upon data from the same detector, 917 and so each input image will have the same noise characteristics. 918 919 \begin{verbatim} 920 typedef struct { 921 psStats *stats; // Statistics to use in combining pixels 922 unsigned int maskVal, // Mask pixels where mask & maskVal == 1 923 float fracHigh; // Fraction of high pixels to throw 924 float fracLow; // Fraction of low pixels to throw 925 int nKeep; // Number of pixels to be sure to keep 926 } pmCombineParams; 927 928 psImage * 929 pmReadoutCombine(psImage *output, // Output image, or NULL 930 const psList *inputs, // List of input readouts 931 pmCombineParams *params, // Combination parameters 932 const psVector *zero, // Offsets to apply for each image 933 const psVector *scale, // Scales to apply for each image 934 bool applyZeroScale, // Are zero and scale for application, or only noise properties? 935 float gain, // Gain in e/ADU 936 float readnoise // Read noise in e 937 ); 938 \end{verbatim} 939 940 \code{pmReadoutCombine} combines input images pixel by pixel --- for 941 each pixel of the output image, a stack of contributing input pixels 942 is formed and combined. Several of its input parameters are lists or 943 vectors, and if these are not all of the same length (or \code{NULL}), 944 the module shall generate an error and return \code{NULL}. 945 946 If the provided \code{output} is \code{NULL}, then the module shall 947 allocate a new image of sufficient size for the input images. If the 948 \code{output} image is non-\code{NULL} and is not of sufficient size 949 for the combined image, the module shall generate an error and return 950 \code{NULL}. 951 952 If the \code{inputs} is \code{NULL}, the module shall generate an 953 error and return \code{NULL}. Otherwise, the \code{inputs} shall be a 954 list of \code{psReadout}s. The images contained within the 955 \code{psReadout}s need not all be of the same size, but the module 956 shall take into account the offsets (\code{col0,row0}) from the corner 957 of the detector when comparing pixels, so that it is the same 958 \textit{physical} pixels that are combined. 959 960 The parameters used in the combination, including how the pixels are 961 to be combined, and how the rejection is performed is contained within 962 the \code{params}, which may not be \code{NULL} (otherwise the module 963 shall generate an error and return \code{NULL}). We choose to use 964 this structure instead of supplying the values separately in order to 965 keep down the number of parameters to \code{pmReadoutCombine}; the 966 \code{psCombineParams} may be recycled for subsequent calls to 967 \code{pmReadoutCombine} since the values are not dependent upon the 968 choice of inputs, but merely specify how the combination is to be 969 performed. 970 971 The particular statistic specified by \code{stats} shall be used to 972 combine each stack of pixels from the input images. Only one of the 973 statistics choices may be specified, otherwise the module shall 974 generate an error and return \code{NULL}. 975 976 If the \code{maskVal} is non-zero, then pixels in the \code{mask} of 977 each \code{psReadout} in the \code{inputs} which satisfy the 978 \code{maskVal} shall not have the corresponding pixels placed in the 979 stack for combination. 980 981 After masking, but before performing the combination, the highest 982 \code{fracHigh} fraction and lowest \code{fracLow} fraction of pixels 983 in the stack are immediately rejected, unless this would leave less 984 than \code{nKeep} pixels in the stack, in which case no immediate 985 rejection is performed. 986 987 If the \code{zero} vector is non-\code{NULL} and \code{applyZeroScale} 988 is \code{true}, then the appropriate values shall be added to the 989 \code{inputs} before rejection is performed. If \code{zero} is 990 non-\code{NULL} and \code{applyZeroScale} is false, then the values 991 shall only be used in calculating the noise. 992 993 If the \code{scale} vector is non-\code{NULL} and 994 \code{applyZeroScale} is \code{true}, then the appropriate values 995 shall multiply the \code{inputs} before rejection is performed. If 996 \code{scale} is non-\code{NULL} and \code{applyZeroScale} is false, 997 then the values shall only be used in calculating the noise. 998 999 The purpose of \code{applyZeroScale} is to allow combination of fringe 1000 frames, where the frames have been deliberately sky-subtracted and 1001 rescaled (to get the fringes amplitudes running from -1 to 1), which 1002 actions should not be undone when combining, but yet it is desirable 1003 to provide the \code{zero} and \code{scale} values so that the correct 1004 noise properties are used in the combination. 1005 1006 If the \code{gain} and \code{readnoise} are positive and non-negative 1007 (respectively), then these shall be used to provide weights for the 1008 combination using Poisson statistics. 1009 1010 The \code{inputs, zero} and \code{scale} may be of S16, S32 and F32 1011 types, and must all be of the same type. The \code{output} shall be 1012 of the same type. 1013 1014 \section{Revision Change Log} 1015 \input{ChangeLogSDRS.tex} 1016 1017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1018 \bibliographystyle{plain} 1019 \bibliography{panstarrs} 1020 1021 \end{document} 1022 562 1023 \subsection{Cosmic rays} 563 1024 … … 705 1166 \code{in}. 706 1167 707 708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%709 710 \section{Read in an FPA}711 712 \TBD{This section on reading in an FPA is all TBD and should not be713 implemented yet.}714 715 Of course, before any image manipulation may occur, the image must be716 read in. This involves populating the FPA with structures to717 represent the true focal plane. However, different instruments have718 different focal planes, and the images are written to disk in719 different ways. We have proposed a configuration file format which720 appears to be able to document the structure of a focal plane and721 specify how the IPP can read the required information from the FITS722 files \tbd{REFERENCE}.723 724 Given an open \code{FILE} pointer to a configuration file,725 \code{config}, and the name of an FPA image, \code{fpaName},726 \code{psFPAGenerate} shall return a \code{psFPA} of the correct727 structure, with all the metadata entries read from the nominated FPA728 image. Astrometric information shall be initialised to values729 specified by the configuration file. The API shall be:730 731 \begin{verbatim}732 psFPA *psFPAGenerate(FILE *config, const char *fpaName);733 \end{verbatim}734 735 Once an FPA has been generated, the pixels may all be read in at once,736 or the pixels may be read in a chip, cell or readout at a time. The737 corresponding APIs are:738 739 \begin{verbatim}740 psFPA *psFPAReadAll(psFPA *in);741 psFPA *psFPAReadChip(psFPA *in, const char *chipName);742 psChip *psChipReadCell(psChip *in, const char *cellName);743 psCell *psCellReadReadout(psCell *in, const char *readoutName);744 \end{verbatim}745 746 Note that reads of a cell or readout do not act upon an FPA, but747 rather a chip and a cell, respectively. This saves the user from748 specifying the name of the FPA, chip, and cell just to get a readout,749 since this information is already stored in the generated \code{psFPA}750 struct.751 752 \tbd{Writing the output}753 754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note:
See TracChangeset
for help on using the changeset viewer.
