def observe(self,freq_GHz,noise_ukarcmin=3.,beam_fwhm_arcmin=8.): import pysm3 import pysm3.units as u #np.random.seed(213114124+int(freq_GHz)) beam = gauss_beam(np.arange(self.lmax_sim+10),beam_fwhm_arcmin)#hp.gauss_beam(beam_fwhm_arcmin*(np.pi/60./180),lmax=3*self.nside) beam[beam==0] = np.inf beam = 1/beam shape,wcs = enmap.fullsky_geometry(self.pixRes_arcmin) Q_noise = np.sqrt(2)*noise_ukarcmin*(np.pi/180/60)*curvedsky.rand_map(shape, wcs, beam**2) U_noise = np.sqrt(2)*noise_ukarcmin*(np.pi/180/60)*curvedsky.rand_map(shape, wcs, beam**2) sky = pysm3.Sky(nside=self.nside_pysm,preset_strings=["d1","s1"],output_unit="K_CMB") # Get the map at the desired frequency: I,Q_foreground,U_foreground = sky.get_emission(freq_GHz*u.GHz)*1e6 I,Q_foreground,U_foreground = reproject.enmap_from_healpix([I,Q_foreground,U_foreground], shape, wcs, ncomp=3, unit=1, lmax=self.lmax_sim,rot=None) Q_map = self.Q_cmb.copy() Q_map += Q_noise Q_map += Q_foreground U_map = self.U_cmb.copy() U_map += U_noise U_map += U_foreground return Q_map,U_map
def test_synch_model_s7_44(model_tag): nside = 2048 freq = 44 * u.GHz model = pysm3.Sky(preset_strings=[model_tag], nside=nside) output = model.get_emission(freq) input_template = pysm3.models.read_map( "synch/synch_template_nside{nside}.fits".format(nside=nside), nside=nside, field=(0, 1, 2), ) freq_ref = 23 * u.GHz beta = pysm3.models.read_map( "synch/synch_beta_nside{nside}.fits".format(nside=nside), nside=nside, field=0, ) curvature = pysm3.models.read_map( "synch/synch_curvature_nside{nside}.fits".format(nside=nside), nside=nside, field=0, ) curvature_term = np.log((freq / (23 * u.GHz))**curvature) scaling = (freq / freq_ref)**(beta + curvature_term) assert_quantity_allclose(input_template * scaling, output, rtol=1e-6)
def test_dust_model(model_tag, freq): # for 'd6' model fix the random seed and skip buggy 353 GHz if model_tag == "d6": if freq == 353: return np.random.seed(123) model = pysm3.Sky(preset_strings=[model_tag], nside=64) model_number = {"d0": 1, "d1": 1, "d2": 6, "d3": 9, "d6": 12}[model_tag] expected_output = pysm3.read_map( "pysm_2_test_data/check{}therm_{}p0_64.fits".format(model_number, freq), 64, unit="uK_RJ", field=(0, 1, 2), ) # for some models we do not have tests, we compare with output from a simular model # and we increase tolerance, mostly just to exercise the code. rtol = {"d0": 0.9}.get(model_tag, 1e-5) assert_quantity_allclose( expected_output, model.get_emission(freq * units.GHz), rtol=rtol )
def test_dust_model_353(model_tag): nside = 2048 freq = 353 * u.GHz model = pysm3.Sky(preset_strings=[model_tag], nside=nside) output = model.get_emission(freq) input_template = pysm3.models.read_map( "dust_gnilc/gnilc_dust_template_galplanefix_nside{nside}.fits".format( nside=nside ), nside=nside, field=(0, 1, 2), ) rtol = 1e-5 # if model_tag == "d11": # beam = 1 * u.deg # input_template = hp.smoothing(input_template, fwhm=beam.to_value(u.radians)) # output = hp.smoothing(output, fwhm=beam.to_value(u.radians)) # rtol = 1e-2 assert_quantity_allclose(input_template, output, rtol=rtol)
def eval_scaled_dust_dbmmb_map(model, nu_ref, nu_test, beta0, beta1, nubreak, nside, fsky, radec_center, T): #def double-beta dust model if model == 'd0': print('one beta model') analytic_expr = ('(exp(nu0 / temp * h_over_k) -1)' '/ (exp(nu / temp * h_over_k) - 1)' '* (nu / nu0)**(1 + beta_d)') dust = AnalyticComponent(analytic_expr, nu0=nu_ref, h_over_k=constants.h * 1e9 / constants.k, temp=T) #print(dust) scaling_factor = dust.eval(nu_test, beta0) else: print('double beta model') analytic_expr = double_beta_dust_FGB_Model(units='K_CMB') dbdust = AnalyticComponent(analytic_expr, nu0=nu_ref, h_over_k=constants.h * 1e9 / constants.k, temp=T) scaling_factor = dbdust.eval(nu_test, beta0, beta1, nubreak) sky = pysm3.Sky(nside=nside, preset_strings=['d0']) dust_map_ref = np.zeros( (3, 12 * nside**2)) #this way the output is w/0 units!! dust_map_ref[0:3, :] = sky.get_emission( nu_ref * u.GHz, None) * utils.bandpass_unit_conversion( nu_ref * u.GHz, None, u.uK_CMB) map_test = dust_map_ref * scaling_factor #mask = s4bi.get_coverage(fsky, nside, center_radec=radec_center) return map_test
def compute_fg(self, dust_model, presets_dust=None, NSIDE_PATCH=4): #print("\nYou're computing thermal dust with model {}\n".format(dust_model)) dustmaps = np.zeros((self.nfreqs, 3, self.npix)) if dust_model == 'd0': sync_model = 's0' else: sync_model = 's1' settings = [dust_model, sync_model] self.preset_fg(dustmodel=dust_model, dict_dust=presets_dust) sky = pysm3.Sky(nside=self.nside, preset_strings=settings) if dust_model == 'd0' or dust_model == 'd1' or dust_model == 'd2' or dust_model == 'd3' or dust_model == 'd6': sky.components[0].mbb_temperature = 20 * sky.components[ 0].mbb_temperature.unit # fix temp at 20 K across the sky #print('Downgrade pixelization of spectral indices at nside = {}'.format(NSIDE_PATCH)) if dust_model != 'd0': #print('Downgrade pixelization of spectral indices at nside = {}'.format(NSIDE_PATCH)) for spectral_param in [ sky.components[0].mbb_index, sky.components[1].pl_index ]: spectral_param[:] = hp.ud_grade( hp.ud_grade(spectral_param.value, NSIDE_PATCH), self.nside) * spectral_param.unit for j in range(self.nfreqs): dustmaps[j] = np.array( sky.get_emission(self.nus[j] * u.GHz) * utils.bandpass_unit_conversion(self.nus[j] * u.GHz, None, u.uK_CMB)) return dustmaps
def create_dustd1(nside, nus): maps_dust = np.zeros(((len(nus), 3, 12 * nside**2))) sky = pysm3.Sky(nside=nside, preset_strings=['d1']) for i, j in enumerate(nus): maps_dust[i] = sky.get_emission(j * u.GHz).to( getattr(u, 'uK_CMB'), equivalencies=u.cmb_equivalencies(j * u.GHz)) return maps_dust
def get_fg_notconvolved(model, nu, nside=256): sky = pysm3.Sky(nside=nside, preset_strings=[model]) maps = np.zeros(((len(nu), 3, 12 * nside**2))) for indi, i in enumerate(nu): maps[indi] = sky.get_emission(i * u.GHz, None) * utils.bandpass_unit_conversion( i * u.GHz, None, u.uK_CMB) return maps
def get_dust_sky(nus, model, nside): sky = pysm3.Sky(nside=nside, preset_strings=[model]) maps_dust = np.zeros(((len(nus), 3, 12 * nside**2))) for i_freq, freq in enumerate(nus): maps_XXXGHz = sky.get_emission(freq * u.GHz, None) * utils.bandpass_unit_conversion( freq * u.GHz, None, u.uK_CMB) maps_dust[i_freq] = maps_XXXGHz.copy() return maps_dust
def get_component_maps(components, ref_freqs, nside, fsky, center_radec=[0., -57.]): maps = [] mask = get_coverage(fsky, nside, center_radec=center_radec) okpix = mask == 1 for c,f in zip(components, ref_freqs): print('Doing: '+c) thesky = pysm3.Sky(nside=nside, preset_strings=[c], output_unit="uK_CMB") themaps = np.zeros((4, 12*nside**2)) # four are I, Q, U and P themaps[0:3,:] = thesky.get_emission(f * u.GHz) #.to(u.uK_CMB, equivalencies=u.cmb_equivalencies(f*u.GHz)) themaps[3,:] = np.sqrt(themaps[1,:]**2 + themaps[2,:]**2) themaps[:, ~okpix] = hp.UNSEEN maps.append(themaps) return maps
def give_me_maps_d1_modified(nus, nubreak, covmap, delta_b, nside, fix_temp=None, nside_index=256): maps_dust = np.ones(((len(nus), 3, 12 * nside**2))) * hp.UNSEEN ind = np.where(covmap > 0)[0] sky = pysm3.Sky(nside=nside, preset_strings=['d1']) maps_dust = sky.get_emission(353 * u.GHz, None) * utils.bandpass_unit_conversion( 353 * u.GHz, None, u.uK_CMB) map_index = np.array(sky.components[0].mbb_index) if fix_temp is not None: sky.components[0].mbb_temperature = fix_temp map_temperature = np.array( np.ones(12 * nside**2) * sky.components[0].mbb_temperature) else: map_temperature = np.array(sky.components[0].mbb_temperature) if nside_index != 256: map_temperature = hp.pixelfunc.ud_grade(map_temperature, nside_index) map_index = hp.pixelfunc.ud_grade(map_index, nside_index) map_temperature = hp.pixelfunc.ud_grade(map_temperature, 256) map_index = hp.pixelfunc.ud_grade(map_index, 256) #hp.mollview(map_temperature, sub=(1, 2, 1)) #hp.mollview(map_index, sub=(1, 2, 2)) #print(map_index.shape) # Evaluation of Mixing Matrix for 2 beta model comp2b = [fgbuster.component_model.Dust_2b(nu0=353)] A2b = fgbuster.MixingMatrix(*comp2b) A2b_ev = A2b.evaluator(nus) new_dust_map = np.ones(((len(nus), 3, 12 * nside**2))) * hp.UNSEEN for i in ind: A2b_maxL = A2b_ev([ np.array(map_index)[i] - delta_b, np.array(map_index)[i] + delta_b, nubreak, np.array(map_temperature)[i] ]) for j in range(len(nus)): new_dust_map[j, :, i] = A2b_maxL[j, 0] * maps_dust[:, i] return new_dust_map, [map_index, map_temperature]
def test_bandpass_unit_conversion(): nside = 32 freqs = np.array([250, 300, 350]) * u.GHz weights = np.ones(len(freqs)) sky = pysm3.Sky(nside=nside, preset_strings=["c2"]) CMB_rj_int = sky.get_emission(freqs, weights) CMB_thermo_int = CMB_rj_int*pysm3.utils.bandpass_unit_conversion( freqs, weights, u.uK_CMB ) expected_map = pysm3.read_map( "pysm_2/lensed_cmb.fits", field=(0, 1), nside=nside, unit=u.uK_CMB ) for pol in [0, 1]: assert_quantity_allclose(expected_map[pol], CMB_thermo_int[pol], rtol=1e-4)
def from_pysm( cls, freq: float, nside: int, preset_strings: List[str] = ["c1"], ) -> Maps: sky = pysm3.Sky(nside=nside, preset_strings=preset_strings) freq_u = freq * u.GHz m = sky.get_emission(freq_u) return cls( CANONICAL_NAME, m.to(u.uK_CMB, equivalencies=u.cmb_equivalencies(freq_u)), name= f"PySM 3 {freq} GHz map with preset {', '.join(preset_strings)}")
def test_model(model, freq): model = pysm3.Sky(preset_strings=[model], nside=64) model_number = 8 expected_map = pysm3.read_map( "pysm_2_test_data/check{}spinn_{}p0_64.fits".format( model_number, freq), 64, unit=pysm3.units.uK_RJ, field=(0, 1, 2), ) assert_quantity_allclose(expected_map, model.get_emission(freq << pysm3.units.GHz), rtol=1e-3)
def test_highfreq_dust_model(model_tag, freq): model = pysm3.Sky(preset_strings=[model_tag], nside=64) expected_output = pysm3.read_map( "pysm_2_test_data/check_{}_{}_uK_RJ_64.fits".format(model_tag, freq), 64, unit="uK_RJ", field=(0, 1, 2), ) rtol = 1e-5 assert_quantity_allclose(expected_output, model.get_emission(freq * units.GHz), rtol=rtol)
def test_d10_vs_d11(): nside = 2048 freq = 857 * u.GHz output_d10 = pysm3.Sky(preset_strings=["d10"], nside=nside).get_emission(freq) d11_configuration = pysm3.sky.PRESET_MODELS["d11"].copy() del d11_configuration["class"] d11 = pysm3.models.ModifiedBlackBodyRealization( nside=nside, seeds=[8192, 777, 888], synalm_lmax=16384, **d11_configuration ) output_d11 = d11.get_emission(freq) rtol = 1e-5 assert_quantity_allclose(output_d10, output_d11, rtol=rtol, atol=0.05 * u.uK_RJ)
def test_synch_model_noscaling(model_tag): nside = 2048 freq = 23 * u.GHz model = pysm3.Sky(preset_strings=[model_tag], nside=nside) output = model.get_emission(freq) input_template = pysm3.models.read_map( "synch/synch_template_nside{nside}.fits".format(nside=nside), nside=nside, field=(0, 1, 2), ) rtol = 1e-5 assert_quantity_allclose(input_template, output, rtol=rtol)
def test_model(model, freq): model = pysm3.Sky(preset_strings=[model], nside=64) model_number = 3 expected_map = pysm3.read_map( "pysm_2_test_data/check{}spinn_{}p0_64.fits".format( model_number, freq), 64, unit=pysm3.units.uK_RJ, field=0, ) emission = model.get_emission(freq << pysm3.units.GHz) assert_quantity_allclose(expected_map, emission[0], rtol=1e-5) for i in [1, 2]: assert_quantity_allclose(0 * pysm3.units.uK_RJ, emission[i])
def test_get_so_models(model_tag): """Test the `get_so_models` function Only check that we can access the 512 version of the template and that the result has no NaN""" sky = pysm.Sky( nside=128, component_objects=[get_so_models(model_tag, nside=128, coord="G")] ) emission = sky.get_emission(freq=100 * u.GHz) assert not np.any(np.isnan(emission)) # Compare I and Q at pixel 100 for IQ in [0, 1]: if expected[model_tag][IQ] != 0: assert_quantity_allclose( emission[IQ][98969], expected[model_tag][IQ] * u.uK_RJ, rtol=1e-4 )
def eval_scaled_sync_map(nu_ref, nu_test, betapl, nside, fsky, radec_center): #def double-beta dust model analytic_expr = '(nu / nu0)**(beta_pl)' sync = AnalyticComponent(analytic_expr, nu0=nu_ref) scaling_factor = sync.eval(nu_test, betapl) sky = pysm3.Sky(nside=nside, preset_strings=['s0']) sync_map_ref = np.zeros( (3, 12 * nside**2)) #this way the output is w/0 units!! sync_map_ref[0:3, :] = sky.get_emission( nu_ref * u.GHz, None) * utils.bandpass_unit_conversion( nu_ref * u.GHz, None, u.uK_CMB) map_test = sync_map_ref * scaling_factor #mask = s4bi.get_coverage(fsky, nside, center_radec=radec_center) return map_test
def test_cmb_lensed(model_tag, freq): # The PySM test was done with a different seed than the one # baked into the preset models pysm3.sky.PRESET_MODELS["c1"]["cmb_seed"] = 1234 model = pysm3.Sky(preset_strings=[model_tag], nside=64) model_number = 5 expected_output = pysm3.read_map( "pysm_2_test_data/check{}cmb_{}p0_64.fits".format(model_number, freq), 64, unit="uK_RJ", field=(0, 1, 2), ) assert_quantity_allclose( expected_output, model.get_emission(freq * u.GHz), rtol=1e-5 )
def create_dustd0(nside, nus): # Create 353 GHz dust maps sky = pysm3.Sky(nside=nside, preset_strings=['d0']) #comp=[fgbuster.component_model.Dust(nu0=353, beta_d=1.54, temp=20)] #A = fgbuster.MixingMatrix(*comp) #A_ev = A.evaluator(nus) #A_maxL = A_ev() new_dust_map = np.zeros(((len(nus), 3, 12 * nside**2))) for i in range(len(nus)): maps_XXXGHz = sky.get_emission(nus[i] * u.GHz, None) * utils.bandpass_unit_conversion( nus[i] * u.GHz, None, u.uK_CMB) new_dust_map[i] = maps_XXXGHz.copy() return new_dust_map
def create_sync(nside, nus): # Create 353 GHz dust maps sky = pysm3.Sky(nside=nside, preset_strings=['s0']) maps_70GHz = sky.get_emission(70 * u.GHz, None) * utils.bandpass_unit_conversion( 70 * u.GHz, None, u.uK_CMB) comp = [fgbuster.component_model.Synchrotron(nu0=70)] A = fgbuster.MixingMatrix(*comp) A_ev = A.evaluator(nus) A_maxL = A_ev(np.array([-3])) new_sync_map = np.zeros(((len(nus), 3, 12 * nside**2))) for i in range(len(nus)): new_sync_map[i] = A_maxL[i, 0] * maps_70GHz return new_sync_map
def test_synchrotron_model(model, freq): synchrotron = pysm3.Sky(preset_strings=[model], nside=64) model_number = {"s0": 2, "s1": 2, "s2": 7, "s3": 10}[model] synch = pysm3.read_map( "pysm_2_test_data/check{}synch_{}p0_64.fits".format( model_number, freq), 64, unit=pysm3.units.uK_RJ, field=(0, 1, 2), ) # for some models we do not have tests, we compare with output from a simular model # and we increase tolerance, mostly just to exercise the code. rtol = {"s0": 5}.get(model, 1e-5) assert_quantity_allclose(synch, synchrotron.get_emission(freq << pysm3.units.GHz), rtol=rtol)
def test_s6_vs_s5(): nside = 2048 freq = 44 * u.GHz output_s5 = pysm3.Sky(preset_strings=["s5"], nside=nside).get_emission(freq) s6_configuration = pysm3.sky.PRESET_MODELS["s6"].copy() del s6_configuration["class"] s6 = pysm3.models.PowerLawRealization(nside=nside, synalm_lmax=16384, seeds=[555, 444], **s6_configuration) output_s6 = s6.get_emission(freq) rtol = 1e-5 assert_quantity_allclose(output_s5, output_s6, rtol=rtol, atol=0.05 * u.uK_RJ)
def get_sky(nside, tag='c1d0s0'): """ Get a pre-defined PySM sky Parameters ---------- nside: int healpix nside of the sky templates tag: string See the `pysm documentation <https://pysm3.readthedocs.io/en/latest/models.html#models>`_ for a complete list of available options. Default is 'c1d0s0', i.e. cmb (c1), dust with constant temperature and spectral index (d0), and synchrotron with constant spectral index (s0). Returns ------- sky: pysm3.Sky See the `pysm documentation <https://pysm3.readthedocs.io/en/latest/api/pysm.Sky.html#pysm.Sky>`_ """ preset_strings = [tag[i:i + 2] for i in range(0, len(tag), 2)] return pysm3.Sky(nside, preset_strings=preset_strings)
def test_gnilc_857(model_tag): freq = 857 * u.GHz model = pysm3.Sky(preset_strings=[model_tag], nside=2048) output = model.get_emission(freq) input_template = pysm3.models.read_map( "dust_gnilc/gnilc_dust_template_galplanefix_nside{nside}.fits".format( nside=2048 ), nside=2048, field=(0, 1, 2), ) freq_ref = 353 * u.GHz beta = ( 1.48 if model_tag == "d9" else pysm3.models.read_map( "dust_gnilc/gnilc_dust_beta_nside{nside}.fits".format(nside=2048), nside=2048, field=0, ) ) Td = ( 19.6 * u.K if model_tag == "d9" else pysm3.models.read_map( "dust_gnilc/gnilc_dust_Td_nside{nside}.fits".format(nside=2048), nside=2048, field=0, ) ) scaling = (freq / freq_ref) ** (beta - 2) scaling *= blackbody_ratio(freq, freq_ref, Td.to_value(u.K)) assert_quantity_allclose(input_template * scaling, output, rtol=1e-6)
def get_sky(self, coverage): setting = [] iscmb = False for k in self.skyconfig: if k == 'cmb': iscmb = True maps = self.get_cmb(coverage) rndstr = random_string(10) hp.write_map('/tmp/' + rndstr, maps) cmbmap = pysm3.CMBMap(self.nside, map_IQU='/tmp/' + rndstr) os.remove('/tmp/' + rndstr) #setting.append(skyconfig[k]) elif k == 'dust': pass else: setting.append(self.skyconfig[k]) sky = pysm3.Sky(nside=self.nside, preset_strings=setting) if iscmb: sky.add_component(cmbmap) return sky
def test_synch_44(model_tag): freq = 44 * u.GHz nside = 2048 model = pysm3.Sky(preset_strings=[model_tag], nside=nside) output = model.get_emission(freq) input_template = pysm3.models.read_map( "synch/synch_template_nside{nside}.fits".format(nside=nside), nside=nside, field=(0, 1, 2), ) freq_ref = 23 * u.GHz beta = (-3.1 if model_tag == "s4" else pysm3.models.read_map( "synch/synch_beta_nside{nside}.fits".format(nside=nside), nside=nside, field=0, )) scaling = (freq / freq_ref)**beta assert_quantity_allclose(input_template * scaling, output, rtol=1e-6)
def getskymaps(self, same_resol=None, verbose=False, coverage=None, iib=1, noise=False, signoise=1., beta=[], fix_temp=None, nside_index=256): """ """ sky = self.get_sky(coverage) allmaps = np.zeros(((len(self.nus), 3, self.npix))) pixok = coverage > 0 if same_resol is not None: self.fwhmdeg = np.ones(len(self.nus)) * np.max(same_resol) for i in self.skyconfig.keys(): if i == 'cmb': cmbmap = self.get_cmb(coverage) for j in range(len(self.nus)): allmaps[j] += cmbmap map_index = [] elif i == 'dust': dustmaps = np.zeros(((len(self.nus), 3, self.npix))) if self.skyconfig[i] == 'd0': if verbose: print('Model : {}'.format(self.skyconfig[i])) for i in range(len(self.nus)): print( 'Integration into bands ({:.0f} bands) -> from {:.2f} to {:.2f} GHz' .format(iib, self.edges[i][0], self.edges[i][1])) #print(self.edges[i]) nus_inter = get_freqs_inter(self.edges[i], iib) #print(nus_inter) dustmaps_inter = create_dustd0( self.nside, nus_inter ) #get_fg_notconvolved('d0', self.nus, nside=self.nside) mean_dust_maps = np.mean(dustmaps_inter, axis=0) dustmaps[i] = mean_dust_maps.copy() allmaps += dustmaps map_index = [] elif self.skyconfig[i] == 'd02b': if verbose: print( 'Model : d02b -> Twos spectral index beta ({:.2f} and {:.2f}) with nu_break = {:.2f}' .format(beta[0], beta[1], beta[2])) # Create 353 GHz dust maps sky = pysm3.Sky(nside=self.nside, preset_strings=['d0']) maps_353GHz = sky.get_emission( 353 * u.GHz, None) * utils.bandpass_unit_conversion( 353 * u.GHz, None, u.uK_CMB) for i in range(len(self.nus)): print( 'Integration into bands ({:.0f} bands) -> from {:.2f} to {:.2f} GHz' .format(iib, self.edges[i][0], self.edges[i][1])) #print(self.edges[i]) nus_inter = get_freqs_inter(self.edges[i], iib) #print(nus_inter) #print(nus_inter) #add Elenia's definition dustmaps_inter = create_dust_with_model2beta( maps_353GHz, self.nside, nus_inter, beta[0], beta[1], beta[2], temp=20, break_width=beta[3]) #print(dustmaps_inter.shape) mean_dust_maps = np.mean(dustmaps_inter, axis=0) dustmaps[i] = mean_dust_maps.copy() allmaps += dustmaps map_index = [] elif self.skyconfig[i] == 'd1' or self.skyconfig[ i] == 'd2' or self.skyconfig[ i] == 'd3' or self.skyconfig[i] == 'd4': skyconf = self.skyconfig[i] #if verbose: print('Model : {}'.format(skyconf)) if iib == 1: dustmaps = get_dust_sky(self.nus, skyconf, self.nside) else: dustmaps = np.zeros(((len(self.nus), 3, self.npix))) for i in range(len(self.nus)): nus_inter = get_freqs_inter(self.edges[i], iib) print(nus_inter) dustmaps_inter = get_dust_sky( nus_inter, skyconf, self.nside) dust_maps_i = np.mean(dustmaps_inter, axis=0) dustmaps[i] = dust_maps_i.copy() allmaps += dustmaps else: print('No dust') elif i == 'synchrotron': syncmaps = np.zeros(((len(self.nus), 3, self.npix))) print('Model : {}'.format(self.skyconfig[i])) for i in range(len(self.nus)): nus_inter = get_freqs_inter(self.edges[i], iib) #print(nus_inter) sync_maps_inter = create_sync(self.nside, nus_inter) mean_sync_maps = np.mean(sync_maps_inter, axis=0) syncmaps[i] = mean_sync_maps.copy() allmaps += syncmaps map_index = [] else: print('No more components') #pass #hp.mollview(allmaps[0, 1]) if same_resol != 0: for j in range(len(self.fwhmdeg)): if verbose: print('Convolution to {:.2f} deg'.format(self.fwhmdeg[j])) allmaps[j] = hp.sphtfunc.smoothing(allmaps[j, :, :], fwhm=np.deg2rad( self.fwhmdeg[j]), verbose=False) if noise: noisemaps = create_noisemaps(signoise, self.nus, self.nside, self.depth_i, self.depth_p, self.npix) maps_noisy = allmaps + noisemaps if coverage is not None: pixok = coverage > 0 maps_noisy[:, :, ~pixok] = hp.UNSEEN noisemaps[:, :, ~pixok] = hp.UNSEEN allmaps[:, :, ~pixok] = hp.UNSEEN return maps_noisy, allmaps, noisemaps return allmaps