|
| FitsChan (Stream &stream, std::string const &options="") |
|
virtual | ~FitsChan () |
|
| FitsChan (FitsChan const &)=delete |
|
| FitsChan (FitsChan &&)=default |
|
FitsChan & | operator= (FitsChan const &)=delete |
|
FitsChan & | operator= (FitsChan &&)=default |
|
void | delFits () |
|
void | emptyFits () |
|
FoundValue< std::string > | findFits (std::string const &name, bool inc) |
|
FoundValue< std::complex< double > > | getFitsCF (std::string const &name="", std::complex< double > defval={0, 0}) const |
|
FoundValue< std::string > | getFitsCN (std::string const &name="", std::string defval="") const |
|
FoundValue< double > | getFitsF (std::string const &name="", double defval=0) const |
|
FoundValue< int > | getFitsI (std::string const &name="", int defval=0) const |
|
FoundValue< bool > | getFitsL (std::string const &name="", bool defval=false) const |
|
FoundValue< std::string > | getFitsS (std::string const &name="", std::string defval="") const |
|
std::vector< std::string > | getAllCardNames () |
|
std::string | getAllWarnings () const |
|
int | getCard () const |
|
std::string | getCardComm () const |
|
std::string | getCardName () const |
|
CardType | getCardType () const |
|
bool | getCarLin () const |
|
bool | getCDMatrix () const |
|
bool | getClean () const |
|
bool | getDefB1950 () const |
|
std::string | getEncoding () const |
|
std::string | getFitsAxisOrder () const |
|
int | getFitsDigits () const |
|
double | getFitsTol () const |
|
bool | getIwc () const |
|
int | getNCard () const |
|
int | getNKey () const |
|
bool | getSipOK () const |
|
bool | getSipReplace () const |
|
int | getTabOK () const |
|
int | getPolyTan () const |
|
std::string | getWarnings () const |
|
void | purgeWcs () |
|
void | putCards (std::string const &cards) |
|
void | putFits (std::string const &card, bool overwrite) |
|
void | readFits () |
|
void | retainFits () |
|
void | setFitsCF (std::string const &name, std::complex< double > value, std::string const &comment="", bool overwrite=false) |
|
void | setFitsCM (std::string const &comment, bool overwrite=false) |
|
void | setFitsCN (std::string const &name, std::string value, std::string const &comment="", bool overwrite=false) |
|
void | setFitsF (std::string const &name, double value, std::string const &comment="", bool overwrite=false) |
|
void | setFitsI (std::string const &name, int value, std::string const &comment="", bool overwrite=false) |
|
void | setFitsL (std::string const &name, bool value, std::string const &comment="", bool overwrite=false) |
|
void | setFitsS (std::string const &name, std::string value, std::string const &comment="", bool overwrite=false) |
|
void | setFitsU (std::string const &name, std::string const &comment="", bool overwrite=false) |
|
void | setCarLin (bool cdMatrix) |
|
void | setCDMatrix (bool cdMatrix) |
|
void | setClean (bool clean) |
|
void | setDefB1950 (bool defB1950) |
|
void | setEncoding (std::string const &encoding) |
|
void | setFitsAxisOrder (std::string const &order) |
|
void | setFitsDigits (int digits) |
|
void | setFitsTol (double tol) |
|
void | setIwc (bool iwcs) |
|
void | setSipOK (bool sipOK) |
|
void | setSipReplace (bool replace) |
|
void | setTabOK (int tabOK) |
|
void | setPolyTan (int polytan) |
|
void | setWarnings (std::string const &warnings) |
|
void | showFits () const |
|
FitsKeyState | testFits (std::string const &name="") const |
|
void | writeFits () |
|
void | clearCard () |
| Rewind the card index to the beginning. More...
|
|
void | setCard (int ind) |
|
std::shared_ptr< KeyMap > | getTables () const |
|
| FitsChan (AstFitsChan *rawFitsChan) |
|
| Channel (Stream &stream, std::string const &options="") |
|
virtual | ~Channel () |
|
| Channel (Channel const &)=delete |
|
| Channel (Channel &&)=default |
|
Channel & | operator= (Channel const &)=delete |
|
Channel & | operator= (Channel &&)=default |
|
std::shared_ptr< Channel > | copy () 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< Object > | read () |
| 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) |
|
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 |
|
int | write (Object const &object) |
| Write an object to a channel. More...
|
|
virtual | ~Object () |
|
| Object (Object const &object) |
| Copy constructor: make a deep copy. More...
|
|
| Object (Object &&)=default |
|
Object & | operator= (Object const &)=delete |
|
Object & | operator= (Object &&)=default |
|
bool | operator== (Object const &rhs) const |
|
bool | operator!= (Object const &rhs) const |
|
std::shared_ptr< Object > | copy () const |
| Return a deep copy of this object. More...
|
|
void | clear (std::string const &attrib) |
|
bool | hasAttribute (std::string const &attrib) const |
|
std::string | getClassName () const |
|
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 |
|
int | getObjSize () const |
| Get ObjSize: the in-memory size of the AST object in bytes. More...
|
|
int | getRefCount () const |
|
bool | getUseDefs () const |
| Get UseDefs: allow use of default values for Object attributes? More...
|
|
void | lock (bool wait) |
|
bool | same (Object const &other) const |
|
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 |
|
std::string | show (bool showComments=true) const |
|
bool | test (std::string const &attrib) const |
|
void | unlock (bool report=false) |
|
AstObject const * | getRawPtr () const |
|
AstObject * | getRawPtr () |
|
|
using | ObjectPtr = std::unique_ptr< AstObject, Deleter > |
| unique pointer holding an AST raw pointer More...
|
|
static std::shared_ptr< Object > | fromString (std::string const &str) |
|
template<typename Class > |
static std::shared_ptr< Class > | fromAstObject (AstObject *rawObj, bool copy) |
|
virtual std::shared_ptr< Object > | copyPolymorphic () const override |
|
| Channel (AstChannel *chan, Stream &stream, bool isFits=false) |
|
| Channel (AstChannel *chan) |
|
| Object (AstObject *object) |
|
template<typename T , typename AstT > |
std::shared_ptr< T > | copyImpl () const |
|
bool | getB (std::string const &attrib) const |
|
std::string const | getC (std::string const &attrib) const |
|
double | getD (std::string const &attrib) const |
|
float | getF (std::string const &attrib) const |
|
int | getI (std::string const &attrib) const |
|
long int | getL (std::string const &attrib) const |
|
void | set (std::string const &setting) |
|
void | setB (std::string const &attrib, bool value) |
|
void | setC (std::string const &attrib, std::string const &value) |
|
void | setD (std::string const &attrib, double value) |
|
void | setF (std::string const &attrib, float value) |
|
void | setI (std::string const &attrib, int value) |
|
void | setL (std::string const &attrib, long int value) |
|
template<typename ShimT , typename AstT > |
static std::shared_ptr< ShimT > | makeShim (AstObject *p) |
|
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:
- astGetTables
- astPutTable
- astPutTables
- astRemoveTables
- astTableSource
Attributes
FitsChan has the following attributes, in addition to those provided by Channel and Object
- AllWarnings: A list of the available conditions
- Card: Index of current FITS card in a FitsChan
- CardComm: The comment of the current FITS card in a FitsChan
- CardName: The keyword name of the current FITS card in a FitsChan
- CardType: The data type of the current FITS card in a FitsChan
- CarLin: Ignore spherical rotations on CAR projections?
- CDMatrix: Use a CD matrix instead of a PC matrix?
- Clean: Remove cards used whilst reading even if an error occurs?
- DefB1950: Use FK4 B1950 as default equatorial coordinates?
- Encoding: System for encoding Objects as FITS headers
- FitsAxisOrder: Sets the order of WCS axes within new FITS-WCS headers
- FitsDigits: Digits of precision for floating-point FITS values
- FitsTol: Tolerance used for writing a FrameSet using a foreign encoding
- Iwc: Add a Frame describing Intermediate World Coords?
- NCard: Number of FITS header cards in a FitsChan
- Nkey: Number of unique keywords in a FitsChan
- SipOK: Use Spitzer Space Telescope keywords to define distortion?
- SipReplace: Ignore inverse SIP coefficients (replacing them with fit coefficients or an iterative inverse)?
- TabOK: Should the FITS "-TAB" algorithm be recognised?
- PolyTan: Use PVi_m keywords to define distorted TAN projection?
- Warnings: Produces warnings about selected conditions
Notes
- Call setFitsU to store a keyword that has no associated value (i.e. a card with unknown value).
- Call setFitsCM to store a pure comment card (i.e. a card with a blank keyword).
- 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 (e.g. setFitsS) to overwrite the old value.
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.
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] | name | The 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] | inc | If 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.