casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
casa::RegionTextParser Class Reference

Parse and store regions and annotations from an ascii region file <author>Dave Mehringer</author> More...

#include <RegionTextParser.h>

Classes

struct  ParamValue
 because of nonstandard access patterns, be careful when using ParamValue and ParamSet outside this class. More...
 

Public Types

using ParamSet = std::map< AnnotationBase::Keyword, ParamValue >
 

Public Member Functions

 RegionTextParser ()=delete
 
 RegionTextParser (const casacore::String &filename, const casacore::CoordinateSystem &csys, const casacore::IPosition &imShape, const casacore::Int requireAtLeastThisVersion, const casacore::String &prependRegion="", const casacore::String &globalOverrideChans="", const casacore::String &globalOverrrideStokes="", casacore::Bool verbose=true, casacore::Bool requireImageRegion=true)
 differentiating between the filename and simple text constructors globalOverrideChans override all spectral selections in the file or text by using this channel selection <src>globalOverrideStokes override all correlation selections in the file or text by using this polarization selection <src>prependRegion allows one to specify region(s) that will be prepended to any text in filename or text requireImageRegion is passed to the AnnRegion constructors to indicate whether to rethrow ToLCRegionConversionError exception when the region is outside the image lattice, or create the object even if the ImageRegion has no lattice region. More...
 
 RegionTextParser (const casacore::CoordinateSystem &csys, const casacore::IPosition &imShape, const casacore::String &text, const casacore::String &prependRegion="", const casacore::String &globalOverrideChans="", const casacore::String &globalOverrrideStokes="", casacore::Bool verbose=true, casacore::Bool requireImageRegion=true)
 
 ~RegionTextParser ()
 
RegionTextParseroperator= (const RegionTextParser &)=delete
 
casacore::Int getFileVersion () const
 
std::vector
< AsciiAnnotationFileLine
getLines () const
 

Static Public Member Functions

static ParamSet getParamSet (casacore::Bool &spectralParmsUpdated, casacore::LogIO &log, const casacore::String &text, const casacore::String &preamble, const casacore::CoordinateSystem &csys, std::shared_ptr< std::pair< casacore::MFrequency, casacore::MFrequency > > overridingFreqRange, std::shared_ptr< casacore::Vector< casacore::Stokes::StokesTypes > > overridingCorrRange)
 get the parameter set from a line of text. More...
 

Static Public Attributes

static const casacore::Int CURRENT_VERSION
 
static const casacore::Regex MAGIC
 

Private Member Functions

void _parse (const casacore::String &contents, const casacore::String &fileDesc, casacore::Bool requireImageRegion)
 
casacore::Array< casacore::String_extractTwoPairs (casacore::uInt &end, const casacore::String &string) const
 
void _addLine (const AsciiAnnotationFileLine &line)
 
AnnotationBase::Type _getAnnotationType (casacore::Vector< casacore::Quantity > &qDirs, std::vector< casacore::Quantity > &quantities, casacore::String &textString, casacore::String &consumeMe, const casacore::String &preamble) const
 
ParamSet _getCurrentParamSet (casacore::Bool &spectralParmsUpdated, ParamSet &newParams, casacore::String &consumeMe, const casacore::String &preamble) const
 
void _createAnnotation (const AnnotationBase::Type annType, const casacore::Vector< casacore::Quantity > &qDirs, const std::pair< casacore::Quantity, casacore::Quantity > &qFreqs, const std::vector< casacore::Quantity > &quantities, const casacore::String &textString, const ParamSet &currentParamSet, const casacore::Bool annOnly, const casacore::Bool isDifference, const casacore::String &preamble, casacore::Bool requireImageRegion)
 
std::pair< casacore::Quantity,
casacore::Quantity
_quantitiesFromFrequencyString (const casacore::String &freqString, const casacore::String &preamble) const
 
casacore::Vector
< casacore::Quantity
_extractQuantityPairAndSingleQuantity (casacore::String &consumeMe, const casacore::String &preamble) const
 
casacore::Vector
< casacore::Quantity
_extractNQuantityPairs (casacore::String &consumeMe, const casacore::String &preamble) const
 
casacore::Vector
< casacore::Quantity
_extractTwoQuantityPairs (casacore::String &consumeMe, const casacore::String &preamble) const
 
std::pair< casacore::Quantity,
casacore::Quantity
_extractSingleQuantityPair (const casacore::String &pair, const casacore::String &preamble) const
 
void _setInitialGlobals ()
 
casacore::Vector
< casacore::Quantity
_extractTwoQuantityPairsAndSingleQuantity (casacore::String &consumeMe, const casacore::String &preamble) const
 
void _extractQuantityPairAndString (std::pair< casacore::Quantity, casacore::Quantity > &quantities, casacore::String &string, casacore::String &consumeMe, const casacore::String &preamble, const casacore::Bool requireQuotesAroundString) const
 
casacore::Vector
< casacore::Quantity
_extractQuantitiesFromPair (const casacore::String &pair, const casacore::String &preamble) const
 
void _determineVersion (const casacore::String &chunk, const casacore::String &filename, const casacore::Int requireAtLeastThisVersion)
 
void _setOverridingCorrelations (const casacore::String &globalOverrideStokes)
 set the casacore::Stokes/polarizations/correlations that will override all global and per line correlation specifications. More...
 
void _setOverridingChannelRange (const casacore::String &globalOverrideChans)
 set the (single) channel range that will override all global and per line frequency specifications. More...
 

Static Private Member Functions

static casacore::Vector
< casacore::String
_extractSinglePair (const casacore::String &string)
 extract s1 and s2 from a string of the form "[s1, s2]" More...
 
static casacore::String _doLabel (casacore::String &consumeMe, const casacore::String &logPreamble)
 
static casacore::String _getKeyValue (casacore::String &consumeMe, const casacore::String &preamble)
 
static casacore::Vector
< casacore::Stokes::StokesTypes
_stokesFromString (const casacore::String &stokes, const casacore::String &preamble)
 

Private Attributes

casacore::CoordinateSystem _csys
 
std::unique_ptr< casacore::LogIO_log
 
ParamSet _currentGlobals
 
std::vector
< AsciiAnnotationFileLine
_lines
 
casacore::Vector
< AnnotationBase::Keyword
_globalKeysToApply
 
casacore::Int _fileVersion
 
casacore::IPosition _imShape
 
casacore::uInt _regions
 
casacore::Bool _verbose
 
std::shared_ptr< std::pair
< casacore::MFrequency,
casacore::MFrequency > > 
_overridingFreqRange
 
std::shared_ptr
< casacore::Vector
< casacore::Stokes::StokesTypes > > 
_overridingCorrRange
 

Static Private Attributes

static const casacore::String sOnePair
 
static const casacore::String bTwoPair
 
static const casacore::String sNPair
 
static const casacore::Regex startOnePair
 
static const casacore::Regex startNPair
 

Detailed Description

Parse and store regions and annotations from an ascii region file <author>Dave Mehringer</author>

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Etymology

This is a class designed to parse and store regions and annotations from an ascii region file

Synopsis

This class is for parsing and storing regions and annotations from an ascii region (CRTF) file. The format spec can be found at https://casa.nrao.edu/casadocs-devel/stable/imaging/image-analysis/region-file-format

Definition at line 56 of file RegionTextParser.h.

Member Typedef Documentation

Definition at line 79 of file RegionTextParser.h.

Constructor & Destructor Documentation

casa::RegionTextParser::RegionTextParser ( )
delete
casa::RegionTextParser::RegionTextParser ( const casacore::String filename,
const casacore::CoordinateSystem csys,
const casacore::IPosition imShape,
const casacore::Int  requireAtLeastThisVersion,
const casacore::String prependRegion = "",
const casacore::String globalOverrideChans = "",
const casacore::String globalOverrrideStokes = "",
casacore::Bool  verbose = true,
casacore::Bool  requireImageRegion = true 
)

differentiating between the filename and simple text constructors globalOverrideChans override all spectral selections in the file or text by using this channel selection <src>globalOverrideStokes override all correlation selections in the file or text by using this polarization selection <src>prependRegion allows one to specify region(s) that will be prepended to any text in filename or text requireImageRegion is passed to the AnnRegion constructors to indicate whether to rethrow ToLCRegionConversionError exception when the region is outside the image lattice, or create the object even if the ImageRegion has no lattice region.

The default (true) rethrows the exception. CAS-12631: added for CARTA, which can import regions outside an image.

casa::RegionTextParser::RegionTextParser ( const casacore::CoordinateSystem csys,
const casacore::IPosition imShape,
const casacore::String text,
const casacore::String prependRegion = "",
const casacore::String globalOverrideChans = "",
const casacore::String globalOverrrideStokes = "",
casacore::Bool  verbose = true,
casacore::Bool  requireImageRegion = true 
)
casa::RegionTextParser::~RegionTextParser ( )

Member Function Documentation

void casa::RegionTextParser::_addLine ( const AsciiAnnotationFileLine line)
private
void casa::RegionTextParser::_createAnnotation ( const AnnotationBase::Type  annType,
const casacore::Vector< casacore::Quantity > &  qDirs,
const std::pair< casacore::Quantity, casacore::Quantity > &  qFreqs,
const std::vector< casacore::Quantity > &  quantities,
const casacore::String textString,
const ParamSet currentParamSet,
const casacore::Bool  annOnly,
const casacore::Bool  isDifference,
const casacore::String preamble,
casacore::Bool  requireImageRegion 
)
private
Parameters
qDirsconst casacore::Vector<casacore::MDirection> dirs,
void casa::RegionTextParser::_determineVersion ( const casacore::String chunk,
const casacore::String filename,
const casacore::Int  requireAtLeastThisVersion 
)
private
static casacore::String casa::RegionTextParser::_doLabel ( casacore::String consumeMe,
const casacore::String logPreamble 
)
staticprivate
casacore::Vector<casacore::Quantity> casa::RegionTextParser::_extractNQuantityPairs ( casacore::String consumeMe,
const casacore::String preamble 
) const
private
casacore::Vector<casacore::Quantity> casa::RegionTextParser::_extractQuantitiesFromPair ( const casacore::String pair,
const casacore::String preamble 
) const
private
casacore::Vector<casacore::Quantity> casa::RegionTextParser::_extractQuantityPairAndSingleQuantity ( casacore::String consumeMe,
const casacore::String preamble 
) const
private
void casa::RegionTextParser::_extractQuantityPairAndString ( std::pair< casacore::Quantity, casacore::Quantity > &  quantities,
casacore::String string,
casacore::String consumeMe,
const casacore::String preamble,
const casacore::Bool  requireQuotesAroundString 
) const
private
static casacore::Vector<casacore::String> casa::RegionTextParser::_extractSinglePair ( const casacore::String string)
staticprivate

extract s1 and s2 from a string of the form "[s1, s2]"

std::pair<casacore::Quantity, casacore::Quantity> casa::RegionTextParser::_extractSingleQuantityPair ( const casacore::String pair,
const casacore::String preamble 
) const
private
casacore::Array<casacore::String> casa::RegionTextParser::_extractTwoPairs ( casacore::uInt end,
const casacore::String string 
) const
private
casacore::Vector<casacore::Quantity> casa::RegionTextParser::_extractTwoQuantityPairs ( casacore::String consumeMe,
const casacore::String preamble 
) const
private
casacore::Vector<casacore::Quantity> casa::RegionTextParser::_extractTwoQuantityPairsAndSingleQuantity ( casacore::String consumeMe,
const casacore::String preamble 
) const
private
AnnotationBase::Type casa::RegionTextParser::_getAnnotationType ( casacore::Vector< casacore::Quantity > &  qDirs,
std::vector< casacore::Quantity > &  quantities,
casacore::String textString,
casacore::String consumeMe,
const casacore::String preamble 
) const
private
ParamSet casa::RegionTextParser::_getCurrentParamSet ( casacore::Bool spectralParmsUpdated,
ParamSet newParams,
casacore::String consumeMe,
const casacore::String preamble 
) const
private
static casacore::String casa::RegionTextParser::_getKeyValue ( casacore::String consumeMe,
const casacore::String preamble 
)
staticprivate
void casa::RegionTextParser::_parse ( const casacore::String contents,
const casacore::String fileDesc,
casacore::Bool  requireImageRegion 
)
private
std::pair<casacore::Quantity, casacore::Quantity> casa::RegionTextParser::_quantitiesFromFrequencyString ( const casacore::String freqString,
const casacore::String preamble 
) const
private
void casa::RegionTextParser::_setInitialGlobals ( )
private
void casa::RegionTextParser::_setOverridingChannelRange ( const casacore::String globalOverrideChans)
private

set the (single) channel range that will override all global and per line frequency specifications.

If multiple ranges are specified, an exception will be thrown.

void casa::RegionTextParser::_setOverridingCorrelations ( const casacore::String globalOverrideStokes)
private

set the casacore::Stokes/polarizations/correlations that will override all global and per line correlation specifications.

If multiple ranges are specified, an exception will be thrown.

static casacore::Vector<casacore::Stokes::StokesTypes> casa::RegionTextParser::_stokesFromString ( const casacore::String stokes,
const casacore::String preamble 
)
staticprivate
casacore::Int casa::RegionTextParser::getFileVersion ( ) const
std::vector<AsciiAnnotationFileLine> casa::RegionTextParser::getLines ( ) const
static ParamSet casa::RegionTextParser::getParamSet ( casacore::Bool spectralParmsUpdated,
casacore::LogIO log,
const casacore::String text,
const casacore::String preamble,
const casacore::CoordinateSystem csys,
std::shared_ptr< std::pair< casacore::MFrequency, casacore::MFrequency > >  overridingFreqRange,
std::shared_ptr< casacore::Vector< casacore::Stokes::StokesTypes > >  overridingCorrRange 
)
static

get the parameter set from a line of text.

preamble is prepended to exception messages.

RegionTextParser& casa::RegionTextParser::operator= ( const RegionTextParser )
delete

Member Data Documentation

casacore::CoordinateSystem casa::RegionTextParser::_csys
private

Definition at line 143 of file RegionTextParser.h.

ParamSet casa::RegionTextParser::_currentGlobals
private

Definition at line 145 of file RegionTextParser.h.

casacore::Int casa::RegionTextParser::_fileVersion
private

Definition at line 148 of file RegionTextParser.h.

casacore::Vector<AnnotationBase::Keyword> casa::RegionTextParser::_globalKeysToApply
private

Definition at line 147 of file RegionTextParser.h.

casacore::IPosition casa::RegionTextParser::_imShape
private

Definition at line 149 of file RegionTextParser.h.

std::vector<AsciiAnnotationFileLine> casa::RegionTextParser::_lines
private

Definition at line 146 of file RegionTextParser.h.

std::unique_ptr<casacore::LogIO> casa::RegionTextParser::_log
private

Definition at line 144 of file RegionTextParser.h.

std::shared_ptr<casacore::Vector<casacore::Stokes::StokesTypes> > casa::RegionTextParser::_overridingCorrRange
private

Definition at line 155 of file RegionTextParser.h.

std::shared_ptr<std::pair<casacore::MFrequency, casacore::MFrequency> > casa::RegionTextParser::_overridingFreqRange
private

Definition at line 153 of file RegionTextParser.h.

casacore::uInt casa::RegionTextParser::_regions
private

Definition at line 150 of file RegionTextParser.h.

casacore::Bool casa::RegionTextParser::_verbose
private

Definition at line 151 of file RegionTextParser.h.

const casacore::String casa::RegionTextParser::bTwoPair
staticprivate

Definition at line 138 of file RegionTextParser.h.

const casacore::Int casa::RegionTextParser::CURRENT_VERSION
static

Definition at line 60 of file RegionTextParser.h.

const casacore::Regex casa::RegionTextParser::MAGIC
static

Definition at line 61 of file RegionTextParser.h.

const casacore::String casa::RegionTextParser::sNPair
staticprivate

Definition at line 139 of file RegionTextParser.h.

const casacore::String casa::RegionTextParser::sOnePair
staticprivate

Definition at line 137 of file RegionTextParser.h.

const casacore::Regex casa::RegionTextParser::startNPair
staticprivate

Definition at line 141 of file RegionTextParser.h.

const casacore::Regex casa::RegionTextParser::startOnePair
staticprivate

Definition at line 140 of file RegionTextParser.h.


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