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
(covariance[, overwrite])Once you have finished adding data points, add a covariance for the entire set.
add_data_point
(data_type, tracers, value[, ...])Add a data point to the set.
add_ell_cl
(data_type, tracer1, tracer2, ell, x)Add a series of 2pt Fourier space data points, either individually or as a group.
add_theta_xi
(data_type, tracer1, tracer2, ...)Add a series of 2pt real space data points, either individually or as a group.
add_tracer
(tracer_type, name, *args, **kwargs)Add a new tracer
add_tracer_object
(tracer)Add a pre-constructed BaseTracer instance to this data set.
copy
()Create a copy of the data set with no data shared with the original.
get_bandpower_windows
(indices)Returns bandpower window functoins for a given set of datapoints.
get_data_points
([data_type, tracers])Get data point objects for a subset of the data
get_data_types
([tracers])Get a list of the different data types stored in the Sacc
get_ell_cl
(data_type, tracer1, tracer2[, ...])Helper method to extract the ell and C_ell values for a specific data type (e.g.
get_mean
([data_type, tracers])Get mean values for each data point matching the criteria.
get_tag
(tag[, data_type, tracers])Get the value of a one tag for (a subset of) the data.
get_tags
(tags[, data_type, tracers])Get the value of a one or more named tags for (a subset of) the data.
get_theta_xi
(data_type, tracer1, tracer2[, ...])Helper method to extract the theta and correlation function values for a specific data type (e.g.
get_tracer
(name)Get the tracer object with the given name
get_tracer_combinations
([data_type])Find all the tracer combinations (e.g.
Return whether or not this data set has a covariance attached to it
indices
([data_type, tracers, warn_empty])Find the indices of all points matching the given selection criteria.
keep_indices
(indices)Select data points, keeping only values where the mask is True or an index is included in it.
keep_selection
([data_type, tracers, warn_empty])Remove data points, keeping only points matching the given criteria.
keep_tracers
(names)Keep only the tracer objects and their associated data points.
load_fits
(filename)Load a Sacc data set from a FITS file.
remove_indices
(indices)Remove data points, getting rid of points where the mask is True or an index is included in it.
remove_selection
([data_type, tracers, ...])Remove data points, getting rid of points matching the given criteria.
remove_tracers
(names)Remove the tracer objects and their associated data points
rename_tracer
(name, new_name)Get the tracer object with the given name
reorder
(indices)Re-order the data set in-place according to the indices passed in.
save_fits
(filename[, overwrite])Save this data set to a FITS format Sacc file.
Re-order the data set in-place to a standard ordering.
- add_covariance(covariance, overwrite=False)[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
- overwrite: bool
If True, it overwrites the stored covariance matrix with the given one.
- Returns:
- None
- add_data_point(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(data_type, tracer1, tracer2, ell, x, window=None, tracers_later=False)[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.
- tracers_later: bool
Optional. If False (the default), complain if n(z) tracers have not yet been defined. Otherwise, suppress this warning
- Returns:
- None
- add_theta_xi(data_type, tracer1, tracer2, theta, x, window=None, tracers_later=False)[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.
- tracers_later: bool
Optional. If False (the default), complain if n(z) tracers have not yet been defined. Otherwise, suppress this warning
- Returns:
- None
- add_tracer(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(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()[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_bandpower_windows(indices)[source]¶
Returns bandpower window functoins for a given set of datapoints. All datapoints must share the same bandpower window.
- Parameters:
- indices: array
indices of the data points you want windows for
- Returns:
- windows: BandpowerWindow object containing the bandpower window
functions for these indices.
- get_data_points(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(tracers=None)[source]¶
Get a list of the different data types stored in the Sacc
- Parameters:
- tracers: tuple
Select only data types which match this tracer combination. If None (the default) then match any tracer combinations.
- Returns:
- data_types: list of strings
A list of the string data types in the data set
- get_ell_cl(data_type, tracer1, tracer2, return_cov=False, return_ind=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
- return_ind: bool
If True, also return the datapoint indices. Default=False
- Returns:
- ell: array
Ell values for this tracer pair
- mu: array
Mean values for this tracer pair
- cov_block: 2D array
(Only if return_cov=True) The block of the covariance for these points
- indices: array
(Only if return_ind=True) datapoint indices.
- get_mean(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(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_tags(tags, data_type=None, tracers=None, **select)[source]¶
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(data_type, tracer1, tracer2, return_cov=False, return_ind=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
- return_ind: bool
If True, also return the datapoint indices. Default=False
- Returns:
- ell: array
Ell values for this tracer pair
- mu: array
Mean values for this tracer pair
- cov_block: 2D array
(Only if return_cov=True) The block of the covariance for these points
- indices: array
(Only if return_ind=True) datapoint indices.
- get_tracer(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(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.
- has_covariance()[source]¶
Return whether or not this data set has a covariance attached to it
- Returns:
- bool
Whether or not a covariance has been added to this data
- indices(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(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(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
- keep_tracers(names)[source]¶
Keep only the tracer objects and their associated data points.
- Parameters:
- names: list
A list of string names of the tracers to be kept
- 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
- property 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(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(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
- remove_tracers(names)[source]¶
Remove the tracer objects and their associated data points
- Parameters:
- names: list
A list of string names of the tracers to be removed
- rename_tracer(name, new_name)[source]¶
Get the tracer object with the given name
- Parameters:
- name: str
A string name of a tracer to be changed the name
- new_name: str
A string with the new name of the tracer
- reorder(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
- sacc.sacc.concatenate_data_sets(*data_sets, labels=None, same_tracers=None)[source]¶
Combine multiple sacc data sets together into one.
In case of two tracers or metadata items with the same name, you can use the labels option to pass in a list of strings to append to all the names.
The Covariance will be combined into either a BlockDiagonal covariance or a Diagonal covariance, depending on the inputs. Either all inputs should have a covariance attached or none of them.
- Parameters:
- *data_sets: Sacc objects
The data sets to combined
- labels: List[str]
Optional list of strings to append to tracer and metadata names, in case of a clash.
- same_tracers: List[str]
Optional list of tracers that are assumed to be the same in the different data_sets but with no correlation between the data points involving them. Only the first occurance of each tracer will be added to the combined data set.
- Returns:
- output: Sacc object
The combined data set.