pointing = create_random_pointings([racenter, deccenter], duration*3600/ts, ang, period=ts)
hwp_angles = np.random.random_integers(0, 7, len(pointing)) * 11.25 
pointing.pitch = 0
pointing.angle_hwp = hwp_angles
npoints = len(pointing)
##################################################################################


############# Instrument with Alternative Primary Beam ###########################
inst = QubicInstrument(detector_tau=0.0001,
                    detector_sigma=noise,
                    detector_fknee=0.,
                    detector_fslope=1)
if hornprofile != 0:
    pb = AltPrimaryBeam(14,hornprofile)
    inst.primary_beam=pb
##################################################################################


############## Input maps ########################################################
# x0 = None
# if rank == 0:
#     print('Rank '+str(rank)+' is Running Synfast')
#     x0 = np.array(hp.synfast(spectra[1:],nside,fwhm=0,pixwin=True,new=True)).T

# x0 = MPI.COMM_WORLD.bcast(x0)
# x0_noI = x0.copy()
# x0_noI[:,0] = 0
# print('Initially I map RMS is : '+str(np.std(x0[:,0])))
# print('Initially Q map RMS is : '+str(np.std(x0[:,1])))
# print('Initially U map RMS is : '+str(np.std(x0[:,2])))