b-thorne / PySM_public

PySM: Software for simulating the Galactic microwave sky
24 stars 29 forks source link

`pysm.Instrument` seems not working properly in some cases #30

Open fincardona opened 5 years ago

fincardona commented 5 years ago

Hello, I have a problem using pysm.Instrument.

I use this standard sky configuration:

nside = 128
sky_config = {
'synchrotron': models('s1', nside),
'dust': models('d1', nside),
'freefree': models('f1', nside),
'cmb': models('c1', nside),
'ame': models('a1', nside)} 

then I create a sky with:

sky = pysm.Sky(sky_config)

Now, I create the two following different instruments:

1)

instrument_mono_noiseless = pysm.Instrument({
    'nside': nside,
    'frequencies' : np.array([143]), 
    'use_smoothing' : True,
    'beams' : np.array([7.1]),  
    'add_noise' : False, 
    'noise_seed' : None,  
    'sens_I': None, 
    'sens_P': None, 
    'use_bandpass' : False,  
    'channel_names' : ['143_GHz'],
    'channels' : None,
    'output_units' : 'uK_RJ',
    'output_directory' : "./",
    'output_prefix' : "noiseless_mono",
    'pixel_indices' : None})

2)

instrument_mono = pysm.Instrument({
    'nside': nside,
    'frequencies' : np.array([143]), 
    'use_smoothing' : True,
    'beams' : np.array([7.1]),  
    'add_noise' : True, 
    'noise_seed' : 0,  
    'sens_I': np.ones(1), 
    'sens_P': np.ones(1), 
    'use_bandpass' : False,  
    'channel_names' : ['143_GHz'],
    'channels' : None,
    'output_units' : 'uK_RJ',
    'output_directory' : "./",
    'output_prefix' : "mono",
    'pixel_indices' : None})

I observe the sky through these two instruments with instrument_*.observe(sky) and then I read the corresponding maps that have been produced.

1) In the first case the created map does not have the polarization components but only the intensity one. In fact, you will get an error message if you try:

hp.read_map('noiseless_mono_nu0143p00GHz_total_nside0128.fits', field=(0, 1, 2))

while the right command would be:

hp.read_map('noiseless_mono_nu0143p00GHz_total_nside0128.fits', field=(0))

but this means that Q and U maps have not been generated.

2) In the second case, the three maps (I, Q, U) are generated but in a wrong way since the Q and U maps are in the same order of magnitude of the I map:

hp.read_map('mono_nu0143p00GHz_total_nside0128.fits', field=(0, 1, 2))

array([[-36.27698898,  14.9692564 ,  25.86756897, ...,  76.63456726, 
         81.74451447,  67.1904068 ],
       [-36.27647781,  14.91915131,  25.87987328, ...,  76.58881378, 
         81.76040649,  67.25320435],
       [-36.32805252,  14.94966221,  25.84389114, ...,  76.66394043, 
         81.7594986 ,  67.2399292 ]])

Is there something I'm doing wrongly somewhere?

NicolettaK commented 5 years ago

Hi, I think the problem is related to the number of frequencies passed to pysm.Instrument. When only one frequency channel is given the smooth function doesn't work properly, if more frequencies are given then everything appears to work well.