Sacc DataSets¶
-
class
sacc.sacc.
Sacc
[source]¶ A class containing a selection of LSST summary statistic measurements, their covariance, and the metadata necessary to compute theoretical predictions for them.
Attributes: mean
Get the vector of mean values for the entire data set.
Methods
add_covariance
(self, covariance)Once you have finished adding data points, add a covariance for the entire set. add_data_point
(self, data_type, tracers, value)Add a data point to the set. add_ell_cl
(self, data_type, tracer1, …[, …])Add a series of 2pt Fourier space data points, either individually or as a group. add_theta_xi
(self, data_type, tracer1, …)Add a series of 2pt real space data points, either individually or as a group. add_tracer
(self, tracer_type, name, \*args, …)Add a new tracer add_tracer_object
(self, tracer)Add a pre-constructed BaseTracer instance to this data set. copy
(self)Create a copy of the data set with no data shared with the original. get_data_points
(self[, data_type, tracers])Get data point objects for a subset of the data get_data_types
(self)Get a list of the different data types stored in the Sacc get_ell_cl
(self, data_type, tracer1, tracer2)Helper method to extract the ell and C_ell values for a specific data type (e.g. get_mean
(self[, data_type, tracers])Get mean values for each data point matching the criteria. get_tag
(self, tag[, data_type, tracers])Get the value of a one tag for (a subset of) the data. get_tags
(self, tags[, data_type, tracers])Get the value of a one or more named tags for (a subset of) the data. get_theta_xi
(self, data_type, tracer1, tracer2)Helper method to extract the theta and correlation function values for a specific data type (e.g. get_tracer
(self, name)Get the tracer object with the given name get_tracer_combinations
(self[, data_type])Find all the tracer combinations (e.g. indices
(self[, data_type, tracers, warn_empty])Find the indices of all points matching the given selection criteria. keep_indices
(self, indices)Select data points, keeping only values where the mask is True or an index is included in it. keep_selection
(self[, data_type, tracers, …])Remove data points, keeping only points matching the given criteria. load_fits
(filename)Load a Sacc data set from a FITS file. remove_indices
(self, indices)Remove data points, getting rid of points where the mask is True or an index is included in it. remove_selection
(self[, data_type, tracers, …])Remove data points, getting rid of points matching the given criteria. reorder
(self, indices)Re-order the data set in-place according to the indices passed in. save_fits
(self, filename[, overwrite])Save this data set to a FITS format Sacc file. to_canonical_order
(self)Re-order the data set in-place to a standard ordering. -
add_covariance
(self, covariance)[source]¶ Once you have finished adding data points, add a covariance for the entire set.
Parameters: - covariance: array or list
2x2 numpy array containing the covariance of the added data points OR a list of blocks
Returns: - None
-
add_data_point
(self, data_type, tracers, value, tracers_later=False, **tags)[source]¶ Add a data point to the set.
Parameters: - data_type: str
- tracers: tuple of str
Strings corresponding to zero or more of the tracers in the data set These should either be already set up using the add_tracer method, or you could set tracers_later=True if you want to add them later. e.g. for 2pt measurements the tracers are the names of the two n(z) samples
- value: float
A single value for the data point
- tracers_later: bool
If True, do not complain if the tracers are not know already
- **tags:
Tags to apply to this data point. Tags can be any arbitrary metadata that you might want later, For 2pt data the tag would include an angle theta or ell.
Returns: - None
-
add_ell_cl
(self, data_type, tracer1, tracer2, ell, x, window=None)[source]¶ Add a series of 2pt Fourier space data points, either individually or as a group.
Parameters: - data_type: str or array/list of str
Which type C_ell to add
- tracer1: str or array/list of str
The name(s) of the first tracer, for example a tomographic bin name
- tracer2: str or array/list of str
The name(s) of the second tracer
- ell: int or array/list of int/float
The ell values for these data points
- x: float or array/list of float
The C_ell values for these data points
- window: Window instance
Optional window object describing the window function of the data point.
Returns: - None
-
add_theta_xi
(self, data_type, tracer1, tracer2, theta, x, window=None)[source]¶ Add a series of 2pt real space data points, either individually or as a group.
Parameters: - data_type: str or array/list of str
Which xi type to extract
- tracer1: str or array/list of str
The name(s) of the first tracer, for example a tomographic bin name
- tracer2: str or array/list of str
The name(s) of the second tracer
- theta: float or array/list of int
The ell values for these data points
- x: float or array/list of float
The C_ell values for these data points
- window: Window instance
Optional window object describing the window function of the data point.
Returns: - None
-
add_tracer
(self, tracer_type, name, *args, **kwargs)[source]¶ Add a new tracer
Parameters: - tracer_type: str
A string corresponding to one of the known tracer types, or ‘misc’ to use a new tracer with no parameters. e.g. “NZ” for n(z) tracers
- name: str
A name for the tracer
- *args:
Additional arguments to pass to the tracer constructor. These depend on the type of the tracer. For n(z) tracers these should be z and nz arrays
- **kwargs:
Additional keyword arguments to pass to the tracer constructor. These depend on the type of the tracer. There are no kwargs for n(z) tracers
Returns: - None
-
add_tracer_object
(self, tracer)[source]¶ Add a pre-constructed BaseTracer instance to this data set. If you just have, for example the z and n(z) data then use the add_tracer method instead.
Parameters: - tracer: Tracer instance
The tracer object to add to the data set
-
copy
(self)[source]¶ Create a copy of the data set with no data shared with the original. You can safely modify the copy without it affecting the original.
Returns: - S: Sacc instance
A new instance of the data set.
-
get_data_points
(self, data_type=None, tracers=None, **select)[source]¶ Get data point objects for a subset of the data
Parameters: - data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
Returns: - values: list
A list of the data point objects for the selection, in the order they were added.
-
get_data_types
(self)[source]¶ Get a list of the different data types stored in the Sacc
Returns: - data_types: list of strings
A list of the string data types in the data set
-
get_ell_cl
(self, data_type, tracer1, tracer2, return_cov=False)[source]¶ Helper method to extract the ell and C_ell values for a specific data type (e.g. ‘shear_ee’ and pair of tomographic bins)
Parameters: - data_type: str
Which C_ell type to extract
- tracer1: str
The name of the first tracer, for example a tomographic bin name
- tracer2: str
The name of the second tracer
- return_cov: bool
If True, also return the block of the covariance corresponding to these points. Default=False
Returns: - ell: array
Ell values for this tracer pair
- mu: array
Mean values for this tracer pair
- cov_block: 2x2 array
(Only if return_cov=True) The block of the covariance for these points
-
get_mean
(self, data_type=None, tracers=None, **select)[source]¶ Get mean values for each data point matching the criteria.
Parameters: - data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
Returns: - values: list
The mean values for each matching data point, in the order they were added.
-
get_tag
(self, tag, data_type=None, tracers=None, **select)[source]¶ Get the value of a one tag for (a subset of) the data.
Parameters: - tag: str
Tag to look up on the selected data
- data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
Returns: - values: list
A list of the value of the tag for given selection, in the order the matching data points were added.
Get the value of a one or more named tags for (a subset of) the data.
Parameters: - tags: list of str
Tags to look up on the selected data
- data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
Returns: - values: list of lists
For each input tag, a corresponding list of the value of that tag for given selection, in the order the matching data points were added.
-
get_theta_xi
(self, data_type, tracer1, tracer2, return_cov=False)[source]¶ Helper method to extract the theta and correlation function values for a specific data type (e.g. ‘shear_xi’ and pair of tomographic bins)
Parameters: - data_type: str
Which type of xi to extract
- tracer1: str
The name of the first tracer, for example a tomographic bin name
- tracer2: str
The name of the second tracer
- return_cov: bool
If True, also return the block of the covariance corresponding to these points. Default=False
Returns: - ell: array
Ell values for this tracer pair
- mu: array
Mean values for this tracer pair
- cov_block: 2x2 array
(Only if return_cov=True) The block of the covariance for these points
-
get_tracer
(self, name)[source]¶ Get the tracer object with the given name
Parameters: - name: str
A string name of a tracer
Returns: - tracer: BaseTracer object
The object corresponding to the name.
-
get_tracer_combinations
(self, data_type=None)[source]¶ Find all the tracer combinations (e.g. tomographic bin pairs) for the given data type
Parameters: - data_type: str
A string name of the data type to find
Returns: - combinations: list of tuples of strings
A list of all the tracer combinations found in any data point. No specific ordering.
-
indices
(self, data_type=None, tracers=None, warn_empty=True, **select)[source]¶ Find the indices of all points matching the given selection criteria.
Parameters: - data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
- Returns
- indices: array
Array of integer indices of matching data points
-
keep_indices
(self, indices)[source]¶ Select data points, keeping only values where the mask is True or an index is included in it.
You can use Sacc.remove_indices to do the opposite operation, keeping points where the mask is False.
You use the Sacc.keep_selection method to find indices and apply this method automatically, or the Sacc.indices method to manually select indices.
Parameters: - indices: array or list
Mask must be either a boolean array or a list/array of integer indices to remove. if boolean then True means to keep a data point and False means to cut it if integers then values indicate data points to keep
-
keep_selection
(self, data_type=None, tracers=None, warn_empty=True, **select)[source]¶ Remove data points, keeping only points matching the given criteria.
You can use Sacc.remove_selection to do the opposite operation, keeping points where the criteria are not matched.
You can manually remove points using the Sacc.indices and Sacc.keep_indices methods.
Parameters: - data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
-
classmethod
load_fits
(filename)[source]¶ Load a Sacc data set from a FITS file.
Don’t try to make these FITS files yourself - use the tools provided in this package to make and save them.
Parameters: - filename: str
A FITS format sacc file
-
mean
¶ Get the vector of mean values for the entire data set.
Returns: - mean: array
numpy array with all the mean values in the data set
-
remove_indices
(self, indices)[source]¶ Remove data points, getting rid of points where the mask is True or an index is included in it.
You can use Sacc.keep_indices to do the opposite operation, keeping points where the mask is True.
You use the Sacc.remove_selection method to find indices and apply this method automatically, or the Sacc.indices method to manually select indices.
Parameters: - indices: array or list
Mask must be either a boolean array or a list/array of integer indices to remove. if boolean then True means to cut data point and False means to keep it if integers then values indicate data points to cut out
-
remove_selection
(self, data_type=None, tracers=None, warn_empty=True, **select)[source]¶ Remove data points, getting rid of points matching the given criteria.
You can use Sacc.keep_selection to do the opposite operation, keeping points where the criteria are matched.
You can manually remove points using the Sacc.indices and Sacc.remove_indices methods.
Parameters: - data_type: str
Select only data points which are of this data type. If None (the default) then match any data types
- tracers: tuple
Select only data points which match this tracer combination. If None (the default) then match any tracer combinations.
- **select:
Select only data points with tag names and values matching all values provided in this kwargs option. You can also use the syntax name__lt=value or name__gt=value in the selection to select points less or greater than a threshold
-
reorder
(self, indices)[source]¶ Re-order the data set in-place according to the indices passed in.
If not all indices are included in the input then the data set will be cut down.
Parameters: - indices: integer list or array
Indices for the re-ordered data