lib.MapMaking.Qatmosphere module

class lib.MapMaking.Qatmosphere.AtmosphereMaps(params)[source]

Bases: AtmosphereProperties

Methods

absorption_spectrum()

Absorption spectrum.

angular_correlation(theta, h_atm, r0)

Angular Kolmogorov correlation function.

atm_absorption_coeff()

Absorption coefficients.

azel_to_horizontal_plane(r, az, el)

cl_from_angular_correlation_int(ell)

Angular power spectrum from angular correlation function.

ctheta_2_cell(theta_deg, ctheta, lmax[, ...])

Angular power spectrum from angular correlation function.

ctheta_2_dell(theta_deg, ctheta, lmax[, ...])

Angular power spectrum from angular correlation function.

generate_spatial_fluctuation_sphercial_harmonics([...])

Spatial fluctuation map from angular correlation function.

generate_spatial_fluctuations_fourier(...[, ...])

Spatial 2d fluctuations.

get_fourier_grid_2d(n_grid, size_atm)

Fourier 2d grid.

get_gas_properties([params_file])

Gas properties.

get_healpy_atm_maps_2d(maps, longitude, latitude)

Healpy 2d atmosphere maps.

get_integrated_absorption_spectrum(band)

Integrated absorption spectrum within a band.

get_mean_water_vapor_density(altitude, ...)

Mean water vapor density.

get_qubic_dict([key])

QUBIC dictionary.

get_sigma_rho(sigma_pwv[, h])

Water vapor density's standard deviation

get_temp_maps(maps)

Atmosphere maps.

get_temperature_atm(altitude, temp_ground, h_T)

Temperature.

get_water_vapor_density_fluctuation_2d_map([flat])

Water vapor density 2d map.

horizontal_plane_to_azel(x, y, z)

Horizontal plane to azimuth and elevation.

integrated_absorption_spectrum()

Integrated absorption spectrum.

kolmogorov_correlation_function(r, r0)

Kolmogorov correlation function.

kolmogorov_spectrum(k, r0[, sigma_rho, atm_size])

Kolmogorov spectrum.

normalized_kolmogorov_spectrum(k, r0[, ...])

Normalized Kolmogorov spectrum.

get_azel_coordinates

angular_correlation(theta, h_atm, r0)[source]

Angular Kolmogorov correlation function.

We compute the angular Kolmogorov correlation function, switching the distance between two points to the angle between them on the surface of the sphere, using the relation :

\[r = 2h_{atm} \sin \left(\frac{\theta}{2}\right) ,\]

where \(h_{atm}\) is the distance between the atmosphere and our instrument and \(\theta\) is the angle between the two points.

Parameters:
  • theta (array_like or float) – Angle between two points, in degrees.

  • h_atm (array_like or float) – Distance between the atmosphere and our instrument, in meters.

  • r0 (float) – Maximum correlation length, in meters.

Returns:

C – Angular Kolmogorov correlation function.

Return type:

array_like or float

azel_to_horizontal_plane(r, az, el)[source]
Parameters:
  • r (array_like) – Radius coordinate.

  • az (array_like) – Azimuth coordinate.

  • el (array_like) – Elevation coordinate.

Returns:

  • x (array_like) – x coordinate.

  • y (array_like) – y coordinate.

  • z (array_like) – z coordinate.

cl_from_angular_correlation_int(ell)[source]

Angular power spectrum from angular correlation function.

Compute the angular power spectrum from the angular correlation function, using the formula:

\[C_{\ell} = 2 \pi \int_{-1}^{1} C(\theta) P_{\ell}(\cos \theta) d \cos \theta ,\]

where \(C(\theta)\) is the angular correlation function and \(P_l(\cos \theta)\) is the Legendre polynomial of order \(l\).

WARNING: This function is not very efficient, as it computes the Legendre polynomial of order l for each value of cos(theta). It takes a long time to compute for high values of l. It is just used for testing purposes and to compute the case ell = 0 which is not possible in ‘ctheta_2_dell’.

Parameters:

ell (int) – Angular multipole order.

Returns:

C_l – Angular power spectrum of order l.

Return type:

float

ctheta_2_cell(theta_deg, ctheta, lmax, normalization=1)[source]

Angular power spectrum from angular correlation function.

Compute the angular power spectrum from the angular correlation function, using the function ‘ctheta_2_dell’, and convert the result to \(C_{\ell}\).

Parameters:
  • theta_deg (array_like) – Angles between two points on the surface of the sphere, in degrees.

  • ctheta (array_like) – Angular correlation function.

  • lmax (int) – Maximum angular multipole order.

  • normalization (int, optional) – Normalization parameter, by default 1

Returns:

cell – Angular power spectrum.

Return type:

array_like

ctheta_2_dell(theta_deg, ctheta, lmax, normalization=1)[source]

Angular power spectrum from angular correlation function.

Compute the angular power spectrum from the angular correlation function, using the formula:

\[C_{\ell} = 2 \pi \int_{-1}^{1} C(\theta) P_{\ell}(\cos \theta) d \cos \theta ,\]

where \(C(\theta)\) is the angular correlation function and \(P_l(\cos \theta)\) is the Legendre polynomial of order \(l\).

This computation is done using the CAMB library, which is much faster than the ‘cl_from_angular_correlation_int’ function.

Parameters:
  • theta_deg (array_like) – Angles between two points on the surface of the sphere, in degrees.

  • ctheta (array_like) – Angular correlation function.

  • lmax (int) – Maximum angular multipole order.

  • normalization (int, optional) – Normalization parameter, by default 1

Returns:

dell – Angular power spectrum.

Return type:

array_like

generate_spatial_fluctuation_sphercial_harmonics(sigma_rho=None, atm_size=None, Debug=False)[source]

Spatial fluctuation map from angular correlation function.

Compute the spatial fluctuation HEALPix map from the angular correlation function, using the function ‘ctheta_2_cell’. Debug can be used to check

Returns:

delta – Spatial fluctuation map, generated accorging HEALPix formalism.

Return type:

array_like

generate_spatial_fluctuations_fourier(n_grid, size_atm, r0, sigma_rho=None, atm_size=None, Debug=False)[source]

Spatial 2d fluctuations.

Produce the spatial fluctuations of the water vapor density, by generating random phases in Fourier space, and then computing the inverse Fourier transform.

Parameters:
  • n_grid (int) – Number of grid points in the 2d grid.

  • size_atm (float) – Size of the atmosphere in m.

  • r0 (float) – Maximum spatial coherence length of the water vapor density, in m

  • Debug (bool) – If True, prints sigma_rho / np.sqrt( np.var(delta_rho)) to check wether the fourier normalization was done correctly in kolmogorov_spectrum. By default False

Returns:

delta_rho_x – Variation of the water vapor density.

Return type:

array_like

get_azel_coordinates()[source]
get_fourier_grid_2d(n_grid, size_atm)[source]

Fourier 2d grid.

Generate a 2d grid of spatial frequencies in Fourier space according to the parameters in the self.params.yml file.

Parameters:
  • n_grid (int) – Number of grid points in the 2d grid.

  • size_atm (float) – Size of the atmosphere in m.

Returns:

  • kx (array_like) – 2d array containing the spatial x frequencies in Fourier space, (n_grid, n_grid).

  • ky (array_like) – 2d array containing the spatial y frequencies in Fourier space, (n_grid, n_grid).

  • k_norm (array_like) – 2d array containing the norm of the spatial frequencies in Fourier space, (n_grid, n_grid).

get_healpy_atm_maps_2d(maps, longitude, latitude)[source]

Healpy 2d atmosphere maps.

Function to project the 2d atmosphere maps in cartesian coordinates, and then project them in spherical coordinates using healpy. By default, the projection is centered on the QUBIC patch (RA=0, DEC=-57).

Returns:

hp_maps_2d – 2d healpy maps of the atmosphere.

Return type:

array_like

get_temp_maps(maps)[source]

Atmosphere maps.

Get the atmosphere maps in temperature, by using the equation 12 from Morris 2021, that compute the induced temperature in the detector due to the water vapor density :

\[dT( \textbf{r}, \nu) = \alpha_b(\nu) \rho(\textbf{r}) T_{atm}(\textbf{r}) dV .\]

And then, convert it in micro Kelvin CMB.

Parameters:

maps (array_like) – Water vapor density 2d map.

Returns:

temp_maps – Temperature maps in micro Kelvin CMB.

Return type:

array_like

get_water_vapor_density_fluctuation_2d_map(flat=True)[source]

Water vapor density 2d map.

Get the water vapor density 2d map with simulated fluctuations. The spatial fluctuations are generated using either the correlation function or the angular correlation function.

Parameters:
  • mean_rho (array_like) – Mean water vapor density.

  • angular (bool, optional) – If True, use the angular correlation function. If False, use the correlation function., by default True

Returns:

atm_maps_2d – Water vapor density 2d map.

Return type:

array_like

horizontal_plane_to_azel(x, y, z)[source]

Horizontal plane to azimuth and elevation.

Convert the coordinates in the horizontal plane to azimuth and elevation.

Parameters:
  • x (array_like) – x coordinate.

  • y (array_like) – y coordinate.

  • z (array_like) – z coordinate.

Returns:

  • az (array_like) – Azimuth coordinate.

  • el (array_like) – Elevation coordinate.

kolmogorov_correlation_function(r, r0)[source]

Kolmogorov correlation function.

Compute the Kolmogorov correlation function by applying the inverse Fourier transform to the Kolmogorov 2d spectrum. This correlation function can be written as:

\[D(r) = \frac{2^{2/3}}{\Gamma(1/3)} \left(\frac{r}{r_0}\right)^{1/3} K_{1/3} \left(\frac{r}{r_0}\right) .\]

We impose that the correlation function is 1 at r = 0.

Parameters:
  • r (array_like or float) – Distance between two points, in meters.

  • r0 (array_like or float) – Maximum correlation length, in meters.

Returns:

D – Correlation function.

Return type:

array_like

kolmogorov_spectrum(k, r0, sigma_rho=None, atm_size=None)[source]

Kolmogorov spectrum.

Compute the Kolmogorov spectrum, which simulate the power spectrum of the spatial fluctuations of the water vapor density, following the equation :

\[P(\textbf{k}) = (r_0^{-2} + \lvert \textbf{k} \rvert ^{2})^{-11/6} .\]
Parameters:
  • k (array_like) – Array containing the spatial frequencies at which we want to compute the Kolmogorov 2d spectrum.

  • r0 (float) – Maximum spatial coherence length of the water vapor density, in m.

Returns:

kolmogorov_spectrum – Kolmogorov spectrum.

Return type:

array_like

normalized_kolmogorov_spectrum(k, r0, sigma_rho=None, atm_size=None)[source]

Normalized Kolmogorov spectrum.

Compute the normalized Kolmogorov spectrum, to ensure :

\[\int_\textbf{k} P(\textbf{k}) d\textbf{k} = 1 .\]
Parameters:
  • k (array_like) – Array containing the spatial frequencies at which we want to compute the normalized Kolmogorov spectrum.

  • r0 (float) – Maximum spatial coherence length of the water vapor density, in m.

Returns:

normalized_kolmogorov_spectrum – Normalized Kolmogorov spectrum.

Return type:

array_like

class lib.MapMaking.Qatmosphere.AtmosphereProperties(params)[source]

Bases: object

Methods

absorption_spectrum()

Absorption spectrum.

atm_absorption_coeff()

Absorption coefficients.

get_gas_properties([params_file])

Gas properties.

get_integrated_absorption_spectrum(band)

Integrated absorption spectrum within a band.

get_mean_water_vapor_density(altitude, ...)

Mean water vapor density.

get_qubic_dict([key])

QUBIC dictionary.

get_sigma_rho(sigma_pwv[, h])

Water vapor density's standard deviation

get_temperature_atm(altitude, temp_ground, h_T)

Temperature.

integrated_absorption_spectrum()

Integrated absorption spectrum.

absorption_spectrum()[source]

Absorption spectrum.

The coefficient \(\alpha_b(\nu)\) (\(m^2/g\)) is defined by:

\[\alpha_b(\nu) = \frac{1}{m_{H_2O}} \left(k_{lines}(\nu) + n_{H_2O}k_{self}(\nu) + n_{air}k_{air}(\nu)\right) ,\]

with \(m_{H_2O}= 2.992\times 10^{-23} g\) the mass of a \(H_2O\) molecule, \(k_{lines}\) (\(m^2\)) the line-by-line absorption coefficient, :math`k_{self}` and :math`k_{air}` (\(m^5\)) the self- and air-induced continua, \(n_{H_2O}\) and \(n_{air}\) (\(m^{-3}\)) the densities of water vapor and air.

Returns:

abs_spectrum – Atmosphere absorption coefficient, in \(m^{2} / g\).

Return type:

array_like

atm_absorption_coeff()[source]

Absorption coefficients.

Method to build the absorption spectrum of the atmopshere using files computed using the am atmospheric model (Paine, 2018). The absorption coefficient has two origins: the line-by-line absorption which reprensents the spectral lines, and a continuum absorption coming from collisions between molecules, either \(H_2O-H_2O\) collisions (self-induced continuum), or collisions between \(H_2O\) and the air (air_induced).

See the am documentation for more details: https://lweb.cfa.harvard.edu/~spaine/am/ .

Returns:

  • frequencies (array_like) – Frequencies at which the absorption spectrum is computed.

  • mol_absorption_coeff (array_like) – Molecular absorption lines spectrum, from water and dioxygene, in \(m^{2}\).

  • self_absorption_coeff (array_like) – Self-induced collisions continuum, from water, in \(m^{5}\).

  • air_absorption_coeff (array_like) – Air_induced collisions continuun, from water, in \(m^{5}\).

get_gas_properties(params_file=True)[source]

Gas properties.

Method to compute the properties of the water vapor and the air in the atmosphere. It uses the CoolProp package (https://github.com/CoolProp/CoolProp) to compute the molar mass of air and water. It can use parameters given in self.params.yml or be baised on the CoolProp package to compute the water vapor density.

The pressure as to be defined in the params.yml file. The temperature is computed using the function ‘get_temp_atm’.

The molar mass of air is given by the CoolProp package: CP.PropsSI(‘MOLARMASS’, ‘Air’) kg/mol. The molar mass of water is given by the CoolProp package: CP.PropsSI(‘MOLARMASS’, ‘Water’) kg/mol.

From molar mass, the mass is given by :

\[m = M / N_A ,\]

where \(m\) is the mass, \(M\) is the molar mass and \(N_A\) is the Avogadro constant, given by scipy.constants .

The mass density of air is computed using CoolProp package, from the pressure and the temperature of the atmosphere. Then, the density of air is computed with :

\[n = \rho / m ,\]

where \(n\) is the density, \(\rho\) is the mass density and \(m\) is the mass.

For the water vapor density, you can follow the same steps by putting the argument params_file = False, or compute it using the mass density computed using ‘get_mean_water_vapor_density’ and the parameters given in self.params_file.

Parameters:

self.params_file (bool, optional) – If True, will use the reference water vapor density given in self.params_file by self.params[‘rho_0’] (in \(g/m^{3}\)) to compute the density in \(m^{-3}\). Else, will use the temperature and pression value to compute it. By default True.

Returns:

  • water_mass (float) – The weight of a \(H_2O\) molecule in \(g\).

  • water_vapor_density (float) – The density of water vapor given the atmospheric temperature and pressure in \(m^{-3}\).

  • air_vapor_density (float) – The density of air vapor given the atmospheric temperature and pressure in \(m^{-3}\).

get_integrated_absorption_spectrum(band)[source]

Integrated absorption spectrum within a band.

Compute the integrated absorption spectrum in a given frequency band, according to the parameters in the self.params.yml file.

Parameters:

band (int) – QUBIC frequency band. Can be either 150 or 220.

Returns:

  • integrated_abs_spectrum (numpy.ndarray) – The integrated absorption spectrum in the given frequency band, in m^2/g.

  • nus (numpy.ndarray) – The frequencies at which the absorption spectrum is computed, in GHz.

get_mean_water_vapor_density(altitude, rho_0, h_h2o)[source]

Mean water vapor density.

Compute the mean water vapor density depending on the altitude, using reference water vapor density and water vapor half_height, given in self.params.yml. The corresponding equation to compute the mean water vapor density, taken from equation (1) in Morris 2021, is :

\[\langle \rho(h) \rangle = \rho_0 e^{\left( -log(2).(h - 5190) / h_0 \right)} .\]
Parameters:

altitude (array_like) – Array containing altitudes at which we want to compute the mean water vapor density.

Returns:

mean_water_vapor_density – Mean water vapor density in \(g/m{3}\).

Return type:

array_like

get_qubic_dict(key='in')[source]

QUBIC dictionary.

Method to modify the qubic dictionary.

Parameters:

key (str, optional) – Can be “in” or “out”. It is used to build respectively the instances to generate the TODs or to reconstruct the sky maps, by default “in”.

Returns:

dict_qubic – Modified QUBIC dictionary.

Return type:

dict

get_sigma_rho(sigma_pwv, h=None)[source]

Water vapor density’s standard deviation

Compute sigma_rho from sigma_pwv at altitude h, with sigma_pwv taken from Table 1 in Sugiyama 2024. The formula, being $sigma_{rho(h)} = frac{sigma_{PWV}}{h}$ , comes from a scale approximation. h should be defined as 2*h_h2o, with h_h2o the water vapor half-height.

Parameters:
  • sigma_pwv (float) – PWV’s STD in mm.(1 mm of water over a 1 m^2 area is equivalent to 1 kg/m^2, the actual dimension of the PWD per definition.)

  • h (float) – height of the considered water vapor in m.

Returns:

sigma_rho – Water vapor density’s standard deviation in kg/m^3

Return type:

float

get_temperature_atm(altitude, temp_ground, h_T)[source]

Temperature.

Compute the temperature of the atmosphere depending on the altitude, using the average ground temperature and a typical height that depend on the observation site. The corresponding equation to compute the temperature, taken from equation (13) in Morris 2021, is :

\[T_{atm}(h) = T_{atm}(0) e^{h / h_T} .\]
Parameters:
  • altitude (array_like) – Array containing altitudes at which we want to compute the temperature.

  • temp_ground (float) – Average ground temperature in K.

  • h_T (float) – Typical height in m.

Returns:

temperature – Temperature in K.

Return type:

array_like

integrated_absorption_spectrum()[source]

Integrated absorption spectrum.

Integrated absorption spectrum in the QUBIC frequency bands: 150 and 220 GHz.

Returns:

  • integrated_abs_spectrum (array_like) – The integrated absorption spectrum in the given frequency band, in \(m^{2} / g\).

  • nus (array_like) – The frequencies at which the absorption spectrum is computed, in \(GHz\).

class lib.MapMaking.Qatmosphere.WindPerturbation(params, qubic_sampling)[source]

Bases: object

Methods

azel_to_cartesian(azimuth, elevation, altitude)

AzEl to Cartesian coordinates.

cartesian_to_azel(x, y, z)

Cartesian to AzEl cooordinates.

get_constant_wind(wind_x, wind_y)

Constant wind field

get_normal_wind(wind_mean, wind_std)

Random normal wind field

get_deviated_coord

get_deviated_index

get_deviated_qubic_sampling

get_wind

azel_to_cartesian(azimuth, elevation, altitude)[source]

AzEl to Cartesian coordinates.

cartesian_to_azel(x, y, z)[source]

Cartesian to AzEl cooordinates.

get_constant_wind(wind_x, wind_y)[source]

Constant wind field

Parameters:
  • wind_x (float) – wind’s x and y components

  • wind_y (float) – wind’s x and y components

Returns:

wind_field – shape (2, npointings)

Return type:

array_like

get_deviated_coord()[source]
get_deviated_index(pos_x, pos_y, wind_x, wind_y)[source]
get_deviated_qubic_sampling()[source]
get_normal_wind(wind_mean, wind_std)[source]

Random normal wind field

Parameters:
  • wind_mean (array_like) – parameters of the Gaussian distribution. Each is a lenght 2 array for x and y components

  • wind_std (array_like) – parameters of the Gaussian distribution. Each is a lenght 2 array for x and y components

Returns:

wind_field – shape (2, npointings)

Return type:

array_like

get_wind()[source]