diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1fbd9e --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.so +*.pyc +*.o +*.model +*.cmd +*ipynb* diff --git a/lib/fortran/make_linux.csh b/lib/fortran/make_linux.csh index 3b116d8..4bbb8b4 100644 --- a/lib/fortran/make_linux.csh +++ b/lib/fortran/make_linux.csh @@ -1,6 +1,6 @@ #!/bin/tcsh -set gf = /usr/bin/gfortran +set gf=/usr/bin/gfortran $gf -O2 -fPIC -fno-second-underscore -c -I. -std=legacy *.f diff --git a/lib/fortran/makefile b/lib/fortran/makefile index f966a3f..4bb1a83 100644 --- a/lib/fortran/makefile +++ b/lib/fortran/makefile @@ -1,4 +1,4 @@ -include makefile.$(OSTYPE) +include makefile.linux all: libne2001.so libykarea.so libsla.so libvxyz.so libgamma.so diff --git a/lib/python/dataobj.py b/lib/python/dataobj.py index ee8684e..c9ed9ca 100644 --- a/lib/python/dataobj.py +++ b/lib/python/dataobj.py @@ -1,9 +1,11 @@ #!/usr/bin/python -import os - -import cPickle +import os, sys +if sys.version_info[0] < 3: + import cPickle +else: + import pickle as cPickle class DataObj: def __init__(self, name, labelDict, dataDict, size): diff --git a/lib/python/degradation.py b/lib/python/degradation.py index 7a264bf..947d6e3 100644 --- a/lib/python/degradation.py +++ b/lib/python/degradation.py @@ -1,9 +1,13 @@ #!/usr/bin/python -import os - +import os, sys import ctypes as C +if sys.version_info[0] < 3: + import cPickle +else: + import pickle as cPickle + # get the FORTRAN libraries __dir__ = os.path.dirname(os.path.abspath(__file__)) __libdir__ = os.path.dirname(__dir__) diff --git a/lib/python/distributions.py b/lib/python/distributions.py index ccf16a8..a03ee47 100644 --- a/lib/python/distributions.py +++ b/lib/python/distributions.py @@ -58,4 +58,4 @@ def draw_double_sided_exp(scale, origin=0.0): def uniform(low,high): """Draw a random number from a uniform distribution between low and high""" - return random.uniform(low,high) + return 10 ** random.uniform(np.log10(low),np.log10(high)) diff --git a/lib/python/dosurvey.py b/lib/python/dosurvey.py index a414089..e83c91e 100755 --- a/lib/python/dosurvey.py +++ b/lib/python/dosurvey.py @@ -5,12 +5,14 @@ import math import random -import cPickle - from population import Population from pulsar import Pulsar from survey import Survey +if sys.version_info[0] < 3: + import cPickle +else: + import pickle as cPickle class Detections: """Just a simple object to store survey detection summary""" @@ -91,8 +93,8 @@ def run(pop, # print the population if not nostdout: - print "Running doSurvey on population..." - print pop + print("Running doSurvey on population...") + print(pop) # loop over the surveys we want to run on the pop file surveyPops = [] @@ -100,7 +102,7 @@ def run(pop, s = Survey(surv) s.discoveries = 0 if not nostdout: - print "\nRunning survey {0}".format(surv) + print("\nRunning survey {0}".format(surv)) # create a new population object to store discovered pulsars in survpop = Population() @@ -152,15 +154,15 @@ def run(pop, # report the results if not nostdout: - print "Total pulsars in model = {0}".format(len(pop.population)) - print "Number detected by survey {0} = {1}".format(surv, ndet) - print "Of which are discoveries = {0}".format(s.discoveries) - print "Number too faint = {0}".format(ntf) - print "Number smeared = {0}".format(nsmear) - print "Number out = {0}".format(nout) + print("Total pulsars in model = {0}".format(len(pop.population))) + print("Number detected by survey {0} = {1}".format(surv, ndet)) + print("Of which are discoveries = {0}".format(s.discoveries)) + print("Number too faint = {0}".format(ntf)) + print("Number smeared = {0}".format(nsmear)) + print("Number out = {0}".format(nout)) if rratssearch: - print "Number didn't burst = {0}".format(nbr) - print "\n" + print("Number didn't burst = {0}".format(nbr)) + print("\n") d = Detections(ndet=ndet, ntf=ntf, diff --git a/lib/python/evolve.py b/lib/python/evolve.py index 07843c7..d6f9842 100755 --- a/lib/python/evolve.py +++ b/lib/python/evolve.py @@ -6,7 +6,6 @@ import random import inspect -import cPickle #import scipy.integrate from scipy import integrate import numpy as np @@ -22,6 +21,10 @@ from progressbar import ProgressBar +if sys.version_info[0] < 3: + import cPickle +else: + import pickle as cPickle class EvolveException(Exception): pass @@ -95,30 +98,30 @@ def generate(ngen, pop.zscale = zscale if widthModel == 'kj07': - print "\tLoading KJ07 models...." + print("\tLoading KJ07 models....") kj_p_vals, kj_pdot_vals, kj_dists = beammodels.load_kj2007_models() - print "\tDone\n" + print("\tDone\n") if not nostdout: - print "\tGenerating evolved pulsars with parameters:" - print "\t\tngen = {0}".format(ngen) - print "\t\tUsing electron distn model {0}".format( - pop.electronModel) - print "\n\t\tPeriod mean, sigma = {0}, {1}".format( + print("\tGenerating evolved pulsars with parameters:") + print("\t\tngen = {0}".format(ngen)) + print("\t\tUsing electron distn model {0}".format( + pop.electronModel)) + print("\n\t\tPeriod mean, sigma = {0}, {1}".format( pop.pmean, - pop.psigma) - print "\t\tLuminosity mean, sigma = {0}, {1}".format( + pop.psigma)) + print("\t\tLuminosity mean, sigma = {0}, {1}".format( pop.lummean, - pop.lumsigma) - print "\t\tSpectral index mean, sigma = {0}, {1}".format( + pop.lumsigma)) + print("\t\tSpectral index mean, sigma = {0}, {1}".format( pop.simean, - pop.sisigma) - print "\t\tGalactic z scale height = {0} kpc".format( - pop.zscale) + pop.sisigma)) + print("\t\tGalactic z scale height = {0} kpc".format( + pop.zscale)) if widthModel is None: - print "\t\tWidth {0}% ".format(duty) + print("\t\tWidth {0}% ".format(duty)) else: - print "\t\tUsing Karastergiou & Johnston beam width model" + print("\t\tUsing Karastergiou & Johnston beam width model") # set up progress bar for fun :) prog = ProgressBar(min_value=0, @@ -228,7 +231,7 @@ def generate(ngen, """ else: - print "Undefined width model!" + print("Undefined width model!") sys.exit() # print width # print pulsar.period, width, pulsar.pdot @@ -338,7 +341,7 @@ def generate(ngen, # update the counter if not nostdout: prog.increment_amount() - print prog, '\r', + print(prog, '\r',) sys.stdout.flush() else: @@ -348,7 +351,7 @@ def generate(ngen, # update the counter if not nostdout: prog.increment_amount() - print prog, '\r', + print(prog, '\r',) sys.stdout.flush() # pulsar isn't dead, add to population! @@ -362,20 +365,20 @@ def generate(ngen, # update the counter if not nostdout: prog.increment_amount() - print prog, '\r', + print(prog, '\r',) sys.stdout.flush() if not nostdout: - print "\n\n" - print " Total pulsars = {0}".format(len(pop.population)) - print " Total detected = {0}".format(pop.ndet) + print("\n\n") + print(" Total pulsars = {0}".format(len(pop.population))) + print(" Total detected = {0}".format(pop.ndet)) for surv in surveys: - print "\n Results for survey '{0}'".format(surv.surveyName) - print " Number detected = {0}".format(surv.ndet) - print " Number too faint = {0}".format(surv.ntf) - print " Number smeared = {0}".format(surv.nsmear) - print " Number outside survey area = {0}".format(surv.nout) + print("\n Results for survey '{0}'".format(surv.surveyName)) + print(" Number detected = {0}".format(surv.ndet)) + print(" Number too faint = {0}".format(surv.ntf)) + print(" Number smeared = {0}".format(surv.nsmear)) + print(" Number outside survey area = {0}".format(surv.nout)) # save list of arguments into the pop #try: diff --git a/lib/python/galacticops.py b/lib/python/galacticops.py index 5035c32..f9a2010 100755 --- a/lib/python/galacticops.py +++ b/lib/python/galacticops.py @@ -11,16 +11,16 @@ # get the FORTRAN libraries __dir__ = os.path.dirname(os.path.abspath(__file__)) __libdir__ = os.path.dirname(__dir__) -fortranpath = os.path.join(__libdir__, 'fortran') -Cpath = os.path.join(__libdir__, 'C') +fortranpath = os.path.join(__libdir__, 'fortran').encode() +Cpath = os.path.join(__libdir__, 'C').encode() -ne2001lib = C.CDLL(os.path.join(fortranpath, 'libne2001.so')) +ne2001lib = C.CDLL(os.path.join(fortranpath, 'libne2001.so'.encode())) ne2001lib.dm_.restype = C.c_float -slalib = C.CDLL(os.path.join(fortranpath, 'libsla.so')) -vxyzlib = C.CDLL(os.path.join(fortranpath, 'libvxyz.so')) +slalib = C.CDLL(os.path.join(fortranpath, 'libsla.so'.encode())) +vxyzlib = C.CDLL(os.path.join(fortranpath, 'libvxyz.so'.encode())) -yklib = C.CDLL(os.path.join(fortranpath, 'libykarea.so')) +yklib = C.CDLL(os.path.join(fortranpath, 'libykarea.so'.encode())) yklib.ykr_.restype = C.c_float yklib.llfr_.restype = C.c_float @@ -63,8 +63,9 @@ def vxyz(pulsar): pulsar.vz = vz.value -def calc_dtrue((x, y, z)): - """Calculate true distance to pulsar from the sun.""" +def calc_dtrue(cart_pos): + """Calculate true distance to pulsar from the sun. ip cart_pos should be tuple with (x,y,z)""" + x, y, z = cart_pos rsun = 8.5 # kpc return math.sqrt(x*x + (y-rsun)*(y-rsun) + z*z) @@ -209,8 +210,9 @@ def radec_to_lb(ra, dec): return l.value, b.value -def xyz_to_lb((x, y, z)): +def xyz_to_lb(cart_pos): """ Convert galactic xyz in kpc to l and b in degrees.""" + x, y, z = cart_pos rsun = 8.5 # kpc # distance to pulsar @@ -382,7 +384,7 @@ def _double_sided_exp(scale, origin=0.0): def readtskyfile(): """Read in tsky.ascii into a list from which temps can be retrieved""" - tskypath = os.path.join(fortranpath, 'lookuptables/tsky.ascii') + tskypath = os.path.join(fortranpath, 'lookuptables/tsky.ascii'.encode()) tskylist = [] with open(tskypath) as f: for line in f: diff --git a/lib/python/orbitalparams.py b/lib/python/orbitalparams.py index 70210b1..13952b9 100644 --- a/lib/python/orbitalparams.py +++ b/lib/python/orbitalparams.py @@ -17,10 +17,10 @@ def test_1802_2124(pulsar): pulsar.inclination_degrees = 78.52 pulsar.pulsar_mass_msolar = 1.24 - print pulsar.gb, pulsar.gl + print(pulsar.gb, pulsar.gl) pulsar.gb = 0.61 pulsar.gl = 4.38 - print pulsar.gb, pulsar.gl + print(pulsar.gb, pulsar.gl) pulsar.galcoords = (0.49, 5.2, 0.04) pulsar.lum_1400 = 8.54 pulsar.t_scatter = 0.0 diff --git a/lib/python/populate.py b/lib/python/populate.py index 93184f0..d4a4167 100755 --- a/lib/python/populate.py +++ b/lib/python/populate.py @@ -6,7 +6,6 @@ import random import inspect -import cPickle import numpy as np import distributions as dists @@ -21,6 +20,11 @@ from progressbar import ProgressBar +if sys.version_info[0] < 3: + import cPickle +else: + import pickle as cPickle + class PopulateException(Exception): pass @@ -39,8 +43,8 @@ def generate(ngen, zscale=0.33, duty_percent=6., scindex=-3.86, - gpsArgs=[None, None], - doubleSpec=[None, None], + gpsArgs=[-1, -1], + doubleSpec=[-1, -1], nostdout=False, pattern='gaussian', orbits=False, @@ -50,6 +54,8 @@ def generate(ngen, accelsearch=False, jerksearch=False, sig_factor=10.0, + bns = False, + orbparams = {'m': [1, 5], 'm1': [1.0, 2.4], 'm2': [0.2, 1e9], 'om': [0, 360.], 'inc': [0, 90], 'ec': [0., 1.], 'pod': [1e-3, 1e3]}, brDistType='log_unif'): """ @@ -76,38 +82,38 @@ def generate(ngen, # check that the distribution types are supported.... if 'd_g' in (pDistType,lumDistType,zscaleType,radialDistType,brDistType) and dgf is None: - print "Provide the distribution generation file" + print("Provide the distribution generation file") sys.exit() elif dgf != None: try: f = open(dgf, 'rb') except IOError: - print "Could not open file {0}.".format(dgf) + print("Could not open file {0}.".format(dgf)) sys.exit() dgf_pop_load = cPickle.load(f) f.close() if lumDistType not in ['lnorm', 'pow', 'log_unif', 'd_g', 'log_st']: - print "Unsupported luminosity distribution: {0}".format(lumDistType) + print("Unsupported luminosity distribution: {0}".format(lumDistType)) if brDistType not in ['log_unif', 'd_g']: - print "Unsupported burst rate distribution: {0}".format(brDistType) + print("Unsupported burst rate distribution: {0}".format(brDistType)) if pDistType not in ['lnorm', 'norm', 'cc97', 'lorimer12','unif', 'd_g']: - print "Unsupported period distribution: {0}".format(pDistType) + print("Unsupported period distribution: {0}".format(pDistType)) if radialDistType not in ['lfl06', 'yk04', 'isotropic', 'slab', 'disk','unif' ,'gauss','d_g', 'gamma']: - print "Unsupported radial distribution: {0}".format(radialDistType) + print("Unsupported radial distribution: {0}".format(radialDistType)) if electronModel not in ['ne2001', 'lmt85','ymw16']: - print "Unsupported electron model: {0}".format(electronModel) + print("Unsupported electron model: {0}".format(electronModel)) if pattern not in ['gaussian', 'airy']: - print "Unsupported gain pattern: {0}".format(pattern) + print("Unsupported gain pattern: {0}".format(pattern)) if duty_percent < 0.: - print "Unsupported value of duty cycle: {0}".format(duty_percent) + print("Unsupported value of duty cycle: {0}".format(duty_percent)) # need to use properties in this class so they're get/set-type props pop.pDistType = pDistType @@ -121,6 +127,10 @@ def generate(ngen, pop.gpsFrac, pop.gpsA = gpsArgs pop.brokenFrac, pop.brokenSI = doubleSpec + + #Set whether system is BNS: + pop.bns = bns + pop.orbparams = orbparams if pop.lumDistType == 'lnorm': pop.lummean, pop.lumsigma = \ @@ -148,14 +158,19 @@ def generate(ngen, # store the dict of arguments inside the model. Could be useful. try: - argspec = inspect.getargspec(generate) - key_values = [(arg, locals()[arg]) for arg in argspec.args] + if sys.version_info[0] > 3: + argspec = inspect.getfullargspec(generate) + else: + argspec = inspect.getargspec(generate) + lcl = locals() + key_values = [(arg, lcl[arg]) for arg in argspec.args] + #key_values = [(arg, locals()['argspec'][arg]) for arg in argspec.args] #pop.arguments = {key: value for (key, value) in key_values} except SyntaxError: pass if not nostdout: - print "\tGenerating pulsars with parameters:" + print("\tGenerating pulsars with parameters:") param_string_list = [] for key, value in key_values: s = ": ".join([key, str(value)]) @@ -163,7 +178,7 @@ def generate(ngen, # join this list of strings, and print it s = "\n\t\t".join(param_string_list) - print "\t\t{0}".format(s) + print("\t\t{0}".format(s)) # set up progress bar for fun :) prog = ProgressBar(min_value=0, @@ -203,7 +218,7 @@ def generate(ngen, elif pop.pDistType == 'cc97': p.period = _cc97() elif pop.pDistType == 'gamma': - print "Gamma function not yet supported" + print("Gamma function not yet supported") sys.exit() elif pop.pDistType == 'd_g': Pbin_num=dists.draw1d(dgf_pop_load['pHist']) @@ -251,7 +266,7 @@ def generate(ngen, # AND double spectra. But for now I assume only have one or # none of these types. if random.random() > pop.gpsFrac: - # This will evaluate true when gpsArgs[0] is NoneType + # This will evaluate true when gpsArgs[0] is -1 # might have to change in future p.gpsFlag = 0 else: @@ -362,11 +377,32 @@ def generate(ngen, logl = lmin + (lmax-lmin)*(lbin_num+random.random())/len(dgf_pop_load['lHist']) p.lum_1400 = 10.0**logl p.lum_inj_mu=p.lum_1400 - + # add in orbital parameters - if orbits: - orbitalparams.test_1802_2124(p) - print p.gb, p.gl + if pop.bns: + + assert isinstance(orbparams, dict), "Orbital parameter distribution limits should be a dictionary of form {'name of orb_param': [min, max]}" + + #These represents the range in which NN was trained. + #DO NOT GO OUTSIDE THESE BOUNDS!! + default_orbparams = {'m': [1, 5], 'm1': [1.0, 2.4], 'm2': [0.2, 1e9], 'om': [0, 360.], 'inc': [0, 90], 'ec': [0., 1.], 'pod': [1e-3, 1e3]} + + if len(pop.orbparams) == 0: + print("Warning: Supplied orbparams dict is empty; Setting ranges to default") + pop.orbparams = default_orbparams + else: + temp_opd = dict(default_orbparams) + temp_opd.update(orbparams) + pop.orbparams = temp_opd + + #Draw a value for each of the orbital parameters from a uniform distribution + p.m = np.int(np.random.uniform(pop.orbparams['m'][0], pop.orbparams['m'][1], size = 1)) #Should typically fix this to one value! + p.m1 = np.random.uniform(pop.orbparams['m1'][0], pop.orbparams['m1'][1], size = 1) + p.m2 = np.random.uniform(pop.orbparams['m2'][0], pop.orbparams['m2'][1], size = 1) + p.om = np.random.uniform(pop.orbparams['om'][0], pop.orbparams['om'][1], size = 1) + p.inc = np.random.uniform(pop.orbparams['inc'][0], pop.orbparams['inc'][1], size = 1) + p.ec = np.random.uniform(pop.orbparams['ec'][0], pop.orbparams['ec'][1], size = 1) + p.pod = np.random.uniform(pop.orbparams['pod'][0], pop.orbparams['pod'][1], size = 1) #dither the distance if dither: @@ -415,7 +451,7 @@ def generate(ngen, pop.ndet += 1 if not nostdout: prog.increment_amount() - print prog, '\r', + print(prog, '\r',) sys.stdout.flush() # if surveys are given, check if pulsar detected or not # in ANY of the surveys @@ -474,24 +510,24 @@ def generate(ngen, pop.ndet += 1 if not nostdout: prog.increment_amount() - print prog, '\r', + print(prog, '\r',) sys.stdout.flush() # print info to stdout if not nostdout: - print "\n" - print " Total pulsars = {0}".format(len(pop.population)) - print " Total detected = {0}".format(pop.ndet) + print("\n") + print(" Total pulsars = {0}".format(len(pop.population))) + print(" Total detected = {0}".format(pop.ndet)) # print " Number not beaming = {0}".format(surv.nnb) for surv in surveys: - print "\n Results for survey '{0}'".format(surv.surveyName) - print " Number detected = {0}".format(surv.ndet) - print " Number too faint = {0}".format(surv.ntf) - print " Number smeared = {0}".format(surv.nsmear) - print " Number outside survey area = {0}".format(surv.nout) + print("\n Results for survey '{0}'".format(surv.surveyName)) + print(" Number detected = {0}".format(surv.ndet)) + print(" Number too faint = {0}".format(surv.ntf)) + print(" Number smeared = {0}".format(surv.nsmear)) + print(" Number outside survey area = {0}".format(surv.nout)) if singlepulse: - print " Number didn't burst = {0}".format(surv.nbr) + print(" Number didn't burst = {0}".format(surv.nbr)) return pop @@ -676,12 +712,12 @@ def _sindegree(angle): # GPS sources parser.add_argument('-gps', type=float, nargs=2, required=False, - default=[None, None], + default=[-1, -1], help='GPS fraction and "a" value') # double-spectral-index sources parser.add_argument('-doublespec', type=float, nargs=2, required=False, - default=[None, None], + default=[-1, -1], help='Dbl spec fraction and alpha value') # dist_gen_file parser.add_argument('-dgf', type=str,metavar='dist_gen_file', required= False, diff --git a/lib/python/population.py b/lib/python/population.py index 32d6eb6..0a3d80b 100755 --- a/lib/python/population.py +++ b/lib/python/population.py @@ -1,10 +1,13 @@ #!/usr/bin/python -import copy -import cPickle +import copy, sys import numpy as np +if sys.version_info[0] < 3: + import cPickle +else: + import pickle as cPickle class Population: @@ -22,10 +25,12 @@ def __init__(self, lumsigma=None, zscale=None, electronModel=None, - gpsFrac=None, + gpsFrac=-1, gpsA=None, brokenFrac=None, brokenSI=None, + bns = False, + orbparams = {}, ref_freq=1400.0): """Initialise the population object.""" @@ -52,7 +57,11 @@ def __init__(self, self.zscale = zscale self.ref_freq = ref_freq - + + #Set whether we are looking at BNS systems: + self.bns = bns + self.orbparams = orbparams + # GPS and double SI values self.gpsFrac = gpsFrac self.gpsA = gpsA diff --git a/lib/python/progressbar.py b/lib/python/progressbar.py index c5dc54c..2755336 100644 --- a/lib/python/progressbar.py +++ b/lib/python/progressbar.py @@ -95,29 +95,29 @@ def __str__(self): def main(): - print + print() limit = 1000000 - print 'Example 1: Fixed Bar' + print('Example 1: Fixed Bar') prog = ProgressBar(0, limit, 77, mode='fixed') oldprog = str(prog) for i in xrange(limit+1): prog.update_amount(i) if oldprog != str(prog): - print prog, "\r", + print(prog, "\r",) sys.stdout.flush() oldprog = str(prog) - print '\n\n' + print('\n\n') - print 'Example 2: Dynamic Bar' + print('Example 2: Dynamic Bar') prog = ProgressBar(0, limit, 77, mode='dynamic', char='-') oldprog = str(prog) for i in xrange(limit+1): prog.increment_amount() if oldprog != str(prog): - print prog, "\r", + print(prog, "\r",) sys.stdout.flush() oldprog = str(prog) - print '\n\n' + print('\n\n') diff --git a/lib/python/pulsar.py b/lib/python/pulsar.py index 6c0b4f3..a230531 100644 --- a/lib/python/pulsar.py +++ b/lib/python/pulsar.py @@ -37,6 +37,14 @@ def __init__(self, brokenSI=None, br=None, det_nos=None, + m = 1, # "n"th harmonic; required for orb_degfac calculation + m1 = 1.4, #Mass of psr; required for orb_degfac calculation + m2 = 1.4, #Mass of companion; required for orb_degfac calculation + om = 90., #angle of periastron passage (omega_per); required for orb_degfac calculation + inc = 90., #inclincation of bns system; required for orb_degfac calculation + ec = 0.01, #eccentricity of bns system; required for orb_degfac calculation + pod = 0.1, #orbital period of bns system; required for orb_degfac calculation + orb_degfac = 1.0, #Add in orbital degradation factor for each pulsar *args, **kwargs): """___init___ function for the Pulsar class""" @@ -49,8 +57,9 @@ def __init__(self, self.dm = dm # convert to -180->+180 range - if gl > 180.: - gl -= 360. + if gl: + if gl > 180.: + gl -= 360. self.gl = gl self.gb = gb @@ -90,6 +99,18 @@ def __init__(self, # need to add pulsar dead/alive for evolution code self.dead = False + + #Set the orbital parameters: + self.m = m + self.m1 = m1 + self.m2 = m2 + self.om = om + self.inc = inc + self.ec = ec + self.pod = pod + + #Set the orbital degradation factor: + self.orb_degfac = orb_degfac # methods to calculate derived properties def s_1400(self): diff --git a/lib/python/survey.py b/lib/python/survey.py index 5f3a634..e4a1145 100644 --- a/lib/python/survey.py +++ b/lib/python/survey.py @@ -273,7 +273,7 @@ def __init__(self, surveyName, pattern='gaussian'): # turn on AA self.AA = True else: - print "Parameter '", a[1].strip(), "' not recognized!" + print("Parameter '", a[1].strip(), "' not recognized!") f.close() @@ -385,8 +385,8 @@ def SNRcalc(self, # (loops over the list of pointings....) if rratssearch: if pulsar.br is None: - print "Population doesn't have a burst rate" - print "Use populate with --singlepulse" + print("Population doesn't have a burst rate") + print("Use populate with --singlepulse") sys.exit() pulsar.pop_time=np.random.poisson(pulsar.br*self.tobs) @@ -492,39 +492,40 @@ def SNRcalc(self, if pulsar.is_binary: # print "the pulsar is a binary!" if jerksearch: - print "jerk" + #print "jerk" gamma = degradation.gamma3(pulsar, self.tobs, 1) elif accelsearch: - print "accel" + #print "accel" gamma = degaadation.gamma2(pulsar, self.tobs, 1) else: - print "norm" + #print "norm" gamma = degradation.gamma1(pulsar, self.tobs, 1) - print "gamma harm1 = ", gamma + #print "gamma harm1 = ", gamma gamma = degradation.gamma1(pulsar, self.tobs, 2) - print "gamma harm2 = ", gamma + #print "gamma harm2 = ", gamma gamma = degradation.gamma1(pulsar, self.tobs, 3) - print "gamma harm3 = ", gamma + #print "gamma harm3 = ", gamma gamma = degradation.gamma1(pulsar, self.tobs, 4) - print "gamma harm4 = ", gamma + #print "gamma harm4 = ", gamma # return the S/N accounting for beam offset + return sig_to_noise * degfac def _AA_factor(self, pulsar): diff --git a/lib/python/two_hist_plotter.py b/lib/python/two_hist_plotter.py index ffe8e1b..e33ff50 100644 --- a/lib/python/two_hist_plotter.py +++ b/lib/python/two_hist_plotter.py @@ -33,7 +33,7 @@ def plot_these(x,y,fit=False,func=None,p0=None,label1=None,label2=None,show=True #print injeted mu, recovered mu, err mu and sigma if print_res is True: - print p0[1],par3[1],err3[1],p0[2],par3[2],err3[2] + print(p0[1],par3[1],err3[1],p0[2],par3[2],err3[2]) except RuntimeError: pass plt.xlabel("Luminosity")