Skip to content

Commit

Permalink
# This is a combination of 24 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:
Merge branch 'development' into SN_flux_est

# This is the commit message #2:

Fixed small bug and merge conflicts

# This is the commit message #3:

Added sn_flux_est.py to setup.py so it's installed

# This is the commit message #4:

Made the travis.yml testing install mwa_pulsar_client

# This is the commit message #5:

Added a password so we can clone private repos

# This is the commit message #6:

Added the CMD_VCS_DB_FILE environmental varaible to the travis.yml to stop crashes

# This is the commit message #7:

Added the glob module

# This is the commit message #8:

Got rid of a useless config load

# This is the commit message #9:

Fixed base path bug

# This is the commit message #10:

Fixed the ondisk file checker

# This is the commit message #11:

Fixed up the pulsar_beam_coverage function and changes all the logger.warn to logger.warning in sn_flux_est.py

# This is the commit message #12:

Fixed up the tests of sn_flux_est.py

# This is the commit message #13:

Fixed up codacy issues (most whitespace and unused)

# This is the commit message #14:

Fixed a bug with nans

# This is the commit message #15:

Merge branch 'SN_flux_est' of https://github.com/CIRA-Pulsars-and-Transients-Group/vcstools into SN_flux_est

# This is the commit message #16:

Some Codacy fixes

# This is the commit message #17:

Fixed an error for the travis.yml testing that wasn't correctly passing the file location of the reciever tempurature file

# This is the commit message #18:

Removed an image that shouldn't of been uploaded

# This is the commit message #19:

added some debugging to sn_flux_est

# This is the commit message #20:

Sped up metadta and ATNF calls. Fixed the tests because they changed slightly

# This is the commit message #21:

Merge branch 'SN_flux_est' of https://github.com/CIRA-Pulsars-and-Transients-Group/vcstools into SN_flux_est

# This is the commit message #22:

Fixed a typo in utils/sn_flux_est.py

# This is the commit message #23:

Added an extra test of est_pulsar_sn that caused a nonetype error

# This is the commit message #24:

Changed the default inputs of fit_plaw_psr so they're no longer lists as it was causing errors
  • Loading branch information
NickSwainston committed Oct 25, 2019
1 parent fb71884 commit 06158a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/test_sn_flux_est.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_find_pulsar_w50():
Tests the find_pulsar_w50 function
"""
test_cases=[]
test_cases.append(("J1614-2230", 2.3581508027839326e-06, 1.9651256689866104e-06))
test_cases.append(("J2241-5236", 7.0000000000000007e-05, 3.5000000000000004e-06))
test_cases.append(("J0206-4028", 0.0049000000000000007, 0.00024500000000000005))
test_cases.append(("J2222-0137", 0.00056999999999999998, 5.0000000000000004e-06))
Expand All @@ -117,6 +118,12 @@ def test_est_pulsar_flux():
flux, flux_err = snfe.est_pulsar_flux(psr, obsid)
assert_almost_equal(exp_flux, flux, decimal=6)
assert_almost_equal(exp_flux_err, flux_err, decimal=6)
#adding a test that gave a none type error for alpha_bound, c_bound
flux, flux_err = snfe.est_pulsar_sn('J1623-2631', 1117643248,
beg=1117643268, end=1117645615,
enter=0.000, exit=0.842)
assert_almost_equal(54.87670949932577, flux, decimal=6)
assert_almost_equal(10.834221841785626, flux_err, decimal=6)

def test_est_pulsar_sn():
"""
Expand Down
12 changes: 9 additions & 3 deletions utils/sn_flux_est.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def pulsar_beam_coverage(obsid, pulsar, beg=None, end=None, ondisk=False):
return enter_files, exit_files

#---------------------------------------------------------------
def fit_plaw_psr(x_data, y_data, alpha_initial=-1.5, c_initial = 30., alpha_bound=[-3., 0.],\
c_bound=[0., 50.]):
def fit_plaw_psr(x_data, y_data, alpha_initial=-1.5, c_initial = 30., alpha_bound=None,
c_bound=None):
"""
Used primarily by est_pulsar_flux() to fit a power law function to input data. Intended for use with pulsar flux densities
Expand Down Expand Up @@ -273,6 +273,12 @@ def fit_plaw_psr(x_data, y_data, alpha_initial=-1.5, c_initial = 30., alpha_boun
covar_matrix: np.matrix
The covariance matrix of the fit. Contains the information required to for uncertainty calculations
"""
# Parse defaults
if alpha_bound is None:
alpha_bound = [-3., 0.]
if c_bound is None:
c_bound = [0., 50.]

def log_plaw_func(nu, a, c):
#pass the log values of nu
return np.exp(a * np.log(nu) + c)
Expand Down Expand Up @@ -559,7 +565,7 @@ def find_pulsar_w50(pulsar, query=None):
#We will nflate this error due to differing frequencies and pulsar behaviour. W_50_err=1. degrees
coeff = 4.8
coeff_err = 2.
period = float(period_query["P0"][0])
period = float(query["P0"][0])

#This estimation is worse for msps, add extra uncetainty if period < 50ms
if period <0.05:
Expand Down

0 comments on commit 06158a3

Please sign in to comment.