Ejemplo n.º 1
0
parser.add_option('--drawPdistPrior', dest='pdistPrior', action='store_true', default=False,
                   help='Draw simulated pulsar distance from prior instead of using mean value)')
parser.add_option('--PdistSeed', dest='pdistSeed', action='store', type=int, default=0,
                   help='Random number seed for drawing pulsar distances from prior (default = 0, no seed)')


# parse arguments
(args, x) = parser.parse_args()

# compute chirp mass if mass m1 and m2 are given
if args.gwmass1 is not None and args.gwmass2 is not None:
    args.gwchirpmass = (args.gwmass1*args.gwmass2)**(3/5) / (args.gwmass1+args.gwmass2)**(1/5) 

# compute luminosity distance from redshift if given
if args.gwredshift is not None:
    args.gwdist = PALutils.computeLuminosityDistance(args.gwredshift)

# make copy of h5file TODO: maybe better way than using os.system?
h5copy = args.outFile
print 'Saving file to {0}'.format(h5copy)
os.system('cp {0} {1}'.format(args.h5file, h5copy))

# import hdf5 file
pfile = h5.File(h5copy, 'r+')

# define the pulsargroup
pulsargroup = pfile['Data']['Pulsars']

# fill in pulsar class
psr = [PALpulsarInit.pulsar(pulsargroup[key], addNoise=True, addGmatrix=True) \
                for key in pulsargroup]