-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error estimation and testing of same
- Loading branch information
Showing
6 changed files
with
752 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
pass | ||
|
||
import pint.profile.fftfit_aarchiba | ||
import pint.profile.fftfit_nustar | ||
import pint.profile.fftfit_presto | ||
|
||
def fftfit_full(template, profile, code="aarchiba"): | ||
if code=="aarchiba": | ||
return pint.profile.fftfit_aarchiba.fftfit_full(template, profile) | ||
elif code=="nustar": | ||
return pint.profile.fftfit_nustar.fftfit_full(template, profile) | ||
elif code=="presto": | ||
if pint.profile.fftfit_presto.presto is None: | ||
raise ValueError("The PRESTO compiled code is not available") | ||
return pint.profile.fftfit_presto.fftfit_full(template, profile) | ||
else: | ||
raise ValueError("Unrecognized FFTFIT implementation {}".format(code)) | ||
|
||
def fftfit_basic(template, profile, code="aarchiba"): | ||
if code=="aarchiba": | ||
return pint.profile.fftfit_aarchiba.fftfit_basic(template, profile) | ||
else: | ||
return fftfit_full(template, profile, code=code).shift | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import numpy as np | ||
from numpy.fft import rfft | ||
from pint.profile.fftfit_aarchiba import wrap | ||
|
||
try: | ||
import presto.fftfit | ||
except ImportError: | ||
presto = None | ||
|
||
class FFTFITResult: | ||
pass | ||
|
||
def fftfit_full(template, profile): | ||
if len(template) != len(profile): | ||
raise ValueError("template has length {} but profile has length {}".format(len(template),len(profile))) | ||
if len(template) > 2**13: | ||
raise ValueError("template has length {} which is too long".format(len(template))) | ||
tc = rfft(template) | ||
shift, eshift, snr, esnr, b, errb, ngood = presto.fftfit.fftfit(profile, np.abs(tc)[1:], -np.angle(tc)[1:]) | ||
r = FFTFITResult() | ||
# Need to add 1 to the shift for some reason | ||
r.shift = wrap((shift + 1)/len(template)) | ||
r.uncertainty = eshift/len(template) | ||
return r | ||
|
||
def fftfit_basic(template, profile): | ||
return fftfit_full(template, profile).shift | ||
|
Oops, something went wrong.