LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Namespaces | Classes | Functions
lsst::ip::isr Namespace Reference

Namespaces

 ampOffset
 
 assembleCcdTask
 
 brighterFatterKernel
 
 calibType
 
 crosstalk
 
 defects
 
 fringe
 
 isrFunctions
 
 isrMock
 
 isrQa
 
 isrTask
 
 linearize
 
 masking
 
 overscan
 
 ptcDataset
 
 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 }
int end
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
int col
Definition: CR.cc:144

◆ 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 }
py::object result
Definition: _schema.cc:429
table::Key< int > b
T begin(T... args)
T end(T... args)
T find(T... args)

◆ 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 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:49
int y
Definition: SpanSet.cc:48
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1056
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1054
An integer coordinate rectangle.
Definition: Box.h:55
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:176
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:359
@ STDEV
estimate sample standard deviation
Definition: Statistics.h:67
@ MEAN
estimate sample mean
Definition: Statistics.h:66

◆ 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 }
uint64_t * ptr
Definition: RangeSet.cc:88
T isfinite(T... args)

◆ 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 }