-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow units for
--ra
and --dec
, improve external trigger info tab…
…le (#4965) * Allow units for --ra and --dec, improve external trigger info table * Fix thinko
- Loading branch information
1 parent
c06f60a
commit 3caa512
Showing
3 changed files
with
82 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,17 @@ | |
import sys | ||
import argparse | ||
from datetime import datetime | ||
import numpy | ||
import math | ||
|
||
import lal | ||
|
||
from pycbc import add_common_pycbc_options, init_logging | ||
import pycbc.version | ||
import pycbc.results | ||
from pycbc.detector import Detector | ||
from pycbc.detector import Detector, ppdets | ||
from pycbc.results.pygrb_postprocessing_utils import get_antenna_dist_factor | ||
from pycbc.types import angle_as_radians | ||
|
||
|
||
__author__ = "Francesco Pannarale <[email protected]>" | ||
__version__ = pycbc.version.git_verbose_msg | ||
|
@@ -48,15 +50,18 @@ add_common_pycbc_options(parser) | |
parser.add_argument("--trigger-time", type=int, | ||
required=True, | ||
help="GPS time of the GRB.") | ||
parser.add_argument("--ra", type=float, | ||
parser.add_argument("--ra", type=angle_as_radians, | ||
required=True, | ||
help="Right ascension (radians) of the GRB.") | ||
parser.add_argument("--dec", type=float, | ||
help="Right ascension of the GRB. Use the rad or deg " | ||
"suffix to specify units, otherwise radians are assumed.") | ||
parser.add_argument("--dec", type=angle_as_radians, | ||
required=True, | ||
help="Declination (radians) of the GRB.") | ||
parser.add_argument("--sky-error", type=float, | ||
default=0, required=False, | ||
help="Sky-localisation error (radians) of the GRB.") | ||
help="Declination of the GRB. Use the rad or deg suffix " | ||
"to specify units, otherwise radians are assumed.") | ||
parser.add_argument("--sky-error", type=angle_as_radians, | ||
default=0, | ||
help="Sky-localisation error of the GRB. Use the rad or " | ||
"deg suffix to specify units, otherwise radians are assumed.") | ||
parser.add_argument("--ifos", action="store", nargs='+', | ||
default=None, required=True, | ||
help="List containing the active IFOs.") | ||
|
@@ -74,40 +79,45 @@ data = [[]] | |
data[0].append(str(opts.trigger_time)) | ||
headers.append('GPS Time') | ||
|
||
utc_time = datetime(*lal.GPSToUTC(opts.trigger_time)[0:6]).strftime("%B %d %Y, %H:%M:%S UTC") | ||
utc_time = datetime(*lal.GPSToUTC(opts.trigger_time)[0:6]).strftime("%Y-%m-%d %H:%M:%S") | ||
data[0].append(utc_time) | ||
headers.append('Coordinated Universal Time') | ||
headers.append('UTC Time') | ||
|
||
data[0].append(str(numpy.rad2deg(opts.ra))) | ||
data[0].append(f'{math.degrees(opts.ra):.3f}') | ||
headers.append('R.A. (deg)') | ||
|
||
data[0].append(str(numpy.rad2deg(opts.dec))) | ||
data[0].append(f'{math.degrees(opts.dec):.3f}') | ||
headers.append('Dec (deg)') | ||
|
||
data[0].append(str(opts.sky_error)) | ||
headers.append('Sky Error') | ||
data[0].append(f'{math.degrees(opts.sky_error):.3f}') | ||
headers.append('Sky Error (deg)') | ||
|
||
data[0].append(''.join(opts.ifos)) | ||
data[0].append(ppdets(opts.ifos, '')) | ||
headers.append('IFOs') | ||
|
||
for ifo in opts.ifos: | ||
antenna = Detector(ifo) | ||
factor = get_antenna_dist_factor(antenna, | ||
opts.ra, | ||
opts.dec, | ||
float(opts.trigger_time)) | ||
data[0].append('%.3f' % factor) | ||
factor = get_antenna_dist_factor( | ||
antenna, opts.ra, opts.dec, float(opts.trigger_time) | ||
) | ||
data[0].append(f'{factor:.3f}') | ||
headers.append(ifo + ' Antenna Factor') | ||
|
||
html = pycbc.results.dq.redirect_javascript + \ | ||
str(pycbc.results.static_table(data, headers)) | ||
|
||
title = 'GRB Summary Information' | ||
caption = 'Parameters of the GRB. The reported antenna factors are the ' | ||
caption += 'dist / eff distance as defined by (4.3) in ' | ||
caption += 'https://arxiv.org/abs/0705.1514.' | ||
|
||
pycbc.results.save_fig_with_metadata(html, opts.output_file, {}, | ||
cmd = ' '.join(sys.argv), | ||
title = title, | ||
caption = caption) | ||
title = 'External Trigger Summary Information' | ||
caption = ( | ||
'Parameters of the external trigger. The reported antenna factors are the ' | ||
'dist / eff distance as defined by Eq (4.3) in ' | ||
'https://arxiv.org/abs/0705.1514.' | ||
) | ||
|
||
pycbc.results.save_fig_with_metadata( | ||
html, | ||
opts.output_file, | ||
{}, | ||
cmd=' '.join(sys.argv), | ||
title=title, | ||
caption=caption | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters