Skip to content

Commit c33a51b

Browse files
authored
Enhancements/gw (#42)
* resolve #41 * fixes to levels for contour * clean up script
1 parent b51c263 commit c33a51b

File tree

4 files changed

+17
-37
lines changed

4 files changed

+17
-37
lines changed

fast_response/GWFollowup.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,22 @@ def get_best_fit_contour(self, proportions=[0.5,0.9]):
193193
Makes a zoomed skymap of the ts-space with contours
194194
'''
195195
if self.tsd is None: return
196-
196+
197+
from scipy import special
197198
from . import plotting_utils
198-
#import meander
199+
import meander
199200
import seaborn as sns
200201

201202
print('Calculating contour around best-fit TS')
202203

203204
#get threshold TS value for that level in the bg distribution
204-
levels = [np.percentile(self.tsd, 100*(1-proportion)) for proportion in proportions]
205-
sample_points = np.array(hp.pix2ang(self.nside, np.arange(len(self.skymap)))).T
205+
dof = 2
206+
delta_llh_levels = special.gammaincinv(dof/2.0, np.array([(1-prop) for prop in proportions]))
207+
levels=2*delta_llh_levels
208+
209+
#sample_points = np.array(hp.pix2ang(self.nside, np.arange(len(self.skymap)))).T
206210
loc=np.array((np.pi/2 - self.ts_scan['dec'], self.ts_scan['ra'])).T
207211
contours_by_level = meander.spherical_contours(loc, self.ts_scan['TS_spatial_prior_0'], levels)
208-
#print(contours_by_level)
209212

210213
thetas = []; phis=[]
211214
for contours in contours_by_level:
@@ -225,7 +228,7 @@ def get_best_fit_contour(self, proportions=[0.5,0.9]):
225228
plotting_utils.plot_zoom(self.ts_scan['TS_spatial_prior_0'], self.skymap_fit_ra, self.skymap_fit_dec,
226229
"", range = [0,10], reso=3., cmap = cmap)
227230

228-
plotting_utils.plot_color_bar(range=[0,6], cmap=cmap, col_label=r"TS",offset=-50)
231+
plotting_utils.plot_color_bar(labels=[0,round(max(self.ts_scan['TS_spatial_prior_0']))], cmap=cmap, col_label=r"TS",offset=-150)
229232
cont_ls = ['solid', 'dashed']*(int(len(proportions)/2))
230233
cont_labels=[f'{proportion*100:.0f}/% CL' for proportion in proportions]
231234

fast_response/precomputed_background/submit_precomputed_trials.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
'--seed_start', type=int,default=0,
1919
help='Seed to start with when running trials')
2020
parser.add_argument(
21-
'--n_per_batch', default=100, type=int,
22-
help='Number of trials to run in each set (default: 100)')
21+
'--n_per_batch', default=50, type=int,
22+
help='Number of trials to run in each set (default: 50)')
2323
args = parser.parse_args()
2424

2525
username = pwd.getpwuid(os.getuid())[0]
@@ -53,41 +53,16 @@
5353
'when_to_transfer_output = ON_EXIT']
5454
)
5555

56-
#glob_jobs = pycondor.Job(
57-
# 'glob_gw_precomp',
58-
# './glob_precomputed_trials.py',
59-
# error=error,
60-
# output=output,
61-
# log=log,
62-
# submit=submit,
63-
# getenv=True,
64-
# universe='vanilla',
65-
# verbose=2,
66-
# request_cpus=5,
67-
# request_memory=5000,
68-
# extra_lines=[
69-
# 'should_transfer_files = YES',
70-
# 'when_to_transfer_output = ON_EXIT']
71-
# )
72-
7356
prev_trials = glob.glob('/data/user/jthwaites/FastResponseAnalysis/output/trials/*.npz')
74-
for bg_rate in [6.6]:#[6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2]:
75-
for seed in range(args.seed_start, int(args.ntrials/args.n_per_batch)):
57+
for bg_rate in [6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2]:
58+
for seed in range(args.seed_start, int(args.ntrials/100)):#int(args.ntrials/args.n_per_batch)):
7659
seed = seed*100
7760
if f'/data/user/jthwaites/FastResponseAnalysis/output/trials/gw_{bg_rate}_mHz_seed_{seed}_delta_t_1.2e+06.npz' not in prev_trials:
7861
#deltaT {args.tw} --ntrials 100 --seed {seed} --bkg {bg}
7962
job.add_arg('--deltaT %s --ntrials %i --seed %i --bkg %s'
8063
%(args.tw, args.n_per_batch, seed, bg_rate))
81-
82-
83-
#job.add_child(glob_jobs)
64+
job.add_arg('--deltaT %s --ntrials %i --seed %i --bkg %s'
65+
%(args.tw, args.n_per_batch, seed+50, bg_rate))
8466

8567
job.build_submit()
8668

87-
#should really use a dag - not working and haven't figured out why
88-
#dagman = pycondor.Dagman(
89-
# 'gw_precomp_trials',
90-
# submit=submit, verbose=2)
91-
92-
#dagman.add_job(job)
93-
#dagman.build_submit()

fast_response/scripts/run_gw_followup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
gw_time = Time(args.time, format='mjd')
3636
delta_t = float(args.tw)
37+
3738
if args.tw==1000:
3839
start_time = gw_time - (delta_t / 86400. / 2.)
3940
stop_time = gw_time + (delta_t / 86400. / 2.)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ subprocess32==3.5.4
2929
zmq==0.0.0
3030
py27hash==1.0.2
3131
pygcn==1.1.2
32+
wheel==0.37.1

0 commit comments

Comments
 (0)