LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
Namespaces | Classes | Functions
lsst::ip::isr Namespace Reference

Namespaces

 assembleCcdTask
 
 crosstalk
 
 fringe
 
 isrFunctions
 
 isrMock
 
 isrQa
 
 isrTask
 
 linearize
 
 masking
 
 measureCrosstalk
 
 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 col
Definition: CR.cc:144
#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 end

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

◆ fitOverscanImage() [1/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) {
78  geom::Box2I bbox = geom::Box2I(geom::Point2I(0,y), geom::Point2I(width,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 }
estimate sample standard deviation
Definition: Statistics.h:68
int y
Definition: SpanSet.cc:49
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:177
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1096
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
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:50
table::Box2IKey bbox
Definition: Detector.cc:169
Point< int, 2 > Point2I
Definition: Point.h:321
estimate sample mean
Definition: Statistics.h:67
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1094

◆ 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 void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< afw::math::Function1< double > > &  overscanFunction,
afw::image::MaskedImage< double > const &  overscan,
double  ssize,
int  sigma 
)

◆ 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
int y
Definition: SpanSet.cc:49
T isfinite(T... args)
int end

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