BitDictionary - EranOfek/AstroPack GitHub Wiki
Description
A class to support storage/read/write of bit dictionaries including basic conversions between bit names, indices and decimal representations.
BitDictionary properties
- BitDictName - Bcit dictionary name. This can be the name of the configuration file containing the bit dictionary (e.g., 'BitMask.Image.Default').
- Dic - Structure array that contains the bit dictionary. This structure has 3 fields: 'BitName', 'BitDescription', and 'BitInd' (start with 0).
Some private properties:
- Nbit - Number of bits.
- Class - Bit class.
and additional hidden constant properties.
Methods
To construct a BitDictionary object:
BD=BitDictionary('BitMask.Image.Default')
% or
BD=BitDictionary
In the following, we are reviewing the available methods for converting between bit indices, bit names, and decimal representations.
BD=BitDictionary
Result = isemptyBitDict(BD)
% To show all available BitMask configuration files
BD = BitDictionary;
[List,Data] = BD.showDictionaries
% Convert an array of bit indices to bit names
[BitName,BitDescription,BitInd]=bitind2name(BD,[1 4;7 12])
% Convert decimal numbers to bit names and indices
[BitName,BitDesc,BitInd]=bitdec2name(BD,[3,1,2^11+7; 1 1 1])
% Convert bit names to bit indices and decimal representation
[BitInd,BitDec,SumBitDec,BitDescription]=name2bit(BD,{'Spike','DeadPix'})
Given a bit mask image, in order to search for pixels in which some specific bits
Search decimal flags array for entries in which all or some bits are open:
BD=BitDictionary
% define a random image of integers
Matrix = uint32(floor(rand(100,100).*1000));
% Look for pixels in which the 'Saturated' bit is on:
% output is a matrix of logical indicating in which pixel the bit is on
[Flag] = findBit(BD, Matrix, {'Saturated'})
% Look for pixels in which the Saturated and BiasFlaring pixels are on:
[Flag] = findBit(BD, Matrix, {'Saturated','BiasFlaring'},'Method','all')
% Look for pixels in which the Saturated or BiasFlaring pixels are on:
% default is any
[Flag] = findBit(BD, Matrix, {'Saturated','BiasFlaring'},'Method','any')
Converting bit mask to flag names.
% load the MergedCat bit mask:
BD = BitDictionary('BitMask.MergedCat.Default');
% convert bit mask decimal 132 to a list of bit mask names:
L=BD.bitdec2name(132);
% present the cell of bit mask names:
L{1}
The default bit mask dictionary
The default bit mask dictionary is stored in the config/ directory (BitMask.Image.Default.yml) and is loaded into the Configuration object.
- Saturated : [0 , 'Pixel is saturated']
- LowRN : [1 , 'Pixel noise is low (Var<median(Var).*0.05) (probably dead)']
- HighRN : [2 , 'Pixel noise is high (Var>10*median(Var)) (noisy pixel)']
- DarkHighVal : [3 , 'Pixel bias/dark value is high (>2*Mean)']
- DarkLowVal : [4 , 'Pixel bias/dark value is low (<0.2*Mean)']
- BiasFlaring : [5 , 'Pixel is possibly flaring (>20 sigma)']
- NaN : [6 , 'Pixel is NaN due to illegal arithmatics']
- FlatHighStd : [7 , 'Flat Std/sqrt(N) is high (Std/sqrt(N)>0.01)']
- FlatLowVal : [8 , 'Flat normalized value is low (<0.1)']
- LowQE : [9 , 'Pixel with low QE (<0.5 from the nominal)']
- Negative : [10 , 'Negative pixel after processing']
- Interpolated : [11 , 'Pixel with interpolated value']
- Hole : [12 , 'Hole (anti-star)']
- Spike : [13 , 'Diffraction spike']
- CR_DeltaHT : [14 , 'CR identified using HT to delta function']
- CR_Laplacian : [15 , 'CR identified using laplacian filter']
- CR_Streak : [16 , 'CR streak']
- Ghost : [17 , 'Ghost']
- Persistent : [18 , 'Persistent charge']
- Xtalk : [19 , 'Cross talk']
- Streak : [20 , 'Streak']
- ColumnLow : [21 , 'Bad column low values']
- ColumnHigh : [22 , 'Bad column high values']
- NearEdge : [23 , 'Near image edge']
- NonLinear : [24 , 'Non linear']
- Bleeding : [25 , 'Possible bleeding/blooming']
- Overlap : [26 , 'In overlap region']
- SrcNoiseDominated: [27 , 'S/N is source dominated (Val-Back)>Back']
- GainHigh : [28 , 'In duel gain-detectors: Gain is high']
- CoaddLessImages : [29 , 'Number of images in coadd is less than X percent']
- SrcDetected : [30 , 'Source detected (all pixels within 1xFWHM radius from detected source)']