Skip to content

Commit

Permalink
Merge pull request #30 from icecube/enhancements/gw
Browse files Browse the repository at this point in the history
Enhancements/gw
  • Loading branch information
jessiethw authored Aug 17, 2022
2 parents 8f2c299 + e84e7b9 commit 627ac2d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ fast_response.egg-info/
examples/
RELEASE_NOTES
fast_response/results_dataframe.pkl
fast_response/results_dataframe_gw.pkl
output/
output/*
fast_response/results_dataframe_bkup.pkl
fast_response/scripts/make_call.py
cascade_skymaps/
cascade_skymaps/*
7 changes: 6 additions & 1 deletion fast_response/listeners/gcn_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
gcn.notice_types.ICECUBE_CASCADE)

def process_gcn(payload, root):
print("INCOMING ALERT")
print("INCOMING ALERT: ",datetime.utcnow())

analysis_path = os.environ.get('FAST_RESPONSE_SCRIPTS')
if analysis_path is None:
try:
Expand Down Expand Up @@ -42,6 +43,10 @@ def process_gcn(payload, root):
print("Found track type alert, running track followup. . . ")
alert_type='track'

# IceCube sends 2: a notice and a revision, only want to run once
if int(params['Rev']) !=0:
return

event_id = params['event_id']
run_id = params['run_id']
eventtime = root.find('.//ISOTime').text
Expand Down
40 changes: 26 additions & 14 deletions fast_response/listeners/gw_gcn_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

def process_gcn(payload, root):

print('INCOMING ALERT FOUND')
print('INCOMING ALERT FOUND: ',datetime.utcnow())
analysis_path = os.environ.get('FAST_RESPONSE_SCRIPTS')
if analysis_path is None:
try:
Expand Down Expand Up @@ -73,14 +73,22 @@ def process_gcn(payload, root):
subprocess.call([command, '--skymap={}'.format(skymap),
'--time={}'.format(str(event_mjd)),
'--name={}'.format(name)]
#'--allow_neg_ts=True']
)

for directory in os.listdir(analysis_path+'../../output'):
if name in directory:
if root.attrib['role'] != 'observation':
skymap_filename=skymap.split('/')[-1]
skymap_filename=skymap.split('/')[-1]
if 'MS22' in name:
#import glob
et = lxml.etree.ElementTree(root)
et.write(analysis_path+'../../output/'+directory+'/{}-{}-{}.xml'.format(params['GraceID'],
params['Pkt_Ser_Num'], params['AlertType']), pretty_print=True)
subprocess.call(['wget', skymap])
subprocess.call(['mv', skymap_filename, analysis_path+'../../output/'+directory])
#pkl_file=glob.glob(analysis_path+'../../output/'+directory+'/*.pickle')
#if len(pkl_file)==1:
# subprocess.call(['rm','-r', pkl_file[0]])
subprocess.call(['mv',analysis_path+'../../output/'+directory, '/data/user/jthwaites/o4-mocks/'])
print('Output directory: ','/data/user/jthwaites/o4-mocks/'+directory)
else:
Expand All @@ -106,13 +114,18 @@ def process_gcn(payload, root):
args = parser.parse_args()

if args.log:
import sys
original_stdout=sys.stdout
#import sys
#original_stdout=sys.stdout
logfile='/home/jthwaites/public_html/FastResponse/gw-webpage/output/log.log'
sys.stdout = open(logfile, 'a+')
#sys.stdout = open(logfile, 'a+')
import logging
logging.basicConfig(filename=logfile,
format='%(levelname)s:%(message)s',
level=logging.INFO)

if args.run_live:
print("Listening for GCNs . . . ")
if args.log: logging.info("Listening for GCNs . . . ")
else: print("Listening for GCNs . . . ")
gcn.listen(handler=process_gcn)
else:
### FOR OFFLINE TESTING
Expand All @@ -121,18 +134,17 @@ def process_gcn(payload, root):
sample_skymap_path='/data/user/jthwaites/o3-gw-skymaps/'
#sample_skymap_path=os.path.dirname(fast_response.__file__) +'/sample_skymaps/'
except Exception as e:
sample_skymap_path='/data/user/apizzuto/fast_response_skylab/' \
+ 'fast-response/fast_response/sample_skymaps/'
sample_skymap_path='/data/user/jthwaites/o3-gw-skymaps/'

payload = open(sample_skymap_path + 'S200302c-4-Update.xml', 'rb').read()
payload = open(sample_skymap_path + 'S190728q-5-Update.xml', 'rb').read()
root = lxml.etree.fromstring(payload)

#test runs on scrambles, observation runs on unblinded data
#root.attrib['role']='test'
process_gcn(payload, root)

if args.log:
print('Finished running.')
sys.stdout=original_stdout
print('Output written to log: ',logfile)

logging.info('Finished running.')
#sys.stdout=original_stdout
logging.info('Output written to log: ',logfile)

2 changes: 1 addition & 1 deletion fast_response/plotting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def plot_color_bar(labels=[0.,2.,4.,6.], col_label=r"IceCube Event Time", range=
fig = plt.gcf()
ax = fig.add_axes([0.95, 0.2, 0.03, 0.6])
labels = labels
cb = mpl.colorbar.ColorbarBase(ax, cmap=ps_map if cmap is None else cmap,
cb = mpl.colorbar.ColorbarBase(ax, cmap="Blues" if cmap is None else cmap,
#norm=mpl.colors.Normalize(vmin=range[0], vmax=range[1]),
orientation="vertical")

Expand Down
1 change: 1 addition & 0 deletions fast_response/scripts/run_gw_followup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

f = GWFollowup(name, args.skymap, start, stop)
f._allow_neg = args.allow_neg_ts
f._dataset = 'GFUOnline_v001p03'

f.unblind_TS()
f.plot_ontime()
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
'astropy==2.0.16',
'healpy==1.13.0',
'matplotlib==2.2.5',
'numpy>=1.16.6',
'pandas>=1.2.2',
'numpy==1.21.5',
'pandas==1.3.5',
'pyfiglet==0.8.post1',
'python-dateutil==2.8.1',
'pyzmq==19.0.1',
'scipy==1.2.3',
'seaborn==0.9.1',
'zmq==0.0.0',
'py27hash==1.0.2',
'pygcn>=1.0.2'
'pygcn==1.1.2'
]
)

0 comments on commit 627ac2d

Please sign in to comment.