MUSE Pipeline Reference Manual  1.0.2
muse_quality.h
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set sw=2 sts=2 et cin: */
3 /*
4  * This file is part of the MUSE Instrument Pipeline
5  * Copyright (C) 2005-2014 European Southern Observatory
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 #ifndef MUSE_QUALITY_H
22 #define MUSE_QUALITY_H
23 
24 /*---------------------------------------------------------------------------*
25  * Includes *
26  *---------------------------------------------------------------------------*/
27 #include <cpl.h>
28 #include "muse_image.h"
29 
30 #include "muse_cplwrappers.h"
31 
32 /*---------------------------------------------------------------------------*
33  * Defines *
34  *---------------------------------------------------------------------------*/
35 
39 /* Euro3D bad pixel states (be sure to use unsigned numbers) */
40 #define EURO3D_GOODPIXEL 0
41 #define EURO3D_TELLURIC (1ul << 0) /* uncorrected */
42 #define EURO3D_TELLCOR (1ul << 1) /* corrected */
43 #define EURO3D_COSMICRAY (1ul << 5) /* uncorrected */
44 #define EURO3D_LOWQEPIXEL (1ul << 6)
45 #define EURO3D_HOTPIXEL (1ul << 8)
46 #define EURO3D_DARKPIXEL (1ul << 9)
47 #define EURO3D_SATURATED (1ul << 12)
48 #define EURO3D_DEADPIXEL (1ul << 13)
49 #define EURO3D_BADOTHER (1ul << 14) /* other kind of bad pixel */
50  /* used for non-positive pixels in flat-fields */
51 #define EURO3D_OBJECT (1ul << 25) /* for object masks, see *
52  * muse_sky_subtract_simple() */
53 #define EURO3D_MUSE_TRAP (1ul << 29)
54 #define EURO3D_MISSDATA (1ul << 30)
55 #define EURO3D_OUTSDRANGE (1ul << 31)
56 #define EURO3D_ALLBITS 0xFFFFul
57 
59 
60 /*----------------------------------------------------------------------------*
61  * Inline functions *
62  *----------------------------------------------------------------------------*/
63 
64 /*---------------------------------------------------------------------------*/
72 /*---------------------------------------------------------------------------*/
73 static inline cpl_boolean
74 muse_quality_is_usable(uint32_t aState, uint32_t aInclude)
75 {
76  return (aState == EURO3D_GOODPIXEL) ||
77  !(aState ^ aInclude);
78 } /* muse_quality_is_usable() */
79 
82 /*---------------------------------------------------------------------------*
83  * Function prototypes *
84  *---------------------------------------------------------------------------*/
85 int muse_quality_dark_badpix(muse_image *, double, double);
86 int muse_quality_bad_columns(muse_image *, double, double);
87 int muse_quality_flat_badpix(muse_image *, cpl_table *, double, double);
89 cpl_table *muse_quality_convert_dq(cpl_image *);
90 cpl_error_code muse_quality_merge_badpix(cpl_table *, const cpl_table *);
91 int muse_quality_image_reject_using_dq(cpl_image *, cpl_image *, cpl_image *);
92 
93 cpl_table *muse_quality_merge_badpix_from_file(const cpl_table *, const char *, const char *, int *);
94 cpl_error_code muse_quality_copy_badpix_table(const char *, const char *, int, const cpl_table *);
95 
96 #endif /* MUSE_QUALITY_H */
int muse_quality_flat_badpix(muse_image *, cpl_table *, double, double)
Find bad (especially dark) pixels (in a master flat).
Definition: muse_quality.c:315
cpl_table * muse_quality_convert_dq(cpl_image *)
Convert a data quality (DQ) image extension to a bad pixel table.
Definition: muse_quality.c:511
int muse_quality_bad_columns(muse_image *, double, double)
Find bad columns (in a master bias).
Definition: muse_quality.c:193
cpl_error_code muse_quality_copy_badpix_table(const char *, const char *, int, const cpl_table *)
Copy bad pixel table on disk, replacing the table in one extension.
Definition: muse_quality.c:764
cpl_table * muse_quality_merge_badpix_from_file(const cpl_table *, const char *, const char *, int *)
Merge bad pixel table in memory with table from file on disk.
Definition: muse_quality.c:698
static cpl_boolean muse_quality_is_usable(uint32_t aState, uint32_t aInclude)
Check for usable pixel quality given a bitmask of usable states.
Definition: muse_quality.h:74
Structure definition of MUSE three extension FITS file.
Definition: muse_image.h:40
int muse_quality_set_saturated(muse_image *)
Set all pixels above the saturation limit in the bad pixel image.
Definition: muse_quality.c:473
const muse_cpltable_def muse_badpix_table_def[]
cpl_error_code muse_quality_merge_badpix(cpl_table *, const cpl_table *)
Merge two bad pixel tables.
Definition: muse_quality.c:567
int muse_quality_dark_badpix(muse_image *, double, double)
Find bad (especially hot) pixels (in a master dark).
Definition: muse_quality.c:80
Definition of a cpl table structure.
int muse_quality_image_reject_using_dq(cpl_image *, cpl_image *, cpl_image *)
Reject pixels of one or two images on a DQ image.
Definition: muse_quality.c:628