Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
This module builds a vector container of Source objects, a map of source identification and an index which is the location of the Source object in the vector container.
In all code examples we present in the next sections, we assume that the following lines are included by default:
Note that namespaces are used to make the example code more readable.
Before creating a Catalog object we need to create a vector of Source objects. A Source object consists of a source identification number and a vector of shared pointers to Attribute objects. There are three Attribute objects for a Source : Photometry, SpectroscopicRedshift and Coordinates objects.
We define the Coordinates Attribute as follows:
In this example, we define two Coordinates objects. A Coordinate object is defined by two double values, the right ascension (e.g. ra_1) and the declinaison (e.g. dec_1). The getRa and getDec functions are available for this class for getting the right ascension and the declinaison value. They are used as follows:
Note that we need to use the dynamic_pointer_cast here.
Output
We define the SpectroscopicRedshift Attribute as follows:
In the above example a SpectroscopicRedshift object needs two double values, a redshift value and the associated error.
The SpectroscopicRedshift class provides two functions, getValue and getError. They can be used as follows:
Output
We define the Photometry Attribute as follows:
The Photometry object needs two parameters. The filter_name_vector_ptr parameter is a shared pointer to a vector of strings and the photometry_vector parameter is a vector of FluxErrorPair objects. The FluxErrorPair objects consist of a couple of double values, the flux and the error associated to this flux. The following example shows how to define them.
The Photometry class provides the find function as follows:
Output:
The Photometry class provides an iterator for reading the data as follows:
Output
Now we need to create a vector of shared pointers to the Attribute objects for building a Source object as follows:
Note that for the needs of the next examples, we have created two attruibute vectors. From this step we are ready to create the Source objects as follows:
The Source object needs an identifier(a number) and a vector of shared pointers to its Attribute objects. In this example above we have created two Source objects as a Catalog object needs a vector of Source objects.
Output:
Output:
From this step we can create a Catalog object providing the vector of Source objects as follows:
To know the size of a Catalog object, use the size function as follows:
Output:
The catalog class provides an iterator in order to play with the Catalog contents, hereafter we display for instance the Source identifier as follows:
Output:
To find a Source object in the Catalog using the identification number (e.g. 20000), proceed as follows:
In this example we try to find the Source with the identifier number 20000. A nullptr is returned in case of no Source found. In our case, we know the Source object exists and we can display some information of the Source as the coordinates for instance.
Output: