Ejemplo n.º 1
0
sigma = .2

logerange = np.log10(ea_erange)
logemingrid = logerange[:-1] * np.ones([nbins, nbins])
logemaxgrid = logerange[1:] * np.ones([nbins, nbins])
logecentergrid = np.transpose(((logerange[:-1] + logerange[1:]) / 2.) * np.ones([nbins, nbins]))

#gauss = lambda p, x: p[0] / np.sqrt(2. * np.pi * p[2] ** 2.) * np.exp(- (x - p[1]) ** 2. / 2. / p[2] ** 2.)
gauss_int = lambda p, x_min, x_max: .5 * (scipy.special.erf((x_max - p[1]) / np.sqrt(2. * p[2] ** 2.)) - scipy.special.erf((x_min - p[1]) / np.sqrt(2. * p[2] ** 2.)))

rm = gauss_int([1., 10. ** logecentergrid, sigma * 10. ** logecentergrid], 10. ** logemingrid, 10. ** logemaxgrid)

logging.info('Sanity check, integrated rows should be 1.: {0}'.format(np.sum(rm, axis=1)))

# Create RM hdulist
hdulist = pf.np_to_rmf(rm, ea_erange, ea_erange, 1E-5,
                       telescope=telescope, instrument=instrument)
# Write RM to file
hdulist.writeto(rmf)

# DEBUG plots
#plt.subplot(221)
#plt.imshow(np.log10(rm[::-1]),  interpolation='nearest')
#cb = plt.colorbar()
#plt.subplot(222)
#plt.imshow(logecentergrid,  interpolation='nearest')
#cb = plt.colorbar()
#plt.subplot(223)
#plt.imshow(logemingrid,  interpolation='nearest')
#cb = plt.colorbar()
#plt.subplot(224)
#plt.imshow(logemaxgrid,  interpolation='nearest')