b-thorne / PySM_public

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

`instrument.observe` returns different maps according to the value of the flag `write_outputs` #31

Open fincardona opened 5 years ago

fincardona commented 5 years ago

Hi, I've created the following instrument:

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

Then, I observe my sky with:

instrument_noisy.observe(pysm.Sky(sky_config))

and I read the maps:

hp.read_map('noisy_nu0143p00GHz_total_nside0128.fits', field=(0,1,2))
array([[-31.023283  ,  11.80905437,  21.81184769, ...,  76.90827179,
         82.10586548,  70.3621521 ],
      [  2.53387022,   1.2787329 ,   2.67105889, ...,  -1.31416452,
        -0.67028081,   2.02661443],
      [  0.53173047,   0.92604077,  -0.27713001, ...,  -0.65416229,
        -2.46461463,   0.93581396]])

hp.read_map('noisy_nu0143p00GHz_noise_nside0128.fits', field=(0,1,2))
array([[ 0.58221883,  0.13207038,  0.3230288 , ..., -0.03905814,
        -0.37743953, -0.55901247],    
       [ 1.17966449, -1.23902667,  1.01518738, ..., -1.45075607,
        -0.27817139,  0.76594335],
       [-0.36754149, -0.32368761, -0.06424909, ...,  0.80313766,
        -0.30539998,  0.36780828]])

Now, I do the same with the flag write_outputs=False and I expected to obtain the same maps. Instead, while the noise maps are the same, the total maps are not since the last one doesn't contain noise:

total, noise = instrument_noisy.observe(pysm.Sky(sky_config), write_outputs=False)
total
array([[[-31.60550231,  11.67698437,  21.4888182 , ...,  76.94732776,
          82.48330691,  70.92116465],
       [  1.35420567,   2.51775958,   1.65587158, ...,   0.13659159,
         -0.39210943,   1.26067109],
       [  0.89927195,   1.24972841,  -0.21288092, ...,  -1.45729993,
         -2.15921475,   0.56800566]]])

So, if you add the noise:

total+noise
array([[[-31.02328346,  11.80905476,  21.811847  , ...,  76.90826962,
          82.10586738,  70.36215217],
       [  2.53387016,   1.27873293,   2.67105895, ...,  -1.31416448,
         -0.67028081,   2.02661443],
       [  0.53173045,   0.92604079,  -0.27713001, ...,  -0.6541623 ,
         -2.46461474,   0.93581394]]])

It might be possible to make the output maps independet on the value of the flag write_outputs or, at least, to update the documentation of the method instrument.observe?