so_map - a module for handling HEALPIX and CAR maps#

SO map class for handling healpix and CAR maps. This is a wrapper around healpix and enlib (pixell).

pspy.so_map.bounding_box_from_map(map_car)#

Get a coordinate box from a map.

Parameters:

map_car (so_map in CAR coordinates) – the map used to define the box

pspy.so_map.car2car(map_car, template)#

Project a CAR map into another CAR map with different pixellisation

Parameters:
  • map (so_map in CAR pixellisation) – the map to be projected

  • template (so_map in CAR pixellisation) – the template that will be projected onto

pspy.so_map.car_template(ncomp, ra0, ra1, dec0, dec1, res, dtype=<class 'numpy.float64'>)#

Create a so_map template with CAR pixellisation in equ coordinates.

Parameters:
  • ncomp (integer) – the number of components of the map can be 1 or 3 (for T,Q,U)

  • ra0 (floats) – coordinates of the box in degrees

  • dec0 (floats) – coordinates of the box in degrees

  • ra1 (floats) – coordinates of the box in degrees

  • dec1 (floats) – coordinates of the box in degrees

  • res (float) – resolution in arcminute

pspy.so_map.car_template_from_shape_wcs(ncomp_out, shape, wcs, dtype=<class 'numpy.float64'>)#

Create a template from shape and wcs args with a number of components ncomp_out

Parameters:
  • ncomp_out (int) – number of components needed (e.g. 3 to create a template for (I, Q, U))

  • shape (tuple) –

  • wcs (wcs object) –

pspy.so_map.draw_random_location_car(map_car, n_pts)#

Draw n_pts uniformly on a car template and return their pixel indices, taking into accout the fact that the car pixels have different area according to their declination. also returns a corresponding hit_map also accounting for the fact that a pixel can be drawn more than once.

Parameters:
  • map_car (so_map in CAR coordinates) – the map used to define the box

  • n_pts (integer) – the number of point to draw on the map

pspy.so_map.fourier_convolution(map_car, fourier_kernel, window=None, use_ducc_rfft=False)#

do a convolution in fourier space with a fourier_kernel, you can optionnaly use a window to remove pathological pixels

Parameters:
  • map_car (so_map in CAR pixellisation) – the map to be convolved

  • fourier_kernel (2d array) – the convolution kernel in Fourier space

  • window (so_map) – a window removing pathological pixels

  • use_ducc_rfft (boolean) – wether to use ducc real fft instead of enmap complex fft

pspy.so_map.from_components(T, Q, U)#

Create a (T,Q,U) so_map object from three fits files.

Parameters:
  • T (fits file) – name of the T fits file

  • Q (fits file) – name of the Q fits file

  • U (fits file) – name of the U fits file

pspy.so_map.from_enmap(emap)#

Get a so_map from an enmap (pixell format).

Parameters:

emap (a ndmap object) – the enmap we want to use to define the so_map

pspy.so_map.full_sky_car_template(ncomp, res, dtype=<class 'numpy.float64'>)#

Create a so_map full sky template with CAR pixellisation in equ coordinates.

Parameters:
  • ncomp (integer) – the number of components of the map can be 1 or 3 (for T,Q,U)

  • res (float) – resolution in arcminute

pspy.so_map.generate_source_mask(binary, coordinates, point_source_radius_arcmin)#

Generate a point source mask in a binary template

Parameters:
  • binary (so_map binary template) – the binay map in which we generate the source mask

  • coordinates (list) – the list of point sources in DEC, RA coordinates (radians)

  • point_source_radius_arcmin (float) – the radius of the point sources

pspy.so_map.get_box(ra0, ra1, dec0, dec1)#

Create box in equatorial coordinates.

Parameters:
  • ra0 (floats) – coordinates of the box in degrees

  • dec0 (floats) – coordinates of the box in degrees

  • ra1 (floats) – coordinates of the box in degrees

  • dec1 (floats) – coordinates of the box in degrees

pspy.so_map.get_submap_car(map_car, box, mode='round')#

Cut a CAR submap (using pixell).

Parameters:
  • map (CAR map in so_map format) – the map to be cut

  • box (array_like) – The [[fromy,fromx],[toy,tox]] bounding box to select. The resulting map will have a bounding box as close as possible to this, but will differ slightly due to the finite pixel size.

  • mode (str) – How to handle partially selected pixels: “round”: round bounds using standard rules “floor”: both upper and lower bounds will be rounded down “ceil”: both upper and lower bounds will be rounded up “inclusive”: lower bounds are rounded down, and upper bounds up “exclusive”: lower bounds are rounded up, and upper bounds down

pspy.so_map.healpix2car(healpix_map, template, lmax=None)#

Project a HEALPIX so_map into a CAR so_map.

The projection will be done in harmonic space, you can specify a lmax to choose a range of multipoles considered in the projection. If the coordinate of the map and the template differ, a rotation will be performed.

Parameters:
  • healpix_map (so_map in healpix pixellisation) – the map to be projected

  • template (so_map in CAR pixellisation) – the template that will be projected onto

  • lmax (integer) – the maximum multipole in the HEALPIX map to project

pspy.so_map.healpix_template(ncomp, nside, coordinate=None)#

Create a so_map template with healpix pixellisation.

Parameters:
  • ncomp (integer) – the number of components of the map can be 1 or 3 (for T,Q,U)

  • nside (integer) – the nside of the healpix map

  • coordinate (string) – coordinate system of the map

pspy.so_map.read_map(file, coordinate=None, fields_healpix=None, car_box=None, geometry=None)#

Create a so_map object from a fits file.

Parameters:
  • file (fits file) – name of the fits file

  • coordinate (string) – coordinate system of the map

  • fields_healpix (integer) – if fields_healpix is not None, load the specified field

  • car_box (2x2 array) – [[dec0,ra0],[dec1,ra1]] in degree

pspy.so_map.simulate_source_mask(binary, n_holes, hole_radius_arcmin)#

Simulate a point source mask in a binary template

Parameters:
  • binary (so_map binary template) – the binay map in which we generate the source mask

  • n_holes (integer) – the number of masked point sources

  • hole_radius_arcmin (float) – the radius of the holes

class pspy.so_map.so_map#

Class defining a so_map object.

calibrate(cal=1.0, pol_eff=1.0)#

Calibrate the so_map, also optionnaly apply a pol efficiency :param cal: the calibration factor to apply :type cal: float :param pol_eff: the polarisation efficiency :type pol_eff: float

convolve_with_pixwin(niter=3, window=None, pixwin=None, order=0, use_ducc_rfft=False)#

Convolve a so_map object with a pixel window function The convolution is done in harmonics space, for CAR maps the pixwin is anisotropic (the pixel varies in size across the maps) and the convolution is done in Fourier space. We optionaly apply a window before doing the operation to remove pathological pixels, note that this operation is dangerous since we do harmonic transform of a masked map.

Parameters:
  • niter (integer) – the number of iteration performed while computing the alm not that for CAR niter=0 should be enough

  • window (so_map) – a window that remove pathological pixel before doing the harmonic space operation

  • pixwin (1d array for healpix, 2d array for CAR) – this allow you to pass a precomputed pixel window function

copy()#

Create a copy of the so_map object.

downgrade(factor)#

Downgrade the so_map.

Parameters:

factor (integer) – factor of decreased pixel resolution (should be a factor of 2)

get_lmax_limit()#

Return the maximum lmax corresponding to the so_map pixellisation

get_pixwin(order=0, dtype=<class 'numpy.float64'>)#

compute the pixel window function corresponding to the map pixellisation order stands for the map making pointing matrix order=0 is Neareast Neighbour while order=1 is bilinear interpolation

info()#

Print information about the so_map object.

plot(color='planck', color_range=None, file_name=None, ticks_spacing_car=1, title='', cbar=True, hp_gnomv=None)#

Plot a so_map.

Parameters:
  • color (cmap) – a matplotlib colormap (or ‘planck’)

  • color_range (scalar for single component or len(3) list for T,Q,U.) – the range of the colorscale

  • file_name (string) – file_name is the name of the png file that will be created, if None the plot will be displayed.

  • title (string) – the title of the plot.

  • cbar (boolean) – set to True to display the colorbar.

  • ticks_spacing_CAR (float) – for CAR plot, choose the spacing of the ticks.

  • hp_gnomv (tuple) – gnomview projection for HEALPIX plotting, expected (lon_c,lat_c,xsize,reso).

subtract_mean(mask=None)#

Subtract mean from a so_map object, optionnaly within a mask

Parameters:

mask (either a single so_map (for ncomp = 1) or a tuple of SO map e.g (mask_T, mask_P)) –

subtract_mono_dipole(mask=None, values=None, bunch=24)#

Subtract monopole and dipole from a so_map object.

Parameters:
  • mask (either a single so_map (for ncomp = 1) or a tuple of SO map e.g (mask_T, mask_P)) –

  • values (the value of the monopole and dipole to subtract) –

  • bunch (int) – the bunch size (default: 24)

synfast(clfile)#

Fill a so_map with a cmb gaussian simulation.

Parameters:

clfile (CAMB data file) – lensed power spectra file from CAMB

upgrade(factor)#

Upgrade the so_map.

Parameters:

factor (integer) – factor of increased pixel resolution (should be a factor of 2)

write_map(file_name)#

Write the so_map to disk.

Parameters:

filename (string) – the name of the fits file

pspy.so_map.subtract_mono_dipole(emap, mask=None, healpix=True, values=None, bunch=24, return_values=False)#

Subtract monopole and dipole from a enmap object.

Parameters:
  • emap (enmap or numpy array) – the map from which to compute mono/dipole values

  • mask (enmap or numpy array) – a mask to put on top of the map

  • healpix (bool) – flag for using HEALPIX (default) or CAR pixellisation

  • bunch (int) – the bunch size (default: 24)

  • values

  • return_values (bool) – Return mono/dipole values with the subtracted map (default: False)

pspy.so_map.white_noise(template, rms_uKarcmin_T, rms_uKarcmin_pol=None)#

Generate a white noise realisation corresponding to the template pixellisation

Parameters:
  • template (so_map template) – the template for the white noise generalisation

  • rms_uKarcmin_T (float) – the white noise temperature rms in uK.arcmin

  • rms_uKarcmin_pol (float) – the white noise polarisation rms in uK.arcmin if None set it to sqrt(2)*rms_uKarcmin_T