micmac.foregrounds.mixingmatrix module¶
-
class MixingMatrix(frequency_array, n_components, spv_nodes_b, nside, params=
None, pos_special_freqs=[0, -1])[source]¶ Bases:
objectNote: units are K_CMB.
- Parameters:
- frequency_array : array¶
Array of frequencies
- n_components : int¶
Number of components
- spv_nodes_b : list¶
List of nodes for b containing info patches to build spv_templates
- nside : int¶
Healpix nside of the expected input maps
- params : array (optional)¶
Initial values of the parameters of the mixing matrix, default None (then initialized with zeros)
- pos_special_freqs : list (optional)¶
List of indexes of special frequencies (e.g. 0 for synchrotron, -1 for dust)
-
__init__(frequency_array, n_components, spv_nodes_b, nside, params=
None, pos_special_freqs=[0, -1])[source]¶ Note: units are K_CMB.
- Parameters:
- frequency_array : array¶
Array of frequencies
- n_components : int¶
Number of components
- spv_nodes_b : list¶
List of nodes for b containing info patches to build spv_templates
- nside : int¶
Healpix nside of the expected input maps
- params : array (optional)¶
Initial values of the parameters of the mixing matrix, default None (then initialized with zeros)
- pos_special_freqs : list (optional)¶
List of indexes of special frequencies (e.g. 0 for synchrotron, -1 for dust)
-
get_B(jax_use=
False)[source]¶ Full mixing matrix, (n_frequencies*n_components). CMB is given as the first component.
-
get_B_db(jax_use=
False)[source]¶ STATUS: Not used currently, to be adjusted with spv
List of derivatives of the Mixing Matrix (wrt to each entry of first comp and then each entry of second comp) Note: w/o pixel dimension
-
get_B_fgs_from_params(params, jax_use=
False)[source]¶ Foreground part of the mixing matrix obtained from the parameters.
- Parameters:
- params : array[float]¶
Flattened version of all free parameters of the mixing matrix per patch expected to be stored as [Bf1_comp1_patch1, Bf1_comp1_patch2, …, Bf2_comp1_patch1, …, Bf1_comp2_patch1, …, Bfn_comp2_patchn, …]
- jax_use : bool (optional)¶
If True, params are expected as JAX Array and B_fgs will be returned as JAX Array, default False
- Returns:
B_fgs – Foreground part of the mixing matrix (including special frequencies)
- Return type:
array[float] of dimensions [n_frequencies, n_components - 1, n_pix]
-
get_B_from_params(params, jax_use=
False)[source]¶ Full mixing matrix, (n_frequencies*n_components), obtained from the parameters. CMB is given as the first component.
- Parameters:
- params : array[float]¶
Flattened version of all free parameters of the mixing matrix per patch expected to be stored as [Bf1_comp1_patch1, Bf1_comp1_patch2, …, Bf2_comp1_patch1, …, Bf1_comp2_patch1, …, Bfn_comp2_patchn, …]
- jax_use : bool (optional)¶
If True, params are expected as JAX Array and B_mat will be returned as JAX Array, default False
- Returns:
B_mat – Full mixing matrix
- Return type:
array[float] of dimensions [n_frequencies, n_components, n_pix]
- get_all_templates()[source]¶
Retrieve all templates maps whose values correspond to the indices of params, and indexed per frequency and component
- Returns:
all_templates – All templates indexes maps whose values correspond to the indices of params for all the patches distributions per frequency and component
- Return type:
array[int] of dimensions [n_frequencies - n_components + 1, n_components - 1, 12*nside**2]
-
get_idx_template_params_long_python(idx_template, params, print_bool=
False)[source]¶ From the params to all the entries of the mixing matrix For a given template index, retrieve the corresponding template
- Parameters:
- idx_template : array[int]¶
index of params of the corresponding template which will be saved
- params : array[float]¶
flatttened compressed array of the free params of the mixing matrix expected to be stored as [Bf1_comp1_patch1, Bf1_comp1_patch2, …, Bf2_comp1_patch1, …, Bf1_comp2_patch1, …, Bfn_comp2_patchn, …]
- Returns:
idx_template – Full parameters of the mixing matrix re-flattened as [(n_frequencies - n_components + 1)*(n_components - 1), n_pix] stacked with one patch distribution template indicated by idx_template
- Return type:
array[int]
- get_one_template(nside_patch)[source]¶
Retrieve all templates maps whose values correspond to the indices of params, and indexed per frequency and component
-
get_params_db(jax_use=
False)[source]¶ STATUS: Not used currently, to be adjusted with spv
Derivatives of the part of the Mixing Matrix w params (wrt to each entry of first comp and then each entry of second comp) Note: w/o pixel dimension
-
get_params_long_python(params, print_bool=
False)[source]¶ From the params (Bf) to all the entries of the mixing matrix only with Python (numpy) without JAX
- Parameters:
- Returns:
params_long – Reshaped free parameters of the mixing matrix
- Return type:
array[float] of dimensions [n_frequencies - n_components + 1, n_components - 1, n_pix]
-
get_patch_B_from_params(nside_patch, params, jax_use=
False)[source]¶ Full mixing matrix, (n_frequencies*n_components) from params and one patch distribution template. cmb is given as the first component.
- Parameters:
- nside_patch : int¶
Healpix nside of one patch distribution, expected lower than nside of the input maps
- params : array[float]¶
Flattened version of all free parameters of the mixing matrix per patch expected to be stored as [Bf1_comp1_patch1, Bf1_comp1_patch2, …, Bf2_comp1_patch1, …, Bf1_comp2_patch1, …, Bfn_comp2_patchn, …]
- jax_use : bool (optional)¶
If True, params are expected as JAX Array and the results will be returned as JAX Array, default False
- Returns:
B_mat (array[float] of dimensions [n_frequencies, n_components, n_pix]) – Full mixing matrix
template (array[int] of dimensions [12*nside_patch**2]) – One template indexes map whose values correspond to the indices of params for one patch distribution according to Healpix pixelization
-
get_template_B_fgs_from_params(nside_patch, params, jax_use=
False)[source]¶ Foreground (fgs) part of the mixing matrix and one patch distribution template obtained from nside_patch expected lower than nside of the input maps.
- Parameters:
- nside_patch : int¶
Healpix nside of one patch distribution, expected lower than nside of the input maps
- params : array[float]¶
Flattened version of all free parameters of the mixing matrix per patch expected to be stored as [Bf1_comp1_patch1, Bf1_comp1_patch2, …, Bf2_comp1_patch1, …, Bf1_comp2_patch1, …, Bfn_comp2_patchn, …]
- jax_use : bool (optional)¶
If True, params are expected as JAX Array and the results will be returned as JAX Array, default False
- Returns:
B_fgs (array[float] of dimensions [n_frequencies, n_components - 1, n_pix]) – Foreground part of the mixing matrix (including special frequencies)
template (array[int] of dimensions [12*nside_patch**2]) – One template indexes map whose values correspond to the indices of params for one patch distribution according to Healpix pixelization
- property n_pix¶
Number of pixels of one input freq map
- get_indexes_b(n_frequencies, n_components, spv_nodes_b)[source]¶
Return indexes of params for all frequencies and components
- get_indexes_patches(indexes_b, len_params)[source]¶
Return indexes of params for all patches of a b
- get_len_params(spv_nodes_b)[source]¶
Return total number of free parameters (per frequency, component, patch)