LSST Applications 24.1.6,g063fba187b+56b85ce14a,g0f08755f38+df8a265115,g12f32b3c4e+891a09f10d,g1524ad2192+7a5d7b3fbd,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g28da252d5a+07cb1400be,g2bbee38e9b+ae03bbfc84,g2bc492864f+ae03bbfc84,g3156d2b45e+6e55a43351,g347aa1857d+ae03bbfc84,g35bb328faa+a8ce1bb630,g3a166c0a6a+ae03bbfc84,g3e281a1b8c+c5dd892a6c,g414038480c+6b9177ef31,g41af890bb2+8f257c4c0b,g781aacb6e4+a8ce1bb630,g7af13505b9+7137b3b17d,g80478fca09+6df6903293,g82479be7b0+091ce1d07f,g858d7b2824+df8a265115,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,g9726552aa6+414189b318,ga5288a1d22+4a2bca08d7,gacef1a1666+c9a8ff65f4,gb58c049af0+d64f4d3760,gbcfae0f0a0+de1d42d831,gc28159a63d+ae03bbfc84,gcf0d15dbbd+72117bf34e,gda6a2b7d83+72117bf34e,gdaeeff99f8+1711a396fd,ge500cccec5+c8c9c9af63,ge79ae78c31+ae03bbfc84,gf0baf85859+c1f95f4921,gfa517265be+df8a265115,gfa999e8aa5+17cd334064,gfb92a5be7c+df8a265115
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions
ast::detail Namespace Reference

Functions

template<class AstMapT , class MapT >
AstMapT * polyTranImpl (MapT const &mapping, bool forward, double acc, double maxacc, int maxorder, std::vector< double > const &lbnd, std::vector< double > const &ubnd)
 Call astPolyTran to set (or replace) one direction of a polynomial transform with a fit based on the other direction.
 
FrameDict makeFrameDict (FrameSet const &frameSet)
 Make a FrameDict from a copy of a FrameSet.
 
void annulAstObject (AstObject *object)
 A wrapper around astAnnul; intended as a custom deleter for std::unique_ptr.
 
template<typename T1 , typename T2 >
void assertEqual (T1 val1, std::string const &descr1, T2 val2, std::string const &descr2)
 
void astBadToNan (std::vector< double > &p)
 Replace AST__BAD with a quiet NaN in a vector.
 
void astBadToNan (ast::Array2D const &arr)
 Replace AST__BAD with a quiet NaN in a 2-D array.
 
std::string formatAxisAttr (std::string const &name, int axis)
 Format an axis-specific attribute by appending the axis index.
 
bool isSeries (AstCmpMap const *cmpMap)
 Return true if the compound map is in series.
 
std::string getClassName (AstObject const *rawObj)
 Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
 
double safeDouble (double val)
 Return a double value after checking status and replacing AST__BAD with nan
 
std::string stringToUpper (std::string const &str)
 Return a copy of a string in which all characters are uppercase.
 
const char * source ()
 Source function that allows astChannel to source from a Stream.
 
void sink (const char *cstr)
 Sink function that allows astChannel to sink to a Stream.
 
 PYBIND11_MODULE (testUtils, mod)
 
template AstChebyMap * polyTranImpl< AstChebyMap > (ChebyMap const &, bool, double, double, int, std::vector< double > const &, std::vector< double > const &)
 
template AstPolyMap * polyTranImpl< AstPolyMap > (PolyMap const &, bool, double, double, int, std::vector< double > const &, std::vector< double > const &)
 

Function Documentation

◆ annulAstObject()

void ast::detail::annulAstObject ( AstObject * object)
inline

A wrapper around astAnnul; intended as a custom deleter for std::unique_ptr.

Definition at line 40 of file utils.h.

40 {
41 if (object != nullptr) {
42 astAnnul(object);
43 assertOK();
44 }
45}
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
Definition base.cc:49

◆ assertEqual()

template<typename T1 , typename T2 >
void ast::detail::assertEqual ( T1 val1,
std::string const & descr1,
T2 val2,
std::string const & descr2 )
inline

Definition at line 48 of file utils.h.

48 {
49 if (val1 != val2) {
51 os << descr1 << " = " << val1 << " != " << descr2 << " = " << val2;
52 throw std::invalid_argument(os.str());
53 }
54}
std::ostream * os
Definition Schema.cc:557

◆ astBadToNan() [1/2]

void ast::detail::astBadToNan ( ast::Array2D const & arr)

Replace AST__BAD with a quiet NaN in a 2-D array.

Definition at line 27 of file utils.cc.

27 {
28 for (auto i = arr.begin(); i != arr.end(); ++i) {
29 for (auto j = i->begin(); j != i->end(); ++j) {
30 if (*j == AST__BAD) {
32 }
33 }
34 }
35}
T quiet_NaN(T... args)

◆ astBadToNan() [2/2]

void ast::detail::astBadToNan ( std::vector< double > & p)
inline

Replace AST__BAD with a quiet NaN in a vector.

Definition at line 59 of file utils.h.

59 {
60 for (auto &val : p) {
61 if (val == AST__BAD) {
63 }
64 }
65}
ImageT val
Definition CR.cc:146

◆ formatAxisAttr()

std::string ast::detail::formatAxisAttr ( std::string const & name,
int axis )
inline

Format an axis-specific attribute by appending the axis index.

Parameters
[in]nameAttribute name
[in]axisAxis index, starting at 1
Returns
"<name>(<axis>)"

Definition at line 79 of file utils.h.

79 {
81 os << name << "(" << axis << ")";
82 return os.str();
83}

◆ getClassName()

std::string ast::detail::getClassName ( AstObject const * rawObj)

Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.

Parameters
[in]rawObjRaw AST object pointer

Definition at line 37 of file utils.cc.

37 {
38 std::string name = astGetC(rawObj, "Class");
39 assertOK();
40 if (name != "CmpMap") {
41 return name;
42 }
43 bool series = isSeries(reinterpret_cast<AstCmpMap const *>(rawObj));
44 return series ? "SeriesMap" : "ParallelMap";
45}
table::Key< std::string > name
Definition Amplifier.cc:116

◆ isSeries()

bool ast::detail::isSeries ( AstCmpMap const * cmpMap)

Return true if the compound map is in series.

Definition at line 47 of file utils.cc.

47 {
48 AstMapping *rawMap1;
49 AstMapping *rawMap2;
50 int series, invert1, invert2;
51 astDecompose(cmpMap, &rawMap1, &rawMap2, &series, &invert1, &invert2);
52 astAnnul(rawMap1);
53 astAnnul(rawMap2);
54 assertOK();
55 return series;
56}

◆ makeFrameDict()

FrameDict ast::detail::makeFrameDict ( FrameSet const & frameSet)

Make a FrameDict from a copy of a FrameSet.

This exists purely to test FrameDict(FrameSet const &) from Python, as the standard pybind11 wrapper isn't sufficient to exercise a bug that was found.

Definition at line 44 of file testUtils.h.

44 {
45 return FrameDict(frameSet);
46}
table::Key< table::Array< std::uint8_t > > frameSet
A FrameSet whose frames can be referenced by domain name.
Definition FrameDict.h:67

◆ polyTranImpl()

template<class AstMapT , class MapT >
AstMapT * ast::detail::polyTranImpl ( MapT const & mapping,
bool forward,
double acc,
double maxacc,
int maxorder,
std::vector< double > const & lbnd,
std::vector< double > const & ubnd )

Call astPolyTran to set (or replace) one direction of a polynomial transform with a fit based on the other direction.

Template Parameters
AstMapTAST mapping class: one of AstChebyMap or AstPolyMap
MapTCorresponding astshim class: one of ast::ChebyMap or ast::PolyMap; this template parameter is second because it can always be deduced.
Parameters
[in]mapping
[in]forwardIf true the forward transformation is replaced. Otherwise the inverse transformation is replaced.
[in]accThe target accuracy, expressed as a geodesic distance within the ChebyMap's input space (if forward is false) or output space (if forward is true).
[in]maxaccThe maximum allowed accuracy for an acceptable polynomial, expressed as a geodesic distance within the ChebyMap's input space (if forward is false) or output space (if forward is true).
[in]maxorderThe maximum allowed polynomial order. This is one more than the maximum power of either input axis. So for instance, a value of 3 refers to a quadratic polynomial. Note, cross terms with total powers greater than or equal to maxorder are not inlcuded in the fit. So the maximum number of terms in each of the fitted polynomials is maxorder*(maxorder + 1)/2.
[in]lbndA vector holding the lower bounds of a rectangular region within the ChebyMap's input space (if forward is false) or output space (if forward is true). The new polynomial will be evaluated over this rectangle. The length should equal getNIn() or getNOut(), depending on forward.
[in]ubndA vector holding the upper bounds of a rectangular region within the ChebyMap's input space (if forward is false) or output space (if forward is true). The new polynomial will be evaluated over this rectangle. The length should equal getNIn() or getNOut(), depending on forward.
Exceptions
std::invalid_argumentif the size of lbnd or ubnd does not match getNIn() (if forward false) or getNOut() (if forward true).

Definition at line 30 of file polyMapUtils.cc.

31 {
32 // desired size of lbnd and ubnd
33 auto const bndSize = static_cast<unsigned int>(forward ? mapping.getNOut() : mapping.getNIn());
34
35 if (lbnd.size() != bndSize) {
37 os << "lbnd.size() = " << lbnd.size() << " != " << bndSize << " = "
38 << (forward ? "getNOut()" : "getNIn()");
39 throw std::invalid_argument(os.str());
40 }
41 if (ubnd.size() != bndSize) {
43 os << "ubnd.size() = " << ubnd.size() << " != " << bndSize << " = "
44 << (forward ? "getNOut()" : "getNIn()");
45 throw std::invalid_argument(os.str());
46 }
47
48 void *outRawMap = astPolyTran(mapping.getRawPtr(), static_cast<int>(forward), acc, maxacc, maxorder,
49 lbnd.data(), ubnd.data());
50 // Failure should result in a null pointer, so calling assertOK is unlikely to do anything,
51 // but better to be sure and than risk missing an uncaught error.
52 assertOK(reinterpret_cast<AstObject *>(outRawMap));
53 if (!outRawMap) {
54 throw std::runtime_error("Could not compute an inverse mapping");
55 }
56 return reinterpret_cast<AstMapT *>(outRawMap);
57}
T data(T... args)
T size(T... args)

◆ polyTranImpl< AstChebyMap >()

template AstChebyMap * ast::detail::polyTranImpl< AstChebyMap > ( ChebyMap const & ,
bool ,
double ,
double ,
int ,
std::vector< double > const & ,
std::vector< double > const &  )

◆ polyTranImpl< AstPolyMap >()

template AstPolyMap * ast::detail::polyTranImpl< AstPolyMap > ( PolyMap const & ,
bool ,
double ,
double ,
int ,
std::vector< double > const & ,
std::vector< double > const &  )

◆ PYBIND11_MODULE()

ast::detail::PYBIND11_MODULE ( testUtils ,
mod  )

Definition at line 39 of file testUtils.cc.

39 {
41 lsst::cpputils::python::WrapperCollection wrappers(mod, "astshim.detail.testUtils");
42 declareUtils(wrappers);
43 wrappers.finish();
44}
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242

◆ safeDouble()

double ast::detail::safeDouble ( double val)
inline

Return a double value after checking status and replacing AST__BAD with nan

Definition at line 100 of file utils.h.

100 {
101 assertOK();
102 return val != AST__BAD ? val : std::numeric_limits<double>::quiet_NaN();
103}

◆ sink()

void ast::detail::sink ( const char * cstr)
inline

Sink function that allows astChannel to sink to a Stream.

This function retrieves a pointer to a Stream ssptr using astChannelData, then calls ssptr->sink(cstr).

Definition at line 239 of file Stream.h.

239 {
240 auto ssptr = reinterpret_cast<Stream *>(astChannelData);
241 if (ssptr) {
242 auto isok = ssptr->sink(cstr);
243 if (!isok) {
244 astSetStatus(AST__ATGER);
245 }
246 }
247}
A stream for ast::Channel.
Definition Stream.h:41
bool sink(char const *cstr)
Sink (write) to the stream.
Definition Stream.h:110

◆ source()

const char * ast::detail::source ( )
inline

Source function that allows astChannel to source from a Stream.

This function retrieves a pointer to a Stream ssptr using astChannelData, then returns the result of calling ssptr->source()

Definition at line 224 of file Stream.h.

224 {
225 auto ssptr = reinterpret_cast<Stream *>(astChannelData);
226 if (ssptr) {
227 return ssptr->source();
228 } else {
229 return nullptr;
230 }
231}
char const * source()
Source (read) from the stream.
Definition Stream.h:84

◆ stringToUpper()

std::string ast::detail::stringToUpper ( std::string const & str)
inline

Return a copy of a string in which all characters are uppercase.

Definition at line 108 of file utils.h.

108 {
109 std::string upstr;
110 upstr.reserve(str.size());
111 for (char c : str) {
112 upstr += std::toupper(c);
113 }
114 return upstr;
115}
T reserve(T... args)
T toupper(T... args)