-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforegrounds_functions.py
More file actions
550 lines (396 loc) · 21.3 KB
/
foregrounds_functions.py
File metadata and controls
550 lines (396 loc) · 21.3 KB
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
###############################################################################
###############################################################################
#
# This piece of code has been developed by
# Lucas C. Olivari
# and is part of the IM Foreground Sky Model (IMFSM).
#
# For more information about the IMFSM contact
# Lucas C. Olivari ([email protected])
#
# May, 2018
#
###############################################################################
###############################################################################
import numpy as np
import healpy as hp
from scipy import interpolate
from scipy import integrate as si
import sys
###############################################################################
###############################################################################
##### Functions that are used to simulate the radio foregrounds:
### Synchrotron: synchrotron
### Free-free: free_free
### AME: ame
### Thermal dust: thermal_dust
### Point sources: source_count_battye, temp_background_fixed_freq, cl_poisson_fixed_freq, map_poisson_fixed_freq_high_flow, cl_cluster_fixed_freq, point_sources
### CMB: cmb
###############################################################################
###############################################################################
##### Constants:
k_bol = 1.38064852e-23 # Boltzmann constant, in J K^-1
h_planck = 6.62607004e-34 # Planck constant, in m^2 kg s^-1
c = 299792458. # speed of light, in m s^-1
jy_to_si = 1.e-26 # jansky to SI
###############################################################################
###############################################################################
##### Synchrotron
def synchrotron(frequencies, nside, model_template, spectral_index_model, curvature_index, curvature_reference_freq):
"""Galactic synchrotron cube: it uses HEALPIX pixelization and is in mK.
"""
### Models: template and spectral index
if model_template == 'haslam2014':
synch_0 = hp.read_map('data/haslam408_dsds_Remazeilles2014_ns2048.fits')
freq_0 = 0.408 # GHz
else:
sys.exit("Not a valid model!!!")
if spectral_index_model == 'uniform':
specind_0 = hp.read_map('data/synchrotron_specind_uniform.fits')
elif spectral_index_model == 'mamd2008':
specind_0 = hp.read_map('data/synchrotron_specind_mamd2008.fits')
elif spectral_index_model == 'giardino2002':
specind_0 = hp.read_map('data/synchrotron_specind_giardino2002.fits')
else:
sys.exit("Not a valid model!!!")
### Maps
nchannels = frequencies.size
synch = hp.ud_grade(synch_0, nside_out = nside)
synch_0 = 0
specind = hp.ud_grade(specind_0, nside_out = nside)
specind_0 = 0
maps = np.zeros((nchannels, hp.nside2npix(nside)))
### Frequency scaling
for i in range(0, nchannels):
maps[i, :] = 1000. * ((frequencies[i]) / freq_0)**(specind - 2.0 + curvature_index * np.log10(frequencies[i] / curvature_reference_freq)) * synch
return maps # mK
###############################################################################
###############################################################################
##### Free-free
def free_free(frequencies, nside, model_template, temp_electron):
"""Galactic free-free cube: it uses HEALPIX pixelization and is in mK.
"""
### Models: template
if model_template == 'dickinson2003':
halpha_0 = hp.read_map('data/onedeg_diff_halpha_JDprocessed_smallscales_2048.fits')
else:
sys.exit("Not a valid model!!!")
### Maps
nchannels = frequencies.size
halpha = hp.ud_grade(halpha_0, nside_out = nside, order_in = 'RING', order_out = 'RING')
halpha_0 = 0
maps = np.zeros((nchannels, hp.nside2npix(nside)))
### Factor a -- see Dickinson et al. 2003)
factor_a = 0.366 * (frequencies)**0.1 * temp_electron**(-0.15) * (np.log(4.995 * 1.0e-2 * (frequencies)**(-1)) + 1.5 * np.log(temp_electron))
### Frequency scaling -- see Dickinson et al. 2003
for i in range(0, nchannels):
maps[i, :] = 8.396 * factor_a[i] * (frequencies[i])**(-2.1) * (temp_electron * 1.0e-4)**0.667 * 10**(0.029 / (temp_electron * 1.0e-4)) * 1.08 * halpha
return maps # mK
###############################################################################
###############################################################################
##### AME
def ame(frequencies, nside, model_template, ame_ratio, ame_freq_in):
"""Galactic AME cube: it uses HEALPIX pixelization and is in mK.
"""
### Models: template
if model_template == 'planck_t353':
tau_0 = hp.read_map('data/Planck_map_t353_small_scales.fits')
else:
sys.exit("Not a valid model!!!")
### Maps
nchannels = frequencies.size
tau = hp.ud_grade(tau_0, nside_out = nside)
tau_0 = 0
maps = np.zeros((nchannels, hp.nside2npix(nside)))
### Frequency scaling: SPDUST -- see Ali-Haimoud et al. 2009 and Silsbee et al. 2011
spdust_file = 'data/spdust2_cnm.dat' # SPDUST code output file to obtain the frequency spectrum shape
freq, flux = np.loadtxt(spdust_file, comments = ';', usecols = (0, 1), unpack = True)
intp = interpolate.interp1d(freq, flux) # get the interpolation function of freq and flux from the spdust file
flux_in = intp(ame_freq_in)
for i in range (0, nchannels):
flux_out = intp(frequencies[i])
scale = flux_out / flux_in * (ame_freq_in / frequencies[i])**2
maps[i, :] = 1.e-3 * tau * ame_ratio * scale
return maps # mK
###############################################################################
###############################################################################
##### Thermal Dust
def thermal_dust(frequencies, nside, model_template, spectral_index_model, temp_model):
"""Galactic thermal dust cube: it uses HEALPIX pixelization and is in mK.
"""
### Models: template, spectral index, and temperature
if model_template == 'gnilc_353':
td_0 = hp.read_map('data/COM_CompMap_Dust-GNILC-F353_2048_R2.00_small_scales.fits')
td_0 = 261.20305067644796 * td_0 # from 'MJy/sr' to 'muK_RJ'
freq_in = 353.0 # GHz
else:
sys.exit("Not a valid model!!!")
if spectral_index_model == 'gnilc_353':
specind_0 = hp.read_map('data/COM_CompMap_Dust-GNILC-Model-Spectral-Index_2048_R2.00.fits')
else:
sys.exit("Not a valid model!!!")
if temp_model == 'gnilc_353':
temp_0 = hp.read_map('data/COM_CompMap_Dust-GNILC-Model-Temperature_2048_R2.00.fits') # K
else:
sys.exit("Not a valid model!!!")
### Maps
nchannels = frequencies.size
td = hp.ud_grade(td_0, nside_out = nside)
td_0 = 0
specind = hp.ud_grade(specind_0, nside_out = nside)
specind_0 = 0
temp = hp.ud_grade(temp_0, nside_out = nside)
temp_0 = 0
maps = np.zeros((nchannels, hp.nside2npix(nside)))
### Frequency scaling: modified blackbody -- see Planck Collaboration XI et al. 2013
gamma = h_planck / (k_bol * temp)
for i in range(0, nchannels):
maps[i, :] = 1.e-3 * td * (frequencies[i] / freq_in)**(specind + 1) * ((np.exp(gamma * (freq_in * 1.e9)) - 1.) / (np.exp(gamma * (frequencies[i] * 1.e9)) - 1.))
return maps # mK
###############################################################################
###############################################################################
##### Point Sources
### Source count models
def source_count_battye(flux):
"""Source count for point sources at 1.4 GHz - see Battye et al 2013.
"""
# Polynomial constants
S_0 = 1.0
N_0 = 1.0
a_0 = 2.593
a_1 = 9.333e-2
a_2 = -4.839e-4
a_3 = 2.488e-1
a_4 = 8.995e-2
a_5 = 8.506e-3
# Nomalized flux
ss = flux / S_0
# Differential source count
if flux <= 1.0e0:
dn_ds = N_0 * flux**(-2.5) * 10**(a_0 + a_1 * np.log10(ss) + a_2 * (np.log10(ss))**2 + a_3 * (np.log10(ss))**3 + a_4 * (np.log10(ss))**4 + a_5 * (np.log10(ss))**5)
# Interpolate for high fluxes (>1.0e0 Jy)
if flux > 1.0e0:
par = np.array([2.59300238, -2.40632446])
dn_ds = 10.**(par[0] + par[1] * np.log10(flux))
# Output
return dn_ds
### Background temperature
def temp_background_fixed_freq(flux_max, model_source_count):
"""Background temperature (in mK) at a fixed frequency (model dependent).
"""
if flux_max <= 1.0e-6:
sys.exit("Maximum flux has to be larger or equal to 1.0e-6 Jy.")
if model_source_count == "battye2013":
fixed_freq = 1.4e9 # Hz
flux_min = 1.0e-6 # Minimum flux (in Jy)
conversion_factor = 2 * k_bol * ((fixed_freq) / c)**2 # flux to temperature
# To ensure the correct convergence of the integral, we divide it in decades (that is
# why we have several integrations in what follows).
if flux_max <= 1.0e-3:
N = 100000
s_integrand = np.linspace(flux_min, flux_max, N)
s_function = np.zeros(N)
for i in range(0, int(N)):
s_function[i] = s_integrand[i] * source_count_battye(s_integrand[i])
temp_ps = (1.0 / conversion_factor) * jy_to_si * (si.simps(s_function, s_integrand))
elif 1.0e-3 < flux_max <= 1.0e1:
N = 100000
s_integrand_1 = np.linspace(flux_min, 1.0e-3, N)
s_integrand_2 = np.linspace(1.0e-3, flux_max, N)
s_function_1 = np.zeros(N)
s_function_2 = np.zeros(N)
for i in range(0, int(N)):
s_function_1[i] = s_integrand_1[i] * source_count_battye(s_integrand_1[i])
s_function_2[i] = s_integrand_2[i] * source_count_battye(s_integrand_2[i])
temp_ps = (1.0 / conversion_factor) * jy_to_si * (si.simps(s_function_1, s_integrand_1) + si.simps(s_function_2, s_integrand_2))
elif 1.0e1 < flux_max <= 1.0e3:
N = 100000
s_integrand_1 = np.linspace(flux_min, 1.0e-3, N, endpoint=True)
s_integrand_2 = np.linspace(1.0e-3, 1.0e1, N, endpoint=True)
s_integrand_3 = np.linspace(1.0e1, flux_max, N, endpoint=True)
s_function_1 = np.zeros(N)
s_function_2 = np.zeros(N)
s_function_3 = np.zeros(N)
for i in range(0, int(N)):
s_function_1[i] = s_integrand_1[i] * source_count_battye(s_integrand_1[i])
s_function_2[i]= s_integrand_2[i] * source_count_battye(s_integrand_2[i])
s_function_3[i]= s_integrand_3[i] * source_count_battye(s_integrand_3[i])
temp_ps = (1.0 / conversion_factor) * jy_to_si * (si.simps(s_function_1, s_integrand_1) + si.simps(s_function_2, s_integrand_2) + si.simps(s_function_3, s_integrand_3))
elif flux_max > 1.0e3:
N = 100000
s_integrand_1 = np.linspace(flux_min, 1.0e-3, N, endpoint=True)
s_integrand_2 = np.linspace(1.0e-3, 1.0e1, N, endpoint=True)
s_integrand_3 = np.linspace(1.0e1, 1.0e3, N, endpoint=True)
s_function_1 = np.zeros(N)
s_function_2 = np.zeros(N)
s_function_3 = np.zeros(N)
for i in range(0, int(N)):
s_function_1[i] = s_integrand_1[i] * source_count_battye(s_integrand_1[i])
s_function_2[i] = s_integrand_2[i] * source_count_battye(s_integrand_2[i])
s_function_3[i] = s_integrand_3[i] * source_count_battye(s_integrand_3[i])
temp_ps = (1.0 / conversion_factor) * jy_to_si * (si.simps(s_function_1, s_integrand_1) + si.simps(s_function_2, s_integrand_2) + si.simps(s_function_3, s_integrand_3))
return 1000.0 * temp_ps
### Poisson at low flux
def cl_poisson_fixed_freq(flux_max, model_source_count):
"""Poisson distribution of the sources (in mK^2) at a fixed frequency (model dependent).
"""
if flux_max <= 1.0e-6:
sys.exit("Maximum flux has to be larger or equal to 1.0e-6 Jy.")
if model_source_count == "battye2013":
fixed_freq = 1.4e9 # Hz
flux_min = 1.0e-6 # Minimum flux (in Jy)
conversion_factor = 2 * k_bol * ((fixed_freq)/ c)**2 # flux to temperature
# To ensure the correct convergence of the integral, we divide it in decades (that is
# why we have several integrations in what follows).
if flux_max <= 1.0e-3:
N = 100000
s_integrand = np.linspace(flux_min, flux_max, N)
s_function = np.zeros(N)
for i in range(0, int(N)):
s_function[i] = s_integrand[i]**2 * source_count_battye(s_integrand[i])
aps_poisson = (1.0 / conversion_factor)**2 * jy_to_si**2 * (si.simps(s_function, s_integrand))
elif 1.0e-3 < flux_max <= 1.0e1:
N = 100000
s_integrand_1 = np.linspace(flux_min, 1.0e-3, N)
s_integrand_2 = np.linspace(1.0e-3, flux_max, N)
s_function_1 = np.zeros(N)
s_function_2 = np.zeros(N)
for i in range(0, int(N)):
s_function_1[i] = s_integrand_1[i]**2 * source_count_battye(s_integrand_1[i])
s_function_2[i] = s_integrand_2[i]**2 * source_count_battye(s_integrand_2[i])
aps_poisson = (1.0 / conversion_factor)**2 * jy_to_si**2 * (si.simps(s_function_1, s_integrand_1) + si.simps(s_function_2, s_integrand_2))
elif 1.0e1 < flux_max <= 1.0e3:
N = 100000
s_integrand_1 = np.linspace(flux_min, 1.0e-3, N, endpoint=True)
s_integrand_2 = np.linspace(1.0e-3, 1.0e1, N, endpoint=True)
s_integrand_3 = np.linspace(1.0e1, flux_max, N, endpoint=True)
s_function_1 = np.zeros(N)
s_function_2 = np.zeros(N)
s_function_3 = np.zeros(N)
for i in range(0, int(N)):
s_function_1[i] = s_integrand_1[i]**2 * source_count_battye(s_integrand_1[i])
s_function_2[i]= s_integrand_2[i]**2 * source_count_battye(s_integrand_2[i])
s_function_3[i]= s_integrand_3[i]**2 * source_count_battye(s_integrand_3[i])
aps_poisson = (1.0 / conversion_factor)**2 * jy_to_si**2 * (si.simps(s_function_1, s_integrand_1) + si.simps(s_function_2, s_integrand_2) + si.simps(s_function_3, s_integrand_3))
elif flux_max > 1.0e3:
N = 100000
s_integrand_1 = np.linspace(flux_min, 1.0e-3, N, endpoint=True)
s_integrand_2 = np.linspace(1.0e-3, 1.0e1, N, endpoint=True)
s_integrand_3 = np.linspace(1.0e1, 1.0e3, N, endpoint=True)
s_function_1 = np.zeros(N)
s_function_2 = np.zeros(N)
s_function_3 = np.zeros(N)
for i in range(0, int(N)):
s_function_1[i] = s_integrand_1[i]**2 * source_count_battye(s_integrand_1[i])
s_function_2[i] = s_integrand_2[i]**2 * source_count_battye(s_integrand_2[i])
s_function_3[i] = s_integrand_3[i]**2 * source_count_battye(s_integrand_3[i])
aps_poisson = (1.0 / conversion_factor)**2 * jy_to_si**2 * (si.simps(s_function_1, s_integrand_1) + si.simps(s_function_2, s_integrand_2) + si.simps(s_function_3, s_integrand_3))
return 1000.0**2 * aps_poisson
### Poisson at high flux (flux_min has to be the same as flux_max of poisson_fixed_freq) - (flux_max ~ 10^3 Jy)
def map_poisson_fixed_freq_high_flow(flux_min_hf, flux_max_hf, nside, model_source_count):
"""Poisson map for high fluxes (in mK) at a fixed frequency (model dependent).
"""
omega_pix = (4.0 * np.pi) / (12.0 * nside**2)
decades = np.floor(np.log10(flux_max_hf)) - np.floor(np.log10(flux_min_hf))
dn_ds = np.zeros(10)
map = np.zeros(hp.nside2npix(nside))
if model_source_count == "battye2013":
fixed_freq = 1.4e9 # Hz
flux_min = 1.0e-6 # Minimum flux (in Jy)
conversion_factor = 2 * k_bol * ((fixed_freq)/ c)**2 # flux to temperature
# We randomly distribute in the sky N of sources with flux S such that these
# sources respect the underlying source count. This is done decade by decade.
for i in range(0, int(decades)):
s = np.linspace(flux_min_hf * 10**i, flux_min_hf * 10**(i + 1), 10)
for j in range(0, 9):
s_delta = np.linspace(s[j], s[j + 1], 10, endpoint=False)
for k in range(0, 10):
dn_ds[k] = source_count_battye(s_delta[k])
delta_n = np.ceil(si.simps(dn_ds, s_delta))
for l in range(0, int(delta_n)):
temp = (1.0 / conversion_factor) * jy_to_si * (1.0 / omega_pix) * np.random.uniform(low=s[j], high=s[j + 1])
map_index = np.random.randint(low=0, high=(hp.nside2npix(nside) - 1))
map[map_index] = temp
return 1000.0 * map
### Clustering distribution
def cl_cluster_fixed_freq(ell, t_ps, model_source_count):
"""Clustering distribution of the sources (in mK^2) at a fixed frequency (model dependet).
"""
if ell == 0:
ell = 1.0e-3
if model_source_count == "battye2013":
w_l = 1.8e-4 * ell**(-1.2)
cl_cluster = w_l * t_ps**2
return cl_cluster
def point_sources(frequencies, nside, model_source_count, max_flux_poisson_cl, max_flux_point_sources, spectral_index, spectral_index_std, add_clustering):
"""Extragalactic point sources cube: it uses HEALPIX pixelization and is in mK.
"""
### Models: source count
if model_source_count == "battye2013":
fixed_freq = 1.4 # in GHz
else:
sys.exit("Not a valid model!!!")
lmax = 3 * nside - 1
### Maps
nchannels = frequencies.size
maps = np.zeros((nchannels, hp.pixelfunc.nside2npix(nside)))
### Map generator (cl to map or dn / ds to map) and frequency scaling
if add_clustering == True:
cl_poisson = np.zeros(lmax + 1)
cl_cluster = np.zeros(lmax + 1)
t_ps = temp_background_fixed_freq(max_flux_point_sources, model_source_count)
cl = cl_poisson_fixed_freq(max_flux_poisson_cl, model_source_count) # the same value for all ells
poisson_high = map_poisson_fixed_freq_high_flow(max_flux_poisson_cl, max_flux_point_sources, nside, model_source_count) # template for the high flux sources
for l in range(0, lmax + 1):
cl_poisson[l] = cl
cl_cluster[l] = cl_cluster_fixed_freq(l, t_ps, model_source_count)
map_poisson_0 = hp.synfast(cl_poisson, nside, lmax=lmax)
map_cluster_0 = hp.synfast(cl_cluster, nside, lmax=lmax)
alpha_array = np.zeros(hp.nside2npix(nside))
for p in range(0, hp.nside2npix(nside)):
alpha_array[p] = spectral_index_std * np.random.randn() + spectral_index
for i in range(0, nchannels):
maps[i, :] = (frequencies[i] / fixed_freq)**(alpha_array) * (map_poisson_0 + map_cluster_0) + (frequencies[i] / fixed_freq)**(alpha_array) * poisson_high + (frequencies[i] / fixed_freq)**(alpha_array) * t_ps
if add_clustering == False:
cl_poisson = np.zeros(lmax + 1)
t_ps = temp_background_fixed_freq(max_flux_point_sources, model_source_count)
cl = cl_poisson_fixed_freq(max_flux_poisson_cl, model_source_count) # the same value for all ells
poisson_high = map_poisson_fixed_freq_high_flow(max_flux_poisson_cl, max_flux_point_sources, nside, model_source_count) # template for the high flux sources
for l in range(0, lmax + 1):
cl_poisson[l] = cl
map_poisson_0 = hp.synfast(cl_poisson, nside, lmax=lmax)
alpha_array = np.zeros(hp.nside2npix(nside))
for p in range(0, hp.nside2npix(nside)):
alpha_array[p] = spectral_index_std * np.random.randn() + spectral_index_std
for i in range(0, nchannels):
maps[i, :] = (frequencies[i] / fixed_freq)**(alpha_array) * map_poisson_0 + (frequencies[i] / fixed_freq)**(alpha_array) * poisson_high + (frequencies[i] / fixed_freq)**(alpha_array) * t_ps
return maps # mK
###############################################################################
###############################################################################
##### CMB
def cmb(frequencies, nside, cmb_model):
"""CMB cube: it uses HEALPIX pixelization and is in mK.
"""
### Models: angular power spectrum
if cmb_model == "standard":
cl_cmb_0 = np.loadtxt('data/cmb_tt.txt')
ell_0 = np.loadtxt('data/cmb_ell.txt')
nside_0 = 2048
lmax_0 = 3 * nside_0 - 1
else:
sys.exit("Not a valid model!!!")
### Maps
nchannels = frequencies.size
maps = np.zeros((nchannels, hp.pixelfunc.nside2npix(nside)))
cl_cmb = np.zeros(lmax_0 + 1)
for l in range(0, lmax_0 - 1):
cl_cmb[l + 2] = 2. * np.pi * cl_cmb_0[l] / (ell_0[l] * (ell_0[l] + 1.))
map_cmb_ther_0 = 1.e-6 * hp.synfast(cl_cmb, nside_0)
map_cmb_ther = hp.ud_grade(map_cmb_ther_0, nside_out = nside)
map_cmb_ther_0 = 0
### Frequency scaling -- from thermodynamic temperature to brightness temperature
gamma = h_planck / k_bol # Planck / Boltzmann
cmb_mean = 2.73 # K
for i in range(0, nchannels):
maps[i, :] = ((gamma * (frequencies[i] * 1.e9) / cmb_mean)**2 * np.exp(gamma * (frequencies[i] * 1.e9) / cmb_mean) / (np.exp(gamma * (frequencies[i] * 1.e9) / cmb_mean) - 1.)**2) * (map_cmb_ther[:]) # relationship between brightness temperature and thermodynamic temperature
return 1.e3 * maps # mK