Skip to content
Snippets Groups Projects
Commit 31a8eb0f authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Create and use set_out_file routine in the grid_search

Previously, each search class named its own output file. This provides a
function `set_out_file` in the top-level class which sets the `out_file`
attribute to be used.
- Adds class name to the out_file for clarity
- Add detectors used
parent 365bf803
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ class GridSearch(BaseSearchClass): ...@@ -49,7 +49,7 @@ class GridSearch(BaseSearchClass):
if os.path.isdir(outdir) is False: if os.path.isdir(outdir) is False:
os.mkdir(outdir) os.mkdir(outdir)
self.out_file = '{}/{}_gridFS.txt'.format(self.outdir, self.label) self.set_out_file()
self.keys = ['_', '_', 'F0', 'F1', 'F2', 'Alpha', 'Delta'] self.keys = ['_', '_', 'F0', 'F1', 'F2', 'Alpha', 'Delta']
def inititate_search_object(self): def inititate_search_object(self):
...@@ -263,6 +263,16 @@ class GridSearch(BaseSearchClass): ...@@ -263,6 +263,16 @@ class GridSearch(BaseSearchClass):
for k, v in d.iteritems(): for k, v in d.iteritems():
print(' {}={}'.format(k, v)) print(' {}={}'.format(k, v))
def set_out_file(self, extra_label=None):
dets = self.detectors.replace(',', '')
if extra_label:
self.out_file = '{}/{}_{}_{}_{}.txt'.format(
self.outdir, self.label, dets, type(self).__name__,
extra_label)
else:
self.out_file = '{}/{}_{}_{}.txt'.format(
self.outdir, self.label, dets, type(self).__name__)
class GridUniformPriorSearch(): class GridUniformPriorSearch():
def __init__(self, theta_prior, NF0, NF1, label, outdir, sftfilepath, def __init__(self, theta_prior, NF0, NF1, label, outdir, sftfilepath,
...@@ -326,7 +336,7 @@ class GridGlitchSearch(GridSearch): ...@@ -326,7 +336,7 @@ class GridGlitchSearch(GridSearch):
if os.path.isdir(outdir) is False: if os.path.isdir(outdir) is False:
os.mkdir(outdir) os.mkdir(outdir)
self.out_file = '{}/{}_gridFS.txt'.format(self.outdir, self.label) self.set_out_file()
self.keys = ['F0', 'F1', 'F2', 'Alpha', 'Delta', 'delta_F0', self.keys = ['F0', 'F1', 'F2', 'Alpha', 'Delta', 'delta_F0',
'delta_F1', 'tglitch'] 'delta_F1', 'tglitch']
...@@ -377,7 +387,7 @@ class FrequencySlidingWindow(GridSearch): ...@@ -377,7 +387,7 @@ class FrequencySlidingWindow(GridSearch):
if os.path.isdir(outdir) is False: if os.path.isdir(outdir) is False:
os.mkdir(outdir) os.mkdir(outdir)
self.out_file = '{}/{}_gridFS.txt'.format(self.outdir, self.label) self.set_out_file()
self.nsegs = 1 self.nsegs = 1
self.F1s = [F1] self.F1s = [F1]
self.F2s = [F2] self.F2s = [F2]
...@@ -524,22 +534,19 @@ class DMoff_NO_SPIN(GridSearch): ...@@ -524,22 +534,19 @@ class DMoff_NO_SPIN(GridSearch):
""" """
self.SSBprec = 2 self.SSBprec = 2
self.out_file = '{}/{}_gridFS_SSBPREC2.txt'.format( self.set_out_file('SSBPREC2')
self.outdir, self.label)
self.F0s = [self.par['F0']+j/self.SIDEREAL_DAY for j in range(-4, 5)] self.F0s = [self.par['F0']+j/self.SIDEREAL_DAY for j in range(-4, 5)]
self.run() self.run()
twoF_SUM = np.sum(self.data[:, -1]) twoF_SUM = np.sum(self.data[:, -1])
self.SSBprec = 4 self.SSBprec = 4
self.out_file = '{}/{}_gridFS_SSBPREC4_SIDEREAL.txt'.format( self.set_out_file('SSBPREC4')
self.outdir, self.label)
self.F0s = [self.par['F0']+j/self.SIDEREAL_DAY self.F0s = [self.par['F0']+j/self.SIDEREAL_DAY
for j in range(-self.m0, self.m0+1)] for j in range(-self.m0, self.m0+1)]
self.run() self.run()
twoFstar_SUM = np.sum(self.data[:, -1]) twoFstar_SUM = np.sum(self.data[:, -1])
self.out_file = '{}/{}_gridFS_SSBPREC4_TERRESTIAL.txt'.format( self.set_out_file('SSBPREC4_TERRESTRIAL')
self.outdir, self.label)
self.F0s = [self.par['F0']+j/self.TERRESTRIAL_DAY self.F0s = [self.par['F0']+j/self.TERRESTRIAL_DAY
for j in range(-self.m0, self.m0+1)] for j in range(-self.m0, self.m0+1)]
self.run() self.run()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment