Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
DataSelector Class Reference

Tool for selecting datasets based on paths, quantities and min/max elevations. More...

#include <DataSelector.h>

Inheritance diagram for DataSelector:
Inheritance graph
[legend]
Collaboration diagram for DataSelector:
Collaboration graph
[legend]

Public Types

enum  Prf {
  SINGLE =1 , DOUBLE =2 , ANY =3 , SINGLE =1 ,
  DOUBLE =2 , ANY =3
}
 Pulse repetition frequency mode.
 
enum  Prf {
  SINGLE =1 , DOUBLE =2 , ANY =3 , SINGLE =1 ,
  DOUBLE =2 , ANY =3
}
 Pulse repetition frequency mode.
 

Public Member Functions

 DataSelector (const std::string &path, const std::string &quantity, unsigned int count=1000, drain::Range< double > elangle={-90.0, 90.0}, int dualPRF=0, drain::Range< int > timespan={0, 0})
 
 DataSelector (const std::string &parameters="")
 
template<typename ... T>
 DataSelector (const ODIMPathElem &elem, const T &... args)
 Inits pathmatcher.
 
template<typename ... T>
 DataSelector (ODIMPathElem::group_t e, const T &... args)
 
 DataSelector (const DataSelector &selector)
 
bool consumeParameters (std::string &args)
 Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives.) More...
 
template<typename ... TT>
void setPathMatcher (TT... args)
 
const ODIMPathMatchergetPathMatcher () const
 
void trimPathMatcher ()
 "Drop leading slashes", ie. remove leading empty elements.
 
void setQuantities (const std::string &s)
 Sets basic quantities and quality quantities. These sets are separated by '/'.
 
void setQuantityRegExp (const std::string &s)
 
bool quantityIsSet () const
 
const std::string & getQuantity () const
 Retrieve quantity list and regular expression, if defined.
 
const drain::KeySelectorgetQuantitySelector () const
 
const drain::KeySelectorgetQualitySelector () const
 
void setMaxCount (unsigned int i)
 
unsigned int getMaxCount () const
 
void setPrf (const std::string &s)
 
void setPrf (Prf prf)
 
template<typename ... TT>
void setOrder (const TT &... args)
 
const DataOrdergetOrder () const
 
void selectPaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
 Collect paths with all the criteria: path, elevation(range), PRF, quantity... More...
 
virtual void updateBean () const
 Updates member objects with their corresponding variable values . More...
 
void ensureDataGroup ()
 In path, ensure trailing DATA or QUANTITY element.
 
void reset ()
 Restore default values. More...
 
void getPaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
 Sets given parameters and implicitly determines missing parameters. More...
 
bool getPath (const Hi5Tree &src, ODIMPath &path) const
 Returns the first path encountered with selector attributes and given groupFilter . More...
 
bool getLastPath (const Hi5Tree &src, ODIMPath &path, ODIMPathElem::group_t group=ODIMPathElem::DATA) const
 Returns the last path encountered with selector attributes and given groupFilter . More...
 
bool getNextPath (const Hi5Tree &src, ODIMPath &path, ODIMPathElem::group_t group=ODIMPathElem::DATA) const
 Returns the a path with index one greater than the retrieved last path.
 
 DataSelector (const std::string &path, const std::string &quantity, unsigned int count=1000, drain::Range< double > elangle={-90.0, 90.0}, DataSelector::Prf prf=Prf::ANY)
 
 DataSelector (const std::string &parameters="")
 
template<typename ... T>
 DataSelector (const ODIMPathElem &elem, const T &... args)
 Inits pathmatcher.
 
template<typename ... T>
 DataSelector (ODIMPathElem::group_t e, const T &... args)
 
 DataSelector (const DataSelector &selector)
 
bool consumeParameters (std::string &args)
 Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives.) More...
 
template<typename ... TT>
void setPathMatcher (TT... args)
 
const ODIMPathMatchergetPathMatcher () const
 
void trimPathMatcher ()
 "Drop leading slashes", ie. remove leading empty elements.
 
void setQuantities (const std::string &s)
 Sets basic quantities and quality quantities. These sets are separated by '/'.
 
void setQuantityRegExp (const std::string &s)
 
bool quantityIsSet () const
 
const std::string & getQuantity () const
 Retrieve quantity list and regular expression, if defined.
 
const drain::KeySelectorgetQuantitySelector () const
 
void setMaxCount (unsigned int i)
 
unsigned int getMaxCount () const
 
void setPrf (const std::string &s)
 
void setPrf (Prf prf)
 
template<typename ... TT>
void setOrder (const TT &... args)
 
const DataOrdergetOrder () const
 
void reset ()
 Collect paths with all the criteria: path, elevation(range), PRF, quantity... More...
 
void getPaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
 Sets given parameters and implicitly determines missing parameters. More...
 
bool getPath (const Hi5Tree &src, ODIMPath &path) const
 Returns the first path encountered with selector attributes and given groupFilter . More...
 
bool getLastPath (const Hi5Tree &src, ODIMPath &path, ODIMPathElem::group_t group=ODIMPathElem::DATA) const
 Returns the last path encountered with selector attributes and given groupFilter . More...
 
bool getNextPath (const Hi5Tree &src, ODIMPath &path, ODIMPathElem::group_t group=ODIMPathElem::DATA) const
 Returns the a path with index one greater than the retrieved last path.
 
void ensureDataGroup ()
 In path, ensure trailing DATA or QUANTITY element. More...
 
- Public Member Functions inherited from BeanLike
virtual const std::string & getName () const
 Return the name of an instance.
 
virtual const std::string & getDescription () const
 Return a brief description.
 
bool hasParameters () const
 
template<class F >
getParameter (const std::string &p) const
 Gets a single parameter.
 
const ReferenceMapgetParameters () const
 
ReferenceMapgetParameters ()
 
template<class F >
void setParametersFromEntries (const F &args)
 
void setParameters (std::initializer_list< Variable::init_pair_t > args)
 Grants access to (if above hidden)
 
virtual void setParameters (const std::string &p, char assignmentSymbol='=', char separatorSymbol=0)
 Sets comma-separated parameters in a predetermined order "a,b,c" or by specifing them "b=2". More...
 
template<class T >
void setParameters (const std::map< std::string, T > &args)
 Set parameters.
 
template<class T >
void setParameters (const SmartMap< T > &args)
 Set parameters.
 
void setParameter (const std::string &p, const Castable &value)
 Sets a single parameter.
 
template<class T >
void setParameter (const std::string &p, const VariableT< T > &value)
 
template<class F >
void setParameter (const std::string &p, const F &value)
 Sets a single parameter. More...
 
template<class F >
void setParameter (const std::string &p, std::initializer_list< F > value)
 Sets a single parameter.
 
BeanLikeoperator= (const BeanLike &b)
 
virtual std::ostream & toStream (std::ostream &ostr, bool compact=true) const
 
 BeanLike (const BeanLike &b)
 
 BeanLike (const std::string &name, const std::string &description="")
 

Static Public Member Functions

static void getTimeMap (const Hi5Tree &srcRoot, ODIMPathElemMap &m)
 
static void swapData (Hi5Tree &src, const ODIMPathElem &srcElem, Hi5Tree &dst)
 Swap branches such that dst gets a /dataset or /data with a new index. More...
 
static void swapData (Hi5Tree &srcGroup, Hi5Tree &dst, ODIMPathElem::group_t groupType)
 Like swapData(Hi5Tree & src,const ODIMPathElem &srcElem, Hi5Tree & dst), but src already at the level.
 
static void swapData (Hi5Tree &src, const ODIMPathElem &srcElem, Hi5Tree &dst)
 Swap branches such that dst gets a /dataset or /data with a new index. More...
 
static void swapData (Hi5Tree &srcGroup, Hi5Tree &dst, ODIMPathElem::group_t groupType)
 Like swapData(Hi5Tree & src,const ODIMPathElem &srcElem, Hi5Tree & dst), but src already at the level.
 
static void getTimeMap (const Hi5Tree &srcRoot, ODIMPathElemMap &m)
 

Protected Member Functions

void updateQuantities () const
 Continue path matching started with getMainPaths() More...
 
void init ()
 Sets the default values and sets references.
 
bool collectPaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer, const ODIMPath &basepath=ODIMPath(), const std::string &parentQuantity="") const
 Collect paths (only) with criteria: path, elevation(range), PRF, quantity. More...
 
bool collectPathsOLD (const Hi5Tree &src, std::list< ODIMPath > &pathContainer, const ODIMPath &basepath=ODIMPath()) const
 
void prunePaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
 Use #DataOrder::criterion DATA , TIME or ELANGLE and #DataOrder::order MIN or MAX to sort paths. More...
 
virtual void updateBean () const override
 Traverses the parameters and updates the corresponding member objects. More...
 
void updateQuantities () const
 Continue path matching started with getMainPaths() More...
 
void init ()
 Sets the default values and sets references.
 
bool collectPaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer, const ODIMPath &basepath=ODIMPath(), const std::string &parentQuantity="", ODIMPathElem::group_t filter=ODIMPathElem::ALL_GROUPS) const
 Collect paths (only) with criteria: path, elevation(range), PRF, quantity. More...
 
void prunePaths (const Hi5Tree &src, std::list< ODIMPath > &pathContainer) const
 Use #DataOrder::criterion DATA , TIME or ELANGLE and #DataOrder::order MIN or MAX to sort paths.
 
- Protected Member Functions inherited from BeanLike
virtual void storeLastArguments (const std::string &p)
 Called after setParameters()
 

Protected Attributes

std::string path
 Regular expression of accepted paths, for example ".*&zwj;/data$". Deprecated. More...
 
ODIMPathMatcher pathMatcher
 
std::string quantities
 Comma-separated list of conventional quantities, optionally followed by '/', and quality quantities.
 
drain::KeySelector quantitySelector
 
drain::KeySelector qualitySelector
 
unsigned int count
 The maximum length of the list of matching keys.
 
drain::Range< double > elangle
 The minimum and maximum elevation angle (applicable with volume scan data only).
 
DataOrder order
 
std::string prf
 Reject or accept VRAD(VH)
 
drain::EnumFlagger< drain::SingleFlagger< Prf > > prfSelector
 
drain::Range< int > timespan
 Time in seconds, compared to nominal time.
 
- Protected Attributes inherited from BeanLike
const std::string name
 
const std::string description
 
ReferenceMap parameters
 

Friends

class drain::ReferenceMap
 

Detailed Description

Tool for selecting datasets based on paths, quantities and min/max elevations.

See also
rack::CmdSelect

Member Function Documentation

◆ collectPaths() [1/2]

bool collectPaths ( const Hi5Tree &  src,
std::list< ODIMPath > &  pathContainer,
const ODIMPath basepath = ODIMPath(),
const std::string &  parentQuantity = "" 
) const
protected

Collect paths (only) with criteria: path, elevation(range), PRF, quantity.

Returns
true, if contained something accepted by tests

◆ collectPaths() [2/2]

bool collectPaths ( const Hi5Tree &  src,
std::list< ODIMPath > &  pathContainer,
const ODIMPath basepath = ODIMPath(),
const std::string &  parentQuantity = "",
ODIMPathElem::group_t  filter = ODIMPathElem::ALL_GROUPS 
) const
protected

Collect paths (only) with criteria: path, elevation(range), PRF, quantity.

ALERT! NEW; EXPERIMENTAL! Does not use separate qualitySelector object but single, with DBHZ|QIND style.

Returns
true, if contained something accepted by tests

Easy example:

DBZH/QIND - accept QIND which is under DBHZ

Then:

QIND - accept whichever QINDs, in the order of appearance

/QIND - accept top-level QIND only

?? QIND - accept top-level QIND only

Or:

/QIND - accept lower-level QIND only

QIND/ - accept higher-level QIND only

QIND - accept any QIND

◆ consumeParameters() [1/2]

bool consumeParameters ( std::string &  args)
inline

Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives.)

Parameters
parameters- the parameters to be changed, using some of the syntaxes:
  • path,quantity,index,count>,elangleMin,elangleMax (complete or partial list of parameter values, in this order)
  • parameter1=value1,parameter2=value2,parameter3=value3 (specific assignments as a list) The regular expressions should not contain comma (,).
specific- if true, the specific assignments are supported Set parameters if args not empty then clear args. return - true, if args were non empty and hence, parameters were set.

Note that args is always empty after invoking this function.

◆ consumeParameters() [2/2]

bool consumeParameters ( std::string &  args)
inline

Sets parameters in predefined order or sets specified parameters. (Python style calling alternatives.)

Parameters
parameters- the parameters to be changed, using some of the syntaxes:
  • path,quantity,index,count>,elangleMin,elangleMax (complete or partial list of parameter values, in this order)
  • parameter1=value1,parameter2=value2,parameter3=value3 (specific assignments as a list) The regular expressions should not contain comma (,).
specific- if true, the specific assignments are supported Set parameters if args not empty then clear args. return - true, if args were non empty and hence, parameters were set.

Note that args is always empty after invoking this function.

◆ ensureDataGroup()

void ensureDataGroup ( )

In path, ensure trailing DATA or QUANTITY element.

Typically used by image selectors

◆ getLastPath() [1/2]

bool getLastPath ( const Hi5Tree &  src,
ODIMPath path,
ODIMPathElem::group_t  group = ODIMPathElem::DATA 
) const

Returns the last path encountered with selector attributes and given groupFilter .

Retrieves paths using current selection criteria and an additional group selector. Returns the first path encountered with selector attributes and given groupFilter .

◆ getLastPath() [2/2]

bool getLastPath ( const Hi5Tree &  src,
ODIMPath path,
ODIMPathElem::group_t  group = ODIMPathElem::DATA 
) const

Returns the last path encountered with selector attributes and given groupFilter .

Retrieves paths using current selection criteria and an additional group selector. Returns the first path encountered with selector attributes and given groupFilter .

◆ getPath() [1/2]

bool getPath ( const Hi5Tree &  src,
ODIMPath path 
) const

Returns the first path encountered with selector attributes and given groupFilter .

Parameters
src- HDF5 data structure
path- resulting path, if found; othewise intact

Consider changing loop order, and just quantitySelector.test(q);

◆ getPath() [2/2]

bool getPath ( const Hi5Tree &  src,
ODIMPath path 
) const

Returns the first path encountered with selector attributes and given groupFilter .

Parameters
src- HDF5 data structure
path- resulting path, if found; othewise intact

◆ getPaths() [1/2]

void getPaths ( const Hi5Tree &  src,
std::list< ODIMPath > &  pathContainer 
) const

Sets given parameters and implicitly determines missing parameters.

 \param parameters - string containing parameters, like "dataset=1:3,quantity=DBZH"
 \param clear      - first reset to default state
 // groups set, if not given in \c parameters

virtual void deriveParameters(const std::string & parameters, bool clear=true);// , ODIMPathElem::group_t defaultGroups = (ODIMPathElem::DATA | ODIMPathElem::QUALITY)); //, char assignmentSymbol='=', char separatorSymbol=0); Retrieves paths using current selection criteria and an additional group selector. Selects paths down to dataset and data group level. Uses metadata of what , where and how but does not include them in the result (container).

Each retrieved path starts with root element (ODIMPathElem::ROOT), corresponding to empty string ("").

Template Parameters
T- container class supporting addPathT(), e.g. std::set, std::list or std::vector.
Parameters
src- the data structure searched for paths
container- container for found paths
groupFilter- selector composed of id's (ODIMPathElem::DATASET etc ) of groups added in the container, typically adjusted by calling functions (not by the end user).

The full tree structure will be searched for; groupFilter does not affect the traversal. When retrieving quality groups, groupFilter should countain ODIMPathElem::QUALITY.

See also
deriveParameters(). Select paths based on path matching, as well as on quantity and elevation matching when applicable.

◆ getPaths() [2/2]

void getPaths ( const Hi5Tree &  src,
std::list< ODIMPath > &  pathContainer 
) const

Sets given parameters and implicitly determines missing parameters.

 \param parameters - string containing parameters, like "dataset=1:3,quantity=DBZH"
 \param clear      - first reset to default state
 // groups set, if not given in \c parameters

virtual void deriveParameters(const std::string & parameters, bool clear=true);// , ODIMPathElem::group_t defaultGroups = (ODIMPathElem::DATA | ODIMPathElem::QUALITY)); //, char assignmentSymbol='=', char separatorSymbol=0); Retrieves paths using current selection criteria and an additional group selector. Selects paths down to dataset and data group level. Uses metadata of what , where and how but does not include them in the result (container).

Each retrieved path starts with root element (ODIMPathElem::ROOT), corresponding to empty string ("").

Template Parameters
T- container class supporting addPathT(), e.g. std::set, std::list or std::vector.
Parameters
src- the data structure searched for paths
container- container for found paths
groupFilter- selector composed of id's (ODIMPathElem::DATASET etc ) of groups added in the container, typically adjusted by calling functions (not by the end user).

The full tree structure will be searched for; groupFilter does not affect the traversal. When retrieving quality groups, groupFilter should countain ODIMPathElem::QUALITY.

See also
deriveParameters(). Select paths based on path matching, as well as on quantity and elevation matching when applicable.

◆ prunePaths()

void prunePaths ( const Hi5Tree &  src,
std::list< ODIMPath > &  pathList 
) const
protected

Use #DataOrder::criterion DATA , TIME or ELANGLE and #DataOrder::order MIN or MAX to sort paths.

Using criterion TIME and order (MIN or MAX)

Future C++20 option: template <DataOrder E> class SuperElemLess { inline bool operator()(const SuperElem & e1, const SuperElem & e2) const { } }

◆ reset() [1/2]

void reset ( )

Restore default values.

The values set maximally accepting ie. all the groups are returned with getPaths() call.

◆ reset() [2/2]

void reset ( )

Collect paths with all the criteria: path, elevation(range), PRF, quantity...

Restore default values. The values set maximally accepting ie. all the groups are returned with getPaths() call.

◆ selectPaths()

void selectPaths ( const Hi5Tree &  src,
std::list< ODIMPath > &  pathContainer 
) const

Collect paths with all the criteria: path, elevation(range), PRF, quantity...

PRESELECT.

◆ swapData() [1/2]

void swapData ( Hi5Tree &  src,
const ODIMPathElem srcElem,
Hi5Tree &  dst 
)
static

Swap branches such that dst gets a /dataset or /data with a new index.

Contents of src[srcElem] will be swapped with dst[dstElem] such that dstElem has an index greater than any index prior to the operation.

After the operation src[srcElem] contains an empty object that was created under dst for swapping.

Stylistic note: semantically this should belong to DataTools, but essentially calls getNextChild() hence is kept here. Also, DataTools stays independent from DataSelector.

◆ swapData() [2/2]

static void swapData ( Hi5Tree &  src,
const ODIMPathElem srcElem,
Hi5Tree &  dst 
)
static

Swap branches such that dst gets a /dataset or /data with a new index.

Contents of src[srcElem] will be swapped with dst[dstElem] such that dstElem has an index greater than any index prior to the operation.

After the operation src[srcElem] contains an empty object that was created under dst for swapping.

Stylistic note: semantically this should belong to DataTools, but essentially calls getNextChild() hence is kept here. Also, DataTools stays independent from DataSelector.

◆ updateBean() [1/2]

void updateBean ( ) const
virtual

Updates member objects with their corresponding variable values .

Traverses (public) parameters and updates the corresponding member objects.

Converts path and quantity strings to pathMatcher and quantity regexps, respectively.

Reimplemented from BeanLike.

◆ updateBean() [2/2]

virtual void updateBean ( ) const
overrideprotectedvirtual

Traverses the parameters and updates the corresponding member objects.

Converts path and quantity strings to pathMatcher and quantity RegExps, respectively.

Reimplemented from BeanLike.

◆ updateQuantities() [1/2]

void updateQuantities ( ) const
protected

Continue path matching started with getMainPaths()

Parameters
src- HDF5 data structure
pathContainer- container for paths to be found
path- search path, dataset<n> by default template <class T> bool getSubPathsFOO(const Hi5Tree & src, T & pathContainer, const ODIMPath & path) const;

◆ updateQuantities() [2/2]

void updateQuantities ( ) const
protected

Continue path matching started with getMainPaths()

Parameters
src- HDF5 data structure
pathContainer- container for paths to be found
path- search path, dataset<n> by default template <class T> bool getSubPathsFOO(const Hi5Tree & src, T & pathContainer, const ODIMPath & path) const;

Member Data Documentation

◆ path

std::string path
protected

Regular expression of accepted paths, for example ".*&zwj;/data$". Deprecated.

Deprecated:
Use dataset and data parameters instead
Deprecated:
Use dataset and data parameters instead

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