File size: 26,894 Bytes
bc65052 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 |
Function: _check_task_dependency(self, level) Docstring: Fill the level list with all the needed modules .. warning:: the ordering of modules is obviously dependent on CLASS module order in the main.c file. This has to be updated in case of a change to this file. Parameters ---------- level : list list of strings, containing initially only the last module required. For instance, to recover all the modules, the input should be ['lensing'] --------------------------------- Function: compute(self, level=["distortions"]) Docstring: compute(level=["distortions"]) Main function, execute all the _init methods for all desired modules. This is called in MontePython, and this ensures that the Class instance of this class contains all the relevant quantities. Then, one can deduce Pk, Cl, etc... Parameters ---------- level : list list of the last module desired. The internal function _check_task_dependency will then add to this list all the necessary modules to compute in order to initialize this last one. The default last module is "lensing". .. warning:: level default value should be left as an array (it was creating problem when casting as a set later on, in _check_task_dependency) --------------------------------- Function: density_factor(self) Docstring: The density factor required to convert from the class-units of density to kg/m^3 (SI units) --------------------------------- Function: kgm3_to_eVMpc3(self) Docstring: Convert from kg/m^3 to eV/Mpc^3 --------------------------------- Function: kgm3_to_MsolMpc3(self) Docstring: Convert from kg/m^3 to Msol/Mpc^3 --------------------------------- Function: raw_cl(self, lmax=-1, nofail=False) Docstring: raw_cl(lmax=-1, nofail=False) Return a dictionary of the primary C_l Parameters ---------- lmax : int, optional Define the maximum l for which the C_l will be returned (inclusively). This number will be checked against the maximum l at which they were actually computed by CLASS, and an error will be raised if the desired lmax is bigger than what CLASS can give. nofail: bool, optional Check and enforce the computation of the harmonic module beforehand, with the desired lmax. Returns ------- cl : dict Dictionary that contains the power spectrum for 'tt', 'te', etc... The index associated with each is defined wrt. Class convention, and are non important from the python point of view. It also returns now the ell array. --------------------------------- Function: lensed_cl(self, lmax=-1,nofail=False) Docstring: lensed_cl(lmax=-1, nofail=False) Return a dictionary of the lensed C_l, computed by CLASS, without the density C_ls. They must be asked separately with the function aptly named density_cl Parameters ---------- lmax : int, optional Define the maximum l for which the C_l will be returned (inclusively) nofail: bool, optional Check and enforce the computation of the lensing module beforehand Returns ------- cl : dict Dictionary that contains the power spectrum for 'tt', 'te', etc... The index associated with each is defined wrt. Class convention, and are non important from the python point of view. --------------------------------- Function: density_cl(self, lmax=-1, nofail=False) Docstring: density_cl(lmax=-1, nofail=False) Return a dictionary of the primary C_l for the matter Parameters ---------- lmax : int, optional Define the maximum l for which the C_l will be returned (inclusively) nofail: bool, optional Check and enforce the computation of the lensing module beforehand Returns ------- cl : numpy array of numpy.ndarrays Array that contains the list (in this order) of self correlation of 1st bin, then successive correlations (set by non_diagonal) to the following bins, then self correlation of 2nd bin, etc. The array starts at index_ct_dd. --------------------------------- Function: luminosity_distance(self, z) Docstring: luminosity_distance(z) --------------------------------- Function: pk(self,double k,double z) Docstring: Gives the total matter pk (in Mpc**3) for a given k (in 1/Mpc) and z (will be non linear if requested to Class, linear otherwise) .. note:: there is an additional check that output contains `mPk`, because otherwise a segfault will occur --------------------------------- Function: pk_cb(self,double k,double z) Docstring: Gives the cdm+b pk (in Mpc**3) for a given k (in 1/Mpc) and z (will be non linear if requested to Class, linear otherwise) .. note:: there is an additional check that output contains `mPk`, because otherwise a segfault will occur --------------------------------- Function: pk_lin(self,double k,double z) Docstring: Gives the linear total matter pk (in Mpc**3) for a given k (in 1/Mpc) and z .. note:: there is an additional check that output contains `mPk`, because otherwise a segfault will occur --------------------------------- Function: pk_cb_lin(self,double k,double z) Docstring: Gives the linear cdm+b pk (in Mpc**3) for a given k (in 1/Mpc) and z .. note:: there is an additional check that output contains `mPk`, because otherwise a segfault will occur --------------------------------- Function: pk_numerical_nw(self,double k,double z) Docstring: Gives the nowiggle (smoothed) linear total matter pk (in Mpc**3) for a given k (in 1/Mpc) and z .. note:: there is an additional check that `numerical_nowiggle` was set to `yes`, because otherwise a segfault will occur --------------------------------- Function: pk_analytic_nw(self,double k) Docstring: Gives the linear total matter pk (in Mpc**3) for a given k (in 1/Mpc) and z .. note:: there is an additional check that `analytic_nowiggle` was set to `yes`, because otherwise a segfault will occur --------------------------------- Function: get_pk(self, np.ndarray[DTYPE_t,ndim=3] k, np.ndarray[DTYPE_t,ndim=1] z, int k_size, int z_size, int mu_size) Docstring: Fast function to get the power spectrum on a k and z array --------------------------------- Function: get_pk_cb(self, np.ndarray[DTYPE_t,ndim=3] k, np.ndarray[DTYPE_t,ndim=1] z, int k_size, int z_size, int mu_size) Docstring: Fast function to get the power spectrum on a k and z array --------------------------------- Function: get_pk_lin(self, np.ndarray[DTYPE_t,ndim=3] k, np.ndarray[DTYPE_t,ndim=1] z, int k_size, int z_size, int mu_size) Docstring: Fast function to get the linear power spectrum on a k and z array --------------------------------- Function: get_pk_cb_lin(self, np.ndarray[DTYPE_t,ndim=3] k, np.ndarray[DTYPE_t,ndim=1] z, int k_size, int z_size, int mu_size) Docstring: Fast function to get the linear power spectrum on a k and z array --------------------------------- Function: get_pk_all(self, k, z, nonlinear = True, cdmbar = False, z_axis_in_k_arr = 0, interpolation_kind='cubic') Docstring: General function to get the P(k,z) for ARBITRARY shapes of k,z Additionally, it includes the functionality of selecting wether to use the non-linear parts or not, and wether to use the cdm baryon power spectrum only For Multi-Dimensional k-arrays, it assumes that one of the dimensions is the z-axis This is handled by the z_axis_in_k_arr integer, as described in the source code --------------------------------- Function: get_pk_and_k_and_z(self, nonlinear=True, only_clustering_species = False, h_units=False) Docstring: Returns a grid of matter power spectrum values and the z and k at which it has been fully computed. Useful for creating interpolators. Parameters ---------- nonlinear : bool Whether the returned power spectrum values are linear or non-linear (default) only_clustering_species : bool Whether the returned power spectrum is for galaxy clustering and excludes massive neutrinos, or always includes everything (default) h_units : bool Whether the units of k in output are h/Mpc or 1/Mpc (default) Returns ------- pk : grid of power spectrum values, pk[index_k,index_z] k : vector of k values, k[index_k] (in units of 1/Mpc by default, or h/Mpc when setting h_units to True) z : vector of z values, z[index_z] --------------------------------- Function: get_transfer_and_k_and_z(self, output_format='class', h_units=False) Docstring: Returns a dictionary of grids of density and/or velocity transfer function values and the z and k at which it has been fully computed. Useful for creating interpolators. When setting CLASS input parameters, include at least one of 'dTk' (for density transfer functions) or 'vTk' (for velocity transfer functions). Following the default output_format='class', all transfer functions will be normalised to 'curvature R=1' at initial time (and not 'curvature R = -1/k^2' like in CAMB). You may switch to output_format='camb' for the CAMB definition and normalisation of transfer functions. (Then, 'dTk' must be in the input: the CAMB format only outputs density transfer functions). When sticking to output_format='class', you also get the newtonian metric fluctuations phi and psi. If you set the CLASS input parameter 'extra_metric_transfer_functions' to 'yes', you get additional metric fluctuations in the synchronous and N-body gauges. Parameters ---------- output_format : ('class' or 'camb') Format transfer functions according to CLASS (default) or CAMB h_units : bool Whether the units of k in output are h/Mpc or 1/Mpc (default) Returns ------- tk : dictionary containing all transfer functions. For instance, the grid of values of 'd_c' (= delta_cdm) is available in tk['d_c'] All these grids have indices [index_k,index,z], for instance tk['d_c'][index_k,index,z] k : vector of k values (in units of 1/Mpc by default, or h/Mpc when setting h_units to True) z : vector of z values --------------------------------- Function: get_Weyl_pk_and_k_and_z(self, nonlinear=False, h_units=False) Docstring: Returns a grid of Weyl potential (phi+psi) power spectrum values and the z and k at which it has been fully computed. Useful for creating interpolators. Note that this function just calls get_pk_and_k_and_z and corrects the output by the ratio of transfer functions [(phi+psi)/d_m]^2. Parameters ---------- nonlinear : bool Whether the returned power spectrum values are linear or non-linear (default) h_units : bool Whether the units of k in output are h/Mpc or 1/Mpc (default) Returns ------- Weyl_pk : grid of Weyl potential (phi+psi) spectrum values, Weyl_pk[index_k,index_z] k : vector of k values, k[index_k] (in units of 1/Mpc by default, or h/Mpc when setting h_units to True) z : vector of z values, z[index_z] --------------------------------- Function: sigma(self,R,z, h_units = False) Docstring: Gives sigma (total matter) for a given R and z (R is the radius in units of Mpc, so if R=8/h this will be the usual sigma8(z). This is unless h_units is set to true, in which case R is the radius in units of Mpc/h, and R=8 corresponds to sigma8(z)) .. note:: there is an additional check to verify whether output contains `mPk`, and whether k_max > ... because otherwise a segfault will occur --------------------------------- Function: sigma_cb(self,double R,double z, h_units = False) Docstring: Gives sigma (cdm+b) for a given R and z (R is the radius in units of Mpc, so if R=8/h this will be the usual sigma8(z) This is unless h_units is set to true, in which case R is the radius in units of Mpc/h, and R=8 corresponds to sigma8(z)) .. note:: there is an additional check to verify whether output contains `mPk`, and whether k_max > ... because otherwise a segfault will occur --------------------------------- Function: pk_tilt(self,double k,double z) Docstring: Gives effective logarithmic slope of P_L(k,z) (total matter) for a given k and z (k is the wavenumber in units of 1/Mpc, z is the redshift, the output is dimensionless) .. note:: there is an additional check to verify whether output contains `mPk` and whether k is in the right range --------------------------------- Function: angular_distance(self, z) Docstring: angular_distance(z) Return the angular diameter distance (exactly, the quantity defined by Class as index_bg_ang_distance in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: angular_distance_from_to(self, z1, z2) Docstring: angular_distance_from_to(z) Return the angular diameter distance of object at z2 as seen by observer at z1, that is, sin_K((chi2-chi1)*np.sqrt(|k|))/np.sqrt(|k|)/(1+z2). If z1>z2 returns zero. Parameters ---------- z1 : float Observer redshift z2 : float Source redshift Returns ------- d_A(z1,z2) in Mpc --------------------------------- Function: comoving_distance(self, z) Docstring: comoving_distance(z) Return the comoving distance Parameters ---------- z : float Desired redshift --------------------------------- Function: scale_independent_growth_factor(self, z) Docstring: scale_independent_growth_factor(z) Return the scale invariant growth factor D(a) for CDM perturbations (exactly, the quantity defined by Class as index_bg_D in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: scale_independent_growth_factor_f(self, z) Docstring: scale_independent_growth_factor_f(z) Return the scale independent growth factor f(z)=d ln D / d ln a for CDM perturbations (exactly, the quantity defined by Class as index_bg_f in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: scale_dependent_growth_factor_f(self, k, z, h_units=False, nonlinear=False, Nz=20) Docstring: scale_dependent_growth_factor_f(k,z) Return the scale dependent growth factor f(z)= 1/2 * [d ln P(k,a) / d ln a] = - 0.5 * (1+z) * [d ln P(k,z) / d z] where P(k,z) is the total matter power spectrum Parameters ---------- z : float Desired redshift k : float Desired wavenumber in 1/Mpc (if h_units=False) or h/Mpc (if h_units=True) --------------------------------- Function: scale_dependent_growth_factor_f_cb(self, k, z, h_units=False, nonlinear=False, Nz=20) Docstring: scale_dependent_growth_factor_f_cb(k,z) Return the scale dependent growth factor calculated from CDM+baryon power spectrum P_cb(k,z) f(z)= 1/2 * [d ln P_cb(k,a) / d ln a] = - 0.5 * (1+z) * [d ln P_cb(k,z) / d z] Parameters ---------- z : float Desired redshift k : float Desired wavenumber in 1/Mpc (if h_units=False) or h/Mpc (if h_units=True) --------------------------------- Function: scale_independent_f_sigma8(self, z) Docstring: scale_independent_f_sigma8(z) Return the scale independent growth factor f(z) multiplied by sigma8(z) Parameters ---------- z : float Desired redshift Returns ------- f(z)*sigma8(z) (dimensionless) --------------------------------- Function: effective_f_sigma8(self, z, z_step=0.1) Docstring: effective_f_sigma8(z) Returns the time derivative of sigma8(z) computed as (d sigma8/d ln a) Parameters ---------- z : float Desired redshift z_step : float Default step used for the numerical two-sided derivative. For z < z_step the step is reduced progressively down to z_step/10 while sticking to a double-sided derivative. For z< z_step/10 a single-sided derivative is used instead. Returns ------- (d ln sigma8/d ln a)(z) (dimensionless) --------------------------------- Function: effective_f_sigma8_spline(self, z, Nz=20) Docstring: effective_f_sigma8_spline(z) Returns the time derivative of sigma8(z) computed as (d sigma8/d ln a) Parameters ---------- z : float Desired redshift Nz : integer Number of values used to spline sigma8(z) in the range [z-0.1,z+0.1] Returns ------- (d ln sigma8/d ln a)(z) (dimensionless) --------------------------------- Function: z_of_tau(self, tau) Docstring: Redshift corresponding to a given conformal time. Parameters ---------- tau : float Conformal time --------------------------------- Function: Hubble(self, z) Docstring: Hubble(z) Return the Hubble rate (exactly, the quantity defined by Class as index_bg_H in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: Om_m(self, z) Docstring: Omega_m(z) Return the matter density fraction (exactly, the quantity defined by Class as index_bg_Omega_m in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: Om_b(self, z) Docstring: Omega_b(z) Return the baryon density fraction (exactly, the ratio of quantities defined by Class as index_bg_rho_b and index_bg_rho_crit in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: Om_cdm(self, z) Docstring: Omega_cdm(z) Return the cdm density fraction (exactly, the ratio of quantities defined by Class as index_bg_rho_cdm and index_bg_rho_crit in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: Om_ncdm(self, z) Docstring: Omega_ncdm(z) Return the ncdm density fraction (exactly, the ratio of quantities defined by Class as Sum_m [ index_bg_rho_ncdm1 + n ], with n=0...N_ncdm-1, and index_bg_rho_crit in the background module) Parameters ---------- z : float Desired redshift --------------------------------- Function: ionization_fraction(self, z) Docstring: ionization_fraction(z) Return the ionization fraction for a given redshift z Parameters ---------- z : float Desired redshift --------------------------------- Function: baryon_temperature(self, z) Docstring: baryon_temperature(z) Give the baryon temperature for a given redshift z Parameters ---------- z : float Desired redshift --------------------------------- Function: T_cmb(self) Docstring: Return the CMB temperature --------------------------------- Function: Omega0_m(self) Docstring: Return the sum of Omega0 for all non-relativistic components --------------------------------- Function: get_background(self) Docstring: Return an array of the background quantities at all times. Parameters ---------- Returns ------- background : dictionary containing background. --------------------------------- Function: get_thermodynamics(self) Docstring: Return the thermodynamics quantities. Returns ------- thermodynamics : dictionary containing thermodynamics. --------------------------------- Function: get_primordial(self) Docstring: Return the primordial scalar and/or tensor spectrum depending on 'modes'. 'output' must be set to something, e.g. 'tCl'. Returns ------- primordial : dictionary containing k-vector and primordial scalar and tensor P(k). --------------------------------- Function: get_perturbations(self, return_copy=True) Docstring: Return scalar, vector and/or tensor perturbations as arrays for requested k-values. .. note:: you need to specify both 'k_output_values', and have some perturbations computed, for instance by setting 'output' to 'tCl'. Do not enable 'return_copy=False' unless you know exactly what you are doing. This will mean that you get access to the direct C pointers inside CLASS. That also means that if class is deallocated, your perturbations array will become invalid. Beware! Returns ------- perturbations : dict of array of dicts perturbations['scalar'] is an array of length 'k_output_values' of dictionary containing scalar perturbations. Similar for perturbations['vector'] and perturbations['tensor']. --------------------------------- Function: get_transfer(self, z=0., output_format='class') Docstring: Return the density and/or velocity transfer functions for all initial conditions today. You must include 'mTk' and/or 'vCTk' in the list of 'output'. The transfer functions can also be computed at higher redshift z provided that 'z_pk' has been set and that 0<z<z_pk. Parameters ---------- z : redshift (default = 0) output_format : ('class' or 'camb') Format transfer functions according to CLASS convention (default) or CAMB convention. Returns ------- tk : dictionary containing transfer functions. --------------------------------- Function: get_current_derived_parameters(self, names) Docstring: get_current_derived_parameters(names) Return a dictionary containing an entry for all the names defined in the input list. Parameters ---------- names : list Derived parameters that can be asked from Monte Python, or elsewhere. Returns ------- derived : dict .. warning:: This method used to take as an argument directly the data class from Monte Python. To maintain compatibility with this old feature, a check is performed to verify that names is indeed a list. If not, it returns a TypeError. The old version of this function, when asked with the new argument, will raise an AttributeError. --------------------------------- Function: nonlinear_scale(self, np.ndarray[DTYPE_t,ndim=1] z, int z_size) Docstring: nonlinear_scale(z, z_size) Return the nonlinear scale for all the redshift specified in z, of size z_size Parameters ---------- z : numpy array Array of requested redshifts z_size : int Size of the redshift array --------------------------------- Function: nonlinear_scale_cb(self, np.ndarray[DTYPE_t,ndim=1] z, int z_size) Docstring: make nonlinear_scale_cb(z, z_size) Return the nonlinear scale for all the redshift specified in z, of size z_size Parameters ---------- z : numpy array Array of requested redshifts z_size : int Size of the redshift array --------------------------------- Function: __call__(self, ctx) Docstring: Function to interface with CosmoHammer Parameters ---------- ctx : context Contains several dictionaries storing data and cosmological information --------------------------------- Function: get_pk_array(self, np.ndarray[DTYPE_t,ndim=1] k, np.ndarray[DTYPE_t,ndim=1] z, int k_size, int z_size, nonlinear) Docstring: Fast function to get the power spectrum on a k and z array --------------------------------- Function: get_pk_cb_array(self, np.ndarray[DTYPE_t,ndim=1] k, np.ndarray[DTYPE_t,ndim=1] z, int k_size, int z_size, nonlinear) Docstring: Fast function to get the power spectrum on a k and z array --------------------------------- Function: Omega0_k(self) Docstring: Curvature contribution --------------------------------- Function: get_sources(self) Docstring: Return the source functions for all k, tau in the grid. Returns ------- sources : dictionary containing source functions. k_array : numpy array containing k values. tau_array: numpy array containing tau values. --------------------------------- |