Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
master_doc = 'index'

# General information about the project.
project = u'PsrPopPy'
copyright = u'2012, S Bates'
project = 'PsrPopPy'
copyright = '2012, S Bates'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -183,8 +183,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'PsrPopPy.tex', u'PsrPopPy Documentation',
u'S Bates', 'manual'),
('index', 'PsrPopPy.tex', 'PsrPopPy Documentation',
'S Bates', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -213,8 +213,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'psrpoppy', u'PsrPopPy Documentation',
[u'S Bates'], 1)
('index', 'psrpoppy', 'PsrPopPy Documentation',
['S Bates'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -227,8 +227,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'PsrPopPy', u'PsrPopPy Documentation',
u'S Bates', 'PsrPopPy', 'One line description of project.',
('index', 'PsrPopPy', 'PsrPopPy Documentation',
'S Bates', 'PsrPopPy', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
4 changes: 2 additions & 2 deletions examples/ppdot.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/python

import sys
import cPickle
import pickle

import matplotlib.pyplot as plt

# open file, read in model
filename = sys.argv[1]
f = open(filename, 'rb')
pop = cPickle.load(f)
pop = pickle.load(f)
f.close()

# lists to store p/pdot
Expand Down
10 changes: 5 additions & 5 deletions psrpoppy/dataobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os

import cPickle
import pickle


class DataObj:
Expand Down Expand Up @@ -46,13 +46,13 @@ def readfile_return_dataobj(filename):
try:
f = open(filename, 'rb')
except IOError:
print "Could not open file {0}.".format(filename)
print(("Could not open file {0}.".format(filename)))
return

try:
pop = cPickle.load(f)
except cPickle.UnpicklingError:
print "File {0} could not be unpickled!".format(filename)
pop = pickle.load(f)
except pickle.UnpicklingError:
print(("File {0} could not be unpickled!".format(filename)))
return
f.close()

Expand Down
30 changes: 15 additions & 15 deletions psrpoppy/dosurvey.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import math
import random

import cPickle
import pickle

try:
# try and import from the current path (for package usage or use as an uninstalled executable)
from population import Population
from pulsar import Pulsar
from survey import Survey
from .population import Population
from .pulsar import Pulsar
from .survey import Survey
except:
try:
# import from the installed package
Expand Down Expand Up @@ -42,7 +42,7 @@ def loadModel(popfile='populate.model', popmodel=None):
or pass in a model from memory (popmodel)"""
if popmodel is None:
with open(popfile, 'rb') as f:
pop = cPickle.load(f)
pop = pickle.load(f)
else:
pop = popmodel

Expand Down Expand Up @@ -97,16 +97,16 @@ 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 = []
for surv in surveyList:
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()
Expand Down Expand Up @@ -154,13 +154,13 @@ 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 "\n"
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("\n")

d = Detections(ndet=ndet,
ntf=ntf,
Expand Down
74 changes: 37 additions & 37 deletions psrpoppy/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
import random

import inspect
import cPickle
import pickle
import scipy.integrate
import numpy as np

try:
# try and import from the current path (for package usage or use as an uninstalled executable)
import distributions as dists
import galacticops as go
import beaming as beammodels
import populate
from . import distributions as dists
from . import galacticops as go
from . import beaming as beammodels
from . import populate

from population import Population
from pulsar import Pulsar
from survey import Survey
from .population import Population
from .pulsar import Pulsar
from .survey import Survey

from progressbar import ProgressBar
from .progressbar import ProgressBar
except:
try:
# import from the installed package
Expand Down Expand Up @@ -109,30 +109,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,
Expand Down Expand Up @@ -233,7 +233,7 @@ def generate(ngen,
"""

else:
print "Undefined width model!"
print("Undefined width model!")
sys.exit()
# print width
# print pulsar.period, width, pulsar.pdot
Expand Down Expand Up @@ -343,7 +343,7 @@ def generate(ngen,
# update the counter
if not nostdout:
prog.increment_amount()
print prog, '\r',
print(prog, '\r', end=' ')
sys.stdout.flush()

else:
Expand All @@ -353,7 +353,7 @@ def generate(ngen,
# update the counter
if not nostdout:
prog.increment_amount()
print prog, '\r',
print(prog, '\r', end=' ')
sys.stdout.flush()

# pulsar isn't dead, add to population!
Expand All @@ -367,20 +367,20 @@ def generate(ngen,
# update the counter
if not nostdout:
prog.increment_amount()
print prog, '\r',
print(prog, '\r', end=' ')
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:
Expand Down
6 changes: 4 additions & 2 deletions psrpoppy/galacticops.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def vxyz(pulsar):
pulsar.vz = vz.value


def calc_dtrue((x, y, z)):
def calc_dtrue(xxx_todo_changeme):
"""Calculate true distance to pulsar from the sun."""
(x, y, z) = xxx_todo_changeme
rsun = 8.5 # kpc
return math.sqrt(x*x + (y-rsun)*(y-rsun) + z*z)

Expand Down Expand Up @@ -198,8 +199,9 @@ def radec_to_lb(ra, dec):
return l.value, b.value


def xyz_to_lb((x, y, z)):
def xyz_to_lb(xxx_todo_changeme1):
""" Convert galactic xyz in kpc to l and b in degrees."""
(x, y, z) = xxx_todo_changeme1
rsun = 8.5 # kpc

# distance to pulsar
Expand Down
4 changes: 2 additions & 2 deletions psrpoppy/orbitalparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading