Changeset 1436
- Timestamp:
- Aug 9, 2004, 1:20:02 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/modules/ModulesSDRS.tex (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/modules/ModulesSDRS.tex
r1145 r1436 1 %%% $Id: ModulesSDRS.tex,v 1. 9 2004-06-30 10:08:52 price Exp $1 %%% $Id: ModulesSDRS.tex,v 1.10 2004-08-09 23:20:02 price Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 4 4 % basic document variables 5 \title{Pan-STARRS IPP Phase 2}5 \title{Pan-STARRS IPP Modules} 6 6 \subtitle{Supplementary Design Requirements} 7 7 \author{Paul Price} … … 52 52 53 53 This document describes the Pan-STARRS Image Processing Pipeline (IPP) 54 Phase 2 image processing modules. Phase 2 is the processing stage wherein 55 the instrumental signatures are removed from the detector images, in 56 preparation for the combination of multiple images in Phase 4. 57 58 The Phase 2 processing \textit{stage} is composed of several 59 \textit{modules} which perform the individual steps in the processing, 60 each of which will act upon a data element of the appropriate size. 61 For example, the bias subtraction module will act upon a detector 62 ``readout'' (\code{psReadout}). It will be the responsibility of the 63 caller of the Phase 2 processing modules (i.e., the Phase 2 processing 64 stage, which will likely be script written in a high-level language 65 such as \tbd{Python}) to iterate over the components with which it is 66 charged. 54 image processing modules. The modules use the functionality \PS{} 55 Library (PSLib) perform more complex tasks. 56 57 In order to preserve name space, globally-visible structures and 58 functions shall be prefixed with \code{pm}, for ``\PS{} Modules''. 59 60 Modules will be constructed to support each of the processing stages. 61 62 \section{Phase 2} 63 64 Phase 2 is the processing stage wherein the instrumental signatures 65 are removed from the detector images, in preparation for the 66 combination of multiple images in Phase 4. 67 68 The Phase 2 processing stage is composed of several modules which 69 perform the individual steps in the processing, each of which will act 70 upon a data element of the appropriate size. For example, the bias 71 subtraction module will act upon a detector ``readout'' 72 (\code{psReadout}). It will be the responsibility of the caller of 73 the Phase 2 processing modules (i.e., the Phase 2 processing stage, 74 which will likely be a script written in a high-level language such as 75 \tbd{Python}) to iterate over the components with which it is charged. 67 76 68 77 The Phase 2 processing modules are: 69 78 \begin{itemize} 70 \item Read in an FPA;71 \item Calculate the convolution kernel;72 \item Convolve an image with the kernel;73 79 \item Subtract bias; 74 \item Trim an image;75 80 \item Correct for non-linearity; 76 81 \item Flat-field; 77 \item Subtract the background;78 82 \item Mask bad pixels; 83 \item \tbd{Subtract the background;} 79 84 \item \tbd{Mask cosmic rays;} 80 85 \item \tbd{Mask optical defects;} … … 89 94 some of which requires further research to define the best algorithm. 90 95 91 These modules are built on top of, and are dependent upon, the \PS{}92 Library, PSLib. Some functions are specified below which should be93 added to PSLib, since we anticipate that these will also find use in94 other modules.95 96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%97 98 \section{Read in an image}99 100 Of course, before any image manipulation may occur, the image must be101 read in. This involves populating the FPA with structures to102 represent the true focal plane. However, different instruments have103 different focal planes, and the images are written to disk in104 different ways. We have proposed a configuration file format which105 appears to be able to document the structure of a focal plane and106 specify how the IPP can read the required information from the FITS107 files \tbd{A REFERENCE GOES HERE}.108 109 Given an open \code{FILE} pointer to a configuration file,110 \code{config}, and the name of an FPA image, \code{fpaName},111 \code{psFPAGenerate} shall return a \code{psFPA} of the correct112 structure, with all the metadata entries read from the nominated FPA113 image. Astrometric information shall be initialised to values114 specified by the configuration file. The API shall be:115 116 \begin{verbatim}117 psFPA *psFPAGenerate(FILE *config, const char *fpaName);118 \end{verbatim}119 120 Once an FPA has been generated, the pixels may all be read in at once,121 or the pixels may be read in a chip, cell or readout at a time. The122 corresponding APIs are:123 124 \begin{verbatim}125 psFPA *psFPAReadAll(psFPA *in);126 psFPA *psFPAReadChip(psFPA *in, const char *chipName);127 psChip *psChipReadCell(psChip *in, const char *cellName);128 psCell *psCellReadReadout(psCell *in, const char *readoutName);129 \end{verbatim}130 131 Note that reads of a cell or readout do not act upon an FPA, but132 rather a chip and a cell, respectively. This saves the user from133 specifying the name of the FPA, chip, and cell just to get a readout,134 since this information is already stored in the generated \code{psFPA}135 struct.136 137 \tbd{How to write the output???}138 139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%140 141 \section{Convolution}142 143 If images on the sky are obtained in Orthogonal Transfer (OT) mode,144 then the calibration frames used to correct them must be convolved by145 a kernel derived from the list of OT shifts made during the exposure.146 147 \subsection{Kernel definition}148 149 In order to perform a convolution, we need to define the convolution150 kernel. We need a more general object than a \code{psImage} so that151 we can incorporate the offset from the $(0,0)$ pixel to the $(0,0)$152 value of the kernel\footnote{The kernel has both positive and negative153 indices to convey the positive and negative shifts. One might154 consider setting the \code{x0} and \code{y0} members of a155 \code{psImage} to the appropriate offsets, but this is not the purpose156 of these members, and doing so may affect the behavior of other157 \code{psImage} operations.}. Hence we define a \code{psKernel}:158 159 \begin{verbatim}160 /** A convolution kernel */161 typedef struct {162 int xMin, yMin; ///< Most negative indices163 int xMax, yMax; ///< Most positive indices164 float **kernel; ///< The kernel data165 } psKernel;166 \end{verbatim}167 168 The \code{kernel} shall contain the kernel values. The kernel has169 both positive and negative indices to convey the positive and negative170 shifts. The maximum extent of these shifts shall be defined by the171 \code{xMin}, \code{xMax}, \code{yMin} and \code{yMax} members. Note172 that \code{xMin} and \code{yMin}, under normal circumstances, should173 be negative numbers. That is, \code{myKernel->kernel[-3][-2]} may be174 defined if \code{yMin} and \code{xMin} are equal to or more negative175 than -3 and -2, respectively.176 177 Of course, we require the appropriate constructor and destructor:178 \begin{verbatim}179 psKernel *psKernelAlloc(int xMin, int xMax, int yMin, int yMax);180 void psKernelFree(psKernel *myKernel);181 \end{verbatim}182 183 \code{psKernelAlloc} shall allocate a kernel. In the event that one184 of the minimum values is greater than the corresponding maximum value,185 the function shall generate a warning, and the offending values shall186 be exchanged.187 188 \subsection{Calculate the convolution kernel}189 190 Given a list of pixel shifts made in the course of OT guiding,191 \code{psPhase2GetKernel} shall return the appropriate kernel. The API192 shall be the following:193 \begin{verbatim}194 psKernel *psPhase2GetKernel(const psVector *xShifts, const psVector *yShifts);195 \end{verbatim}196 197 The shift vectors, \code{xShifts} and \code{yShifts}, will be supplied198 by the user, most probably from the FITS file containing the image.199 200 The elements of the shift vectors should be of an integer type;201 otherwise the values shall be truncated to integers. The output202 kernel shall be normalized such that the sum over the kernel is unity.203 204 The format of the shifts vectors will be a list of the net shift205 position relative to the starting point for each timestep. In the206 normal course of \PS{} observations using orthogonal transfer, there207 will likely be about 10~Hz $\times$ 30~sec $=$ 300 timesteps.208 209 If the vectors are not of the same number of elements, then the210 function shall generate a warning shall be generated, following which,211 the longer vector trimmed to the length of the shorter, and the212 function shall continue.213 214 \subsection{Convolve an image with the kernel}215 216 Given an input image and the convolution kernel,217 \code{psPhase2ConvolveWithKernel} shall convolve the input image,218 \code{in}, with the kernel, \code{kernel} and return the convolved219 image, \code{out}. The API shall be the following:220 \begin{verbatim}221 psImage *psImageConvolve(psImage *out, const psImage *in, const psKernel *kernel, bool direct);222 \end{verbatim}223 224 Two methods shall be available for the convolution: if \code{direct}225 is \code{true}, then the convolution shall be performed in real space226 (appropriate for small kernels); otherwise, the convolution shall be227 performed using Fast Fourier Transforms (FFTs; appropriate for larger228 kernels).229 230 In the event that \code{out} is \code{NULL}, a new \code{psImage}231 shall be allocated and returned.232 233 \subsection{PSLib Routines}234 235 \code{psKernel} and \code{psImageConvolve} shall be incorporated into236 the \PS{} Library, \code{PSLib}, so that they may be re-used for other237 modules.238 239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%240 241 \section{Bias subtraction and trim}242 243 The following modules correct detector images for the electronic244 pedestal introduced by the readout electronics.245 246 \subsection{Image region specification}247 248 In order to specify regions on the detector image which may be used to249 determine the bias levels (i.e., a prescan or overscan region), we250 define the following structure:251 \begin{verbatim}252 /** Image regions */253 typedef struct {254 const int x0, y0; ///< Offset to region255 const int nX, nY; ///< Size of region256 } psImageRegion;257 \end{verbatim}258 259 A \code{psImageRegion} specifies the offset from $(0,0)$ on the260 detector\footnote{Note that an image may be smaller than the entire261 area of the detector if the detector is windowed, or if a subimage has262 been generated.} and the size of the region.263 264 We also require a corresponding constructor and destructor:265 \begin{verbatim}266 psImageRegion *psImageRegionAlloc(int x0, int y0, int nX, int nY);267 void psImageRegionFree(psImageRegion *reg);268 \end{verbatim}269 270 Multiple image regions may be specified using a linked list271 (\code{psList}) of \code{psImageRegion}s.272 273 \subsection{Splines}274 275 A spline is a popular choice for fitting 1D data, such as overscans,276 but we neglected to define them for PSLib. We now define277 one-dimensional cubic splines, \code{psSpline1D}, which shall be278 incorporated into PSLib:279 280 \begin{verbatim}281 /** A 1D cubic-spline */282 typedef struct {283 int n; ///< Number of spline pieces284 float *coeff[4]; ///< Coefficients. There are 4 coefficients for each spline piece.285 float *coeffErr[4]; ///< Errors in the coefficients.286 bool *mask[4]; ///< Mask for the coefficients.287 float *domains; ///< The boundaries between each spline piece. Size is n+1.288 } psSpline1D;289 \end{verbatim}290 291 The \code{psSpline1D} structure is very similar to that of the292 one-dimensional Chebyshev polynomial, \code{psPolynomial1D},293 except for the following:294 \begin{itemize}295 \item Each spline piece has 4 coefficients (with corresponding error296 and mask), corresponding to each of the zeroth through third order297 coefficients of a cubic; and298 \item It includes an additional member, \code{domains}, which299 specifies the boundaries between each spline piece (including the two300 ends).301 \end{itemize}302 303 Of course, we require the appropriate constructors and destructor:304 \begin{verbatim}305 psSpline1D *psSpline1DAlloc(int n, float min, float max);306 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds);307 void psSpline1DFree(psSpline1D *mySpline);308 \end{verbatim}309 310 \code{psSpline1DAlloc} shall allocate and return a \code{psSpline1D},311 setting the \code{domains} on the basis of the input number of spline312 pieces, \code{n}, and the minimum (\code{min}) and maximum313 (\code{max}) data values.314 315 \code{psSpline1DAllocGeneric} shall allocate and return a316 \code{psSpline1D}, using the \code{bounds} to define the number of317 spline pieces and the \code{domains}.318 319 \code{psSpline1DFree} shall free the given spline, and its members.320 321 Also, as for the polynomials, we require an evaluator. Given a322 \code{spline} and ordinate at which to evaluate, \code{x},323 \code{psSpline1DEval} shall evaluate and return the value of the324 spline at the ordinate. If the ordinate is outside the bounds, then325 the function shall generate a warning, and extrapolate the spline to326 the ordinate and return the value.327 328 \begin{verbatim}329 float psSpline1DEval(const psSpline1D *spline, float x);330 \end{verbatim}331 332 333 96 \subsection{Bias subtraction} 334 97 \label{sec:bias} 335 98 99 The bias subtraction module provides a facility to correct detector 100 images for the electronic pedestal introduced by the readout 101 electronics. 102 336 103 Given an input image and various other parameters, 337 \code{p sPhase2SubtractBias} shall subtract the bias from the image.104 \code{pmSubtractBias} shall subtract the bias from the image. 338 105 The API shall be the following: 339 106 \begin{verbatim} 340 psReadout *psPhase2SubtractBias(psReadout *in, void *fitSpec, psOverscanAxis overscanAxis, psFit fit, 341 int nBin, const psList *regions, const psStats *stat, const psImage *bias); 107 psReadout *pmSubtractBias(psReadout *in, void *fitSpec, const psList *overscans, 108 pmOverscanAxis overscanAxis, const psStats *stat, 109 int nBin, psFit fit, const psReadout *bias); 342 110 \end{verbatim} 343 111 344 112 The input image, \code{in}, shall have the bias subtracted in-place. 345 113 346 The type of the overscan fit specification, \code{fitSpec}, shall be114 The type of the overscan fit function, \code{fitSpec}, shall be 347 115 dependent upon the value of \code{fit}, which specifies the type of 348 116 fit to be employed. \code{fit} is an enumerated type: 349 117 350 118 \begin{verbatim} 351 /** Fit type */119 /** Fit types */ 352 120 typedef enum { 353 PS_FIT_NONE, ///< No fit 354 PS_FIT_LINEAR, ///< Do linear interpolation 355 PS_FIT_POLYNOMIAL, ///< Fit polynomial 356 PS_FIT_CHEBYSHEV, ///< Fit chebyshev 357 PS_FIT_SPLINE ///< Fit cubic splines 358 } psFit; 359 \end{verbatim} 360 361 If \code{fitSpec} is \code{NULL}, or \code{fit} is \code{PS_FIT_NONE}, 362 then no fit shall be performed to the overscan. If \code{fit} is 363 \code{PS_FIT_LINEAR}, then the function shall perform simple linear 364 interpolation between points in the overscan. Otherwise, 121 PM_FIT_NONE, ///< No fit 122 PM_FIT_POLYNOMIAL, ///< Fit polynomial 123 PM_FIT_SPLINE ///< Fit cubic splines 124 } pmFit; 125 \end{verbatim} 126 127 If \code{fitSpec} is \code{NULL}, or \code{fit} is \code{PM_FIT_NONE}, 128 then no fit shall be performed to the overscan. Otherwise, 365 129 \code{fitSpec} shall be interpreted to be a structure of the 366 appropriate type (\code{psPolynomial1D} for \code{PS_FIT_POLYNOMIAL} 367 and \code{PS_FIT_CHEBYSHEV}, and \code{psSpline1D} for 368 \code{PS_FIT_SPLINE}), and the overscan shall be fit using the 369 specified functional form. Upon return, the \code{fitSpec} shall 370 contain the coefficients of the overscan fit. 130 appropriate type (\code{psPolynomial1D} for \code{PM_FIT_POLYNOMIAL}, 131 and \code{psSpline1D} for \code{PM_FIT_SPLINE}), and the overscan 132 shall be fit using the specified functional form. Upon return, the 133 \code{fitSpec} shall contain the coefficients of the overscan fit. 134 135 The prescan and/or overscan regions to be used are specified in 136 \code{overscans}, which is a linked list of subimages. If 137 \code{overscans} is non-\code{NULL} and \code{overscanAxis} is not 138 \code{PM_OVERSCAN_NONE}, then the function shall generate a warning. 371 139 372 140 The \code{overscanAxis} specifies how the prescan/overscan subtraction … … 375 143 /** Overscan axis */ 376 144 typedef enum { 377 P S_OVERSCAN_NONE, ///< No overscan subtraction378 P S_OVERSCAN_ROWS, ///< Subtract rows379 P S_OVERSCAN_COLUMNS, ///< Subtract columns380 P S_OVERSCAN_ALL ///< Subtract the statistic of all pixels in overscan region381 } p sOverscanAxis;382 \end{verbatim} 383 384 If the \code{overscanAxis} is \code{P S_OVERSCAN_NONE}, then the145 PM_OVERSCAN_NONE, ///< No overscan subtraction 146 PM_OVERSCAN_ROWS, ///< Subtract rows 147 PM_OVERSCAN_COLUMNS, ///< Subtract columns 148 PM_OVERSCAN_ALL ///< Subtract the statistic of all pixels in overscan region 149 } pmOverscanAxis; 150 \end{verbatim} 151 152 If the \code{overscanAxis} is \code{PM_OVERSCAN_NONE}, then the 385 153 function shall not perform any overscan subtraction. If the 386 \code{overscanAxis} is \code{P S_OVERSCAN_ALL}, then all the overscan154 \code{overscanAxis} is \code{PM_OVERSCAN_ALL}, then all the overscan 387 155 regions shall be used to generate a single statistic (specified by 388 156 \code{stat}) which shall be subtracted from the entire image. A 389 157 warning shall be generated if the \code{overscanAxis} is 390 \code{PS_OVERSCAN_NONE} or \code{PS_OVERSCAN_ALL} and the \code{fit} 391 is not \code{PS_FIT_NONE}. 392 393 If the \code{overscanAxis} is \code{PS_OVERSCAN_ROWS} or 394 \code{PS_OVERSCAN_COLUMNS}, then the overscan shall be reduced to a 395 single vector in the dimension specified using the specified statistic 396 (\code{stat}). If \code{nBin} is positive and less than the dimension 397 of the vector, then the vector shall subsequently be binned down into 398 \code{nBin} bins, again using the specified statistic (\code{stat}). 399 If the overscan is not defined for each row/column, then the function 400 shall generate a warning and then interpolate using the provided 401 functional form if \code{fit} is not \code{PS_FIT_NONE}; 402 otherwise, the function shall generate an error. 403 404 The prescan and/or overscan regions to be used are specified in 405 \code{regions}, which is a linked list of \code{psImageRegion}s. If 406 \code{regions} is non-\code{NULL} and \code{overscanAxis} is not 407 \code{PS_OVERSCAN_NONE}, then the function shall generate a warning. 158 \code{PM_OVERSCAN_NONE} or \code{PM_OVERSCAN_ALL} and the \code{fit} 159 is not \code{PM_FIT_NONE}. 160 161 If the \code{overscanAxis} is \code{PM_OVERSCAN_ROWS} or 162 \code{PM_OVERSCAN_COLUMNS}, then the overscan shall be reduced to a 163 single vector (in the specified dimension) using the specified 164 statistic (\code{stat}). 408 165 409 166 The statistic to use in combining multiple pixels in the … … 418 175 \code{PS_STAT_ROBUST_MODE}. 419 176 177 If \code{nBin} is positive and less than the dimension 178 of the vector, then the vector shall subsequently be binned down into 179 \code{nBin} bins, again using the specified statistic (\code{stat}). 180 If the overscan is not defined for each row/column, then the function 181 shall generate a warning and then interpolate using the provided 182 functional form if \code{fit} is not \code{PM_FIT_NONE}; 183 otherwise, the function shall generate an error. 184 185 Following any binning, the vector shall be fit by the functional form 186 specified by \code{fit} (see above). Then the overscan shall be 187 subtracted from the image, using values from the fit if \code{fit} is 188 not \code{PM_FIT_NONE}; otherwise using values from the overscan vector 189 if \code{overscanAxis} is not \code{PM_OVERSCAN_ALL}; otherwise using 190 the appropriate statistic applied to all the prescan/overscan pixels. 191 420 192 A bias (or dark) image shall be subtracted pixel-by-pixel from the 421 193 input image if \code{bias} is non-NULL. Note that the input image, … … 426 198 image is too small (i.e., pixels on the input image refer to pixels 427 199 outside the range of the \code{bias} image), the function shall 428 generate an error. 429 430 431 \subsection{Trim} 432 433 Given an input image and region to keep, \code{psPhase2Trim} shall 434 trim the input image, \code{in}, leaving only the specified region, 435 \code{region}. The API shall be the following: 436 \begin{verbatim} 437 psReadout *psPhase2Trim(psReadout *in, const psImageRegion *region); 438 \end{verbatim} 439 440 Note that the trim shall be performed on the input image in-place, so 441 that the input image is modified. 442 443 The offset of the input image (\code{in->x0} and \code{in->y0}) shall 444 be updated to reflect the trim. 445 446 The function shall generate an error if the \code{region} is outside 447 the bounds of the input image. 448 449 \subsection{PSLib} 450 451 The \code{psSpline1D} and \code{psFit} shall be incorporated into 452 PSLib. 453 454 455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 456 457 \section{Preparation for photometry} 458 459 The following modules take an image and process it so that counts are 460 proportional to the flux from an astronomical source. 200 generate an error. Any pixels masked in the \code{bias} shall also be 201 masked in the output. 202 203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 461 204 462 205 \subsection{Non-linearity} … … 466 209 the correction. 467 210 468 The first, \code{p sPhase2NonLinearityPolynomial} shall correct the469 i nput image for non-linearity by applying the given polynomial,211 The first, \code{pmNonLinearityPolynomial} shall correct the input 212 image for non-linearity by applying the given polynomial, 470 213 \code{coeff}, to the flux of each pixel in the input image, \code{in}. 471 214 The API shall be the following: 472 215 473 216 \begin{verbatim} 474 /** Applies the correction for detector non-linearity. */ 475 psReadout *psPhase2CorrectNonLinearity(psReadout *in, const psPolynomial1D *coeff); 217 psReadout *pmNonLinearityPolynomial(psReadout *in, const psPolynomial1D *coeff); 476 218 \end{verbatim} 477 219 … … 479 221 caller, likely from the image metadata. 480 222 481 The second function, \code{p sPhase2NonLinearityLookup} shall correct223 The second function, \code{pmNonLinearityLookup} shall correct 482 224 the input image for non-linearity by using a lookup table. The API 483 225 shall be the following: 484 226 485 227 \begin{verbatim} 486 psReadout *p sPhase2NonLinearityLookup(psReadout *in, const psVector *inFlux, const psVector *outFlux);228 psReadout *pmNonLinearityLookup(psReadout *in, const psVector *inFlux, const psVector *outFlux); 487 229 \end{verbatim} 488 230 … … 495 237 to be pre-sorted. 496 238 497 Both \code{psPhase2NonLinearityPolynomial} and 498 \code{psPhase2NonLinearityLookup} shall modify the input image 499 in-place. 239 If the particular value of a pixel is not found in the \code{inFlux} 240 vector, the corresponding \code{outFlux} shall be calculated through 241 linear interpolation. 242 243 In the event that the \code{inFlux} vector does not contain two or 244 more entries (necessary for linear interpolation), then the function 245 shall generate a warning, and make no correction to any of the pixels. 246 247 Both \code{pmNonLinearityPolynomial} and \code{pmNonLinearityLookup} 248 shall modify the input image in-place. 500 249 501 250 \subsection{Flat-fielding} 502 251 503 Given an input image and a flat-field image, \code{p sPhase2FlatField}252 Given an input image and a flat-field image, \code{pmFlatField} 504 253 shall divide the input image by the flat-field image. The API shall 505 254 be the following: 506 255 \begin{verbatim} 507 psReadout *p sPhase2FlatField(psReadout *in, const psImage*flat);256 psReadout *pmFlatField(psReadout *in, const psReadout *flat); 508 257 \end{verbatim} 509 258 … … 519 268 520 269 Pixels which are negative or zero in the \code{flat} shall be masked 521 in the input image with the value \code{PS_MASK_FLAT} (see 522 \S\ref{sec:maskValues}). 270 in the input image with the value \code{PM_MASK_FLAT} (see 271 \S\ref{sec:maskValues}). Negative pixels in the \code{flat} may be 272 set to zero so that they are treated identically to zeroes. And 273 pixels masked in the \code{flat} shall be masked in the \code{output}. 523 274 524 275 The function shall not normalize the \code{flat}; this responsibility 525 276 is left to the caller. This function is basically equivalent to a 526 divide, but with care for the region that is divided. 277 divide (with \code{psImageOp}), but with care for the region that is 278 divided, checking for negative pixels, and copying of the mask from 279 the \code{flat} to the output. 280 281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 282 283 \subsection{Masking} 284 285 The following modules mask various defects on an image. 286 287 \subsubsection{Mask values} 288 \label{sec:maskValues} 289 290 We define several mask values for use in the phase 2 processing: 291 \begin{verbatim} 292 /** Mask values */ 293 typedef enum { 294 PM_MASK_TRAP, ///< The pixel is a charge trap 295 PM_MASK_BADCOL, ///< The pixel is a bad column 296 PM_MASK_SAT, ///< The pixel is saturated 297 PM_MASK_FLAT, ///< The pixel is non-positive in the flat-field 298 PM_MASK_CR_MORPH ///< The pixel is determined to be a cosmic ray, from morphology 299 } pmMaskValue; 300 \end{verbatim} 301 302 Of these, masks for the charge traps need to be grown by the extent of 303 the OT convolution kernel. For other pixel types, orthogonal transfer 304 of the flux in this pixel will not (necessarily) affect the flux in 305 neighbouring pixels. 306 307 \subsubsection{Bad pixels} 308 309 Given an input image, \code{in}, a bad pixel \code{mask}, a 310 corresponding value in the bad pixel mask to mask in the input image, 311 \code{maskVal}, a saturation level, and a growing radius, 312 \code{pmMaskBadPixels} shall mask in the input image those 313 pixels in the bad pixel mask that match the value to mask. The API 314 shall be the following: 315 \begin{verbatim} 316 psReadout *pmMaskBadPixels(psReadout *in, const psImage *mask, int maskVal, float sat, int grow); 317 \end{verbatim} 318 319 Note that the input image, \code{in}, is modified in-place. All 320 pixels in the \code{mask} which satisfy the \code{maskVal} shall have 321 their corresponding pixels in the input image, \code{in}, along with 322 all pixels within the \code{grow} radius masked. Pixels which have 323 flux greater than \code{sat} shall also be masked, but not grown. 324 325 Note that the input image, \code{in}, and the \code{mask} need not be 326 the same size, since the input image may already have been trimmed 327 (following overscan subtraction), but the function shall use the 328 offsets in the image (\code{in->x0} and \code{in->y0}) to determine 329 the appropriate offsets to obtain the correct pixel on the mask. In 330 the event that the \code{mask} image is too small (i.e., pixels on the 331 input image refer to pixels outside the range of the \code{mask} 332 image), the function shall generate an error. 333 334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 335 \bibliographystyle{plain} 336 \bibliography{panstarrs} 337 338 \end{document} 339 340 341 342 527 343 528 344 \subsection{Subtract sky} … … 577 393 578 394 579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%580 581 \section{Masking}582 583 The following modules mask various defects on an image.584 585 \subsection{Mask values}586 \label{sec:maskValues}587 588 We define several mask values for use in the phase 2 processing:589 \begin{verbatim}590 /** Mask values */591 typedef enum {592 PS_MASK_TRAP, ///< The pixel is a charge trap593 PS_MASK_BADCOL, ///< The pixel is a bad column594 PS_MASK_SAT, ///< The pixel is saturated595 PS_MASK_FLAT, ///< The pixel is non-positive in the flat-field596 PS_MASK_CR_MORPH ///< The pixel is determined to be a cosmic ray, from morphology597 } psMaskValue;598 \end{verbatim}599 600 Of these, masks for the charge traps need to be grown by the601 extent of the OT convolution kernel. For other pixel types,602 orthogonal transfer of the flux in this pixel will not (necessarily)603 affect the flux in neighbouring pixels604 605 \subsection{Bad pixels}606 607 Given an input image, \code{in}, a bad pixel \code{mask}, a608 corresponding value in the bad pixel mask to mask in the input image,609 \code{maskVal}, a saturation level, and a growing radius,610 \code{psPhase2MaskBadPixels} shall mask in the input image those611 pixels in the bad pixel mask that match the value to mask. The API612 shall be the following:613 \begin{verbatim}614 psReadout *psPhase2MaskBadPixels(psReadout *in, const psImage *mask, int maskVal, float sat, int grow);615 \end{verbatim}616 617 Note that the input image, \code{in}, is modified in-place. All618 pixels in the \code{mask} which satisfy the \code{maskVal} shall have619 their corresponding pixels in the input image, \code{in}, along with620 all pixels within the \code{grow} radius masked. Pixels which have621 flux greater than \code{sat} shall also be masked, but not grown.622 623 624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%625 626 627 628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%629 \bibliographystyle{plain}630 \bibliography{panstarrs}631 632 \end{document}633 634 395 \subsection{Cosmic rays} 635 396 … … 776 537 not all of which may correspond to legal positions on the input chip, 777 538 \code{in}. 539 540 541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 542 543 \section{Read in an FPA} 544 545 \TBD{This section on reading in an FPA is all TBD and should not be 546 implemented yet.} 547 548 Of course, before any image manipulation may occur, the image must be 549 read in. This involves populating the FPA with structures to 550 represent the true focal plane. However, different instruments have 551 different focal planes, and the images are written to disk in 552 different ways. We have proposed a configuration file format which 553 appears to be able to document the structure of a focal plane and 554 specify how the IPP can read the required information from the FITS 555 files \tbd{REFERENCE}. 556 557 Given an open \code{FILE} pointer to a configuration file, 558 \code{config}, and the name of an FPA image, \code{fpaName}, 559 \code{psFPAGenerate} shall return a \code{psFPA} of the correct 560 structure, with all the metadata entries read from the nominated FPA 561 image. Astrometric information shall be initialised to values 562 specified by the configuration file. The API shall be: 563 564 \begin{verbatim} 565 psFPA *psFPAGenerate(FILE *config, const char *fpaName); 566 \end{verbatim} 567 568 Once an FPA has been generated, the pixels may all be read in at once, 569 or the pixels may be read in a chip, cell or readout at a time. The 570 corresponding APIs are: 571 572 \begin{verbatim} 573 psFPA *psFPAReadAll(psFPA *in); 574 psFPA *psFPAReadChip(psFPA *in, const char *chipName); 575 psChip *psChipReadCell(psChip *in, const char *cellName); 576 psCell *psCellReadReadout(psCell *in, const char *readoutName); 577 \end{verbatim} 578 579 Note that reads of a cell or readout do not act upon an FPA, but 580 rather a chip and a cell, respectively. This saves the user from 581 specifying the name of the FPA, chip, and cell just to get a readout, 582 since this information is already stored in the generated \code{psFPA} 583 struct. 584 585 \tbd{Writing the output} 586 587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 588
Note:
See TracChangeset
for help on using the changeset viewer.
