LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
ast::FitsChan Class Reference

A specialized form of Channel which reads and writes FITS header cards. More...

#include <FitsChan.h>

Inheritance diagram for ast::FitsChan:
ast::Channel ast::Object

Public Types

using ObjectPtr = std::unique_ptr< AstObject, Deleter >
 unique pointer holding an AST raw pointer More...
 

Public Member Functions

 FitsChan (Stream &stream, std::string const &options="")
 Construct a channel that uses a provided Stream. More...
 
virtual ~FitsChan ()
 
 FitsChan (FitsChan const &)=delete
 
 FitsChan (FitsChan &&)=default
 
FitsChanoperator= (FitsChan const &)=delete
 
FitsChanoperator= (FitsChan &&)=default
 
void delFits ()
 Delete the current FITS card. More...
 
void emptyFits ()
 Delete all cards and associated information from a FitsChan. More...
 
FoundValue< std::stringfindFits (std::string const &name, bool inc)
 Search for a card in a FitsChan by keyword. More...
 
FoundValue< std::complex< double > > getFitsCF (std::string const &name="", std::complex< double > defval={0, 0}) const
 Get the value of a complex double card. More...
 
FoundValue< std::stringgetFitsCN (std::string const &name="", std::string defval="") const
 Get the value of a CONTINUE card. More...
 
FoundValue< double > getFitsF (std::string const &name="", double defval=0) const
 Get the value of a double card. More...
 
FoundValue< int > getFitsI (std::string const &name="", int defval=0) const
 Get the value of a int card. More...
 
FoundValue< bool > getFitsL (std::string const &name="", bool defval=false) const
 Get the value of a bool card. More...
 
FoundValue< std::stringgetFitsS (std::string const &name="", std::string defval="") const
 Get the value of a string card. More...
 
std::vector< std::stringgetAllCardNames ()
 Get the name of all cards, in order, starting from the first card. More...
 
std::string getAllWarnings () const
 Get AllWarnings: a space separated list of all the conditions names recognized by the Warnings attribute. More...
 
int getCard () const
 Get Card: the index of the current card, where 1 is the first card. More...
 
std::string getCardComm () const
 Get CardComm: the comment of the current card. More...
 
std::string getCardName () const
 Get CardName: the keyword name of the current card. More...
 
CardType getCardType () const
 Get CardType: data type of the current FITS card. More...
 
bool getCarLin () const
 Get CarLin: ignore spherical rotations on CAR projections? More...
 
bool getCDMatrix () const
 Get CDMatrix: use CDi_j keywords to represent pixel scaling, rotation, etc? More...
 
bool getClean () const
 Get Clean: remove cards used whilst reading even if an error occurs? More...
 
bool getDefB1950 () const
 Get DefB1950: use FK4 B1950 as default equatorial coordinates? More...
 
std::string getEncoding () const
 Get Encoding: the encoding system to use when AST Objects are stored as FITS header cards in a FitsChan. More...
 
std::string getFitsAxisOrder () const
 Get FitsAxisOrder: the order for the WCS axes in any new FITS-WCS headers created using Channel::write. More...
 
int getFitsDigits () const
 Get FitsDigits: digits of precision for floating-point FITS values. More...
 
double getFitsTol () const
 Get FitsTol: Tolerance used for writing a FrameSet using a foreign encoding. More...
 
bool getIwc () const
 Get Iwc: add a Frame describing Intermediate World Coords? More...
 
int getNCard () const
 Get NCard: the number of cards. More...
 
int getNKey () const
 Get Nkey: the number of unique keywords. More...
 
bool getSipOK () const
 Get SipOK: use Spitzer Space Telescope keywords to define distortion? More...
 
bool getSipReplace () const
 Get SipReplace: ignore inverse SIP coefficients (replacing them with fit coefficients or an iterative inverse)? More...
 
int getTabOK () const
 Get TabOK: should the FITS "-TAB" algorithm be recognised? More...
 
int getPolyTan () const
 Get PolyTan: use PVi_m keywords to define distorted TAN projection? More...
 
std::string getWarnings () const
 Get Warnings attribute, which controls the issuing of warnings about selected conditions when an Object or keyword is read from or written to a FitsChan. More...
 
void purgeWcs ()
 Delete all cards in a FitsChan that relate to any of the recognised WCS encodings. More...
 
void putCards (std::string const &cards)
 Replace all FITS header cards. More...
 
void putFits (std::string const &card, bool overwrite)
 Store a FITS header card in a FitsChan. More...
 
void readFits ()
 Read cards from the source and store them in the FitsChan. More...
 
void retainFits ()
 Keep the current card when an Object is read that uses the card. More...
 
void setFitsCF (std::string const &name, std::complex< double > value, std::string const &comment="", bool overwrite=false)
 Create a new card of type std::complex<double>, possibly overwriting the current card. More...
 
void setFitsCM (std::string const &comment, bool overwrite=false)
 Create a new comment card, possibly overwriting the current card. More...
 
void setFitsCN (std::string const &name, std::string value, std::string const &comment="", bool overwrite=false)
 Create a new "CONTINUE" card, possibly overwriting the current card. More...
 
void setFitsF (std::string const &name, double value, std::string const &comment="", bool overwrite=false)
 Create a new card of type double, possibly overwriting the current card. More...
 
void setFitsI (std::string const &name, int value, std::string const &comment="", bool overwrite=false)
 Create a new card of type int, possibly overwriting the current card. More...
 
void setFitsL (std::string const &name, bool value, std::string const &comment="", bool overwrite=false)
 Create a new card of type bool, possibly overwriting the current card. More...
 
void setFitsS (std::string const &name, std::string value, std::string const &comment="", bool overwrite=false)
 Create a new card of type string, possibly overwriting the current card. More...
 
void setFitsU (std::string const &name, std::string const &comment="", bool overwrite=false)
 Create a new card with an undefined value, possibly overwriting the current card. More...
 
void setCarLin (bool cdMatrix)
 Set CarLin: ignore spherical rotations on CAR projections? More...
 
void setCDMatrix (bool cdMatrix)
 Get CDMatrix: Use CDi_j keywords to represent pixel scaling, rotation, etc? More...
 
void setClean (bool clean)
 Set Clean: remove cards used whilst reading even if an error occurs? More...
 
void setDefB1950 (bool defB1950)
 Set DefB1950: use FK4 B1950 as default equatorial coordinates? More...
 
void setEncoding (std::string const &encoding)
 Set Encoding: the encoding system to use when AST Objects are stored as FITS header cards in a FitsChan. More...
 
void setFitsAxisOrder (std::string const &order)
 Set FitsAxisOrder: the order for the WCS axes in any new FITS-WCS headers created using Channel::write. More...
 
void setFitsDigits (int digits)
 Set FitsDigits: digits of precision for floating-point FITS values. More...
 
void setFitsTol (double tol)
 Set FitsTol: Tolerance used for writing a FrameSet using a foreign encoding. More...
 
void setIwc (bool iwcs)
 Set Iwc: add a Frame describing Intermediate World Coords? More...
 
void setSipOK (bool sipOK)
 Set SipOK: use Spitzer Space Telescope keywords to define distortion? More...
 
void setSipReplace (bool replace)
 Set SipReplace: ignore inverse SIP coefficients (replacing them with fit coefficients or an iterative inverse)? More...
 
void setTabOK (int tabOK)
 Set TabOK: should the FITS "-TAB" algorithm be recognised? More...
 
void setPolyTan (int polytan)
 Set PolyTan: use PVi_m keywords to define distorted TAN projection? More...
 
void setWarnings (std::string const &warnings)
 Set Warnings attribute, which controls the issuing of warnings about selected conditions when an Object or keyword is read from or written to a FitsChan. More...
 
void showFits () const
 Write all the cards in the channel to standard output. More...
 
FitsKeyState testFits (std::string const &name="") const
 Determine if a card is present, and if so, whether it has a value. More...
 
void writeFits ()
 Write out all cards currently in the channel and clear the channel. More...
 
void clearCard ()
 Rewind the card index to the beginning. More...
 
void setCard (int ind)
 Set Card: the index of the current card, where 1 is the first card. More...
 
std::shared_ptr< Channelcopy () const
 Return a deep copy of this object. More...
 
bool getComment () const
 Get Comment: include textual comments in output? More...
 
int getFull () const
 Get Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose. More...
 
int getIndent () const
 Get Indent: indentation increment between objects. More...
 
int getReportLevel () const
 Get ReportLevel: report level. More...
 
bool getSkip () const
 Get Skip: skip irrelevant data on input? More...
 
bool getStrict () const
 Get Strict: generate errors instead of warnings? More...
 
std::shared_ptr< Objectread ()
 Read an object from a channel. More...
 
void setComment (bool skip)
 Set Comment: include textual comments in output? More...
 
void setFull (int full)
 Set Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose. More...
 
void setIndent (int indent)
 Set Indent: indentation increment between objects. More...
 
void setReportLevel (int level)
 Set ReportLevel: report level; an integer in the range [0, 3] where 0 is the most verbose. More...
 
void setSkip (bool skip)
 Set Skip: skip irrelevant data on input? More...
 
void setStrict (bool strict)
 Set Strict: generate errors instead of warnings? More...
 
KeyMap warnings () const
 Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of read or write. More...
 
int write (Object const &object)
 Write an object to a channel. More...
 
bool operator== (Object const &rhs) const
 Return True if this and rhs are the equal. More...
 
bool operator!= (Object const &rhs) const
 Return True if this and rhs are not equal. More...
 
void clear (std::string const &attrib)
 Clear the values of a specified set of attributes for an Object. More...
 
bool hasAttribute (std::string const &attrib) const
 Does this object have an attribute with the specified name? More...
 
std::string getClassName () const
 Get Class: the name of the class (e.g. More...
 
std::string getID () const
 Get ID: object identification string that is not copied. More...
 
std::string getIdent () const
 Get Ident: object identification string that is copied. More...
 
int getNObject () const
 Get NObject: number of AST objects in existence of the same type as the underlying AST class. More...
 
int getObjSize () const
 Get ObjSize: the in-memory size of the AST object in bytes. More...
 
int getRefCount () const
 Get RefCount: number of active pointers to the underlying AST object. More...
 
bool getUseDefs () const
 Get UseDefs: allow use of default values for Object attributes? More...
 
void lock (bool wait)
 Lock this object for exclusive use by the calling thread. More...
 
bool same (Object const &other) const
 Does this contain the same AST object as another? More...
 
void setID (std::string const &id)
 Set ID: object identification string that is not copied. More...
 
void setIdent (std::string const &ident)
 Set Ident: object identification string that is copied. More...
 
void setUseDefs (bool usedefs)
 Set UseDefs: allow use of default values for Object attributes? More...
 
void show (std::ostream &os, bool showComments=true) const
 Print a textual description the object to an ostream. More...
 
std::string show (bool showComments=true) const
 Return a textual description the object as a string. More...
 
bool test (std::string const &attrib) const
 Has this attribute been explicitly set (and not subsequently cleared)? More...
 
void unlock (bool report=false)
 Unlock this object previously locked using lock, so that other threads can use this object. More...
 
AstObject const * getRawPtr () const
 Get the raw AST pointer. More...
 
AstObject * getRawPtr ()
 Get the raw AST pointer. More...
 

Static Public Member Functions

static std::shared_ptr< ObjectfromString (std::string const &str)
 Construct an Object from a string, using astFromString. More...
 
template<typename Class >
static std::shared_ptr< Class > fromAstObject (AstObject *rawObj, bool copy)
 Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type. More...
 

Protected Member Functions

virtual std::shared_ptr< ObjectcopyPolymorphic () const override
 Return a deep copy of this object. More...
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 Implementation of deep copy. More...
 
bool getB (std::string const &attrib) const
 Get the value of an attribute as a bool. More...
 
std::string const getC (std::string const &attrib) const
 Get the value of an attribute as a string. More...
 
double getD (std::string const &attrib) const
 Get the value of an attribute as a double. More...
 
float getF (std::string const &attrib) const
 Get the value of an attribute as a float. More...
 
int getI (std::string const &attrib) const
 Get the value of an attribute as an int. More...
 
long int getL (std::string const &attrib) const
 Get the value of an attribute as a long int. More...
 
void set (std::string const &setting)
 Assign a set of attribute values, over-riding any previous values. More...
 
void setB (std::string const &attrib, bool value)
 Set the value of an attribute as a bool. More...
 
void setC (std::string const &attrib, std::string const &value)
 Set the value of an attribute as a string. More...
 
void setD (std::string const &attrib, double value)
 Set the value of an attribute as a double. More...
 
void setF (std::string const &attrib, float value)
 Set the value of an attribute as a float. More...
 
void setI (std::string const &attrib, int value)
 Set the value of an attribute as an int. More...
 
void setL (std::string const &attrib, long int value)
 Set the value of an attribute as a long int. More...
 

Static Protected Member Functions

template<typename ShimT , typename AstT >
static std::shared_ptr< ShimT > makeShim (AstObject *p)
 Functor to make an astshim instance from a raw AST pointer of the corresponding type. More...
 

Detailed Description

A specialized form of Channel which reads and writes FITS header cards.

Writing an Object to a FitsChan will, if the Object is suitable, generate a description of that Object composed of FITS header cards, and reading from a FitsChan will create a new Object from its FITS header card description.

While a FitsChan is active, it represents a buffer which may contain zero or more 80-character "header cards" conforming to FITS conventions. Any sequence of FITS-conforming header cards may be stored, apart from the "END" card whose existence is merely implied. The cards may be accessed in any order by using the FitsChan's Card attribute, which identifies a "current" card, to which subsequent operations apply. Searches based on keyword may be performed (using findFits), new cards may be inserted (putFits, putCards, setFitsS and similar) and existing ones may be deleted with delFits, extracted with getFitsS and similar, or changed with setFitsS and similar.

Missing Methods

Tables are not yet supported, so the following AST functions are not wrapped as methods:

Attributes

FitsChan has the following attributes, in addition to those provided by Channel and Object

Notes

As for any Channel, when you create a FitsChan, you specify a Stream which sources and sinks data by reading and writing FITS header cards. If you provide a source, it is used to fill the FitsChan with header cards when it is accessed for the first time. If you do not provide a source, the FitsChan remains empty until you explicitly enter data into it (e.g. using putFits, putCards, write or by using the SourceFile attribute to specifying a text file from which headers should be read). When the FitsChan is deleted, any remaining header cards in the FitsChan will be written to the sink.

Coordinate system information may be described using FITS header cards using several different conventions, termed "encodings". When an AST Object is written to (or read from) a FitsChan, the value of the FitsChan's Encoding attribute determines how the Object is converted to (or from) a description involving FITS header cards. In general, different encodings will result in different sets of header cards to describe the same Object. Examples of encodings include the DSS encoding (based on conventions used by the STScI Digitised Sky Survey data), the FITS-WCS encoding (based on a proposed FITS standard) and the NATIVE encoding (a near loss-less way of storing AST Objects in FITS headers).

The available encodings differ in the range of Objects they can represent, in the number of Object descriptions that can coexist in the same FitsChan, and in their accessibility to other (external) astronomy applications (see the Encoding attribute for details). Encodings are not necessarily mutually exclusive and it may sometimes be possible to describe the same Object in several ways within a particular set of FITS header cards by using several different encodings.

The detailed behaviour of read and write, when used with a FitsChan, depends on the encoding in use. In general, however, all successful use of read is destructive, so that FITS header cards are consumed in the process of reading an Object, and are removed from the FitsChan (this deletion can be prevented for specific cards by calling the retainFits function). An unsuccessful call of read (for instance, caused by the FitsChan not containing the necessary FITS headers cards needed to create an Object) results in the contents of the FitsChan being left unchanged.

If the encoding in use allows only a single Object description to be stored in a FitsChan (e.g. the DSS, FITS-WCS and FITS-IRAF encodings), then write operations using write will over-write any existing Object description using that encoding. Otherwise (e.g. the NATIVE encoding), multiple Object descriptions are written sequentially and may later be read back in the same sequence.

Definition at line 201 of file FitsChan.h.

Member Typedef Documentation

◆ ObjectPtr

using ast::Object::ObjectPtr = std::unique_ptr<AstObject, Deleter>
inherited

unique pointer holding an AST raw pointer

Definition at line 59 of file Object.h.

Constructor & Destructor Documentation

◆ FitsChan() [1/3]

ast::FitsChan::FitsChan ( Stream stream,
std::string const &  options = "" 
)
explicit

Construct a channel that uses a provided Stream.

Parameters
[in]streamStream for channel I/O:
  • For file I/O: provide a FileStream
  • For string I/O (e.g. unit tests): provide a StringStream
  • For standard I/O provide Stream(&std::cin, &std::cout)) where either stream can be nullptr if not wanted
[in]optionsComma-separated list of attribute assignments.

Definition at line 44 of file FitsChan.cc.

45  : Channel(reinterpret_cast<AstChannel *>(
46  astFitsChan(detail::source, detail::sink, "%s", options.c_str())),
47  stream, true) {
48  assertOK();
49 }
void sink(const char *cstr)
Sink function that allows astChannel to sink to a Stream.
Definition: Stream.h:239
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
tuple options
Definition: lsstimport.py:47
Channel(Stream &stream, std::string const &options="")
Construct a channel that uses a provided Stream.
Definition: Channel.cc:31
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224

◆ ~FitsChan()

ast::FitsChan::~FitsChan ( )
virtual

Definition at line 51 of file FitsChan.cc.

51  {
52  // when an astFitsChan is destroyed it first writes out any cards, but if I let astFitsChan
53  // do this automatically then it occurs while the Channel and its Source are being destroyed,
54  // which is too late
55  astWriteFits(getRawPtr());
56  // No 'assertOK' here: can't throw in a Dtor.
57 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292

◆ FitsChan() [2/3]

ast::FitsChan::FitsChan ( FitsChan const &  )
delete

◆ FitsChan() [3/3]

ast::FitsChan::FitsChan ( FitsChan &&  )
default

Member Function Documentation

◆ clear()

void ast::Object::clear ( std::string const &  attrib)
inlineinherited

Clear the values of a specified set of attributes for an Object.

Clearing an attribute cancels any value that has previously been explicitly set for it, so that the standard default attribute value will subsequently be used instead. This also causes the astTest function to return the value zero for the attribute, indicating that no value has been set.

Definition at line 119 of file Object.h.

119  {
120  astClear(getRawPtr(), attrib.c_str());
121  assertOK();
122  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ clearCard()

void ast::FitsChan::clearCard ( )
inline

Rewind the card index to the beginning.

Definition at line 1030 of file FitsChan.h.

1030 { clear("Card"); }
void clear(std::string const &attrib)
Clear the values of a specified set of attributes for an Object.
Definition: Object.h:119

◆ copy()

std::shared_ptr<Channel> ast::Channel::copy ( ) const
inlineinherited

Return a deep copy of this object.

Definition at line 84 of file Channel.h.

84  {
85  throw std::logic_error(
86  "Channel cannot be deep copied because its contained stream cannot be deep copied");
87  }
STL class.

◆ copyImpl()

template<typename T , typename AstT >
std::shared_ptr<T> ast::Object::copyImpl ( ) const
inlineprotectedinherited

Implementation of deep copy.

Should be called to implement copyPolymorphic by all derived classes.

Definition at line 320 of file Object.h.

320  {
321  auto *rawptr = reinterpret_cast<AstT *>(astCopy(getRawPtr()));
322  auto retptr = std::shared_ptr<T>(new T(rawptr));
323  assertOK();
324  return retptr;
325  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ copyPolymorphic()

virtual std::shared_ptr<Object> ast::Channel::copyPolymorphic ( ) const
inlineoverrideprotectedvirtualinherited

Return a deep copy of this object.

This is called by copy.

Each subclass must override this method. The standard implementation is:

return copyImpl<astshim_class, ast_class>();

for example Frame implements this as:

return copyImpl<Frame, AstFrame>();

Implements ast::Object.

Definition at line 159 of file Channel.h.

◆ delFits()

void ast::FitsChan::delFits ( )
inline

Delete the current FITS card.

The current card may be selected using the Card attribute (if its index is known) or by using findFits (if only the FITS keyword is known). After deletion, the following card becomes the current card.

Definition at line 229 of file FitsChan.h.

229  {
230  astDelFits(getRawPtr());
231  assertOK();
232  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ emptyFits()

void ast::FitsChan::emptyFits ( )
inline

Delete all cards and associated information from a FitsChan.

Notes

  • This method simply deletes the cards currently in the FitsChan. Unlike astWriteFits, they are not first written out.
  • Any Tables or warnings stored in the FitsChan are also deleted.

Definition at line 243 of file FitsChan.h.

243  {
244  astEmptyFits(getRawPtr());
245  assertOK();
246  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ findFits()

FoundValue< std::string > ast::FitsChan::findFits ( std::string const &  name,
bool  inc 
)

Search for a card in a FitsChan by keyword.

The search commences at the current card (identified by the Card attribute) and ends when a card is found whose FITS keyword matches the template supplied, or when the last card in the FitsChan has been searched.

Warning
this is very different than the getFitsX methods such as getFitsS, whose search wraps around. In order to search all keys using findFits you must first call clearCard.

If the search is successful (i.e. a card is found which matches the template), the contents of the card are returned and the Card attribute is adjusted to identify the card found (if inc false) or the one following it (if inc is true).

If the search is not successful, the Card attribute is set to the "end-of-file".

Parameters
[in]nameThe keyword to be found. In the simplest case, this should simply be the keyword name (the search is case insensitive and trailing spaces are ignored). However, this template may also contain "field specifiers" which are capable of matching a range of characters (see the "Keyword Templates" section for details). In this case, the first card with a keyword which matches the template will be found. To find the next FITS card regardless of its keyword, you should use the template "%f".
[in]incIf false (and the search is successful), the FitsChan's Card attribute will be set to the index of the card that was found. If true, however, the Card attribute will be incremented to identify the card which follows the one found.
Returns
data as a FoundValue

Keyword Templates

The templates used to match FITS keywords are normally composed of literal characters, which must match the keyword exactly (apart from case). However, a template may also contain "field specifiers" which can match a range of possible characters. This allows you to search for keywords that contain (for example) numbers, where the digits comprising the number are not known in advance.

A field specifier starts with a "%" character. This is followed by an optional single digit (0 to 9) specifying a field width. Finally, there is a single character which specifies the

type of character to be matched, as follows:

  • "c": matches all upper case letters,
  • "d": matches all decimal digits,
  • "f": matches all characters which are permitted within a FITS keyword (upper case letters, digits, underscores and hyphens).

If the field width is omitted, the field specifier matches one or more characters. If the field width is zero, it matches zero or more characters. Otherwise, it matches exactly the number of characters specified. In addition to this:

  • The template "%f" will match a blank FITS keyword consisting of 8 spaces (as well as matching all other keywords).
  • A template consisting of 8 spaces will match a blank keyword (only).

For example:

  • The template "BitPix" will match the keyword "BITPIX" only.
  • The template "crpix%1d" will match keywords consisting of "CRPIX" followed by one decimal digit.
  • The template "P%c" will match any keyword starting with "P" and followed by one or more letters.
  • The template "E%0f" will match any keyword beginning with "E".
  • The template "%f" will match any keyword at all (including a blank one).

Examples

auto foundvalue = fitschan.findFits("%f", true)

Return the current FITS card and advance the @ref FitsChan_Card "Card" attribute
to the card that follows (the "%f" template matches any keyword).

`auto foundvalue = fitschan.findFits("BITPIX", false)

Return the next FITS card with the "BITPIX" keyword
and leave the @ref FitsChan_Card "Card" attribute pointing to it.
You might wish to then call `setFitsI(...)` to modify its value.

auto foundvalue = fitscan.findFits("COMMENT", true)

Return the next COMMENT card and advance the @ref FitsChan_Card "Card" attribute
to the card that follows.

auto foundvalue = fitschan.findFits("CRVAL%1d", true)

Return the next keyword of the form "CRVALi" (for example,
any of the keywords "CRVAL1", "CRVAL2" or "CRVAL3" would be matched).
Advance the @ref FitsChan_Card "Card" attribute to the card that follows.

Definition at line 124 of file FitsChan.cc.

124  {
125  std::unique_ptr<char[]> fitsbuf(new char[detail::FITSLEN + 1]);
126  fitsbuf[0] = '\0'; // in case nothing is found
127  bool success = static_cast<bool>(astFindFits(getRawPtr(), name.c_str(), fitsbuf.get(), inc));
128  assertOK();
129  return FoundValue<std::string>(success, std::string(fitsbuf.get()));
130 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
STL class.
STL class.

◆ fromAstObject()

template<typename Class >
template std::shared_ptr< Object > ast::Object::fromAstObject< Object > ( AstObject *  rawObj,
bool  copy 
)
staticinherited

Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.

The returned object takes ownership of the pointer. This is almost always what you want, for instance astDecompose returns shallow copies of the internal pointers.

Template Parameters
ClassThe class of the returned shared pointer. (The actual class will be the correct class of rawPtr.)
Parameters
[in]rawObjA bare AST object pointer
[in]copyIf True then make a deep copy of the pointer (and free the original)

Definition at line 132 of file Object.cc.

132  {
133  AstObject *rawObjCopy = rawObj;
134  if (copy) {
135  rawObjCopy = reinterpret_cast<AstObject *>(astCopy(rawObj));
136  astAnnul(rawObj);
137  }
138  assertOK(rawObjCopy);
139 
140  // Make the appropriate ast shim object and dynamically cast to the desired output type
141  auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
142  auto retObject = std::dynamic_pointer_cast<Class>(retObjectBeforeCast);
143  if (!retObject) {
145  os << "The component is of type " << retObject->getClassName()
146  << ", which could not be cast to the desired type " << typeid(Class).name();
147  throw std::runtime_error(os.str());
148  }
149  return retObject;
150 }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
Definition: Object.h:109
T str(T... args)
T dynamic_pointer_cast(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ fromString()

static std::shared_ptr<Object> ast::Object::fromString ( std::string const &  str)
inlinestaticinherited

Construct an Object from a string, using astFromString.

Definition at line 88 of file Object.h.

88  {
89  auto *rawPtr = reinterpret_cast<AstObject *>(astFromString(str.c_str()));
90  assertOK(rawPtr);
91  return Object::_basicFromAstObject(rawPtr);
92  }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ getAllCardNames()

std::vector< std::string > ast::FitsChan::getAllCardNames ( )

Get the name of all cards, in order, starting from the first card.

Not "const" because the code changes the index of the current card while operating (but restores the original index when done).

Definition at line 106 of file FitsChan.cc.

106  {
107  int const initialIndex = getCard();
108  int const numCards = getNCard();
109  std::vector<std::string> nameList;
110  nameList.reserve(numCards);
111  try {
112  for (auto i = 1; i <= numCards; ++i) {
113  setCard(i);
114  nameList.emplace_back(getCardName());
115  }
116  } catch (...) {
117  setCard(initialIndex);
118  throw;
119  }
120  setCard(initialIndex);
121  return nameList;
122 }
std::string getCardName() const
Get CardName: the keyword name of the current card.
Definition: FitsChan.h:495
int getNCard() const
Get NCard: the number of cards.
Definition: FitsChan.h:554
void setCard(int ind)
Set Card: the index of the current card, where 1 is the first card.
Definition: FitsChan.h:1035
int getCard() const
Get Card: the index of the current card, where 1 is the first card.
Definition: FitsChan.h:485
T reserve(T... args)
T emplace_back(T... args)

◆ getAllWarnings()

std::string ast::FitsChan::getAllWarnings ( ) const
inline

Get AllWarnings: a space separated list of all the conditions names recognized by the Warnings attribute.

Definition at line 480 of file FitsChan.h.

480 { return getC("AllWarnings"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getB()

bool ast::Object::getB ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as a bool.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 348 of file Object.h.

348  {
349  bool val = astGetI(getRawPtr(), attrib.c_str());
350  assertOK();
351  return val;
352  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getC()

std::string const ast::Object::getC ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as a string.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 361 of file Object.h.

361  {
362  char const *rawval = astGetC(getRawPtr(), attrib.c_str());
363  assertOK();
364  return std::string(rawval);
365  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
STL class.

◆ getCard()

int ast::FitsChan::getCard ( ) const
inline

Get Card: the index of the current card, where 1 is the first card.

Definition at line 485 of file FitsChan.h.

485 { return getI("Card"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getCardComm()

std::string ast::FitsChan::getCardComm ( ) const
inline

Get CardComm: the comment of the current card.

Definition at line 490 of file FitsChan.h.

490 { return getC("CardComm"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getCardName()

std::string ast::FitsChan::getCardName ( ) const
inline

Get CardName: the keyword name of the current card.

Definition at line 495 of file FitsChan.h.

495 { return getC("CardName"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getCardType()

CardType ast::FitsChan::getCardType ( ) const
inline

Get CardType: data type of the current FITS card.

Definition at line 500 of file FitsChan.h.

500 { return static_cast<CardType>(getI("CardType")); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400
CardType
Enums describing the FITS card type.
Definition: FitsChan.h:48

◆ getCarLin()

bool ast::FitsChan::getCarLin ( ) const
inline

Get CarLin: ignore spherical rotations on CAR projections?

Definition at line 505 of file FitsChan.h.

505 { return getB("CarLin"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getCDMatrix()

bool ast::FitsChan::getCDMatrix ( ) const
inline

Get CDMatrix: use CDi_j keywords to represent pixel scaling, rotation, etc?

Definition at line 511 of file FitsChan.h.

511 { return getB("CDMatrix"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getClassName()

std::string ast::Object::getClassName ( ) const
inlineinherited

Get Class: the name of the class (e.g.

ZoomMap)

Note: if AST returns "CmpMap" then the name will be changed to "SeriesMap" or "ParallelMap", as appropriate.

Definition at line 139 of file Object.h.

139 { return detail::getClassName(getRawPtr()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
Definition: utils.cc:37

◆ getClean()

bool ast::FitsChan::getClean ( ) const
inline

Get Clean: remove cards used whilst reading even if an error occurs?

Definition at line 516 of file FitsChan.h.

516 { return getB("Clean"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getComment()

bool ast::Channel::getComment ( ) const
inlineinherited

Get Comment: include textual comments in output?

Definition at line 90 of file Channel.h.

90 { return getB("Comment"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getD()

double ast::Object::getD ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as a double.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 374 of file Object.h.

374  {
375  double val = astGetD(getRawPtr(), attrib.c_str());
376  assertOK();
377  return val;
378  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getDefB1950()

bool ast::FitsChan::getDefB1950 ( ) const
inline

Get DefB1950: use FK4 B1950 as default equatorial coordinates?

Definition at line 521 of file FitsChan.h.

521 { return getB("DefB1950"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getEncoding()

std::string ast::FitsChan::getEncoding ( ) const
inline

Get Encoding: the encoding system to use when AST Objects are stored as FITS header cards in a FitsChan.

Definition at line 527 of file FitsChan.h.

527 { return getC("Encoding"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getF()

float ast::Object::getF ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as a float.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 387 of file Object.h.

387  {
388  float val = astGetF(getRawPtr(), attrib.c_str());
389  assertOK();
390  return val;
391  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getFitsAxisOrder()

std::string ast::FitsChan::getFitsAxisOrder ( ) const
inline

Get FitsAxisOrder: the order for the WCS axes in any new FITS-WCS headers created using Channel::write.

Definition at line 533 of file FitsChan.h.

533 { return getC("FitsAxisOrder"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getFitsCF()

FoundValue< std::complex< double > > ast::FitsChan::getFitsCF ( std::string const &  name = "",
std::complex< double >  defval = {0, 0} 
) const

Get the value of a complex double card.

Parameters
[in]nameName of keyword, or empty for the current card
[in]defvalValue to return if keyword not found
Returns
value as a FoundValue, where found is false if the keyword was not found

Notes

  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 59 of file FitsChan.cc.

60  {
61  std::complex<double> val = defval;
62  // this use of reinterpret_cast is explicitly permitted, for C compatibility
63  double *rawval = reinterpret_cast<double(&)[2]>(val);
64  bool found = astGetFitsCF(getRawPtr(), cstrOrNull(name), rawval);
65  assertOK();
66  return FoundValue<std::complex<double>>(found, val);
67 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getFitsCN()

FoundValue< std::string > ast::FitsChan::getFitsCN ( std::string const &  name = "",
std::string  defval = "" 
) const

Get the value of a CONTINUE card.

CONTINUE cards are treated like string values, but are encoded without an equals sign.

Parameters
[in]nameName of keyword, or empty for the current card
[in]defvalvalue to return if keyword not found
Returns
value as a FoundValue, where found is false if the keyword was not found

Notes

  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 69 of file FitsChan.cc.

69  {
70  char *rawval; // astGetFitsCN has its own static buffer for the value
71  bool found = astGetFitsCN(getRawPtr(), cstrOrNull(name), &rawval);
72  assertOK();
73  std::string val = found ? rawval : defval;
74  return FoundValue<std::string>(found, val);
75 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146
STL class.

◆ getFitsDigits()

int ast::FitsChan::getFitsDigits ( ) const
inline

Get FitsDigits: digits of precision for floating-point FITS values.

Definition at line 539 of file FitsChan.h.

539 { return getI("FitsDigits"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getFitsF()

FoundValue< double > ast::FitsChan::getFitsF ( std::string const &  name = "",
double  defval = 0 
) const

Get the value of a double card.

Parameters
[in]nameName of keyword, or empty for the current card
[in]defvalvalue to return if keyword not found
Returns
value as a FoundValue, where found is false if the keyword was not found

Notes

  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 77 of file FitsChan.cc.

77  {
78  double val = defval;
79  bool found = astGetFitsF(getRawPtr(), cstrOrNull(name), &val);
80  assertOK();
81  return FoundValue<double>(found, val);
82 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getFitsI()

FoundValue< int > ast::FitsChan::getFitsI ( std::string const &  name = "",
int  defval = 0 
) const

Get the value of a int card.

Parameters
[in]nameName of keyword, or empty for the current card
[in]defvalvalue to return if keyword not found
Returns
value as a FoundValue, where found is false if the keyword was not found

Notes

  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 84 of file FitsChan.cc.

84  {
85  int val = defval;
86  bool found = astGetFitsI(getRawPtr(), cstrOrNull(name), &val);
87  assertOK();
88  return FoundValue<int>(found, val);
89 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getFitsL()

FoundValue< bool > ast::FitsChan::getFitsL ( std::string const &  name = "",
bool  defval = false 
) const

Get the value of a bool card.

Parameters
[in]nameName of keyword, or empty for the current card
[in]defvalValue to return if keyword not found
Returns
value as a FoundValue, where found is false if the keyword was not found

Notes

  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 91 of file FitsChan.cc.

91  {
92  int val = static_cast<int>(defval);
93  bool found = astGetFitsL(getRawPtr(), cstrOrNull(name), &val);
94  assertOK();
95  return FoundValue<bool>(found, static_cast<bool>(val));
96 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getFitsS()

FoundValue< std::string > ast::FitsChan::getFitsS ( std::string const &  name = "",
std::string  defval = "" 
) const

Get the value of a string card.

Parameters
[in]nameName of keyword, or empty for the current card
[in]defvalValue to return if keyword not found
Returns
value as a FoundValue, where found is false if the keyword was not found

Notes

  • The FITS standard says that string keyword values should be padded with trailing spaces if they are shorter than 8 characters. For this reason, trailing spaces are removed from the returned string if the original string (including any trailing spaces) contains 8 or fewer characters. Trailing spaces are not removed from longer strings.
  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 98 of file FitsChan.cc.

98  {
99  char *rawval; // astGetFitsS has its own static buffer for the value
100  bool found = astGetFitsS(getRawPtr(), cstrOrNull(name), &rawval);
101  assertOK();
102  std::string val = found ? rawval : defval;
103  return FoundValue<std::string>(found, val);
104 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146
STL class.

◆ getFitsTol()

double ast::FitsChan::getFitsTol ( ) const
inline

Get FitsTol: Tolerance used for writing a FrameSet using a foreign encoding.

Definition at line 544 of file FitsChan.h.

544 { return getD("FitsTol"); }
double getD(std::string const &attrib) const
Get the value of an attribute as a double.
Definition: Object.h:374

◆ getFull()

int ast::Channel::getFull ( ) const
inlineinherited

Get Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.

Definition at line 93 of file Channel.h.

93 { return getI("Full"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getI()

int ast::Object::getI ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as an int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 400 of file Object.h.

400  {
401  int val = astGetI(getRawPtr(), attrib.c_str());
402  assertOK();
403  return val;
404  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getID()

std::string ast::Object::getID ( ) const
inlineinherited

Get ID: object identification string that is not copied.

Definition at line 142 of file Object.h.

142 { return getC("ID"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getIdent()

std::string ast::Object::getIdent ( ) const
inlineinherited

Get Ident: object identification string that is copied.

Definition at line 145 of file Object.h.

145 { return getC("Ident"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ getIndent()

int ast::Channel::getIndent ( ) const
inlineinherited

Get Indent: indentation increment between objects.

Definition at line 96 of file Channel.h.

96 { return getB("Indent"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getIwc()

bool ast::FitsChan::getIwc ( ) const
inline

Get Iwc: add a Frame describing Intermediate World Coords?

Definition at line 549 of file FitsChan.h.

549 { return getB("Iwc"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getL()

long int ast::Object::getL ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as a long int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 413 of file Object.h.

413  {
414  long int val = astGetL(getRawPtr(), attrib.c_str());
415  assertOK();
416  return val;
417  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getNCard()

int ast::FitsChan::getNCard ( ) const
inline

Get NCard: the number of cards.

Definition at line 554 of file FitsChan.h.

554 { return getI("NCard"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getNKey()

int ast::FitsChan::getNKey ( ) const
inline

Get Nkey: the number of unique keywords.

Definition at line 559 of file FitsChan.h.

559 { return getI("NKey"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getNObject()

int ast::Object::getNObject ( ) const
inlineinherited

Get NObject: number of AST objects in existence of the same type as the underlying AST class.

Warning
Intended only for debugging astshim.

Definition at line 153 of file Object.h.

153 { return getI("NObject"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getObjSize()

int ast::Object::getObjSize ( ) const
inlineinherited

Get ObjSize: the in-memory size of the AST object in bytes.

Definition at line 156 of file Object.h.

156 { return getI("ObjSize"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getPolyTan()

int ast::FitsChan::getPolyTan ( ) const
inline

Get PolyTan: use PVi_m keywords to define distorted TAN projection?

Definition at line 581 of file FitsChan.h.

581 { return getI("PolyTan"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getRawPtr() [1/2]

AstObject const* ast::Object::getRawPtr ( ) const
inlineinherited

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 292 of file Object.h.

292 { return &*_objPtr; };

◆ getRawPtr() [2/2]

AstObject* ast::Object::getRawPtr ( )
inlineinherited

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 294 of file Object.h.

294 { return &*_objPtr; };

◆ getRefCount()

int ast::Object::getRefCount ( ) const
inlineinherited

Get RefCount: number of active pointers to the underlying AST object.

Warning
Intended only for debugging astshim.

Definition at line 163 of file Object.h.

163 { return getI("RefCount"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getReportLevel()

int ast::Channel::getReportLevel ( ) const
inlineinherited

Get ReportLevel: report level.

Definition at line 99 of file Channel.h.

99 { return getI("ReportLevel"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getSipOK()

bool ast::FitsChan::getSipOK ( ) const
inline

Get SipOK: use Spitzer Space Telescope keywords to define distortion?

Definition at line 564 of file FitsChan.h.

564 { return getB("SipOK"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getSipReplace()

bool ast::FitsChan::getSipReplace ( ) const
inline

Get SipReplace: ignore inverse SIP coefficients (replacing them with fit coefficients or an iterative inverse)?

Definition at line 570 of file FitsChan.h.

570 { return getB("SipReplace"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getSkip()

bool ast::Channel::getSkip ( ) const
inlineinherited

Get Skip: skip irrelevant data on input?

Definition at line 102 of file Channel.h.

102 { return getB("Skip"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getStrict()

bool ast::Channel::getStrict ( ) const
inlineinherited

Get Strict: generate errors instead of warnings?

Definition at line 105 of file Channel.h.

105 { return getB("Strict"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getTabOK()

int ast::FitsChan::getTabOK ( ) const
inline

Get TabOK: should the FITS "-TAB" algorithm be recognised?

Definition at line 575 of file FitsChan.h.

575 { return getI("TabOK"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:400

◆ getUseDefs()

bool ast::Object::getUseDefs ( ) const
inlineinherited

Get UseDefs: allow use of default values for Object attributes?

Definition at line 166 of file Object.h.

166 { return getB("UseDefs"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:348

◆ getWarnings()

std::string ast::FitsChan::getWarnings ( ) const
inline

Get Warnings attribute, which controls the issuing of warnings about selected conditions when an Object or keyword is read from or written to a FitsChan.

Definition at line 587 of file FitsChan.h.

587 { return getC("Warnings"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:361

◆ hasAttribute()

bool ast::Object::hasAttribute ( std::string const &  attrib) const
inlineinherited

Does this object have an attribute with the specified name?

Definition at line 127 of file Object.h.

127  {
128  bool ret = astHasAttribute(getRawPtr(), attrib.c_str());
129  assertOK();
130  return ret;
131  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ lock()

void ast::Object::lock ( bool  wait)
inlineinherited

Lock this object for exclusive use by the calling thread.

The thread-safe public interface to AST is designed so that an error is reported if any thread attempts to use an Object that it has not previously locked for its own exclusive use using this function. When an Object is created, it is initially locked by the thread that creates it, so newly created objects do not need to be explicitly locked. However, if an Object pointer is passed to another thread, the original thread must first unlock it (using astUnlock) and the new thread must then lock it (using astLock) before the new thread can use the Object.

Parameters
[in]waitIf the Object is curently locked by another thread then this function will either report an error or block. If a non-zero value is supplied for "wait", the calling thread waits until the object is available for it to use. Otherwise, an error is reported and the function returns immediately without locking the Object.

Notes

  • The Locked object will belong to the current AST context.
  • This function returns without action if the Object is already locked by the calling thread.
  • If simultaneous use of the same object is required by two or more threads, Object::copy should be used to to produce a deep copy of the Object for each thread. Each copy should then be unlocked by the parent thread (i.e. the thread that created the copy), and then locked by the child thread (i.e. the thread that wants to use the copy).
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 202 of file Object.h.

202  {
203  astLock(getRawPtr(), static_cast<int>(wait));
204  assertOK();
205  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ makeShim()

template<typename ShimT , typename AstT >
static std::shared_ptr<ShimT> ast::Object::makeShim ( AstObject *  p)
inlinestaticprotectedinherited

Functor to make an astshim instance from a raw AST pointer of the corresponding type.

Template Parameters
ShimTOutput astshim class
AstTOutput AST class

Definition at line 310 of file Object.h.

310  {
311  return std::shared_ptr<ShimT>(new ShimT(reinterpret_cast<AstT *>(p)));
312  }

◆ operator!=()

bool ast::Object::operator!= ( Object const &  rhs) const
inlineinherited

Return True if this and rhs are not equal.

See operator== for details

Definition at line 82 of file Object.h.

82  {
83  return !(*this == rhs); };

◆ operator=() [1/2]

FitsChan& ast::FitsChan::operator= ( FitsChan const &  )
delete

◆ operator=() [2/2]

FitsChan& ast::FitsChan::operator= ( FitsChan &&  )
default

◆ operator==()

bool ast::Object::operator== ( Object const &  rhs) const
inherited

Return True if this and rhs are the equal.

For two objects be equal, they both must have the same attributes and all contained objects must be equal.

Definition at line 82 of file Object.cc.

82  {
83  auto thisStr = this->show(false);
84  auto rhsStr = rhs.show(false);
85  return rhsStr == thisStr;
86 }
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition: Object.cc:152

◆ purgeWcs()

void ast::FitsChan::purgeWcs ( )
inline

Delete all cards in a FitsChan that relate to any of the recognised WCS encodings.

On exit, the current card is the first remaining card in the FitsChan.

Definition at line 594 of file FitsChan.h.

594  {
595  astPurgeWCS(getRawPtr());
596  assertOK();
597  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ putCards()

void ast::FitsChan::putCards ( std::string const &  cards)
inline

Replace all FITS header cards.

The cards are supplied concatenated together into a single character string. Any existing cards in the FitsChan are removed before the new cards are added. The FitsChan is "re-wound" on exit. This means that a subsequent invocation of read can be made immediately without the need to re-wind the FitsChan first.

Parameters
[in]cardsA string containing the FITS cards to be stored. Each individual card should occupy 80 characters in this string, and there should be no delimiters, new lines, etc, between adjacent cards. The final card may be less than 80 characters long. This is the format produced by the fits_hdr2str function in the CFITSIO library.

Definition at line 615 of file FitsChan.h.

615  {
616  astPutCards(getRawPtr(), cards.c_str());
617  assertOK();
618  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ putFits()

void ast::FitsChan::putFits ( std::string const &  card,
bool  overwrite 
)
inline

Store a FITS header card in a FitsChan.

The card is either inserted before the current card or over-writes the current card, depending on overwrite.

Parameters
[in]cardA character string containing the FITS cards to be stored. Each individual card should occupy 80 characters in this string, and there should be no delimiters, new lines, etc, between adjacent cards. The final card may be less than 80 characters long. This is the format produced by the fits_hdr2str function in the CFITSIO library.
[in]overwriteif false, the new card is inserted in before the current card. If true the new card replaces the current card. In either case, the Card attribute is then incremented by one so that it subsequently identifies the card following the one stored.

Notes

  • If the Card attribute initially points at the "end-of-file" (i.e. exceeds the number of cards in the FitsChan), then the new card is appended as the last card in the FitsChan.
  • An error will result if the supplied string cannot be interpreted as a FITS header card.

Definition at line 643 of file FitsChan.h.

643  {
644  astPutFits(getRawPtr(), card.c_str(), overwrite);
645  assertOK();
646  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ read()

std::shared_ptr< Object > ast::Channel::read ( )
inherited

Read an object from a channel.

Definition at line 52 of file Channel.cc.

52  {
53  AstObject *rawRet = reinterpret_cast<AstObject *>(astRead(getRawPtr()));
54  assertOK(rawRet);
55  if (!rawRet) {
56  throw std::runtime_error("Could not read an AST object from this channel");
57  }
58  return Object::fromAstObject<Object>(rawRet, false);
59 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ readFits()

void ast::FitsChan::readFits ( )
inline

Read cards from the source and store them in the FitsChan.

This normally happens once-only, when the FitsChan is accessed for the first time. This function provides a means of forcing a re-read of the external source, and may be useful if (say) new cards have been deposited into the external source. Any new cards read from the source are appended to the end of the current contents of the FitsChan.

Notes

  • This is a no-op if the Stream has no source.

Definition at line 660 of file FitsChan.h.

660  {
661  astReadFits(getRawPtr());
662  assertOK();
663  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ retainFits()

void ast::FitsChan::retainFits ( )
inline

Keep the current card when an Object is read that uses the card.

Cards that have not been flagged in this way are removed when a read operation completes succesfully, but only if the card was used in the process of creating the returned Object. Any cards that are irrelevant to the creation of the Object are retained whether or not they are flagged.

Definition at line 673 of file FitsChan.h.

673  {
674  astRetainFits(getRawPtr());
675  assertOK();
676  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ same()

bool ast::Object::same ( Object const &  other) const
inlineinherited

Does this contain the same AST object as another?

This is a test of identity, not of equality.

Definition at line 212 of file Object.h.

212 { return astSame(getRawPtr(), other.getRawPtr()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
ItemVariant const * other
Definition: Schema.cc:56

◆ set()

void ast::Object::set ( std::string const &  setting)
inlineprotectedinherited

Assign a set of attribute values, over-riding any previous values.

The attributes and their new values are specified via a character string, which should contain a comma-separated list of the form: "attribute_1 = value_1, attribute_2 = value_2, ... " where "attribute_n" specifies an attribute name, and the value to the right of each " =" sign should be a suitable textual representation of the value to be assigned. This value will be interpreted according to the attribute's data type.

Notes

  • Attribute names are not case sensitive and may be surrounded by white space
  • Attribute names are not case sensitive and may be surrounded by white space.
  • White space may also surround attribute values, where it will generally be ignored (except for string-valued attributes where it is significant and forms part of the value to be assigned).
  • To include a literal comma or percent sign in the value assigned to an attribute, the whole attribute value should be enclosed in quotation markes.
Exceptions
std::runtime_errorif the attribute is read-only

Definition at line 440 of file Object.h.

440  {
441  astSet(getRawPtr(), "%s", setting.c_str());
442  assertOK();
443  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setB()

void ast::Object::setB ( std::string const &  attrib,
bool  value 
)
inlineprotectedinherited

Set the value of an attribute as a bool.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 452 of file Object.h.

452  {
453  astSetI(getRawPtr(), attrib.c_str(), value);
454  assertOK();
455  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setC()

void ast::Object::setC ( std::string const &  attrib,
std::string const &  value 
)
inlineprotectedinherited

Set the value of an attribute as a string.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 464 of file Object.h.

464  {
465  astSetC(getRawPtr(), attrib.c_str(), value.c_str());
466  assertOK();
467  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setCard()

void ast::FitsChan::setCard ( int  ind)
inline

Set Card: the index of the current card, where 1 is the first card.

Definition at line 1035 of file FitsChan.h.

1035 { setI("Card", ind); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500

◆ setCarLin()

void ast::FitsChan::setCarLin ( bool  cdMatrix)
inline

Set CarLin: ignore spherical rotations on CAR projections?

Definition at line 922 of file FitsChan.h.

922 { setB("CarLin", cdMatrix); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setCDMatrix()

void ast::FitsChan::setCDMatrix ( bool  cdMatrix)
inline

Get CDMatrix: Use CDi_j keywords to represent pixel scaling, rotation, etc?

Definition at line 928 of file FitsChan.h.

928 { setB("CDMatrix", cdMatrix); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setClean()

void ast::FitsChan::setClean ( bool  clean)
inline

Set Clean: remove cards used whilst reading even if an error occurs?

Definition at line 933 of file FitsChan.h.

933 { setB("Clean", clean); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452
def clean(srcMatch, wcs, order=3, nsigma=3)

◆ setComment()

void ast::Channel::setComment ( bool  skip)
inlineinherited

Set Comment: include textual comments in output?

Definition at line 111 of file Channel.h.

111 { setB("Comment", skip); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setD()

void ast::Object::setD ( std::string const &  attrib,
double  value 
)
inlineprotectedinherited

Set the value of an attribute as a double.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 476 of file Object.h.

476  {
477  astSetD(getRawPtr(), attrib.c_str(), value);
478  assertOK();
479  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setDefB1950()

void ast::FitsChan::setDefB1950 ( bool  defB1950)
inline

Set DefB1950: use FK4 B1950 as default equatorial coordinates?

Definition at line 938 of file FitsChan.h.

938 { setB("DefB1950", defB1950); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setEncoding()

void ast::FitsChan::setEncoding ( std::string const &  encoding)
inline

Set Encoding: the encoding system to use when AST Objects are stored as FITS header cards in a FitsChan.

Definition at line 944 of file FitsChan.h.

944 { setC("Encoding", encoding); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:464

◆ setF()

void ast::Object::setF ( std::string const &  attrib,
float  value 
)
inlineprotectedinherited

Set the value of an attribute as a float.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 488 of file Object.h.

488  {
489  astSetF(getRawPtr(), attrib.c_str(), value);
490  assertOK();
491  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFitsAxisOrder()

void ast::FitsChan::setFitsAxisOrder ( std::string const &  order)
inline

Set FitsAxisOrder: the order for the WCS axes in any new FITS-WCS headers created using Channel::write.

Definition at line 950 of file FitsChan.h.

950 { setC("FitsAxisOrder", order); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:464

◆ setFitsCF()

void ast::FitsChan::setFitsCF ( std::string const &  name,
std::complex< double >  value,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new card of type std::complex<double>, possibly overwriting the current card.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]valuethe value of the card.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Definition at line 695 of file FitsChan.h.

696  {
697  // this use of reinterpret_cast is explicitly permitted, for C compatibility
698  astSetFitsCF(getRawPtr(), name.c_str(), reinterpret_cast<double(&)[2]>(value), comment.c_str(),
699  overwrite);
700  assertOK();
701  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFitsCM()

void ast::FitsChan::setFitsCM ( std::string const &  comment,
bool  overwrite = false 
)
inline

Create a new comment card, possibly overwriting the current card.

The card will have a name of " " (eight spaces) and no equals sign. There is presently no way to generate a card with name HISTORY or COMMENT, but FITS treats those essentially the same as cards with blank names.

Parameters
[in]commentComment to associated with the keyword.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • If, on exit, there are no cards following the card written by this function, then the current card is left pointing at the "end-of-file" .
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 724 of file FitsChan.h.

724  {
725  astSetFitsCM(getRawPtr(), comment.c_str(), overwrite);
726  assertOK();
727  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFitsCN()

void ast::FitsChan::setFitsCN ( std::string const &  name,
std::string  value,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new "CONTINUE" card, possibly overwriting the current card.

"CONTINUE" cards are treated like string values, but are encoded without an equals sign.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]valuethe value of the card.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • If, on exit, there are no cards following the card written by this function, then the current card is left pointing at the "end-of-file" .
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 755 of file FitsChan.h.

756  {
757  astSetFitsCN(getRawPtr(), name.c_str(), value.c_str(), comment.c_str(), overwrite);
758  assertOK();
759  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T c_str(T... args)

◆ setFitsDigits()

void ast::FitsChan::setFitsDigits ( int  digits)
inline

Set FitsDigits: digits of precision for floating-point FITS values.

Definition at line 956 of file FitsChan.h.

956 { setI("FitsDigits", digits); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500

◆ setFitsF()

void ast::FitsChan::setFitsF ( std::string const &  name,
double  value,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new card of type double, possibly overwriting the current card.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]valuethe value of the card.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • If, on exit, there are no cards following the card written by this function, then the current card is left pointing at the "end-of-file" .
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 785 of file FitsChan.h.

786  {
787  astSetFitsF(getRawPtr(), name.c_str(), value, comment.c_str(), overwrite);
788  assertOK();
789  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFitsI()

void ast::FitsChan::setFitsI ( std::string const &  name,
int  value,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new card of type int, possibly overwriting the current card.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]valuethe value of the card.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • If, on exit, there are no cards following the card written by this function, then the current card is left pointing at the "end-of-file" .
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 815 of file FitsChan.h.

816  {
817  astSetFitsI(getRawPtr(), name.c_str(), value, comment.c_str(), overwrite);
818  assertOK();
819  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFitsL()

void ast::FitsChan::setFitsL ( std::string const &  name,
bool  value,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new card of type bool, possibly overwriting the current card.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]valuethe value of the card.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • If, on exit, there are no cards following the card written by this function, then the current card is left pointing at the "end-of-file" .
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 845 of file FitsChan.h.

846  {
847  astSetFitsL(getRawPtr(), name.c_str(), value, comment.c_str(), overwrite);
848  assertOK();
849  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFitsS()

void ast::FitsChan::setFitsS ( std::string const &  name,
std::string  value,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new card of type string, possibly overwriting the current card.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]valuethe value of the card.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • The FITS standard says that string keyword values should be padded with trailing spaces if they are shorter than 8 characters. For this reason, trailing spaces are removed from the returned string if the original string (including any trailing spaces) contains 8 or fewer characters. Trailing spaces are not removed from longer strings.
  • If the requested card is found, it becomes the current card; otherwise the current card is left pointing at the end-of-file
  • If the stored keyword values is not of the requested type, it is converted (if possible) into the requested type
  • If the keyword is found but has no associated value, an error is reported. If necessary, the testFits function can be used to determine if the keyword has a defined value, prior to calling this function.

Definition at line 883 of file FitsChan.h.

884  {
885  astSetFitsS(getRawPtr(), name.c_str(), value.c_str(), comment.c_str(), overwrite);
886  assertOK();
887  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T c_str(T... args)

◆ setFitsTol()

void ast::FitsChan::setFitsTol ( double  tol)
inline

Set FitsTol: Tolerance used for writing a FrameSet using a foreign encoding.

Definition at line 961 of file FitsChan.h.

961 { return setD("FitsTol", tol); }
void setD(std::string const &attrib, double value)
Set the value of an attribute as a double.
Definition: Object.h:476

◆ setFitsU()

void ast::FitsChan::setFitsU ( std::string const &  name,
std::string const &  comment = "",
bool  overwrite = false 
)
inline

Create a new card with an undefined value, possibly overwriting the current card.

Parameters
[in]nameName of keyword for the new card. This may be a complete FITS header card, in which case the keyword to use is extracted from it.
[in]commentComment to associated with the keyword. If blank, then any comment included in the string supplied for the name parameter is used instead. If name contains no comment, then any existing comment in the card being over-written is retained. Otherwise, no comment is stored with the card.
[in]overwriteif true the new card formed from the supplied keyword name, value and comment over-writes the current card, and the current card is incremented to refer to the next card (see the Card attribute). If false, the new card is inserted before the current card and the current card is left unchanged. In either case, if the current card on entry points to the "end-of-file", the new card is appended to the end of the list.

Notes

  • To assign a new value for an existing keyword, first find the card describing the keyword using findFits, and then use the appropriate setFits function to over-write the old value.
  • If, on exit, there are no cards following the card written by this function, then the current card is left pointing at the "end-of-file" .
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 914 of file FitsChan.h.

914  {
915  astSetFitsU(getRawPtr(), name.c_str(), comment.c_str(), overwrite);
916  assertOK();
917  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setFull()

void ast::Channel::setFull ( int  full)
inlineinherited

Set Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.

Definition at line 114 of file Channel.h.

114 { setI("Full", full); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500

◆ setI()

void ast::Object::setI ( std::string const &  attrib,
int  value 
)
inlineprotectedinherited

Set the value of an attribute as an int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 500 of file Object.h.

500  {
501  astSetI(getRawPtr(), attrib.c_str(), value);
502  assertOK();
503  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setID()

void ast::Object::setID ( std::string const &  id)
inlineinherited

Set ID: object identification string that is not copied.

Definition at line 215 of file Object.h.

215 { setC("ID", id); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:464

◆ setIdent()

void ast::Object::setIdent ( std::string const &  ident)
inlineinherited

Set Ident: object identification string that is copied.

Definition at line 218 of file Object.h.

218 { setC("Ident", ident); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:464

◆ setIndent()

void ast::Channel::setIndent ( int  indent)
inlineinherited

Set Indent: indentation increment between objects.

Definition at line 117 of file Channel.h.

117 { setI("Indent", indent); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500

◆ setIwc()

void ast::FitsChan::setIwc ( bool  iwcs)
inline

Set Iwc: add a Frame describing Intermediate World Coords?

Definition at line 966 of file FitsChan.h.

966 { setB("Iwc", iwcs); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setL()

void ast::Object::setL ( std::string const &  attrib,
long int  value 
)
inlineprotectedinherited

Set the value of an attribute as a long int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 512 of file Object.h.

512  {
513  astSetL(getRawPtr(), attrib.c_str(), value);
514  assertOK();
515  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setPolyTan()

void ast::FitsChan::setPolyTan ( int  polytan)
inline

Set PolyTan: use PVi_m keywords to define distorted TAN projection?

Definition at line 988 of file FitsChan.h.

988 { setI("PolyTan", polytan); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500

◆ setReportLevel()

void ast::Channel::setReportLevel ( int  level)
inlineinherited

Set ReportLevel: report level; an integer in the range [0, 3] where 0 is the most verbose.

Exceptions
std::invalid_argumentif level is not in range [0, 3]

Definition at line 125 of file Channel.h.

125  {
126  if ((level < 0) || (level > 3)) {
128  os << "level = " << level << " not in range [0, 3]";
129  throw std::invalid_argument(os.str());
130  }
131  setI("ReportLevel", level);
132  }
T str(T... args)
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500
std::ostream * os
Definition: Schema.cc:746

◆ setSipOK()

void ast::FitsChan::setSipOK ( bool  sipOK)
inline

Set SipOK: use Spitzer Space Telescope keywords to define distortion?

Definition at line 971 of file FitsChan.h.

971 { setB("SipOK", sipOK); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setSipReplace()

void ast::FitsChan::setSipReplace ( bool  replace)
inline

Set SipReplace: ignore inverse SIP coefficients (replacing them with fit coefficients or an iterative inverse)?

Definition at line 977 of file FitsChan.h.

977 { setB("SipReplace", replace); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setSkip()

void ast::Channel::setSkip ( bool  skip)
inlineinherited

Set Skip: skip irrelevant data on input?

Definition at line 135 of file Channel.h.

135 { setB("Skip", skip); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setStrict()

void ast::Channel::setStrict ( bool  strict)
inlineinherited

Set Strict: generate errors instead of warnings?

Definition at line 138 of file Channel.h.

138 { setB("Strict", strict); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setTabOK()

void ast::FitsChan::setTabOK ( int  tabOK)
inline

Set TabOK: should the FITS "-TAB" algorithm be recognised?

Definition at line 982 of file FitsChan.h.

982 { setI("TabOK", tabOK); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition: Object.h:500

◆ setUseDefs()

void ast::Object::setUseDefs ( bool  usedefs)
inlineinherited

Set UseDefs: allow use of default values for Object attributes?

Definition at line 221 of file Object.h.

221 { setB("UseDefs", usedefs); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:452

◆ setWarnings()

void ast::FitsChan::setWarnings ( std::string const &  warnings)
inline

Set Warnings attribute, which controls the issuing of warnings about selected conditions when an Object or keyword is read from or written to a FitsChan.

Definition at line 994 of file FitsChan.h.

994 { setC("Warnings", warnings); }
KeyMap warnings() const
Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of rea...
Definition: Channel.cc:67
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:464

◆ show() [1/2]

void ast::Object::show ( std::ostream os,
bool  showComments = true 
) const
inherited

Print a textual description the object to an ostream.

Parameters
[in,out]osThe stream to which to write the string representation.
[in]showCommentsShow comments?

Definition at line 152 of file Object.cc.

152  {
153  Stream stream(nullptr, &os);
154  Channel ch(stream, showComments ? "" : "Comment=0");
155  ch.write(*this);
156  assertOK();
157 }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ show() [2/2]

std::string ast::Object::show ( bool  showComments = true) const
inherited

Return a textual description the object as a string.

Parameters
[in]showCommentsShow comments?

Definition at line 159 of file Object.cc.

159  {
161  show(os, showComments);
162  return os.str();
163 }
T str(T... args)
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition: Object.cc:152
std::ostream * os
Definition: Schema.cc:746

◆ showFits()

void ast::FitsChan::showFits ( ) const
inline

Write all the cards in the channel to standard output.

Definition at line 999 of file FitsChan.h.

999  {
1000  astShowFits(getRawPtr());
1001  assertOK();
1002  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ test()

bool ast::Object::test ( std::string const &  attrib) const
inlineinherited

Has this attribute been explicitly set (and not subsequently cleared)?

Warning
Unlike the underlying astTest function, throws an exception if an error results

Notes

  • Attribute names are not case sensitive and may be surrounded by white space.
  • As you might expect, the returned value for a read-only attribute is always false.
Exceptions
std::runtime_errorif an error results.

Definition at line 250 of file Object.h.

250  {
251  bool res = astTest(getRawPtr(), attrib.c_str());
252  assertOK();
253  return res;
254  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ testFits()

FitsKeyState ast::FitsChan::testFits ( std::string const &  name = "") const

Determine if a card is present, and if so, whether it has a value.

Parameters
[in]nameName of keyword, or empty for the current card

Notes

  • This function does not change the current card.
  • If name is not empty then the card following the current card is checked first. If this is not the required card, then the rest of the FitsChan is searched, starting with the first card added to the FitsChan. Therefore cards should be accessed in the order they are stored in the FitsChan (if possible) as this will minimise the time spent searching for cards.
  • An error will be reported if the keyword name does not conform to FITS requirements.

Definition at line 132 of file FitsChan.cc.

132  {
133  int there;
134  int hasvalue = astTestFits(getRawPtr(), cstrOrNull(name), &there);
135  assertOK();
136  if (hasvalue) {
137  return FitsKeyState::PRESENT;
138  }
140 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
keyword is present and has a value
keyword is present, but has no value
keyword is not present

◆ unlock()

void ast::Object::unlock ( bool  report = false)
inlineinherited

Unlock this object previously locked using lock, so that other threads can use this object.

See lock for further details.

Parameters
[in]reportIf true, an error will be reported if the supplied Object, or any Object contained within the supplied Object, is not currently locked by the running thread. If false, such Objects will be left unchanged, and no error will be reported.

Notes

  • This function attempts to execute even if AST's global error status is set, but no further error report will be made if it subsequently fails under these circumstances.
  • All unlocked Objects are excluded from AST context handling until they are re-locked using astLock.
  • This function returns without action if the Object is not currently locked by any thread. If it is locked by the running thread, it is unlocked. If it is locked by another thread, an error will be reported if "error" is non-zero.
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 280 of file Object.h.

280  {
281  astUnlock(getRawPtr(), static_cast<int>(report));
282  assertOK();
283  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ warnings()

KeyMap ast::Channel::warnings ( ) const
inherited

Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of read or write.

If no warnings were issued, an empty KeyMap will be returned. Such warnings are non-fatal and will not prevent the read or write operation succeeding. However, the converted object may not be identical to the original object in all respects. Differences which would usually be deemed as insignificant in most usual cases will generate a warning, whereas more significant differences will generate an error.

The " Strict" attribute allows this warning facility to be switched off, so that a fatal error is always reported for any conversion error.

Definition at line 67 of file Channel.cc.

67  {
68  AstKeyMap *rawKeyMap =
69  reinterpret_cast<AstKeyMap *>(astWarnings(reinterpret_cast<AstChannel const *>(getRawPtr())));
70  assertOK();
71  return rawKeyMap ? KeyMap(rawKeyMap) : KeyMap();
72 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ write()

int ast::Channel::write ( Object const &  object)
inherited

Write an object to a channel.

Definition at line 61 of file Channel.cc.

61  {
62  int ret = astWrite(getRawPtr(), object.getRawPtr());
63  assertOK();
64  return ret;
65 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ writeFits()

void ast::FitsChan::writeFits ( )
inline

Write out all cards currently in the channel and clear the channel.

Definition at line 1024 of file FitsChan.h.

1024  {
1025  astWriteFits(getRawPtr());
1026  assertOK();
1027  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

The documentation for this class was generated from the following files: