Commit 718d9186 authored by Leo Pound Singer's avatar Leo Pound Singer

Add ligo-skymap-flatten

parent bc610f71
......@@ -17,6 +17,9 @@ Changelog
- Fix an error in the volume element that resulted in ``ligo-skymap-stats``
underestimating credible volumes by a factor of 2.
- Add the ``ligo-skymap-flatten`` tool to convert multi-resolution HEALPix
files to flat, fixed-resolution, implicitly indexed HEALPix files.
0.0.17 (2018-10-24)
Flatten Multi-Resolution Sky Maps (`ligo-skymap-flatten`)
.. argparse::
:module: ligo.skymap.tool.ligo_skymap_flatten
:func: parser
# Copyright (C) 2018 Leo Singer
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
"""Convert a HEALPix FITS file from multi-resolution UNIQ indexing to the more
common IMPLICIT indexing."""
from . import ArgumentParser, FileType
def parser():
parser = ArgumentParser(description=__doc__)
parser.add_argument('input', metavar='INPUT.fits[.gz]',
type=FileType('rb'), help='Input FITS file')
parser.add_argument('output', metavar='OUTPUT.fits',
type=FileType('wb'), help='Output FITS file')
return parser
def main(args=None):
args = parser().parse_args(args)
import sys
from import fits
from import read_sky_map, write_sky_map
from ..bayestar import rasterize
hdus =
ordering = hdus[1].header['ORDERING']
expected_ordering = 'NUNIQ'
if ordering != expected_ordering:
print('error: expected the FITS file',, 'to have ordering', expected_ordering,
'but it is', ordering, file=sys.stderr)
table = read_sky_map(hdus, moc=True)
write_sky_map(args.output, rasterize(table), nest=True)
......@@ -74,6 +74,7 @@ bayestar-realize-coincs = ligo.skymap.tool.bayestar_realize_coincs:main
bayestar-sample-model-psd = ligo.skymap.tool.bayestar_sample_model_psd:main
ligo-skymap-combine = ligo.skymap.tool.ligo_skymap_combine:main
ligo-skymap-contour = ligo.skymap.tool.ligo_skymap_contour:main
ligo-skymap-flatten = ligo.skymap.tool.ligo_skymap_flatten:main
ligo-skymap-from-samples = ligo.skymap.tool.ligo_skymap_from_samples:main
ligo-skymap-plot = ligo.skymap.tool.ligo_skymap_plot:main
ligo-skymap-plot-airmass = ligo.skymap.tool.ligo_skymap_plot_airmass:main
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