LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Namespaces | Classes | Functions
lsst::ip::isr Namespace Reference

Namespaces

 assembleCcdTask
 
 calibType
 
 crosstalk
 
 fringe
 
 isrFunctions
 
 isrMock
 
 isrQa
 
 isrTask
 
 linearize
 
 masking
 
 measureCrosstalk
 
 overscan
 
 straylight
 
 version
 
 vignette
 

Classes

class  CountMaskedPixels
 

Functions

template<typename PixelT >
int applyLookupTable (afw::image::Image< PixelT > &image, ndarray::Array< PixelT, 1, 1 > const &table, PixelT indOffset)
 Add the values in a lookup table to an image, e.g. More...
 
template<typename PixelT >
size_t maskNans (afw::image::MaskedImage< PixelT > const &mi, afw::image::MaskPixel maskVal, afw::image::MaskPixel allow=0)
 Mask NANs in an image. More...
 
template<typename ImagePixelT , typename FunctionT >
void fitOverscanImage (std::shared_ptr< lsst::afw::math::Function1< FunctionT > > &overscanFunction, lsst::afw::image::MaskedImage< ImagePixelT > const &overscan, double ssize=1., int sigma=1)
 
 PYBIND11_MODULE (applyLookupTable, mod)
 
 PYBIND11_MODULE (isr, mod)
 
template int applyLookupTable< float > (afw::image::Image< float > &, ndarray::Array< float, 1, 1 > const &, float)
 
template int applyLookupTable< double > (afw::image::Image< double > &, ndarray::Array< double, 1, 1 > const &, double)
 
std::string between (std::string &s, char ldelim, char rdelim)
 
template void fitOverscanImage (std::shared_ptr< afw::math::Function1< double > > &overscanFunction, afw::image::MaskedImage< float > const &overscan, double ssize, int sigma)
 
template void fitOverscanImage (std::shared_ptr< afw::math::Function1< double > > &overscanFunction, afw::image::MaskedImage< double > const &overscan, double ssize, int sigma)
 
template size_t maskNans< float > (afw::image::MaskedImage< float > const &, afw::image::MaskPixel, afw::image::MaskPixel)
 
template size_t maskNans< double > (afw::image::MaskedImage< double > const &, afw::image::MaskPixel, afw::image::MaskPixel)
 

Function Documentation

◆ applyLookupTable()

template<typename PixelT >
int lsst::ip::isr::applyLookupTable ( afw::image::Image< PixelT > &  image,
ndarray::Array< PixelT, 1, 1 > const &  table,
PixelT  indOffset 
)

Add the values in a lookup table to an image, e.g.

for non-linearity correction

The algorithm is as follows: numOutOfRange = 0 For each i,j of the image: lookupInd = int(indOffset + image[i,j]) if lookupInd not in range [0, table.size() - 1]: set lookupInd to nearest edge and increment numOutOfRange image[i,j] += table[lookupInd] return numOutOfRange

Parameters
[in,out]imageimage to which to add the values; modified in place
[in]tablelookup table
[in]indOffsetscalar added to image value before truncating to lookup column
Returns
the number of pixels whose values were out of range

Definition at line 35 of file applyLookupTable.cc.

39  {
40  if (table.size() == 0u) {
41  throw LSST_EXCEPT(
42  pex::exceptions::LengthError,
43  "Lookup table has zero size."
44  );
45  }
46  int numOutOfRange = 0;
47  int const maxLookupCol = table.size() - 1;
48  for (int col = 0, imHeight = image.getHeight(); col < imHeight; ++col) {
49  for (auto imPtr = image.row_begin(col), end = image.row_end(col); imPtr != end; ++imPtr) {
50  int lookupCol = indOffset + *imPtr;
51  if (lookupCol < 0) {
52  lookupCol = 0;
53  ++numOutOfRange;
54  } else if (lookupCol > maxLookupCol) {
55  lookupCol = maxLookupCol;
56  ++numOutOfRange;
57  }
58  *imPtr += table[lookupCol];
59  }
60  }
61  return numOutOfRange;
62 }

◆ applyLookupTable< double >()

template int lsst::ip::isr::applyLookupTable< double > ( afw::image::Image< double > &  ,
ndarray::Array< double, 1, 1 > const &  ,
double   
)

◆ applyLookupTable< float >()

template int lsst::ip::isr::applyLookupTable< float > ( afw::image::Image< float > &  ,
ndarray::Array< float, 1, 1 > const &  ,
float   
)

◆ between()

std::string lsst::ip::isr::between ( std::string s,
char  ldelim,
char  rdelim 
)

Definition at line 100 of file Isr.cc.

100  {
101  std::string::iterator b(s.begin());
102  std::string::iterator e(s.end());
103  std::string::iterator lp;
104  std::string::iterator rp;
105 
107 
108  if((lp = std::find(b, e, ldelim)) != e)
109  if((rp = std::find(++lp, e, rdelim)) != e)
110  result = std::string(lp, rp);
111 
112  return result;
113 }

◆ fitOverscanImage() [1/3]

template void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< afw::math::Function1< double > > &  overscanFunction,
afw::image::MaskedImage< double > const &  overscan,
double  ssize,
int  sigma 
)

◆ fitOverscanImage() [2/3]

template void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< afw::math::Function1< double > > &  overscanFunction,
afw::image::MaskedImage< float > const &  overscan,
double  ssize,
int  sigma 
)

◆ fitOverscanImage() [3/3]

template<typename ImagePixelT , typename FunctionT >
void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< lsst::afw::math::Function1< FunctionT > > &  overscanFunction,
lsst::afw::image::MaskedImage< ImagePixelT > const &  overscan,
double  ssize = 1.,
int  sigma = 1 
)

geom::Box2I bbox = geom::Box2I( geom::Point2I(0, y), geom::Point2I(0, width) ); The above was how this was defined before ticket #1556. As I understand it the following is the new way to do this

geom::Box2I bbox = geom::Box2I( geom::Point2I(0, y), geom::Point2I(0, width) ); The above was how this was defined before ticket #1556. As I understand it the following is the new way to do this

Definition at line 53 of file Isr.cc.

58  {
59  typedef afw::image::MaskedImage<ImagePixelT> MaskedImage;
60 
61 
62  const int height = overscan.getHeight();
63  const int width = overscan.getWidth();
64  std::vector<double> values(height);
65  std::vector<double> errors(height);
66  std::vector<double> positions(height);
67 
68  std::vector<double> parameters(overscanFunction->getNParameters(), 0.);
69  std::vector<double> stepsize(overscanFunction->getNParameters(), ssize);
70 
71  for (int y = 0; y < height; ++y) {
79  MaskedImage mi = MaskedImage(overscan, bbox);
80  afw::math::Statistics stats = afw::math::makeStatistics(*(mi.getImage()), afw::math::MEAN | afw::math::STDEV);
81 
82  values[y] = stats.getValue(afw::math::MEAN);
83  errors[y] = stats.getValue(afw::math::STDEV);
84  positions[y] = y;
85 
86  }
87  afw::math::FitResults fitResults = afw::math::minimize(
88  *overscanFunction,
89  parameters,
90  stepsize,
91  values,
92  errors,
93  positions,
94  sigma
95  );
96 
97  overscanFunction->setParameters(fitResults.parameterList);
98 }

◆ maskNans()

template<typename PixelT >
size_t lsst::ip::isr::maskNans ( afw::image::MaskedImage< PixelT > const &  mi,
afw::image::MaskPixel  maskVal,
afw::image::MaskPixel  allow = 0 
)

Mask NANs in an image.

NANs in the image or variance that are not already masked by the 'allow' value are masked with the 'maskVal'.

Returns
Number of pixels masked
Parameters
miInput image
maskValBit mask value to give a NaN
allowRetain NANs with this bit mask (0 to mask all NANs)

Definition at line 35 of file Isr.cc.

37 {
38  typedef typename afw::image::MaskedImage<PixelT>::x_iterator x_iterator;
39  size_t nPix = 0;
40  for (int y = 0; y != mi.getHeight(); ++y) {
41  for (x_iterator ptr = mi.row_begin(y), end = mi.row_end(y); ptr != end; ++ptr) {
42  if (!(ptr.mask() & allow) && (!std::isfinite(ptr.image()) ||
43  !std::isfinite(ptr.variance()))) {
44  nPix += 1;
45  ptr.mask() |= maskVal;
46  }
47  }
48  }
49  return nPix;
50 }

◆ maskNans< double >()

template size_t lsst::ip::isr::maskNans< double > ( afw::image::MaskedImage< double > const &  ,
afw::image::MaskPixel  ,
afw::image::MaskPixel   
)

◆ maskNans< float >()

template size_t lsst::ip::isr::maskNans< float > ( afw::image::MaskedImage< float > const &  ,
afw::image::MaskPixel  ,
afw::image::MaskPixel   
)

◆ PYBIND11_MODULE() [1/2]

lsst::ip::isr::PYBIND11_MODULE ( applyLookupTable  ,
mod   
)

Definition at line 45 of file applyLookupTable.cc.

45  {
46  declareApplyLookupTable<float>(mod);
47  declareApplyLookupTable<double>(mod);
48 }

◆ PYBIND11_MODULE() [2/2]

lsst::ip::isr::PYBIND11_MODULE ( isr  ,
mod   
)

Definition at line 68 of file isr.cc.

68  {
69  declareAll<float>(mod, "F");
70  declareAll<double>(mod, "D");
71 }
y
int y
Definition: SpanSet.cc:49
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
std::string
STL class.
std::vector< double >
std::find
T find(T... args)
sigma
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:50
lsst::afw::math::minimize
FitResults minimize(lsst::afw::math::Function1< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, double errorDef)
Find the minimum of a function(x)
Definition: minimize.cc:175
lsst::afw::image::MaskedImage::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1093
lsst::afw::image::MaskedImage::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1095
end
int end
Definition: BoundedField.cc:105
lsst::afw::math::makeStatistics
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition: Statistics.h:354
std::isfinite
T isfinite(T... args)
lsst::afw::math::MEAN
@ MEAN
estimate sample mean
Definition: Statistics.h:67
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
result
py::object result
Definition: _schema.cc:429
b
table::Key< int > b
Definition: TransmissionCurve.cc:467
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::math::STDEV
@ STDEV
estimate sample standard deviation
Definition: Statistics.h:68
std::string::begin
T begin(T... args)
col
int col
Definition: CR.cc:144
lsst::geom::Point< int, 2 >
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
std::string::end
T end(T... args)
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117