NaMaster: utils.h File Reference

NaMaster

- Main Page
- Data Structures
- Files

- File List
- Globals

Macros | Functions
utils.h File Reference

Go to the source code of this file.

## Macros
#define | HE_NITER_DEFAULT 3
| Default number of iterations used for full-sky spherical harmonic transforms. More...

## Functions
gsl_rng * | init_rng (unsigned int seed)
| Initialize a random number generator. More...
double | rng_01 (gsl_rng *rng)
| Top-hat random numbers. More...
int | rng_poisson (double lambda, gsl_rng *rng)
| Poisson random numbers. More...
void | rng_delta_gauss (double *module, double *phase, gsl_rng *rng, double sigma2)
| Gaussian random numbers (mod-phase). More...
void | rng_gauss (gsl_rng *rng, double *r1, double *r2)
| Gaussian random numbers. More...
void | end_rng (gsl_rng *rng)
| Destructor for random number generators. More...
int | my_linecount (FILE *f)
| Count number of lines in an ASCII file. More...
void * | my_malloc (size_t size)
| Error-checked malloc. More...
void * | my_calloc (size_t nmemb, size_t size)
| Error-checked calloc. More...
FILE * | my_fopen (const char *path, const char *mode)
| Error-checked fopen. More...
size_t | my_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
| Error-checked fwrite. More...
size_t | my_fread (void *ptr, size_t size, size_t count, FILE *stream)
| Error-checked fread. More...
int | drc3jj (int il2, int il3, int im2, int im3, int *l1min_out, int *l1max_out, double *thrcof, int size)
| Wigner 3-j symbols. More...
void | moore_penrose_pinv (gsl_matrix *M, double threshold)
| Moore-Penrose pseudo-inverse. More...
void * | dftw_malloc (size_t n)
| Wrapper around fftw_malloc More...
void | dftw_free (void *p)
| Wrapper around fftw_free More...
void | fs_mapcpy (nmt_flatsky_info *fs, flouble *destmap, flouble *srcmap)
| Copies a map. More...
void | fs_map_product (nmt_flatsky_info *fs, flouble *mp1, flouble *mp2, flouble *mp_out)
| Multiplies two flat-sky maps. More...
flouble | fs_map_dot (nmt_flatsky_info *fs, flouble *mp1, flouble *mp2)
| Dot product of flat-sky maps. More...
void | fs_map2alm (nmt_flatsky_info *fs, int ntrans, int spin, flouble **map, fcomplex **alm)
| Flat-sky SHT. More...
void | fs_alm2map (nmt_flatsky_info *fs, int ntrans, int spin, flouble **map, fcomplex **alm)
| Flat-sky inverse SHT. More...
nmt_k_function * | fs_generate_beam_window (double fwhm_amin)
| Gaussian beam. More...
void | fs_zero_alm (nmt_flatsky_info *fs, fcomplex *alm)
| Zero SHT coefficients. More...
void | fs_alter_alm (nmt_flatsky_info *fs, double fwhm_amin, fcomplex *alm_in, fcomplex *alm_out, nmt_k_function *window, int add_to_out)
| Multiply SHT coefficients by beam. More...
void | fs_alm2cl (nmt_flatsky_info *fs, nmt_binning_scheme_flat *bin, fcomplex **alms_1, fcomplex **alms_2, int spin_1, int spin_2, flouble **cls, flouble lmn_x, flouble lmx_x, flouble lmn_y, flouble lmx_y)
| Computes Flat-sky power spectrum from Fourier coefficients. More...
void | fs_anafast (nmt_flatsky_info *fs, nmt_binning_scheme_flat *bin, flouble **maps_1, flouble **maps_2, int spin_1, int spin_2, flouble **cls)
| Computes Flat-sky power spectrum from maps. More...
fcomplex ** | fs_synalm (int nx, int ny, flouble lx, flouble ly, int nmaps, nmt_k_function **cells, nmt_k_function **beam, int seed)
| Gaussian realizations of flat-sky Fourier coefficients. More...
flouble * | fs_read_flat_map (char *fname, int *nx, int *ny, flouble *lx, flouble *ly, int nfield)
| Reads flat-sky map. More...
long | he_nside2npix (long nside)
| HEALPix number of pixels. More...
void | he_pix2vec_ring (long nside, long ipix, double *vec)
| HEALPix pix2vec. More...
long | he_ang2pix (long nside, double cth, double phi)
| Modified HEALPix ang2pix. More...
long | he_nalms (int lmax)
| Number of alm coefficients. More...
long | he_indexlm (int l, int m, int lmax)
| Harmonic coefficient ordering. More...
void | he_alm2map (nmt_curvedsky_info *cs, int lmax, int ntrans, int spin, flouble **maps, fcomplex **alms)
| Full-sky inverse SHT. More...
void | he_map2alm (nmt_curvedsky_info *cs, int lmax, int ntrans, int spin, flouble **maps, fcomplex **alms, int niter)
| Full-sky SHT. More...
void | he_alm2cl (fcomplex **alms_1, fcomplex **alms_2, int spin_1, int spin_2, flouble **cls, int lmax)
| Computes Full-sky power spectrum from harmonic coefficients. More...
int | he_get_largest_possible_lmax (nmt_curvedsky_info *cs)
| Gets the multipole approximately corresponding to the Nyquist frequency. More...
int | he_get_lmax (nmt_curvedsky_info *cs)
| Get maximum multipole allowed by sky geometry configuration. More...
void | he_anafast (flouble **maps_1, flouble **maps_2, int spin_1, int spin_2, flouble **cls, nmt_curvedsky_info *cs, int lmax, int iter)
| Computes Full-sky power spectrum from maps. More...
void | he_write_healpix_map (flouble **tmap, int nfields, long nside, char *fname)
| Writes full-sky maps to FITS file. More...
void | he_write_CAR_map (flouble **tmap, int nfields, nmt_curvedsky_info *sky_info, char *fname)
| Writes CAR maps to FITS file. More...
nmt_curvedsky_info * | he_get_file_params (char *fname, int is_healpix, int *nfields, int *isnest)
| Read map parameters from FITS file. More...
flouble * | he_read_map (char *fname, nmt_curvedsky_info *sky_info, int nfield)
| Reads full-sky map from FITS file. More...
int | he_ring_num (long nside, double z)
| HEALPix ring number. More...
void | he_query_strip (long nside, double theta1, double theta2, int *pixlist, long *npix_strip)
| Returns pixel indices in a given latitude strip. More...
void | he_ring2nest_inplace (flouble *map_in, long nside)
| Transform from RING to NEST. More...
void | he_nest2ring_inplace (flouble *map_in, long nside)
| Transform from NEST to RING. More...
void | he_in_ring (int nside, int iz, flouble phi0, flouble dphi, int *listir, int *nir)
| Returns pixel indices in a given ring. More...
void | he_query_disc (int nside, double cth0, double phi, flouble radius, int *listtot, int *nlist, int inclusive)
| Returns pixel indices in a given disc. More...
void | he_udgrade (flouble *map_in, long nside_in, flouble *map_out, long nside_out, int nest)
| Up/down grade map resolution. More...
double * | he_generate_beam_window (int lmax, double fwhm_amin)
| Gaussian beam. More...
void | he_zero_alm (int lmax, fcomplex *alm)
| Zero SHT coefficients. More...
void | he_alter_alm (int lmax, double fwhm_amin, fcomplex *alm_in, fcomplex *alm_out, double *window, int add_to_out)
| Multiply SHT coefficients by beam. More...
flouble | he_get_pix_area (nmt_curvedsky_info *cs, long i)
| Computes pixel area. More...
void | he_map_product (nmt_curvedsky_info *cs, flouble *mp1, flouble *mp2, flouble *mp_out)
| Multiplies two full-sky maps. More...
flouble | he_map_dot (nmt_curvedsky_info *cs, flouble *mp1, flouble *mp2)
| Dot product of full-sky maps. More...
fcomplex ** | he_synalm (nmt_curvedsky_info *cs, int nmaps, int lmax, flouble **cells, flouble **beam, int seed)
| Gaussian realizations of full-sky harmonic coefficients. More...
int | cov_get_coupling_pair_index (int na, int nc, int nb, int nd, int ia1, int ia2, int ic1, int ic2, int ib1, int ib2, int id1, int id2)

## Macro Definition Documentation

#define HE_NITER_DEFAULT 3

Default number of iterations used for full-sky spherical harmonic transforms.

## Function Documentation

int cov_get_coupling_pair_index | ( | int | na,
|  | int | nc,
|  | int | nb,
|  | int | nd,
|  | int | ia1,
|  | int | ia2,
|  | int | ic1,
|  | int | ic2,
|  | int | ib1,
|  | int | ib2,
|  | int | id1,
|  | int | id2
| ) |  |

void dftw_free | ( | void * | p | ) |

Wrapper around fftw_free

Wrapping function to support simultaneously single and double precision FFTW memory freeing.

Parameters

  p | Pointer to free.

void* dftw_malloc | ( | size_t | n | ) |

Wrapper around fftw_malloc

Wrapping function to support simultaneously single and double precision FFTW memory allocation.

Parameters

  n | Number of bytes to allocate

Returns
  Allocated pointer.

int drc3jj | ( | int | il2,
|  | int | il3,
|  | int | im2,
|  | int | im3,
|  | int * | l1min_out,
|  | int * | l1max_out,
|  | double * | thrcof,
|  | int | size
| ) |  |

Wigner 3-j symbols.

Returns all non-zero wigner-3j symbols

for

Parameters

  il2 | =
  im2 | =
  il3 | =
  im3 | =
  l1min_out | Minimum value of allowed by selection rules (output).
  l1max_out | Maximum value of allowed by selection rules (output).
  thrcof | Output array that will contain the values of the wigner-3j symbols for `l1min_out` `l1max_out`.
  size | Number of elements allocated for thrcof.

Note that the selection rule completely fix .

void end_rng | ( | gsl_rng * | rng | ) |

Destructor for random number generators.

void fs_alm2cl | ( | nmt_flatsky_info * | fs,
|  | nmt_binning_scheme_flat * | bin,
|  | fcomplex ** | alms_1,
|  | fcomplex ** | alms_2,
|  | int | spin_1,
|  | int | spin_2,
|  | flouble ** | cls,
|  | flouble | lmn_x,
|  | flouble | lmx_x,
|  | flouble | lmn_y,
|  | flouble | lmx_y
| ) |  |

Computes Flat-sky power spectrum from Fourier coefficients.

Bins the product of two sets of Fourier coefficients into bandpowers.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  bin | nmt_binning_scheme_flat structure defining the bandpowers to use.
  alms_1 | First set of Fourier coefficients to correlate.
  alms_2 | Second set of Fourier coefficients to correlate.
  spin_1 | alms_1 spin.
  spin_2 | alms_2 spin.
  cls | Will hold the output power spectra. Should have shape [`ncls`][`nbands`], where `ncls` is the appropriate number of power spectra given the spins of the input fields (e.g. `ncls` = 2*2 = 4 if both fields have spin=2) and `nbpw` is the number of bandpowers defined by `bin`.
  lmn_x | Lower end of the range of multipoles in the x direction that should be masked.
  lmx_x | Upper end of the range of multipoles in the x direction that should be masked. if `lmx_x` < `lmn_x`, no Fourier-space masked is performed.
  lmn_y | Same as `lmn_x` for the y direction.
  lmx_y | Same as `lmx_x` for the y direction.

void fs_alm2map | ( | nmt_flatsky_info * | fs,
|  | int | ntrans,
|  | int | spin,
|  | flouble ** | map,
|  | fcomplex ** | alm
| ) |  |

Flat-sky inverse SHT.

Computes the inverse SHT of a set of spin-s flat-sky fields. See scientific documentation and companion paper for further details.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  ntrans | Number of transfoms to carry out.
  spin | Spin of the fields to transform (0 or 2).
  map | Will hold the output maps. Must have shape [`ntrans` * `nmap`][`nx` * `ny`], where `nmap` is 1 or 2 for spin-0 and spin-2 respectively, and (`nx`,`ny`) are the dimensions of the patch in the (x,y) directions as defined by `fs`.
  alm | SHT coefficients to inverse-transform. Must have shape [`ntrans` * `nmap`][`ny` * (`nx` /2+1)], where `nmap`, `nx` and `ny` have been defined above.

void fs_alter_alm | ( | nmt_flatsky_info * | fs,
|  | double | fwhm_amin,
|  | fcomplex * | alm_in,
|  | fcomplex * | alm_out,
|  | nmt_k_function * | window,
|  | int | add_to_out
| ) |  |

Multiply SHT coefficients by beam.

Multiplies a given set of flat-sky Fourier coefficients by a circularly-symmetric function.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  fwhm_amin | Full-width at half-maximum of the Gaussian beam in arcminutes. Only used if `window` is a NULL pointer.
  alm_in | Input Fourier coefficients.
  alm_out | Output Fourier coefficients.
  window | nmt_k_function defining the function to multiply the coefficients by. Pass a NULL pointer if you want a Gaussian beam with a FWHM defined by `fwhm_amin`.
  add_to_out | If >0, the result of multiplying `alm_in` with the window function will be added to the current contents of `alm_out`. Otherwise, `alm_out` is overwritten with the product.

void fs_anafast | ( | nmt_flatsky_info * | fs,
|  | nmt_binning_scheme_flat * | bin,
|  | flouble ** | maps_1,
|  | flouble ** | maps_2,
|  | int | spin_1,
|  | int | spin_2,
|  | flouble ** | cls
| ) |  |

Computes Flat-sky power spectrum from maps.

Similar to fs_alm2cl() but starting from maps.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  bin | nmt_binning_scheme_flat structure defining the bandpowers to use.
  maps_1 | First set of maps to correlate.
  maps_2 | Second set of maps to correlate.
  spin_1 | maps_1 spin.
  spin_2 | maps_2 spin.
  cls | Will hold the output power spectra. Should have shape [`ncls`][`nbands`], where `ncls` is the appropriate number of power spectra given the spins of the input fields (e.g. `ncls` = 2*2 = 4 if both fields have spin=2). and `nbpw` is the number of bandpowers defined by `bin`.

nmt_k_function* fs_generate_beam_window | ( | double | fwhm_amin | ) |

Gaussian beam.

Generates an nmt_k_function structure defining a circularly symmetric Gaussian beam for flat-sky fields.

Parameters

  fwhm_amin | Full-width at half-maximum of the beam in arcminutes.

Returns
  nmt_k_function defining the beam.

void fs_map2alm | ( | nmt_flatsky_info * | fs,
|  | int | ntrans,
|  | int | spin,
|  | flouble ** | map,
|  | fcomplex ** | alm
| ) |  |

Flat-sky SHT.

Computes the direct SHT of a set of spin-s flat-sky fields. See scientific documentation and companion paper for further details.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  ntrans | Number of transfoms to carry out.
  spin | Spin of the fields to transform (0 or 2).
  map | Maps to transform. Must have shape [`ntrans` * `nmap`][`nx` * `ny`], where `nmap` is 1 or 2 for spin-0 and spin-2 respectively, and (`nx`,`ny`) are the dimensions of the patch in the (x,y) directions as defined by `fs`.
  alm | Will hold the output SHT coefficients. Must have shape [`ntrans` * `nmap`][`ny` * (`nx` /2+1)], where `nmap`, `nx` and `ny` have been defined above.

flouble fs_map_dot | ( | nmt_flatsky_info * | fs,
|  | flouble * | mp1,
|  | flouble * | mp2
| ) |  |

Dot product of flat-sky maps.

Computes the integral over the patch of the product of two maps:

where is the flat-sky patch defined by `fs`. The integral is computed as a Riemann sum over all pixels in the map.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  mp1 | First map to multiply.
  mp2 | Second map to multiply.

Returns
  Dot product.

void fs_map_product | ( | nmt_flatsky_info * | fs,
|  | flouble * | mp1,
|  | flouble * | mp2,
|  | flouble * | mp_out
| ) |  |

Multiplies two flat-sky maps.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  mp1 | First map to multiply
  mp2 | Second map to multiply.
  mp_out | Output map containing the product of `mp1` and `mp2`. It is safe to pass either of the input maps as `mp_out`, in which case that map will be overwritten with the product.

void fs_mapcpy | ( | nmt_flatsky_info * | fs,
|  | flouble * | destmap,
|  | flouble * | srcmap
| ) |  |

Copies a map.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  destmap | Map to copy into.
  destmap | Map to copy from.

flouble* fs_read_flat_map | ( | char * | fname,
|  | int * | nx,
|  | int * | ny,
|  | flouble * | lx,
|  | flouble * | ly,
|  | int | nfield
| ) |  |

Reads flat-sky map.

Reads a flat-sky map from a FITS file. The flat map should be in an image HDU with WCS header keywords defining the sky patch (read from file).

Parameters

  fname | Path to input file.
  nx | Number of grid points in the x dimension (read from file).
  ny | Number of grid points in the y dimension (read from file).
  lx | Length of the x dimension (in steradians) (read from file).
  ly | Length of the y dimension (in steradians) (read from file).
  nfield | Which field to read (i.e. HDU number to read the map from, starting from 0).

Returns
  Read map (with size `ny` * `nx`).

fcomplex** fs_synalm | ( | int | nx,
|  | int | ny,
|  | flouble | lx,
|  | flouble | ly,
|  | int | nmaps,
|  | nmt_k_function ** | cells,
|  | nmt_k_function ** | beam,
|  | int | seed
| ) |  |

Gaussian realizations of flat-sky Fourier coefficients.

Generates a Gaussian realization of a set of Fourier coefficients given an input power spectrum.

Parameters

  nx | Number of grid points in the x dimension.
  ny | Number of grid points in the y dimension.
  lx | Length of the x dimension (in steradians).
  ly | Length of the y dimension (in steradians).
  nmaps | Number of fields to generate.
  cells | Set of `nmaps` * (`nmaps` + 1) / 2 nmt_k_function structures defining each of the power spectra needed to generate the Fourier coefficients. It must contain only the the upper-triangular part in row-major order (e.g. if `nmaps` is 3, there will be 6 power spectra ordered as [1-1,1-2,1-3,2-2,2-3,3-3].
  beam | Set of `nmaps` nmt_k_function structures defining the beam of each field.
  seed | Seed for this particular realization.

Returns
  Gaussian realization with shape [`nmaps`][`ny` * (`nx` /2 +1)].

void fs_zero_alm | ( | nmt_flatsky_info * | fs,
|  | fcomplex * | alm
| ) |  |

Zero SHT coefficients.

Sets all elements of a set of flat-sky Fourier coefficients to zero.

Parameters

  fs | nmt_flatsky_info structure describing the flat-sky patch.
  alm | Set of Fourier coefficients to zero. See fs_map2alm() for the expected shape of flat-sky Fourier coefficients.

void he_alm2cl | ( | fcomplex ** | alms_1,
|  | fcomplex ** | alms_2,
|  | int | spin_1,
|  | int | spin_2,
|  | flouble ** | cls,
|  | int | lmax
| ) |  |

Computes Full-sky power spectrum from harmonic coefficients.

Computes the angular power spectrum of two sets of harmonic coefficients

Parameters

  alms_1 | First set of harmonic coefficients to correlate.
  alms_2 | Second set of harmonic coefficients to correlate.
  spin_1 | alms_1 spin.
  spin_2 | alms_2 spin.
  cls | Will hold the output power spectra. Should have shape [`ncls`][`lmax` + 1], where `ncls` is the appropriate number of power spectra given the spins of the input fields (e.g. `ncls` = 2*2 = 4 if both fields have spin=2).
  lmax | maximum multipole order.

void he_alm2map | ( | nmt_curvedsky_info * | cs,
|  | int | lmax,
|  | int | ntrans,
|  | int | spin,
|  | flouble ** | maps,
|  | fcomplex ** | alms
| ) |  |

Full-sky inverse SHT.

Computes the inverse SHT of a set of spin-s full-sky fields. See scientific documentation and companion paper for further details.

Parameters

  cs | curved sky geometry information.
  lmax | maximum multipole order.
  ntrans | Number of transfoms to carry out.
  spin | Spin of the fields to transform (0 or 2).
  maps | Will hold the output maps. Must have shape [`ntrans` * `nmap`][`npix`], where `nmap` is 1 or 2 for spin-0 and spin-2 respectively, and `npix` is the number of pixels associated with `nside`.
  alms | SHT coefficients to inverse-transform. Must have shape [`ntrans` * `nmap`][`nalm`], where `nmap` is defined above and `nalm` can be computed with he_nalm().

void he_alter_alm | ( | int | lmax,
|  | double | fwhm_amin,
|  | fcomplex * | alm_in,
|  | fcomplex * | alm_out,
|  | double * | window,
|  | int | add_to_out
| ) |  |

Multiply SHT coefficients by beam.

Multiplies a given set of harmonic coefficients by a circularly-symmetric function.

Parameters

  lmax | Maximum multipole order.
  fwhm_amin | Full-width at half-maximum of the Gaussian beam in arcminutes. Only used if `window` is a NULL pointer.
  alm_in | Input harmonic coefficients.
  alm_out | Output harmonic coefficients.
  window | Array of size `lmax` + 1 containing the function to multiply by. Pass a NULL pointer if you want a Gaussian beam with a FWHM defined by `fwhm_amin`.
  add_to_out | If >0, the result of multiplying `alm_in` with the window function will be added to the current contents of `alm_out`. Otherwise, `alm_out` is overwritten with the product.

void he_anafast | ( | flouble ** | maps_1,
|  | flouble ** | maps_2,
|  | int | spin_1,
|  | int | spin_2,
|  | flouble ** | cls,
|  | nmt_curvedsky_info * | cs,
|  | int | lmax,
|  | int | iter
| ) |  |

Computes Full-sky power spectrum from maps.

Computes the angular power spectrum of two sets of maps.

Parameters

  maps_1 | First set of maps to correlate.
  maps_2 | Second set of maps to correlate.
  spin_1 | maps_1 spin.
  spin_2 | maps_2 spin.
  cls | Will hold the output power spectra. Should have shape [`ncls`][`lmax` + 1], where `ncls` is the appropriate number of power spectra given the spins of the input fields (e.g. `ncls` = 2*2 = 4 if both fields have spin=2).
  cs | curved sky geometry information.
  lmax | maximum multipole order.
  iter | Number of iterations to use when computing the spherical harmonic transforms.

long he_ang2pix | ( | long | nside,
|  | double | cth,
|  | double | phi
| ) |  |

Modified HEALPix ang2pix.

Returns pixel containing a given point in the sphere.

Parameters

  nside | HEALPix resolution parameter
  phi | Azimuth spherical coordinate (in radians).
  cth | Cosine of inclination spherical coordinate .

Returns
  Pixel index.

double* he_generate_beam_window | ( | int | lmax,
|  | double | fwhm_amin
| ) |  |

Gaussian beam.

Generates an array defining the harmonic coefficients of a Gaussian beam.

Parameters

  lmax | Maximum multipole order.
  fwhm_amin | FWHM of the beam in arcminutes.

Returns
  List of harmonic coefficients from 0 to lmax (inclusive).

nmt_curvedsky_info* he_get_file_params | ( | char * | fname,
|  | int | is_healpix,
|  | int * | nfields,
|  | int * | isnest
| ) |  |

Read map parameters from FITS file.

Parameters

  fname | Path to input FITS file.
  is_healpix | Whether pixelization should be HEALPix.
  nfields | number of fields in file.
  isnest | >0 if maps are in NESTED ordering.

Returns
  curved sky geometry information.

int he_get_largest_possible_lmax | ( | nmt_curvedsky_info * | cs | ) |

Gets the multipole approximately corresponding to the Nyquist frequency.

Computes the maximum multipole probed by a map.

Parameters

  cs | curved sky geometry info.

Returns
  maximum multipole.

int he_get_lmax | ( | nmt_curvedsky_info * | cs | ) |

Get maximum multipole allowed by sky geometry configuration.

Returns the maximum multipole for a nmt_curvedsky_info.

Parameters

  cs | curved sky geometry info.

Returns
  maximum multipole.

flouble he_get_pix_area | ( | nmt_curvedsky_info * | cs,
|  | long | i
| ) |  |

Computes pixel area.

Parameters

  cs | curved sky geometry info.
  i | ring number.

Returns
  pixel area in sterad.

void he_in_ring | ( | int | nside,
|  | int | iz,
|  | flouble | phi0,
|  | flouble | dphi,
|  | int * | listir,
|  | int * | nir
| ) |  |

Returns pixel indices in a given ring.

Parameters

  nside | HEALPix resolution parameter
  iz | Ring index.
  phi0 | Center of azimuth range.
  dphi | Width of azimuth range.
  listir | Output list of pixels
  nir | On input, it should hold the number of elements allocated in `listir`. On output, it contains the number of pixels in the ring.

long he_indexlm | ( | int | l,
|  | int | m,
|  | int | lmax
| ) |  |

Harmonic coefficient ordering.

Returns the position of a given harmonic coefficient.

Parameters

  l | index
  m | index
  lmax | maximum multipole order.

Returns
  Index holding the value of .

void he_map2alm | ( | nmt_curvedsky_info * | cs,
|  | int | lmax,
|  | int | ntrans,
|  | int | spin,
|  | flouble ** | maps,
|  | fcomplex ** | alms,
|  | int | niter
| ) |  |

Full-sky SHT.

Computes the direct SHT of a set of spin-s full-sky fields. See scientific documentation and companion paper for further details.

Parameters

  cs | curved sky geometry information.
  lmax | maximum multipole order.
  ntrans | Number of transfoms to carry out.
  spin | Spin of the fields to transform (0 or 2).
  maps | Maps to transform. Must have shape [`ntrans` * `nmap`][`npix`], where `nmap` is 1 or 2 for spin-0 and spin-2 respectively, and `npix` is the number of pixels associated with `nside`.
  alms | Will hold the output SHT coefficients. Must have shape [`ntrans` * `nmap`][`nalm`], where `nmap` is defined above and `nalm` can be computed with he_nalm().
  niter | Number of iterations to use when computing the spherical harmonic transforms.

flouble he_map_dot | ( | nmt_curvedsky_info * | cs,
|  | flouble * | mp1,
|  | flouble * | mp2
| ) |  |

Dot product of full-sky maps.

Computes the integral over the full sphere of the product of two maps:

The integral is computed as a Riemann sum over all pixels in the map.

Parameters

  cs | curved sky geometry information.
  mp1 | First map to multiply.
  mp2 | Second map to multiply.

Returns
  Dot product.

void he_map_product | ( | nmt_curvedsky_info * | cs,
|  | flouble * | mp1,
|  | flouble * | mp2,
|  | flouble * | mp_out
| ) |  |

Multiplies two full-sky maps.

Parameters

  cs | curved sky geometry information.
  mp1 | First map to multiply
  mp2 | Second map to multiply.
  mp_out | Output map containing the product of `mp1` and `mp2`. It is safe to pass either of the input maps as `mp_out`, in which case that map will be overwritten with the product.

long he_nalms | ( | int | lmax | ) |

Number of alm coefficients.

Returns number of harmonic coefficients up to a given multipole order.

Parameters

  lmax | Maximum multipole order.

Returns
  Number of harmonic coefficients.

void he_nest2ring_inplace | ( | flouble * | map_in,
|  | long | nside
| ) |  |

Transform from NEST to RING.

Transforms a HEALPix map from NEST to RING ordering in place.

Parameters

  map_in | Map to transform.
  nside | HEALPix resolution parameter

long he_nside2npix | ( | long | nside | ) |

HEALPix number of pixels.

Parameters

  nside | HEALPix resolution parameter

Returns
  12 * `nside` * `nside`.

void he_pix2vec_ring | ( | long | nside,
|  | long | ipix,
|  | double * | vec
| ) |  |

HEALPix pix2vec.

Returns normal vector pointing in the direction of a given pixel.

Parameters

  nside | HEALPix resolution parameter.
  ipix | Pixel index in RING ordering.
  vec | Output vector.

void he_query_disc | ( | int | nside,
|  | double | cth0,
|  | double | phi,
|  | flouble | radius,
|  | int * | listtot,
|  | int * | nlist,
|  | int | inclusive
| ) |  |

Returns pixel indices in a given disc.

Parameters

  nside | HEALPix resolution parameter
  cth0 | for the disc centre.
  phi | Azimuth for the disc centre.
  radius | Disc radius in radians.
  listtot | Output list of pixels
  nlist | On input, it should hold the number of elements allocated in `listtot`. On output, it contains the number of pixels in the disc.
  inclusive | If >0, include all pixels that are partially insie the disc. Otherwise include only pixels whose centres are inside the disc.

void he_query_strip | ( | long | nside,
|  | double | theta1,
|  | double | theta2,
|  | int * | pixlist,
|  | long * | npix_strip
| ) |  |

Returns pixel indices in a given latitude strip.

Parameters

  nside | HEALPix resolution parameter
  theta1 | Lower edge of latitude range.
  theta2 | Upper edge of latitude range.
  pixlist | Output list of pixels
  npix_strip | On input, it should hold the number of elements allocated in `pixlist`. On output, it contains the number of pixels in the strip.

flouble* he_read_map | ( | char * | fname,
|  | nmt_curvedsky_info * | sky_info,
|  | int | nfield
| ) |  |

Reads full-sky map from FITS file.

Parameters

  fname | Path to input FITS file.
  sky_info | curved sky geometry information.
  nfield | Which field to read (i.e. HDU number to read the map from, starting from 0).

Returns
  Read map.

void he_ring2nest_inplace | ( | flouble * | map_in,
|  | long | nside
| ) |  |

Transform from RING to NEST.

Transforms a HEALPix map from RING to NEST ordering in place.

Parameters

  map_in | Map to transform.
  nside | HEALPix resolution parameter

int he_ring_num | ( | long | nside,
|  | double | z
| ) |  |

HEALPix ring number.

Parameters

  nside | HEALPix resolution parameter.
  z | z (cos(theta)) coordinate.

Returns
  ring number

fcomplex** he_synalm | ( | nmt_curvedsky_info * | cs,
|  | int | nmaps,
|  | int | lmax,
|  | flouble ** | cells,
|  | flouble ** | beam,
|  | int | seed
| ) |  |

Gaussian realizations of full-sky harmonic coefficients.

Generates a Gaussian realization of a set of harmonic coefficients given an input power spectrum.

Parameters

  cs | curved sky geometry information.
  nmaps | Number of fields to generate.
  lmax | Maximum multipole order
  cells | Set of `nmaps` * (`nmaps` + 1) / 2 arrays of length `lmax` + 1 defining each of the power spectra needed to generate the Fourier coefficients. It must contain only the the upper-triangular part in row-major order (e.g. if `nmaps` is 3, there will be 6 power spectra ordered as [1-1,1-2,1-3,2-2,2-3,3-3].
  beam | Set of `nmaps` arrays of length `lmax` + 1 defining the beam of each field.
  seed | Seed for this particular realization.

Returns
  Gaussian realization with shape [`nmaps`][`nalm`], where `nalm` can be computed with he_nalms().

void he_udgrade | ( | flouble * | map_in,
|  | long | nside_in,
|  | flouble * | map_out,
|  | long | nside_out,
|  | int | nest
| ) |  |

Up/down grade map resolution.

Parameters

  map_in | Input map.
  nside_in | Input HEALPix resolution parameter.
  map_out | Output map.
  nside_out | Output HEALPix resolution parameter.
  nest | If >0, intput and output maps are in NESTED ordering.

void he_write_CAR_map | ( | flouble ** | tmap,
|  | int | nfields,
|  | nmt_curvedsky_info * | sky_info,
|  | char * | fname
| ) |  |

Writes CAR maps to FITS file.

Parameters

  tmap | Array of maps to write.
  nfields | Number of maps to write.
  sky_info | curved sky geometry information
  fname | Path to output FITS file.

void he_write_healpix_map | ( | flouble ** | tmap,
|  | int | nfields,
|  | long | nside,
|  | char * | fname
| ) |  |

Writes full-sky maps to FITS file.

Parameters

  tmap | Array of maps to write.
  nfields | Number of maps to write.
  nside | HEALPix resolution parameter.
  fname | Path to output FITS file.

void he_zero_alm | ( | int | lmax,
|  | fcomplex * | alm
| ) |  |

Zero SHT coefficients.

Sets all elements of a set of harmonic coefficients to zero.

Parameters

  lmax | Maximum multipole order
  alm | Coefficients to zero. Must have a length given by he_nalms().

gsl_rng* init_rng | ( | unsigned int | seed | ) |

Initialize a random number generator.

Parameters

  seed | Seed.

Returns
  A GSL random number generator object.

void moore_penrose_pinv | ( | gsl_matrix * | M,
|  | double | threshold
| ) |  |

Moore-Penrose pseudo-inverse.

Returns the Moore-Penrose pseudo-inverse.

Parameters

  M | Input matrix to invert. Will be overwritten with inverse.
  threshold | When inverting, all eigenvalues smaller than `threshold` times the largest eigenvalue will be discarded (i.e. the corresponding eigenvalue of the pseudo-inverse will be set to zero).

void* my_calloc | ( | size_t | nmemb,
|  | size_t | size
| ) |  |

Error-checked calloc.

Parameters

  nmemb | Number of elements in pointer to initialize.
  size | Size in bytes of each element in pointer to initialize.

Returns
  Allocated pointer.

FILE* my_fopen | ( | const char * | path,
|  | const char * | mode
| ) |  |

Error-checked fopen.

Parameters

  path | Path to file.
  mode | Opening mode ("w", "r" etc.).

Returns
  Opened file.

size_t my_fread | ( | void * | ptr,
|  | size_t | size,
|  | size_t | count,
|  | FILE * | stream
| ) |  |

Error-checked fread.

Parameters

  ptr | Pointer to data to input data.
  size | Size of each element of input data in bytes.
  count | Number of elements in input data.
  stream | Open file to read from.

Returns
  `count`.

size_t my_fwrite | ( | const void * | ptr,
|  | size_t | size,
|  | size_t | nmemb,
|  | FILE * | stream
| ) |  |

Error-checked fwrite.

Parameters

  ptr | Pointer to data to output data.
  size | Size of each element of output data in bytes.
  nmemb | Number of elements in output data.
  stream | Open file to write into.

Returns
  `nmbemb`.

int my_linecount | ( | FILE * | f | ) |

Count number of lines in an ASCII file.

Parameters

  f | An open file.

Returns
  Number of lines in file.

void* my_malloc | ( | size_t | size | ) |

Error-checked malloc.

Parameters

  size | Size in bytes of pointer to initialize.

Returns
  Allocated pointer.

double rng_01 | ( | gsl_rng * | rng | ) |

Top-hat random numbers.

Draw a random number from 0 to 1 with a top-hat distribution.

Parameters

  rng | A random number generator.

Returns
  Random number.

void rng_delta_gauss | ( | double * | module,
|  | double * | phase,
|  | gsl_rng * | rng,
|  | double | sigma2
| ) |  |

Gaussian random numbers (mod-phase).

Draw modulus and phase of a complex Gaussian random numbers with variance `sigma`.

Parameters

  module | Output random modulus.
  phase | Output random phase.
  rng | A random number generator.
  sigma2 | Input variance.

Warning
  From `module` and `phase` you could build a complex number with real and imaginary parts `re` and `im`. The input `sigma2` parameter is the mean modulus squared, i.e. `sigma2` = < `re^2` + `im^2` >. Therefore the variance of either `re` or `im` on their own is `sigma2` / 2.

void rng_gauss | ( | gsl_rng * | rng,
|  | double * | r1,
|  | double * | r2
| ) |  |

Gaussian random numbers.

Draw a pair of Gaussian random numbers with zero mean and unit variance.

Parameters

  rng | A random number generator.
  r1 | First output random number.
  r2 | Second output random number.

int rng_poisson | ( | double | lambda,
|  | gsl_rng * | rng
| ) |  |

Poisson random numbers.

Draw a random integer from a Poisson distribution with mean and variance given by `lambda`.

Parameters

  lambda | Mean and variance of the distribution.
  rng | A random number generator.

Returns
  Random integer.