Skip to content

Commit

Permalink
Fixed and improved imports
Browse files Browse the repository at this point in the history
  • Loading branch information
scottransom committed Nov 16, 2019
1 parent 3655f29 commit 8b9b8a8
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 68 deletions.
1 change: 1 addition & 0 deletions python/presto/Pgplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
where this file was found: ftp://cfa-ftp.harvard.edu/pub/ransom
"""
from __future__ import print_function
from __future__ import absolute_import
from builtins import range
from builtins import object
import sys
Expand Down
38 changes: 38 additions & 0 deletions python/presto/parfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,44 @@ def __str__(self):
out += "%10s = %-20.15g\n" % (k, v)
return out


def ELL1_check(par_file, output=False):
"""
ELL1_check(par_file):
Check the parfile to see if ELL1 can be safely used as the
binary model. To work properly, we should have:
asini/c * ecc**2 << timing precision / sqrt(# TOAs)
"""
psr = psr_par(par_file)
try:
lhs = psr.A1 * psr.E ** 2.0 * 1e6
except:
if output:
print("Can't compute asini/c * ecc**2, maybe parfile doesn't have a binary?")
return
try:
rhs = psr.TRES / Num.sqrt(psr.NTOA)
except:
if output:
print("Can't compute TRES / sqrt(# TOAs), maybe this isn't a TEMPO output parfile?")
return
if output:
print("Condition is asini/c * ecc**2 << timing precision / sqrt(# TOAs) to use ELL1:")
print(" asini/c * ecc**2 = %8.3g us" % lhs)
print(" TRES / sqrt(# TOAs) = %8.3g us" % rhs)
if lhs * 50.0 < rhs:
if output:
print("Should be fine.")
return True
elif lhs * 5.0 < rhs:
if output:
print("Should be OK, but not optimal.")
return True
else:
if output:
print("Should probably use BT or DD instead.")
return False

if __name__ == '__main__':
a = psr_par("2140-2310A.par")
print(a)
1 change: 0 additions & 1 deletion python/presto/psr_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
Rsun = float('6.9551e8') # m
Rearth = float('6.378e6') # m
SOL = float('299792458.0') # m/s
MSUN = float('1.989e+30') # kg
G = float('6.673e-11') # m^3/s^2/kg
C = SOL
Loading

0 comments on commit 8b9b8a8

Please sign in to comment.