imagine.observables package¶
Submodules¶
imagine.observables.dataset module¶
Datasets are auxiliary classes used to facilitate the reading and inclusion of observational data in the IMAGINE pipeline
-
class
imagine.observables.dataset.
Dataset
[source]¶ Bases:
imagine.tools.class_tools.BaseClass
Base class for writing helpers to convert arbitrary observational datasets into IMAGINE’s standardized format
-
REQ_ATTRS
= ['NAME']¶
-
data
¶ Array in the shape (1, N)
-
frequency
¶
-
key
¶ Key used in the Observables_dictionary
-
name
¶
-
var
¶
-
-
class
imagine.observables.dataset.
TabularDataset
(data, name, *, data_col=None, units=None, coords_type=None, lon_col='lon', lat_col='lat', x_col='x', y_col='y', z_col='z', err_col=None, frequency=None, tag=None)[source]¶ Bases:
imagine.observables.dataset.Dataset
Base class for tabular datasets, where the data is input in either in a Python dictionary-like object (
dict
,astropy.table.Table
,pandas.DataFrame
, etc).Parameters: data (dict_like) – Can be a
dict
,astropy.table.Table
,pandas.DataFrame
, or similar object containing the data.name (str) – Standard name of this type of observable. E.g. ‘fd’, ‘sync’, ‘dm’.
Optional
——–
data_col (str or None. Default: None) – Key used to access the relevant dataset from the provided data (i.e. data[data_column]). If None, this value is equal to name.
units (
Unit
object, str or None. Default: None) – Units used for the data. If None, the units are inferred from the given data_column.coords_type ({‘galactic’; ‘cartesian’} or None. Default: None) – Type of coordinates used. If None, type is inferred from present coordinate columns.
lon_col, lat_col (str. Default: (‘lon’, ‘lat’)) – Key used to access the Galactic longitudes/latitudes (in deg) from data.
x_col, y_col, z_col (str. Default: (‘x’, ‘y’, ‘z’)) – Keys used to access the coordinates (in kpc) from data.
err_col (str or None. Default: None) – The key used for accessing the error for the data values. If None, no errors are used.
frequency (
Quantity
object or None. Default: None) – Frequency of the measurement (if relevant)tag (str or None. Default: None) –
- Extra information associated with the observable.
- ‘I’ - total intensity (in unit K-cmb)
- ‘Q’ - Stokes Q (in unit K-cmb, IAU convention)
- ‘U’ - Stokes U (in unit K-cmb, IAU convention)
- ‘PI’ - polarisation intensity (in unit K-cmb)
- ‘PA’ - polarisation angle (in unit rad, IAU convention)
-
class
imagine.observables.dataset.
HEALPixDataset
(data, error=None, cov=None, Nside=None)[source]¶ Bases:
imagine.observables.dataset.Dataset
Base class for HEALPix datasets, which are input as a simple 1D-array without explicit coordinate information
-
class
imagine.observables.dataset.
ImageDataset
(data, name, lon_min, lon_max, lat_min, lat_max, object_id=None, units=None, error=None, cov=None, frequency=None, tag=None)[source]¶ Bases:
imagine.observables.dataset.Dataset
Class for simple non-full-sky image data
-
class
imagine.observables.dataset.
FaradayDepthHEALPixDataset
(data, error=None, cov=None, Nside=None)[source]¶ Bases:
imagine.observables.dataset.HEALPixDataset
Stores a Faraday depth map into an IMAGINE-compatible dataset
Parameters: - data (numpy.ndarray) – 1D-array containing the HEALPix map
- Nside (int, optional) – For extra internal consistency checking. If Nside is present, it will be checked whether \(12\times N_{side}^2\) matches
- error (float or array) – If errors are uncorrelated, this can be used to specify them (a diagonal covariance matrix will then be constructed).
- cov (numpy.ndarray) – 2D-array containing the covariance matrix
-
data
¶ Data in ObservablesDict-compatible shape
-
key
¶ Standard key associated with this observable
-
NAME
= 'fd'¶
-
class
imagine.observables.dataset.
SynchrotronHEALPixDataset
(data, frequency, typ, **kwargs)[source]¶ Bases:
imagine.observables.dataset.HEALPixDataset
Stores a synchrotron emission map into an IMAGINE-compatible dataset. This can be Stokes parameters, total and polarised intensity, and polarisation angle.
The parameter typ and the units of the map in data must follow:
- ‘I’ - total intensity (in unit K-cmb)
- ‘Q’ - Stokes Q (in unit K-cmb, IAU convention)
- ‘U’ - Stokes U (in unit K-cmb, IAU convention)
- ‘PI’ - polarisation intensity (in unit K-cmb)
- ‘PA’ - polarisation angle (in unit rad, IAU convention)
Parameters: - data (numpy.ndarray) – 1D-array containing the HEALPix map
- frequency (astropy.units.Quantity) – Frequency of the measurement (if relevant)
- Nside (int, optional) – For extra internal consistency checking. If Nside is present, it will be checked whether \(12\times N_{side}^2\) matches data.size
- typ (str) – The type of map being supplied in data.
- error (float or array) – If errors are uncorrelated, this can be used to specify them (a diagonal covariance matrix will then be constructed).
- cov (numpy.ndarray) – 2D-array containing the covariance matrix
-
data
¶ Data in ObservablesDict-compatible shape
-
key
¶ Standard key associated with this observable
-
NAME
= 'sync'¶
-
class
imagine.observables.dataset.
DispersionMeasureHEALPixDataset
(data, error=None, cov=None, Nside=None)[source]¶ Bases:
imagine.observables.dataset.HEALPixDataset
Stores a dispersion measure map into an IMAGINE-compatible dataset
Parameters: - data (numpy.ndarray) – 1D-array containing the HEALPix map
- Nside (int, optional) – For extra internal consistency checking. If Nside is present, it will be checked whether \(12\times N_{side}^2\) matches
- error (float or array) – If errors are uncorrelated, this can be used to specify them (a diagonal covariance matrix will then be constructed).
- cov (numpy.ndarray) – 2D-array containing the covariance matrix
-
data
¶ Data in ObservablesDict-compatible shape
-
key
¶ Standard key associated with this observable
-
NAME
= 'dm'¶
imagine.observables.observable module¶
In the Observable class we define three data types, i.e., - ‘measured’ - ‘simulated’ - ‘covariance’ where ‘measured’ indicates the hosted data is from measurements, which has a single realization, ‘simulated’ indicates the hosted data is from simulations, which has multiple realizations, ‘covariance’ indicates the hosted data is a covariance matrix, which has a single realization but by default should not be stored/read/written by a single computing node.
‘measred’ data puts its identical copies on all computing nodes, which means each node has a full storage of ‘measured’ data.
‘simulated’ data puts different realizations on different nodes, which means each node has part of the full realizations, but at least a full version of one single realization.
‘covariance’ data distributes itself into all computing nodes, which means to have a full set of ‘covariance’ data, we have to collect pieces from all the computing nodes.
-
class
imagine.observables.observable.
Observable
(data=None, dtype=None, coords=None, otype=None)[source]¶ Bases:
object
Observable class is designed for storing/manipulating distributed information. For the testing suits, please turn to “imagine/tests/observable_tests.py”.
Parameters: - data (numpy.ndarray) – distributed/copied data
- dtype (str) – Data type, must be either: ‘measured’, ‘simulated’ or ‘covariance’
- otype (str) – Observable type, must be either: ‘HEALPix’, ‘tabular’ or ‘plain’
-
append
(new_data)[source]¶ appending new data happens only to SIMULATED dtype the new data to be appended should also be distributed which makes the appending operation naturally in parallel
rewrite flag will be switched off once rewriten has been performed
-
data
¶ Data stored in the local processor
-
dtype
¶ ‘measured’, ‘simulated’ or ‘covariance’
Type: Data type, can be either
-
ensemble_mean
¶
-
global_data
¶ Data gathered from ALL processors (numpy.ndarray, read-only). Note that only master node hosts the global data, while slave nodes hosts None.
-
rw_flag
¶ Rewriting flag, if true, append method will perform rewriting
-
shape
¶ Shape of the GLOBAL array, i.e. considering all processors (numpy.ndarray, read-only).
-
size
¶ Local data size (int, read-only) this size means the dimension of input data not the sample size of realizations
-
var
¶ The stored variance, if the Observable is a variance or covariance
imagine.observables.observable_dict module¶
For convenience we define dictionary of Observable objects as ObservableDict from which one can define define the classes Measurements, Covariances, Simulations and Masks, which can be used to store:
- measured data sets
- measured/simulated covariances
- simulated ensemble sets
- mask “maps”
- Conventions for observables key values
- Faraday depth: (‘fd’, None, size/Nside, None)
- Dispersion measure: (‘dm’, None, size/Nsize, None)
- Synchrotron emission: (‘sync’, freq, size/Nside, tag)
- where tag stands for:
- ‘I’ - total intensity (in unit K-cmb)
- ‘Q’ - Stokes Q (in unit K-cmb, IAU convention)
- ‘U’ - Stokes U (in unit K-cmb, IAU convention)
- ‘PI’ - polarisation intensity (in unit K-cmb)
- ‘PA’ - polarisation angle (in unit rad, IAU convention)
- Remarks:
- freq, frequency in GHz
- str(pix/nside) stores either Healpix Nside, or just number of
- pixels/points
- Masking convention
- masked area associated with pixel value 0, unmasked area with pixel value 1
- Masking
- After applying a mask, the Observables change otype from ‘HEALPix’ to ‘plain’.
-
class
imagine.observables.observable_dict.
ObservableDict
(*datasets)[source]¶ Bases:
imagine.tools.class_tools.BaseClass
Base class from which
Measurements
,Covariances
,Simulations
and classMasks
classes are derived.Parameters: datasets (imagine.observables.Dataset, optional) – If present, Datasets that are appended to this ObservableDict
object after initialization.-
append
(dataset=None, *, name=None, data=None, cov_data=None, otype=None, coords=None)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
show
(**kwargs)[source]¶ Shows the contents of this ObservableDict using
imagine.tools.visualization.show_observable_dict()
-
archive
¶
-
-
class
imagine.observables.observable_dict.
Masks
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores HEALPix mask maps.
After the Masks dictionary is assembled it can be applied to any other observables dictionary to return a dictionary containing masked maps (see below).
Example
>>> import imagine.observables as obs >>> import numpy as np >>> meas, cov, mask = obs.Measurements(), obs.Covariances(), obs.Masks() >>> key = ('test','nan','4','nan') >>> meas.append(name=key, data=np.array([[1,2,3,4.]]), otype='plain') >>> mask.append(name=key, data=np.array([[1,2,3,4.]]), otype='plain') >>> masked_meas = mask(meas) >>> print(masked_meas[('test','nan','2','nan')].data) [[1. 2.]] >>> cov.append(name=key, cov_data=np.diag((1,2,3,4.)), otype='plain') >>> masked_cov = mask(cov) >>> print(masked_cov[('test',None, 2 ,None)].data) [[1. 0.] [0. 2.]]
-
__call__
(observable_dict)[source]¶ Applies the masks
Parameters: observable_dict (imagine.observables.ObservableDict) – Dictionary containing (some) entries where one wants to apply the masks. Returns: masked_dict – New observables dictionary containing masked entries (any entries in the original dictionary for which no mask was specified are referenced in masked_dict without modification). Return type: imagine.observables.ObservableDict
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
-
class
imagine.observables.observable_dict.
Measurements
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores observational data.
Parameters: datasets (imagine.observables.Dataset, optional) – If present, Datasets that are appended to this ObservableDict
object after initialization.-
cov
¶ The
Covariances
object associated with these measurements.Type: imagine.observables.observable_dict.Covariances
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
-
class
imagine.observables.observable_dict.
Simulations
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores simulated ensemble sets
See imagine.observables.observable_dict module documentation for further details.
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
estimate_covariances
(cov_est=<function oas_cov>)[source]¶ Produces a Covariances object based on the present Simulations
Parameters: cov_est (func) – A function that computes the covariance given a matrix of data Returns: covs – IMAGINE Covariances object Return type: imagine.observables.Covariances
-
sub_sim
(indices)[source]¶ Creates a new
Simulations
object based on a subset of the ensemble of a largerSimulations
.Parameters: indices – A tuple of indices numbers, a slice object or a boolean array which will be used to select the data for the sub-simulation Returns: sims_subset – The selected sub-simulation Return type: imagine.observables.Simulations
-
-
class
imagine.observables.observable_dict.
Covariances
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores observational covariances
See imagine.observables.observable_dict module documentation for further details.
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
show_variances
(**kwargs)[source]¶ Shows the contents of this ObservableDict using
imagine.tools.visualization.show_observable_dict()
-
Module contents¶
-
class
imagine.observables.
Dataset
[source]¶ Bases:
imagine.tools.class_tools.BaseClass
Base class for writing helpers to convert arbitrary observational datasets into IMAGINE’s standardized format
-
REQ_ATTRS
= ['NAME']¶
-
data
¶ Array in the shape (1, N)
-
frequency
¶
-
key
¶ Key used in the Observables_dictionary
-
name
¶
-
var
¶
-
-
class
imagine.observables.
TabularDataset
(data, name, *, data_col=None, units=None, coords_type=None, lon_col='lon', lat_col='lat', x_col='x', y_col='y', z_col='z', err_col=None, frequency=None, tag=None)[source]¶ Bases:
imagine.observables.dataset.Dataset
Base class for tabular datasets, where the data is input in either in a Python dictionary-like object (
dict
,astropy.table.Table
,pandas.DataFrame
, etc).Parameters: data (dict_like) – Can be a
dict
,astropy.table.Table
,pandas.DataFrame
, or similar object containing the data.name (str) – Standard name of this type of observable. E.g. ‘fd’, ‘sync’, ‘dm’.
Optional
——–
data_col (str or None. Default: None) – Key used to access the relevant dataset from the provided data (i.e. data[data_column]). If None, this value is equal to name.
units (
Unit
object, str or None. Default: None) – Units used for the data. If None, the units are inferred from the given data_column.coords_type ({‘galactic’; ‘cartesian’} or None. Default: None) – Type of coordinates used. If None, type is inferred from present coordinate columns.
lon_col, lat_col (str. Default: (‘lon’, ‘lat’)) – Key used to access the Galactic longitudes/latitudes (in deg) from data.
x_col, y_col, z_col (str. Default: (‘x’, ‘y’, ‘z’)) – Keys used to access the coordinates (in kpc) from data.
err_col (str or None. Default: None) – The key used for accessing the error for the data values. If None, no errors are used.
frequency (
Quantity
object or None. Default: None) – Frequency of the measurement (if relevant)tag (str or None. Default: None) –
- Extra information associated with the observable.
- ‘I’ - total intensity (in unit K-cmb)
- ‘Q’ - Stokes Q (in unit K-cmb, IAU convention)
- ‘U’ - Stokes U (in unit K-cmb, IAU convention)
- ‘PI’ - polarisation intensity (in unit K-cmb)
- ‘PA’ - polarisation angle (in unit rad, IAU convention)
-
class
imagine.observables.
HEALPixDataset
(data, error=None, cov=None, Nside=None)[source]¶ Bases:
imagine.observables.dataset.Dataset
Base class for HEALPix datasets, which are input as a simple 1D-array without explicit coordinate information
-
class
imagine.observables.
ImageDataset
(data, name, lon_min, lon_max, lat_min, lat_max, object_id=None, units=None, error=None, cov=None, frequency=None, tag=None)[source]¶ Bases:
imagine.observables.dataset.Dataset
Class for simple non-full-sky image data
-
class
imagine.observables.
FaradayDepthHEALPixDataset
(data, error=None, cov=None, Nside=None)[source]¶ Bases:
imagine.observables.dataset.HEALPixDataset
Stores a Faraday depth map into an IMAGINE-compatible dataset
Parameters: - data (numpy.ndarray) – 1D-array containing the HEALPix map
- Nside (int, optional) – For extra internal consistency checking. If Nside is present, it will be checked whether \(12\times N_{side}^2\) matches
- error (float or array) – If errors are uncorrelated, this can be used to specify them (a diagonal covariance matrix will then be constructed).
- cov (numpy.ndarray) – 2D-array containing the covariance matrix
-
data
¶ Data in ObservablesDict-compatible shape
-
key
¶ Standard key associated with this observable
-
NAME
= 'fd'¶
-
class
imagine.observables.
SynchrotronHEALPixDataset
(data, frequency, typ, **kwargs)[source]¶ Bases:
imagine.observables.dataset.HEALPixDataset
Stores a synchrotron emission map into an IMAGINE-compatible dataset. This can be Stokes parameters, total and polarised intensity, and polarisation angle.
The parameter typ and the units of the map in data must follow:
- ‘I’ - total intensity (in unit K-cmb)
- ‘Q’ - Stokes Q (in unit K-cmb, IAU convention)
- ‘U’ - Stokes U (in unit K-cmb, IAU convention)
- ‘PI’ - polarisation intensity (in unit K-cmb)
- ‘PA’ - polarisation angle (in unit rad, IAU convention)
Parameters: - data (numpy.ndarray) – 1D-array containing the HEALPix map
- frequency (astropy.units.Quantity) – Frequency of the measurement (if relevant)
- Nside (int, optional) – For extra internal consistency checking. If Nside is present, it will be checked whether \(12\times N_{side}^2\) matches data.size
- typ (str) – The type of map being supplied in data.
- error (float or array) – If errors are uncorrelated, this can be used to specify them (a diagonal covariance matrix will then be constructed).
- cov (numpy.ndarray) – 2D-array containing the covariance matrix
-
data
¶ Data in ObservablesDict-compatible shape
-
key
¶ Standard key associated with this observable
-
NAME
= 'sync'¶
-
class
imagine.observables.
DispersionMeasureHEALPixDataset
(data, error=None, cov=None, Nside=None)[source]¶ Bases:
imagine.observables.dataset.HEALPixDataset
Stores a dispersion measure map into an IMAGINE-compatible dataset
Parameters: - data (numpy.ndarray) – 1D-array containing the HEALPix map
- Nside (int, optional) – For extra internal consistency checking. If Nside is present, it will be checked whether \(12\times N_{side}^2\) matches
- error (float or array) – If errors are uncorrelated, this can be used to specify them (a diagonal covariance matrix will then be constructed).
- cov (numpy.ndarray) – 2D-array containing the covariance matrix
-
data
¶ Data in ObservablesDict-compatible shape
-
key
¶ Standard key associated with this observable
-
NAME
= 'dm'¶
-
class
imagine.observables.
Observable
(data=None, dtype=None, coords=None, otype=None)[source]¶ Bases:
object
Observable class is designed for storing/manipulating distributed information. For the testing suits, please turn to “imagine/tests/observable_tests.py”.
Parameters: - data (numpy.ndarray) – distributed/copied data
- dtype (str) – Data type, must be either: ‘measured’, ‘simulated’ or ‘covariance’
- otype (str) – Observable type, must be either: ‘HEALPix’, ‘tabular’ or ‘plain’
-
append
(new_data)[source]¶ appending new data happens only to SIMULATED dtype the new data to be appended should also be distributed which makes the appending operation naturally in parallel
rewrite flag will be switched off once rewriten has been performed
-
data
¶ Data stored in the local processor
-
dtype
¶ ‘measured’, ‘simulated’ or ‘covariance’
Type: Data type, can be either
-
ensemble_mean
¶
-
global_data
¶ Data gathered from ALL processors (numpy.ndarray, read-only). Note that only master node hosts the global data, while slave nodes hosts None.
-
rw_flag
¶ Rewriting flag, if true, append method will perform rewriting
-
shape
¶ Shape of the GLOBAL array, i.e. considering all processors (numpy.ndarray, read-only).
-
size
¶ Local data size (int, read-only) this size means the dimension of input data not the sample size of realizations
-
var
¶ The stored variance, if the Observable is a variance or covariance
-
class
imagine.observables.
ObservableDict
(*datasets)[source]¶ Bases:
imagine.tools.class_tools.BaseClass
Base class from which
Measurements
,Covariances
,Simulations
and classMasks
classes are derived.Parameters: datasets (imagine.observables.Dataset, optional) – If present, Datasets that are appended to this ObservableDict
object after initialization.-
append
(dataset=None, *, name=None, data=None, cov_data=None, otype=None, coords=None)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
show
(**kwargs)[source]¶ Shows the contents of this ObservableDict using
imagine.tools.visualization.show_observable_dict()
-
archive
¶
-
-
class
imagine.observables.
Masks
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores HEALPix mask maps.
After the Masks dictionary is assembled it can be applied to any other observables dictionary to return a dictionary containing masked maps (see below).
Example
>>> import imagine.observables as obs >>> import numpy as np >>> meas, cov, mask = obs.Measurements(), obs.Covariances(), obs.Masks() >>> key = ('test','nan','4','nan') >>> meas.append(name=key, data=np.array([[1,2,3,4.]]), otype='plain') >>> mask.append(name=key, data=np.array([[1,2,3,4.]]), otype='plain') >>> masked_meas = mask(meas) >>> print(masked_meas[('test','nan','2','nan')].data) [[1. 2.]] >>> cov.append(name=key, cov_data=np.diag((1,2,3,4.)), otype='plain') >>> masked_cov = mask(cov) >>> print(masked_cov[('test',None, 2 ,None)].data) [[1. 0.] [0. 2.]]
-
__call__
(observable_dict)[source]¶ Applies the masks
Parameters: observable_dict (imagine.observables.ObservableDict) – Dictionary containing (some) entries where one wants to apply the masks. Returns: masked_dict – New observables dictionary containing masked entries (any entries in the original dictionary for which no mask was specified are referenced in masked_dict without modification). Return type: imagine.observables.ObservableDict
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
-
class
imagine.observables.
Measurements
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores observational data.
Parameters: datasets (imagine.observables.Dataset, optional) – If present, Datasets that are appended to this ObservableDict
object after initialization.-
cov
¶ The
Covariances
object associated with these measurements.Type: imagine.observables.observable_dict.Covariances
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
-
class
imagine.observables.
Simulations
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores simulated ensemble sets
See imagine.observables.observable_dict module documentation for further details.
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
estimate_covariances
(cov_est=<function oas_cov>)[source]¶ Produces a Covariances object based on the present Simulations
Parameters: cov_est (func) – A function that computes the covariance given a matrix of data Returns: covs – IMAGINE Covariances object Return type: imagine.observables.Covariances
-
sub_sim
(indices)[source]¶ Creates a new
Simulations
object based on a subset of the ensemble of a largerSimulations
.Parameters: indices – A tuple of indices numbers, a slice object or a boolean array which will be used to select the data for the sub-simulation Returns: sims_subset – The selected sub-simulation Return type: imagine.observables.Simulations
-
-
class
imagine.observables.
Covariances
(*datasets)[source]¶ Bases:
imagine.observables.observable_dict.ObservableDict
Stores observational covariances
See imagine.observables.observable_dict module documentation for further details.
-
append
(*args, **kwargs)[source]¶ Adds/updates name and data
Parameters: - dataset (imagine.observables.dataset.Dataset) – The IMAGINE dataset already adjusts the format of the data and sets the adequate key. If dataset is present, all other arguments will be ignored.
- name (str tuple) – Should follow the convention:
(data-name, data-freq, data-Nside/"tab", ext)
. If data is independent from frequency, set None. ext can be ‘I’,’Q’,’U’,’PI’,’PA’, None or other customized tags. - data (numpy.ndarray or imagine.observables.observable.Observable) – distributed/copied
numpy.ndarray
orObservable
- otype (str) – Type of observable. May be: ‘HEALPix’, for HEALPix-like sky map; ‘tabular’, for tabular data; or ‘plain’ for unstructured data.
- coords (dict) – A dictionary containing the coordinates of tabular data
-
show_variances
(**kwargs)[source]¶ Shows the contents of this ObservableDict using
imagine.tools.visualization.show_observable_dict()
-