Commit 611a5832 authored by Leo Pound Singer's avatar Leo Pound Singer
Browse files

from-stats and localize-lvalert should write flat HEALPix files

For backwards compatibility.
parent b436790d
...@@ -10,8 +10,9 @@ Changelog ...@@ -10,8 +10,9 @@ Changelog
- Un-pin Numpy version now that Numpy 1.15.4 is out. - Un-pin Numpy version now that Numpy 1.15.4 is out.
- The ``bayestar-localize-lvalert`` and ``ligo-skymap-from-samples`` tools will - The ``bayestar-localize-lvalert`` and ``ligo-skymap-from-samples`` tools can
now natively output multi-resolution HEALPix files. now natively output multi-resolution HEALPix files, although they still
natively output flat, fixed-resolution HEALPix files.
- Fix an error in the volume element that resulted in ``ligo-skymap-stats`` - Fix an error in the volume element that resulted in ``ligo-skymap-stats``
underestimating credible volumes by a factor of 2. underestimating credible volumes by a factor of 2.
......
...@@ -32,8 +32,8 @@ terminal, or redirected from a fifo):: ...@@ -32,8 +32,8 @@ terminal, or redirected from a fifo)::
""" """
from . import ( from . import (
ArgumentParser, waveform_parser, prior_parser, mcmc_parser, random_parser, ArgumentParser, EnableAction, waveform_parser, prior_parser, mcmc_parser,
iterlines) random_parser, iterlines)
def parser(): def parser():
...@@ -51,6 +51,9 @@ def parser(): ...@@ -51,6 +51,9 @@ def parser():
parser.add_argument( parser.add_argument(
'-o', '--output', metavar='FILE.fits', default='bayestar.fits', '-o', '--output', metavar='FILE.fits', default='bayestar.fits',
help='Name for uploaded file') help='Name for uploaded file')
parser.add_argument(
'--enable-multiresolution', action=EnableAction, default=False,
help='generate a multiresolution HEALPix map')
parser.add_argument( parser.add_argument(
'graceid', metavar='G123456', nargs='*', 'graceid', metavar='G123456', nargs='*',
help='Run on these GraceDB IDs. If no GraceDB IDs are listed on the ' help='Run on these GraceDB IDs. If no GraceDB IDs are listed on the '
...@@ -67,7 +70,7 @@ def main(args=None): ...@@ -67,7 +70,7 @@ def main(args=None):
import sys import sys
import tempfile import tempfile
import urllib.parse import urllib.parse
from ..bayestar import localize from ..bayestar import localize, rasterize
from ..io import fits from ..io import fits
from ..io import events from ..io import events
from ..util.file import rename from ..util.file import rename
...@@ -139,6 +142,8 @@ def main(args=None): ...@@ -139,6 +142,8 @@ def main(args=None):
mcmc=opts.mcmc, chain_dump=chain_dump, mcmc=opts.mcmc, chain_dump=chain_dump,
enable_snr_series=opts.enable_snr_series, enable_snr_series=opts.enable_snr_series,
f_high_truncate=opts.f_high_truncate) f_high_truncate=opts.f_high_truncate)
if not opts.enable_multiresolution:
sky_map = rasterize(sky_map)
sky_map.meta['objid'] = str(graceid) sky_map.meta['objid'] = str(graceid)
sky_map.meta['url'] = '{}/{}'.format(base_url, graceid) sky_map.meta['url'] = '{}/{}'.format(base_url, graceid)
log.info("sky localization complete") log.info("sky localization complete")
......
...@@ -54,6 +54,9 @@ def parser(): ...@@ -54,6 +54,9 @@ def parser():
help='number of trials at each clustering number') help='number of trials at each clustering number')
parser.add_argument('--enable-distance-map', action=EnableAction, parser.add_argument('--enable-distance-map', action=EnableAction,
help='generate HEALPix map of distance estimates') help='generate HEALPix map of distance estimates')
parser.add_argument('--enable-multiresolution', action=EnableAction,
default=False,
help='generate a multiresolution HEALPix map')
parser.add_argument('-j', '--jobs', action='store_true', parser.add_argument('-j', '--jobs', action='store_true',
help='Use multiple threads') help='Use multiple threads')
parser.add_argument('--objid', help='event ID to store in FITS header') parser.add_argument('--objid', help='event ID to store in FITS header')
...@@ -66,6 +69,7 @@ def main(args=None): ...@@ -66,6 +69,7 @@ def main(args=None):
# Late imports # Late imports
from .. import io from .. import io
from ..bayestar import rasterize
from .. import version from .. import version
from astropy.table import Table from astropy.table import Table
from astropy.time import Time from astropy.time import Time
...@@ -124,6 +128,8 @@ def main(args=None): ...@@ -124,6 +128,8 @@ def main(args=None):
log.info('making skymap') log.info('making skymap')
hpmap = skypost.as_healpix() hpmap = skypost.as_healpix()
if not args.enable_multiresolution:
hpmap = rasterize(hpmap)
hpmap.meta.update(io.fits.metadata_for_version_module(version)) hpmap.meta.update(io.fits.metadata_for_version_module(version))
hpmap.meta['creator'] = _parser.prog hpmap.meta['creator'] = _parser.prog
hpmap.meta['origin'] = 'LIGO/Virgo' hpmap.meta['origin'] = 'LIGO/Virgo'
......
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