lyapower.CLASS¶
Linear power spectra and transfer functions (CLASS / cosmoprimo).
lyapower.CLASS ¶
Linear power spectra and transfer functions from CLASS / cosmoprimo.
Wraps the Boltzmann code CLASS (via classy) in :class:MyClass to compute
and write linear matter power spectra P(k) and transfer functions T_i(k)
in the CLASS or CAMB conventions (as needed by MP-Gadget / MP-Genic / 2LPT /
CosmicIC initial-condition codes), with helpers for grid scans and massive
neutrinos. :class:CosmoprimoInterface provides the same linear P(k) (and
its no-wiggle version) through the cosmoprimo façade.
Convention: wavenumber k in h/Mpc, power spectrum in (h^-1 Mpc)^3.
@author: cravoux
MyClass ¶
Bases: object
A configured CLASS model producing power spectra and transfer functions.
Source code in lyapower/CLASS.py
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 | |
define_output_format ¶
define_output_format()
Set self.output_format from the settings (default "class").
Source code in lyapower/CLASS.py
76 77 78 79 80 81 | |
write_pk_tk ¶
write_pk_tk(z, name, kmin=-4, kmax=3, nb_points=2000, output=True, verbose=True)
return Power Spectra with k in h.Mpc-1 and P in h3.Mpc-3 in the convention of CAMB and CLASS (the one needed for MP-Gadget). return Transfer function in the convention of CLASS (needed for MP-Genic) or CAMB (needed for 2LPT) !!! note : . CLASS format for MP-GENIC, CAMB format for 2LPT, CAMB format for COSMICIC . for 2LPT & COSMICIC: no header! k vector need to be equidistant in log-k space and length of pk must be the same than tk
Source code in lyapower/CLASS.py
83 84 85 86 87 88 89 90 91 92 93 94 | |
write_pk_tk_grid_variation ¶
write_pk_tk_grid_variation(z, name, varying_dictionary, derived_params=None, kmin=-4, kmax=3, nb_points=2000, output=True)
return Power Spectra with k in h.Mpc-1 and P in h3.Mpc-3 in the convention of CAMB and CLASS (the one needed for MP-Gadget). return Transfer function in the convention of CLASS (needed for MP-Genic) or CAMB (needed for 2LPT) !!! note : . CLASS format for MP-GENIC, CAMB format for 2LPT, CAMB format for COSMICIC . for 2LPT & COSMICIC: no header! k vector need to be equidistant in log-k space and length of pk must be the same than tk
Source code in lyapower/CLASS.py
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 | |
write_pk_tk_neutrino_mass ¶
write_pk_tk_neutrino_mass(z, name, kmin=-4, kmax=3, nb_points=2000, nb_neutrinos=3, nb_neutrinos_massif=1, neutrino_mass=None, method='cbnu', output=True)
return Power Spectra with k in h.Mpc-1 and P in h3.Mpc-3 in the convention of CAMB and CLASS (the one needed for MP-Gadget). return Transfer function in the convention of CLASS (needed for MP-Genic) or CAMB (needed for 2LPT) !!!
Source code in lyapower/CLASS.py
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 | |
write_pk ¶
write_pk(name, z, kmin=-4, kmax=3, nb_points=2000, output=True, header_output=True, verbose=True)
Compute and (optionally) write the linear power spectrum P(k).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Output file base name. |
required |
z
|
float
|
Redshift. |
required |
kmin, kmax
|
float
|
log10 wavenumber bounds (h/Mpc). |
required |
nb_points
|
int
|
Number of k samples. |
2000
|
output
|
bool
|
Write the |
True
|
header_output
|
bool
|
Include a descriptive header. |
True
|
verbose
|
bool
|
Print the cosmology summary. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
|
|
sigma_8. |
Source code in lyapower/CLASS.py
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 | |
write_tk ¶
write_tk(name, z, output=True, header_output=True)
Compute and (optionally) write the transfer functions T_i(k).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Output file base name. |
required |
z
|
float
|
Redshift. |
required |
output
|
bool
|
Write the |
True
|
header_output
|
bool
|
Include a descriptive header. |
True
|
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray: The transfer-function table (CLASS or CAMB format). |
Source code in lyapower/CLASS.py
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 | |
compute_power_spectrum ¶
compute_power_spectrum(z, kmin=-4, kmax=3, nb_points=2000, k_array=None, verbose=True)
Evaluate the linear power spectrum on a k-grid (h-normalised).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
float
|
Redshift. |
required |
kmin, kmax
|
float
|
log10 wavenumber bounds (h/Mpc). |
required |
nb_points
|
int
|
Number of k samples (if |
2000
|
k_array
|
ndarray
|
Explicit k grid (h/Mpc). |
None
|
verbose
|
bool
|
Print the cosmology summary. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Source code in lyapower/CLASS.py
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 | |
interp_to_equidistant_log_space_camb_format ¶
interp_to_equidistant_log_space_camb_format(Transfer)
Resample a transfer-function table onto a log-equidistant k grid.
Required by the CAMB output format (2LPT / CosmicIC expect equidistant log-k).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Transfer
|
ndarray
|
Transfer table (first column is k). |
required |
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray: The resampled table. |
Source code in lyapower/CLASS.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
sigmaR_all_species_at ¶
sigmaR_all_species_at(R, z)
Compute sigma(R, z) over all species.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
float
|
Smoothing radius (Mpc/h). |
required |
z
|
float
|
Redshift. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
The RMS density fluctuation sigma(R, z). |
Source code in lyapower/CLASS.py
345 346 347 348 349 350 351 352 353 354 355 356 | |
free_structure ¶
free_structure()
Free the CLASS internal structures (struct_cleanup).
Source code in lyapower/CLASS.py
358 359 360 | |
close_class ¶
close_class()
Empty the CLASS model (release its parameters).
Source code in lyapower/CLASS.py
362 363 364 | |
get_omeganu_from_mass ¶
get_omeganu_from_mass(mass)
Convert a summed neutrino mass (eV) to omega_nu = m / (93.14 h^2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass
|
float
|
Summed neutrino mass (eV). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
|
Source code in lyapower/CLASS.py
366 367 368 369 370 371 372 373 374 375 | |
get_mass_from_omeganu ¶
get_mass_from_omeganu(omeganu)
Convert omega_nu back to a summed neutrino mass (eV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omeganu
|
float
|
Physical neutrino density parameter. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
Summed neutrino mass (eV). |
Source code in lyapower/CLASS.py
377 378 379 380 381 382 383 384 385 386 | |
CosmoprimoInterface ¶
Linear power spectra via the cosmoprimo façade (CLASS engine).
Source code in lyapower/CLASS.py
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 | |
Pl_class_cosmoprimo ¶
Pl_class_cosmoprimo(k_array, z)
Linear matter power spectrum from cosmoprimo (CLASS engine).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k_array
|
ndarray
|
Wavenumbers (h/Mpc). |
required |
z
|
float
|
Redshift. |
required |
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray: |
Source code in lyapower/CLASS.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
Pl_class_cosmoprimo_no_wiggle ¶
Pl_class_cosmoprimo_no_wiggle(k_array, z)
No-wiggle (BAO-smoothed) linear power spectrum from cosmoprimo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k_array
|
ndarray
|
Wavenumbers (h/Mpc). |
required |
z
|
float
|
Redshift. |
required |
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray: The BAO-filtered |
Source code in lyapower/CLASS.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |