Commit 5620799e authored by Leo Pound Singer's avatar Leo Pound Singer

Add options to specify site manually

parent 574cb4a2
......@@ -5,7 +5,8 @@ Changelog
0.1.6 (unreleased)
- No changes yet.
- Add options to ``ligo-skymap-plot-airmass`` to specify site coordinates
explicitly rather than by a site nickname.
0.1.5 (2019-03-20)
......@@ -33,11 +33,27 @@ def parser():
'input', metavar='INPUT.fits[.gz]', type=FileType('rb'),
default='-', nargs='?', help='Input FITS file')
'--time', help='UTC time')
'--site', choices=EarthLocation.get_site_names(),
help='Observatory site', required=True)
help='Observatory site')
'--time', help='UTC time')
'--site-longitude', metavar='DEG', type=float,
help='Observatory longitude on the WGS84 ellipsoid. '
'Mutually exclusive with --site.')
'--site-latitude', metavar='DEG', type=float,
help='Observatory latitude on the WGS84 ellipsoid. '
'Mutually exclusive with --site.')
'--site-height', metavar='METERS', type=float,
help='Observatory height from the WGS84 ellipsoid .'
'Mutually exclusive with --site.')
help='Observatory time zone, e.g. "US/Pacific". '
'Mutually exclusive with --site.')
return parser
......@@ -52,7 +68,8 @@ def clip_verylarge(x, max=1e300):
def main(args=None):
opts = parser().parse_args(args)
p = parser()
opts = p.parse_args(args)
# Late imports
import operator
......@@ -60,9 +77,10 @@ def main(args=None):
from astroplan import Observer
from astroplan.plots import plot_airmass
from astropy.coordinates import SkyCoord
from astropy.coordinates import EarthLocation, SkyCoord
from astropy.table import Table
from astropy.time import Time
from astropy import units as u
from matplotlib import dates
from matplotlib.patches import Patch
from matplotlib import pyplot as plt
......@@ -74,13 +92,33 @@ def main(args=None):
from .. import plot # noqa
from ..extern.quantile import percentile
if is None:
if opts.site_longitude is None or opts.site_latitude is None:
p.error('must specify either --site or both '
'--site-longitude and --site-latitude')
location = EarthLocation(
lon=opts.site_longitude * u.deg,
lat=opts.site_latitude * u.deg,
height=(opts.site_height or 0) * u.m)
if opts.site_timezone is not None: = {'timezone': opts.site_timezone}
observer = Observer(location)
if not((opts.site_longitude is None) and
(opts.site_latitude is None) and
(opts.site_height is None) and
(opts.site_timezone is None)):
p.error('argument --site not allowed with arguments '
'--site-longitude, --site-latitude, '
'--site-height, or --site-timezone')
observer = Observer.at_site(
m = fits.read_sky_map(, moc=True)
# Make an empty airmass chart.
# FIXME: have to add a dummy target until
# is in a release of astroplan
observer = Observer.at_site(
t0 = Time(opts.time) if opts.time is not None else
t0 = observer.midnight(t0)
ax = plot_airmass(
......@@ -152,7 +190,7 @@ def main(args=None):
zorder=3, linewidth=0)
# Add local time axis
timezone ='timezone')
timezone = ( or {}).get('timezone')
if timezone:
tzinfo = pytz.timezone(timezone)
ax2 = ax.twiny()
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