Tracers

class sacc.tracers.BaseTracer(name, **kwargs)[source]

A class representing some kind of tracer of astronomical objects.

Generically, SACC data points correspond to some combination of tracers for example, tomographic two-point data has two tracers for each data point, indicating the n(z) for the corresponding tomographic bin.

All Tracer objects have at least a name attribute. Different subclassses have other requirements. For example, n(z) tracers require z and n(z) arrays.

In general you don’t need to create tracer objects yourself - the Sacc.add_tracer method will construct them for you.

Methods

from_tables(table_list) Convert a list of astropy tables into a dictionary of tracers
make(tracer_type, name, \*args, \*\*kwargs) Select a Tracer subclass based on tracer_type and instantiate in instance of it with the remaining arguments.
to_tables(instance_list) Convert a list of tracers to a list of astropy tables
classmethod from_tables(table_list)[source]

Convert a list of astropy tables into a dictionary of tracers

This is used when loading data from a file.

This class method takes a list of tracers, such as those read from a file, and converts them into a list of instances.

It is not quite the inverse of the to_tables method, since it returns a dict instead of a list.

Subclasses overrides of this method do the actual work, but should NOT call this parent base method.

Parameters:
table_list: list

List of astropy tables

Returns:
tracers: dict

Dict mapping string names to tracer objects.

classmethod make(tracer_type, name, *args, **kwargs)[source]

Select a Tracer subclass based on tracer_type and instantiate in instance of it with the remaining arguments.

Parameters:
tracer_type: str

Must correspond to the tracer_type of a subclass

name: str

The name for this specific tracer, e.g. a tomographic bin identifier.

Returns:
instance: Tracer object

An instance of a Tracer subclass

classmethod to_tables(instance_list)[source]

Convert a list of tracers to a list of astropy tables

This is used when saving data to a file.

This class method converts a list of tracers, each of which can instances of any subclass of BaseTracer, and turns them into a list of astropy tables, ready to be saved to disk.

Some tracers generate a single table for all of the different instances, and others generate one table per instance.

Parameters:
instance_list: list

List of tracer instances

Returns:
tables: list

List of astropy tables

class sacc.tracers.MiscTracer(name, **kwargs)[source]

A Tracer type for miscellaneous other data points.

MiscTracers do not have any attributes except for their name, so can be used for tagging external data, for example.

Attributes:
name: str

The name of the tracer

Methods

from_tables(table_list) Convert a list of astropy table into a dictionary of MiscTracer instances.
make(tracer_type, name, \*args, \*\*kwargs) Select a Tracer subclass based on tracer_type and instantiate in instance of it with the remaining arguments.
to_tables(instance_list) Convert a list of MiscTracer instances to a astropy tables.
classmethod from_tables(table_list)[source]

Convert a list of astropy table into a dictionary of MiscTracer instances.

In general table_list should have a single element in, since all the MiscTracers are stored in a single table during to_tables

Parameters:
table_list: List[astropy.table.Table]
Returns:
tracers: Dict[str: MiscTracer]
classmethod to_tables(instance_list)[source]

Convert a list of MiscTracer instances to a astropy tables.

This is used when saving data to file.

All the instances are converted to a single table, which is returned in a list with one element so that it can be used in combination with the parent.

You can use the parent class to_tables class method to convert a mixed list of different tracer types.

You shouldn’t generally need to call this method directly.

Parameters:
instance_list: list

list of MiscTracer objects

Returns:
tables: list

List containing one astropy table

class sacc.tracers.NZTracer(name, z, nz, extra_columns=None, **kwargs)[source]

A Tracer type for tomographic n(z) data.

Takes two arguments arrays of z and n(z)

Attributes:
z: array

Redshift sample values

nz: array

Number density n(z) at redshift sample points.

extra_columns: dict[str: array] or dict[int:array]

Additional estimates of the same n(z), by name

Methods

from_tables(table_list) Convert an astropy table into a dictionary of tracers
make(tracer_type, name, \*args, \*\*kwargs) Select a Tracer subclass based on tracer_type and instantiate in instance of it with the remaining arguments.
to_tables(instance_list) Convert a list of NZTracers to a list of astropy tables
classmethod from_tables(table_list)[source]

Convert an astropy table into a dictionary of tracers

This is used when loading data from a file. A single tracer object is read from the table.

Parameters:
table_list: list[astropy.table.Table]

Must contain the appropriate data, for example as saved by to_table.

Returns:
tracers: dict

Dict mapping string names to tracer objects. Only contains one key/value pair for the one tracer.

classmethod to_tables(instance_list)[source]

Convert a list of NZTracers to a list of astropy tables

This is used when saving data to a file. One table is generated per tracer.

Parameters:
instance_list: list

List of tracer instances

Returns:
tables: list

List of astropy tables