Commit 25fdba90 authored by Sudarshan Ghonge's avatar Sudarshan Ghonge
Browse files

Add internal injection functionality that was previously (accidentally) removed

parent f4bdc3eb
......@@ -168,7 +168,9 @@ def make_skyview(directory='.', mdc=None, NSIDE=128, inj=None, npost=5000, geo=F
# Note: We may only need the trigger time from this
# ---------------------------------------
ifoNames = []
for line in bayeswave:
internal_ra_dec = None
lines = bayeswave.readlines()
for line in lines:
spl = line.split()
if len(spl) < 1: continue
......@@ -189,6 +191,15 @@ def make_skyview(directory='.', mdc=None, NSIDE=128, inj=None, npost=5000, geo=F
spl = line.split()
gps = spl[3]
break
try:
injline = lines[26].split(' ')
if injline[2]=='Signal':
print("Found Signal Injection data!")
internal_ra = float(lines[27].split()[1])
internal_dec = np.arcsin(float(lines[27].split()[2]))
internal_ra_dec = [internal_ra, internal_dec]
except Exception as e:
print("No internal injection found on line 27 of bayeswave.run")
bayeswave.close()
# --------------------------------
......@@ -241,6 +252,11 @@ def make_skyview(directory='.', mdc=None, NSIDE=128, inj=None, npost=5000, geo=F
injdec = np.pi/2 - injtheta
print("GOT INJECTION PARAMTERS")
print(injtheta, injra)
if internal_ra_dec is not None:
injra = internal_ra_dec[0]
injdec = internal_ra_dec[1]
print("Got Internal Injection parameters")
# -- Make plots directory, if needed
plotsDir = './plots'
......@@ -287,6 +303,8 @@ def make_skyview(directory='.', mdc=None, NSIDE=128, inj=None, npost=5000, geo=F
ax.plot_coord(SkyCoord(np.rad2deg(inj['ra']), np.rad2deg(inj['dec']), unit='deg'), '*',markerfacecolor='white', markeredgecolor='black', markersize=10)
if mdc is not None:
ax.plot_coord(SkyCoord(np.rad2deg(injra), np.rad2deg(injdec), unit='deg'), '*', markerfacecolor='white', markeredgecolor='black', markersize=10)
if internal_ra_dec is not None:
ax.plot_coord(SkyCoord(np.rad2deg(injra), np.rad2deg(injdec), unit='deg'), '*', markerfacecolor='white', markeredgecolor='black', markersize=10)
plt.savefig(plotsDir+'/skymap.png')
plt.close()
......@@ -306,6 +324,10 @@ def make_skyview(directory='.', mdc=None, NSIDE=128, inj=None, npost=5000, geo=F
print("Calculating p value of command line injection")
true_ra = inj['ra']
true_dec = inj['dec']
elif (internal_ra_dec is not None):
print("Calculating p value of internal injection")
true_ra = injra
true_dec = injdec
else:
true_ra = None
true_dec = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment