def visibility_main(): """Plot a single target.""" parser = argparse.ArgumentParser( description="A visibility plotter for a single target.") parser.add_argument("target", type=six.text_type, help="Object name as resolved by SIMBAD") parser.add_argument("-d", "--date", help="Date before night, as parsed by Astropy.", default=Time.now()) parser.add_argument("-o", "--output", type=six.text_type, help="Output filename.") parser.add_argument("-O", "--observatory", type=six.text_type, help="Observatory Name", default="Mauna Kea") parser.add_argument("--tz", type=six.text_type, help="Local Timezone.") parser.add_argument("--show", action="store_true", help="Show, don't save.") options = parser.parse_args() # Setup Target t = Target(name=options.target, position=ICRS.from_name(options.target)) date = Time(options.date, scale='utc') if not options.output: options.output = "visibility_{0}_{1:%Y%m%d}.pdf".format( t.name.replace(" ", "_"), date.datetime) o = Observatory.from_name(options.observatory) print(o) t.compute(o) print(t) # Setup Figure fig = plt.figure() bbox = (0.1, 0.1, 0.65, 0.8) # l, b, w, h v_ax = fig.add_axes(bbox) v = VisibilityPlot(o, date) v.add(t) v(v_ax, moon_distance_maximum=(60 * u.degree)) if options.show: plt.show() else: plt.savefig(options.output) subprocess.call(["open", options.output])
def test_table_can_be_read_and_coords_good(): objs = Table.read(TABLE_NAME, format='ascii', delimiter=',') columns = ['object', 'ra', 'dec'] for col in columns: assert col in objs.colnames for row in objs: try: simbad_pos = ICRS.from_name(row['object']) except name_resolve.NameResolveError: continue table_pos = ICRS(row['ra'], row['dec'], unit=(u.hour, u.degree)) # CHANGE ASSERT TO IF/THEN, print name then assert 0 sep = table_pos.separation(simbad_pos).arcsec warn = '' if sep > MAX_SEP: warn = ('Bad RA/Dec for object {}, ' 'separation is {} arcsec'.format(row['object'], sep)) print (warn) assert len(warn) == 0
def visibility_main(): """Plot a single target.""" parser = argparse.ArgumentParser(description="A visibility plotter for a single target.") parser.add_argument("target", type=six.text_type, help="Object name as resolved by SIMBAD") parser.add_argument("-d","--date", help="Date before night, as parsed by Astropy.", default=Time.now()) parser.add_argument("-o","--output", type=six.text_type, help="Output filename.") parser.add_argument("-O", "--observatory", type=six.text_type, help="Observatory Name", default="Mauna Kea") parser.add_argument("--tz", type=six.text_type, help="Local Timezone.") parser.add_argument("--show", action="store_true", help="Show, don't save.") options = parser.parse_args() # Setup Target t = Target(name=options.target, position=ICRS.from_name(options.target)) date = Time(options.date, scale='utc') if not options.output: options.output = "visibility_{0}_{1:%Y%m%d}.pdf".format(t.name.replace(" ", "_"), date.datetime) o = Observatory.from_name(options.observatory) print(o) t.compute(o) print(t) # Setup Figure fig = plt.figure() bbox = (0.1, 0.1, 0.65, 0.8) # l, b, w, h v_ax = fig.add_axes(bbox) v = VisibilityPlot(o, date) v.add(t) v(v_ax, moon_distance_maximum=(60 * u.degree)) if options.show: plt.show() else: plt.savefig(options.output) subprocess.call(["open", options.output])
def set_targets(self, v_plotter): """Setup the single target.""" t = Target(name=self.opts.target, position=ICRS.from_name(self.opts.target)) self.log.log(_ll(2), t) v_plotter.add(t)
logger.error('Must supply gpstime') sys.exit(1) coord = None if options.ra is not None and options.dec is not None: ra, dec = options.ra, options.dec if 'h' in ra or ':' in ra: coord = ICRS(ra=ra, dec=dec, unit=(u.hour, u.degree)) else: coord = ICRS(ra=ra, dec=dec, unit=(u.degree, u.degree)) if options.l is not None and options.b is not None: coord = Galactic(l=options.l, b=options.b, unit=(u.degree, u.degree)).transform_to(ICRS) if options.source is not None: try: coord = ICRS.from_name(options.source) except: logger.error("Unable to find coordinates for '%s'" % options.source) sys.exit(1) if coord is None: logger.error('Must supply one of (RA,Dec), (l,b), source') sys.exit(1) observation_num = get_observation_info.find_closest_observation(observationid, maxdiff=0, db=db) if observation_num is None: logger.error('Observation not found for gpstime=%d' % observationid) sys.exit(1) obs = get_observation_info.MWA_Observation(observationid, db=db)