diff --git a/examples/computing_the_Bayes_factor.py b/examples/computing_the_Bayes_factor.py index 76d92564b807abec9c2b33575d863b0ab8c79f9e..69129607339640302f7e1ae201711008520a69f3 100644 --- a/examples/computing_the_Bayes_factor.py +++ b/examples/computing_the_Bayes_factor.py @@ -24,7 +24,7 @@ nwalkers = 100 nsteps = [500, 500] mcmc = MCMCSearch(label='computing_the_Bayes_factor', outdir='data', - sftfilepath='data/*basic*sft', theta_prior=theta_prior, + sftfilepattern='data/*basic*sft', theta_prior=theta_prior, tref=tref, tstart=tstart, tend=tend, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) diff --git a/examples/follow_up.py b/examples/follow_up.py index cfd8575952dbc0c4c88c6cb2c85a021e2f5db4d5..d79b9a66068a8920a76478c113a902f442d1006a 100644 --- a/examples/follow_up.py +++ b/examples/follow_up.py @@ -26,7 +26,7 @@ run_setup = [(1000, 50), (1000, 25), (1000, 1, False), mcmc = pyfstat.MCMCFollowUpSearch( label='follow_up', outdir='data', - sftfilepath='data/*basic*sft', theta_prior=theta_prior, tref=tref, + sftfilepattern='data/*basic*sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) mcmc.run(run_setup) diff --git a/examples/fully_coherent_search_using_MCMC.py b/examples/fully_coherent_search_using_MCMC.py index 4a6bdf48e8992e884298dd423e5911bc93afecb0..254f79106051b8c1bd219e14a08489246553ff67 100644 --- a/examples/fully_coherent_search_using_MCMC.py +++ b/examples/fully_coherent_search_using_MCMC.py @@ -53,7 +53,7 @@ nsteps = [50, 50] mcmc = pyfstat.MCMCSearch( label='fully_coherent_search_using_MCMC', outdir='data', - sftfilepath='data/*'+data_label+'*sft', theta_prior=theta_prior, tref=tref, + sftfilepattern='data/*'+data_label+'*sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) mcmc.run(context='paper', subtractions=[30, -1e-10]) diff --git a/examples/fully_coherent_search_using_MCMC_on_glitching_data.py b/examples/fully_coherent_search_using_MCMC_on_glitching_data.py index 75c35cbd33573b335737771964d9b172fb7aefbc..3b9b60a3bbeb0f624027cebea6e9376ca483811e 100644 --- a/examples/fully_coherent_search_using_MCMC_on_glitching_data.py +++ b/examples/fully_coherent_search_using_MCMC_on_glitching_data.py @@ -26,7 +26,7 @@ nwalkers = 100 nsteps = [500, 500] mcmc = MCMCSearch('fully_coherent_search_using_MCMC_on_glitching_data', 'data', - sftfilepath='data/*_glitch*.sft', + sftfilepattern='data/*_glitch*.sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) diff --git a/examples/glitch_robust_search.py b/examples/glitch_robust_search.py index 86e16b7736587f834b4549443c1824993bc0fbf5..731fb83a7fb3df59c1dcf98f4b528c62e1d2253e 100644 --- a/examples/glitch_robust_search.py +++ b/examples/glitch_robust_search.py @@ -17,7 +17,7 @@ Delta = np.radians(22.0144) tref = tstart + .5 * Tspan -sftfilepath = 'data/*glitching_signal*sft' +sftfilepattern = 'data/*glitching_signal*sft' F0_width = np.sqrt(3)/(np.pi*Tspan) F1_width = np.sqrt(45/4.)/(np.pi*Tspan**2) @@ -45,7 +45,7 @@ theta_prior = {'F0': {'type': 'unif', } search = pyfstat.MCMCGlitchSearch( - label=label, outdir=outdir, sftfilepath=sftfilepath, + label=label, outdir=outdir, sftfilepattern=sftfilepattern, theta_prior=theta_prior, nglitch=1, tref=tref, nsteps=[500, 500], ntemps=3, log10temperature_min=-0.5, minStartTime=tstart, maxStartTime=tstart+Tspan) diff --git a/examples/semi_coherent_glitch_search_using_MCMC.py b/examples/semi_coherent_glitch_search_using_MCMC.py index 789481de83b5fcd0670f44e1a39d09d39070af3d..f55c3429654c6e1ffe23f6ccfaa84d226718fa0e 100644 --- a/examples/semi_coherent_glitch_search_using_MCMC.py +++ b/examples/semi_coherent_glitch_search_using_MCMC.py @@ -31,7 +31,7 @@ nsteps = [5000, 1000, 1000] mcmc = pyfstat.MCMCGlitchSearch( 'semi_coherent_glitch_search_using_MCMC', 'data', - sftfilepath='data/*_glitch*sft', theta_prior=theta_prior, tref=tref, + sftfilepattern='data/*_glitch*sft', theta_prior=theta_prior, tref=tref, tstart=tstart, tend=tend, nsteps=nsteps, nwalkers=nwalkers, scatter_val=1e-10, nglitch=1, ntemps=ntemps, log10temperature_min=log10temperature_min) diff --git a/examples/semi_coherent_search_using_MCMC.py b/examples/semi_coherent_search_using_MCMC.py index 86e4ecc2a87a9a4034032b212c8aa76539489965..4d08e3d64d4985e1dc5c56ebb9420eb4198d5cfe 100644 --- a/examples/semi_coherent_search_using_MCMC.py +++ b/examples/semi_coherent_search_using_MCMC.py @@ -25,7 +25,7 @@ nsteps = [500, 500, 500] mcmc = pyfstat.MCMCSemiCoherentSearch( label='semi_coherent_search_using_MCMC', outdir='data', nsegs=20, - sftfilepath='data/*basic*sft', theta_prior=theta_prior, tref=tref, + sftfilepattern='data/*basic*sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) mcmc.run() diff --git a/examples/semi_coherent_twoglitch_search_using_MCMC.py b/examples/semi_coherent_twoglitch_search_using_MCMC.py index 3e3a7d3bbe307b923372edb9952a4e1d3c0ba2b1..b467557320391cc5fc6bb8569823efa55314878d 100644 --- a/examples/semi_coherent_twoglitch_search_using_MCMC.py +++ b/examples/semi_coherent_twoglitch_search_using_MCMC.py @@ -34,7 +34,7 @@ nwalkers = 100 nsteps = [1000, 1000, 5000] mcmc = pyfstat.MCMCGlitchSearch( - 'semi_coherent_twoglitch_search', 'data', sftfilepath='data/*twoglitch*sft', + 'semi_coherent_twoglitch_search', 'data', sftfilepattern='data/*twoglitch*sft', theta_prior=theta_prior, tref=tref, tstart=tstart, tend=tend, nsteps=nsteps, nwalkers=nwalkers, scatter_val=1e-10, nglitch=2) diff --git a/examples/sliding_window.py b/examples/sliding_window.py index 34b4311ecce0152536edd68847b45bedf42ac55f..96ea6745b4ca5d8249b7ecedc4ad9955bfffbd12 100644 --- a/examples/sliding_window.py +++ b/examples/sliding_window.py @@ -27,7 +27,7 @@ data.make_data() DeltaF0 = 1e-5 search = pyfstat.FrequencySlidingWindow( - label='sliding_window', outdir='data', sftfilepath='data/*sliding_window*sft', + label='sliding_window', outdir='data', sftfilepattern='data/*sliding_window*sft', F0s=[F0-DeltaF0, F0+DeltaF0, DeltaF0/100.], F1=F1, F2=0, Alpha=Alpha, Delta=Delta, tref=tref, minStartTime=tstart, maxStartTime=tend, window_size=25*86400, window_delta=1*86400) diff --git a/examples/transient_search_using_MCMC.py b/examples/transient_search_using_MCMC.py index 12125f0c237cbbd3f6bc6e58539a741f737aab22..62419c11086f5cd177250e02cc0c1f39a40a0e73 100644 --- a/examples/transient_search_using_MCMC.py +++ b/examples/transient_search_using_MCMC.py @@ -40,7 +40,7 @@ nsteps = [100, 100] mcmc = pyfstat.MCMCTransientSearch( label='transient_search', outdir='data', - sftfilepath='data/*simulated_transient_signal*sft', + sftfilepattern='data/*simulated_transient_signal*sft', theta_prior=theta_prior, tref=tref, minStartTime=minStartTime, maxStartTime=maxStartTime, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) diff --git a/examples/weak_signal_follow_up.py b/examples/weak_signal_follow_up.py index 5aa1e1d11f909c59a9e7c1de4d7eb44e86b98f1c..4c51c0d286f11f198bf7fd5b82114fc40b141425 100644 --- a/examples/weak_signal_follow_up.py +++ b/examples/weak_signal_follow_up.py @@ -55,7 +55,7 @@ nsteps = [100, 100] mcmc = pyfstat.MCMCFollowUpSearch( label='weak_signal_follow_up', outdir='data', - sftfilepath='data/*'+data_label+'*sft', theta_prior=theta_prior, tref=tref, + sftfilepattern='data/*'+data_label+'*sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nwalkers=nwalkers, nsteps=nsteps, ntemps=ntemps, log10temperature_min=log10temperature_min, scatter_val=scatter_val) diff --git a/pyfstat/core.py b/pyfstat/core.py index 6a6fbdc7e0acb2b984739e9d2dfb00e534868a93..18eb009d0956fe49cb3ec17ee2a66129edd97ed5 100755 --- a/pyfstat/core.py +++ b/pyfstat/core.py @@ -174,16 +174,15 @@ class BaseSearchClass(object): return thetas def _get_list_of_matching_sfts(self): - # first make sure we have a list of paths, to avoid - # list comprehension trying to glob each single character - sftfilepathlist = np.atleast_1d(self.sftfilepath) - matches = [glob.glob(p) for p in sftfilepathlist] + """ Returns a list of sfts matching the sftfilepattern """ + sftfilepatternlist = np.atleast_1d(self.sftfilepattern.split(';')) + matches = [glob.glob(p) for p in sftfilepatternlist] matches = [item for sublist in matches for item in sublist] if len(matches) > 0: return matches else: raise IOError('No sfts found matching {}'.format( - self.sftfilepath)) + self.sftfilepattern)) class ComputeFstat(object): @@ -193,7 +192,7 @@ class ComputeFstat(object): sun_ephem_default = sun_ephem @helper_functions.initializer - def __init__(self, tref, sftfilepath=None, minStartTime=None, + def __init__(self, tref, sftfilepattern=None, minStartTime=None, maxStartTime=None, binary=False, transient=True, BSGL=False, detectors=None, minCoverFreq=None, maxCoverFreq=None, earth_ephem=None, sun_ephem=None, injectSources=None, @@ -203,8 +202,9 @@ class ComputeFstat(object): ---------- tref: int GPS seconds of the reference time. - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. minStartTime, maxStartTime: float GPStime Only use SFTs with timestemps starting from (including, excluding) this epoch @@ -250,7 +250,7 @@ class ComputeFstat(object): def get_SFTCatalog(self): if hasattr(self, 'SFTCatalog'): return - if self.sftfilepath is None: + if self.sftfilepattern is None: for k in ['minStartTime', 'maxStartTime', 'detectors']: if getattr(self, k) is None: raise ValueError('You must provide "{}" to injectSources' @@ -285,8 +285,8 @@ class ComputeFstat(object): constraints.maxStartTime = lal.LIGOTimeGPS(self.maxStartTime) logging.info('Loading data matching pattern {}'.format( - self.sftfilepath)) - SFTCatalog = lalpulsar.SFTdataFind(self.sftfilepath, constraints) + self.sftfilepattern)) + SFTCatalog = lalpulsar.SFTdataFind(self.sftfilepattern, constraints) detector_names = list(set([d.header.name for d in SFTCatalog.data])) self.detector_names = detector_names SFT_timestamps = [d.header.epoch for d in SFTCatalog.data] @@ -572,7 +572,7 @@ class ComputeFstat(object): times = np.linspace(self.minStartTime, self.maxStartTime, N+1)[1:] times = np.insert(times, 0, self.minStartTime + 86400/2.) out = [predict_fstat(minStartTime=self.minStartTime, maxStartTime=t, - sftfilepattern=self.sftfilepath, IFO=IFO, + sftfilepattern=self.sftfilepattern, IFO=IFO, **pfs_input) for t in times] pfs, pfs_sigma = np.array(out).T return times, pfs, pfs_sigma @@ -647,7 +647,7 @@ class SemiCoherentSearch(BaseSearchClass, ComputeFstat): """ A semi-coherent search """ @helper_functions.initializer - def __init__(self, label, outdir, tref, nsegs=None, sftfilepath=None, + def __init__(self, label, outdir, tref, nsegs=None, sftfilepattern=None, binary=False, BSGL=False, minStartTime=None, maxStartTime=None, minCoverFreq=None, maxCoverFreq=None, detectors=None, earth_ephem=None, sun_ephem=None, @@ -661,8 +661,9 @@ class SemiCoherentSearch(BaseSearchClass, ComputeFstat): GPS seconds of the reference time, and start and end of the data. nsegs: int The (fixed) number of segments - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. For all other parameters, see pyfstat.ComputeFStat. """ @@ -776,7 +777,7 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat): @helper_functions.initializer def __init__(self, label, outdir, tref, minStartTime, maxStartTime, - nglitch=0, sftfilepath=None, theta0_idx=0, BSGL=False, + nglitch=0, sftfilepattern=None, theta0_idx=0, BSGL=False, minCoverFreq=None, maxCoverFreq=None, assumeSqrtSX=None, detectors=None, earth_ephem=None, sun_ephem=None, SSBprec=None, injectSources=None): @@ -790,8 +791,9 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat): nglitch: int The (fixed) number of glitches; this can zero, but occasionally this causes issue (in which case just use ComputeFstat). - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. theta0_idx, int Index (zero-based) of which segment the theta refers to - uyseful if providing a tight prior on theta to allow the signal to jump diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py index 6eb8c2550834978d792bb6d1e6de0518a9d7ad42..8ef2ca13d04fc58bb5cbd67208df06d8f867862c 100644 --- a/pyfstat/grid_based_searches.py +++ b/pyfstat/grid_based_searches.py @@ -17,7 +17,7 @@ from core import tqdm, args, earth_ephem, sun_ephem, read_par class GridSearch(BaseSearchClass): """ Gridded search using ComputeFstat """ @helper_functions.initializer - def __init__(self, label, outdir, sftfilepath, F0s=[0], F1s=[0], F2s=[0], + def __init__(self, label, outdir, sftfilepattern, F0s=[0], F1s=[0], F2s=[0], Alphas=[0], Deltas=[0], tref=None, minStartTime=None, maxStartTime=None, nsegs=1, BSGL=False, minCoverFreq=None, maxCoverFreq=None, earth_ephem=None, sun_ephem=None, @@ -28,8 +28,9 @@ class GridSearch(BaseSearchClass): ---------- label, outdir: str A label and directory to read/write data from/to - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. F0s, F1s, F2s, delta_F0s, delta_F1s, tglitchs, Alphas, Deltas: tuple Length 3 tuple describing the grid for each parameter, e.g [F0min, F0max, dF0], for a fixed value simply give [F0]. Unless @@ -56,7 +57,7 @@ class GridSearch(BaseSearchClass): logging.info('Setting up search object') if self.nsegs == 1: self.search = ComputeFstat( - tref=self.tref, sftfilepath=self.sftfilepath, + tref=self.tref, sftfilepattern=self.sftfilepattern, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, earth_ephem=self.earth_ephem, sun_ephem=self.sun_ephem, detectors=self.detectors, transient=False, @@ -68,7 +69,7 @@ class GridSearch(BaseSearchClass): else: self.search = SemiCoherentSearch( label=self.label, outdir=self.outdir, tref=self.tref, - nsegs=self.nsegs, sftfilepath=self.sftfilepath, + nsegs=self.nsegs, sftfilepattern=self.sftfilepattern, BSGL=self.BSGL, minStartTime=self.minStartTime, maxStartTime=self.maxStartTime, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, detectors=self.detectors, @@ -106,7 +107,7 @@ class GridSearch(BaseSearchClass): if os.path.isfile(self.out_file) is False: logging.info('No old data found, continuing with grid search') return False - if self.sftfilepath is not None: + if self.sftfilepattern is not None: oldest_sft = min([os.path.getmtime(f) for f in self._get_list_of_matching_sfts()]) if os.path.getmtime(self.out_file) < oldest_sft: @@ -275,7 +276,7 @@ class GridSearch(BaseSearchClass): class GridUniformPriorSearch(): - def __init__(self, theta_prior, NF0, NF1, label, outdir, sftfilepath, + def __init__(self, theta_prior, NF0, NF1, label, outdir, sftfilepattern, tref, minStartTime, maxStartTime, minCoverFreq=None, maxCoverFreq=None, BSGL=False, detectors=None, nsegs=1): dF0 = (theta_prior['F0']['upper'] - theta_prior['F0']['lower'])/NF0 @@ -283,7 +284,7 @@ class GridUniformPriorSearch(): F0s = [theta_prior['F0']['lower'], theta_prior['F0']['upper'], dF0] F1s = [theta_prior['F1']['lower'], theta_prior['F1']['upper'], dF1] self.search = GridSearch( - label, outdir, sftfilepath, F0s=F0s, F1s=F1s, tref=tref, + label, outdir, sftfilepattern, F0s=F0s, F1s=F1s, tref=tref, Alphas=[theta_prior['Alpha']], Deltas=[theta_prior['Delta']], minStartTime=minStartTime, maxStartTime=maxStartTime, BSGL=BSGL, detectors=detectors, minCoverFreq=minCoverFreq, @@ -299,7 +300,7 @@ class GridUniformPriorSearch(): class GridGlitchSearch(GridSearch): """ Grid search using the SemiCoherentGlitchSearch """ @helper_functions.initializer - def __init__(self, label, outdir, sftfilepath=None, F0s=[0], + def __init__(self, label, outdir, sftfilepattern=None, F0s=[0], F1s=[0], F2s=[0], delta_F0s=[0], delta_F1s=[0], tglitchs=None, Alphas=[0], Deltas=[0], tref=None, minStartTime=None, maxStartTime=None, minCoverFreq=None, maxCoverFreq=None, @@ -310,8 +311,9 @@ class GridGlitchSearch(GridSearch): ---------- label, outdir: str A label and directory to read/write data from/to - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. F0s, F1s, F2s, delta_F0s, delta_F1s, tglitchs, Alphas, Deltas: tuple Length 3 tuple describing the grid for each parameter, e.g [F0min, F0max, dF0], for a fixed value simply give [F0]. @@ -328,7 +330,7 @@ class GridGlitchSearch(GridSearch): self.sun_ephem = self.sun_ephem_default self.search = SemiCoherentGlitchSearch( - label=label, outdir=outdir, sftfilepath=self.sftfilepath, + label=label, outdir=outdir, sftfilepattern=self.sftfilepattern, tref=tref, minStartTime=minStartTime, maxStartTime=maxStartTime, minCoverFreq=minCoverFreq, maxCoverFreq=maxCoverFreq, earth_ephem=self.earth_ephem, sun_ephem=self.sun_ephem, @@ -357,7 +359,7 @@ class GridGlitchSearch(GridSearch): class FrequencySlidingWindow(GridSearch): """ A sliding-window search over the Frequency """ @helper_functions.initializer - def __init__(self, label, outdir, sftfilepath, F0s, F1, F2, + def __init__(self, label, outdir, sftfilepattern, F0s, F1, F2, Alpha, Delta, tref, minStartTime=None, maxStartTime=None, window_size=10*86400, window_delta=86400, BSGL=False, minCoverFreq=None, maxCoverFreq=None, @@ -368,8 +370,9 @@ class FrequencySlidingWindow(GridSearch): ---------- label, outdir: str A label and directory to read/write data from/to - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. F0s: array Frequency range F1, F2, Alpha, Delta: float @@ -397,7 +400,7 @@ class FrequencySlidingWindow(GridSearch): def inititate_search_object(self): logging.info('Setting up search object') self.search = ComputeFstat( - tref=self.tref, sftfilepath=self.sftfilepath, + tref=self.tref, sftfilepattern=self.sftfilepattern, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, earth_ephem=self.earth_ephem, sun_ephem=self.sun_ephem, detectors=self.detectors, transient=True, @@ -473,7 +476,7 @@ class FrequencySlidingWindow(GridSearch): class DMoff_NO_SPIN(GridSearch): """ DMoff test using SSBPREC_NO_SPIN """ @helper_functions.initializer - def __init__(self, par, label, outdir, sftfilepath, minStartTime=None, + def __init__(self, par, label, outdir, sftfilepattern, minStartTime=None, maxStartTime=None, minCoverFreq=None, maxCoverFreq=None, earth_ephem=None, sun_ephem=None, detectors=None, injectSources=None, assumeSqrtSX=None): @@ -485,8 +488,9 @@ class DMoff_NO_SPIN(GridSearch): and 'tref') or a path to a .par file to read in the F0, F1 etc label, outdir: str A label and directory to read/write data from/to - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. minStartTime, maxStartTime: int GPS seconds of the start time and end time diff --git a/pyfstat/mcmc_based_searches.py b/pyfstat/mcmc_based_searches.py index e41fe8c9a5a9e3ace293532eadf45090fcc051c8..64fa524ab33099538ed088bf351db6a9476fffe5 100644 --- a/pyfstat/mcmc_based_searches.py +++ b/pyfstat/mcmc_based_searches.py @@ -36,7 +36,7 @@ class MCMCSearch(core.BaseSearchClass): @helper_functions.initializer def __init__(self, label, outdir, theta_prior, tref, minStartTime, - maxStartTime, sftfilepath=None, nsteps=[100, 100], + maxStartTime, sftfilepattern=None, nsteps=[100, 100], nwalkers=100, ntemps=1, log10temperature_min=-5, theta_initial=None, scatter_val=1e-10, rhohatmax=1000, binary=False, BSGL=False, minCoverFreq=None, SSBprec=None, @@ -46,7 +46,7 @@ class MCMCSearch(core.BaseSearchClass): Parameters label, outdir: str A label and directory to read/write data from/to - sftfilepath: str + sftfilepattern: str Pattern to match SFTs using wildcards (*?) and ranges [0-9]; mutiple patterns can be given separated by colons. theta_prior: dict @@ -94,10 +94,10 @@ class MCMCSearch(core.BaseSearchClass): os.mkdir(outdir) self._add_log_file() logging.info('Set-up MCMC search for model {}'.format(self.label)) - if sftfilepath: - logging.info('Using data {}'.format(self.sftfilepath)) + if sftfilepattern: + logging.info('Using data {}'.format(self.sftfilepattern)) else: - logging.info('No sftfilepath given') + logging.info('No sftfilepattern given') if injectSources: logging.info('Inject sources: {}'.format(injectSources)) self.pickle_path = '{}/{}_saved_data.p'.format(self.outdir, self.label) @@ -132,7 +132,7 @@ class MCMCSearch(core.BaseSearchClass): def _initiate_search_object(self): logging.info('Setting up search object') self.search = core.ComputeFstat( - tref=self.tref, sftfilepath=self.sftfilepath, + tref=self.tref, sftfilepattern=self.sftfilepattern, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, earth_ephem=self.earth_ephem, sun_ephem=self.sun_ephem, detectors=self.detectors, BSGL=self.BSGL, transient=False, @@ -1112,7 +1112,7 @@ class MCMCSearch(core.BaseSearchClass): logging.info('No pickled data found') return False - if self.sftfilepath is not None: + if self.sftfilepattern is not None: oldest_sft = min([os.path.getmtime(f) for f in self._get_list_of_matching_sfts()]) if os.path.getmtime(self.pickle_path) < oldest_sft: @@ -1275,7 +1275,7 @@ class MCMCSearch(core.BaseSearchClass): ' --refTime={} --outputLoudest="{}/{}.loudest" ' '--minStartTime={} --maxStartTime={}').format( params['Alpha'], params['Delta'], params['F0'], - params['F1'], self.sftfilepath, params['tref'], + params['F1'], self.sftfilepattern, params['tref'], self.outdir, self.label, self.minStartTime, self.maxStartTime) subprocess.call([cmd], shell=True) @@ -1459,7 +1459,7 @@ class MCMCGlitchSearch(MCMCSearch): ) @helper_functions.initializer - def __init__(self, label, outdir, sftfilepath, theta_prior, tref, + def __init__(self, label, outdir, sftfilepattern, theta_prior, tref, minStartTime, maxStartTime, nglitch=1, nsteps=[100, 100], nwalkers=100, ntemps=1, log10temperature_min=-5, theta_initial=None, scatter_val=1e-10, rhohatmax=1000, @@ -1471,8 +1471,9 @@ class MCMCGlitchSearch(MCMCSearch): ---------- label, outdir: str A label and directory to read/write data from/to - sftfilepath: str - File patern to match SFTs + sftfilepattern: str + Pattern to match SFTs using wildcards (*?) and ranges [0-9]; + mutiple patterns can be given separated by colons. theta_prior: dict Dictionary of priors and fixed values for the search parameters. For each parameters (key of the dict), if it is to be held fixed @@ -1530,7 +1531,7 @@ class MCMCGlitchSearch(MCMCSearch): self._add_log_file() logging.info(('Set-up MCMC glitch search with {} glitches for model {}' ' on data {}').format(self.nglitch, self.label, - self.sftfilepath)) + self.sftfilepattern)) self.pickle_path = '{}/{}_saved_data.p'.format(self.outdir, self.label) self._unpack_input_theta() self.ndim = len(self.theta_keys) @@ -1554,7 +1555,7 @@ class MCMCGlitchSearch(MCMCSearch): def _initiate_search_object(self): logging.info('Setting up search object') self.search = core.SemiCoherentGlitchSearch( - label=self.label, outdir=self.outdir, sftfilepath=self.sftfilepath, + label=self.label, outdir=self.outdir, sftfilepattern=self.sftfilepattern, tref=self.tref, minStartTime=self.minStartTime, maxStartTime=self.maxStartTime, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, earth_ephem=self.earth_ephem, @@ -1718,7 +1719,7 @@ class MCMCGlitchSearch(MCMCSearch): class MCMCSemiCoherentSearch(MCMCSearch): """ MCMC search for a signal using the semi-coherent ComputeFstat """ @helper_functions.initializer - def __init__(self, label, outdir, theta_prior, tref, sftfilepath=None, + def __init__(self, label, outdir, theta_prior, tref, sftfilepattern=None, nsegs=None, nsteps=[100, 100, 100], nwalkers=100, binary=False, ntemps=1, log10temperature_min=-5, theta_initial=None, scatter_val=1e-10, rhohatmax=1000, @@ -1735,7 +1736,7 @@ class MCMCSemiCoherentSearch(MCMCSearch): self._add_log_file() logging.info(('Set-up MCMC semi-coherent search for model {} on data' '{}').format( - self.label, self.sftfilepath)) + self.label, self.sftfilepattern)) self.pickle_path = '{}/{}_saved_data.p'.format(self.outdir, self.label) self._unpack_input_theta() self.ndim = len(self.theta_keys) @@ -1767,7 +1768,7 @@ class MCMCSemiCoherentSearch(MCMCSearch): logging.info('Setting up search object') self.search = core.SemiCoherentSearch( label=self.label, outdir=self.outdir, tref=self.tref, - nsegs=self.nsegs, sftfilepath=self.sftfilepath, binary=self.binary, + nsegs=self.nsegs, sftfilepattern=self.sftfilepattern, binary=self.binary, BSGL=self.BSGL, minStartTime=self.minStartTime, maxStartTime=self.maxStartTime, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, detectors=self.detectors, @@ -2124,7 +2125,7 @@ class MCMCTransientSearch(MCMCSearch): def _initiate_search_object(self): logging.info('Setting up search object') self.search = core.ComputeFstat( - tref=self.tref, sftfilepath=self.sftfilepath, + tref=self.tref, sftfilepattern=self.sftfilepattern, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, earth_ephem=self.earth_ephem, sun_ephem=self.sun_ephem, detectors=self.detectors, transient=True, diff --git a/tests.py b/tests.py index e11b5f5ddb7585dfee3db72b2192d567bafde5b4..22fe7a0ca8c8ad1ccdaa589b98c7fe0419a7d188 100644 --- a/tests.py +++ b/tests.py @@ -95,7 +95,7 @@ class TestComputeFstat(Test): search = pyfstat.ComputeFstat( tref=Writer.tref, - sftfilepath='{}/*{}*sft'.format(Writer.outdir, Writer.label)) + sftfilepattern='{}/*{}*sft'.format(Writer.outdir, Writer.label)) FS = search.run_computefstatistic_single_point(Writer.tstart, Writer.tend, Writer.F0, @@ -113,7 +113,7 @@ class TestComputeFstat(Test): search = pyfstat.ComputeFstat( tref=Writer.tref, assumeSqrtSX=1, - sftfilepath='{}/*{}*sft'.format(Writer.outdir, Writer.label)) + sftfilepattern='{}/*{}*sft'.format(Writer.outdir, Writer.label)) FS = search.run_computefstatistic_single_point(Writer.tstart, Writer.tend, Writer.F0, @@ -162,7 +162,7 @@ class TestSemiCoherentGlitchSearch(Test): search = pyfstat.SemiCoherentGlitchSearch( label=self.label, outdir=outdir, - sftfilepath='{}/*{}*sft'.format(Writer.outdir, Writer.label), + sftfilepattern='{}/*{}*sft'.format(Writer.outdir, Writer.label), tref=Writer.tref, minStartTime=Writer.tstart, maxStartTime=Writer.tend, nglitch=1) @@ -221,7 +221,7 @@ class TestMCMCSearch(Test): search = pyfstat.MCMCSearch( label=self.label, outdir=outdir, theta_prior=theta, tref=tref, - sftfilepath='{}/*{}*sft'.format(Writer.outdir, Writer.label), + sftfilepattern='{}/*{}*sft'.format(Writer.outdir, Writer.label), minStartTime=minStartTime, maxStartTime=maxStartTime, nsteps=[100, 100], nwalkers=100, ntemps=2, log10temperature_min=-1) search.setup_convergence_testing()