How to use the astroplan.FixedTarget function in astroplan

To help you get started, we’ve selected a few astroplan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TOMToolkit / tom_base / tom_observations / utils.py View on Github external
:returns: ra/dec positions of the sun over the time range,
        time range between start_time and end_time at interval
    :rtype: astropy SkyCoord, astropy Time
    """

    start = Time(start_time)
    end = Time(end_time)

    time_range = time_grid_from_range(time_range=[start, end], time_resolution=interval*units.minute)

    number_of_days = end.mjd - start.mjd
    if number_of_days*4 < float(interval)/2:
        # Hack to speed up calculation by factor of ~3
        sun_coords = get_sun(time_range[int(len(time_range)/2)])
        sun = FixedTarget(name='sun', coord=SkyCoord(sun_coords.ra, sun_coords.dec, unit='deg'))
    else:
        sun = get_sun(time_range)

    return sun, time_range
github TOMToolkit / tom_base / tom_observations / utils.py View on Github external
:rtype: dict
    """

    if target.type != 'SIDEREAL':
        msg = '\033[1m\033[91mAirmass plotting is only supported for sidereal targets\033[0m'
        logger.info(msg)
        empty_visibility = {}
        return empty_visibility

    if end_time < start_time:
        raise Exception('Start must be before end')

    if airmass_limit is None:
        airmass_limit = 10

    body = FixedTarget(name=target.name, coord=SkyCoord(target.ra, target.dec, unit='deg'))

    visibility = {}
    sun, time_range = get_astroplan_sun_and_time(start_time, end_time, interval)
    for observing_facility in facility.get_service_classes():
        observing_facility_class = facility.get_service_class(observing_facility)
        sites = observing_facility_class().get_observing_sites()
        for site, site_details in sites.items():
            observer = Observer(longitude=site_details.get('longitude')*units.deg,
                                latitude=site_details.get('latitude')*units.deg,
                                elevation=site_details.get('elevation')*units.m)

            sun_alt = observer.altaz(time_range, sun).alt
            obj_airmass = observer.altaz(time_range, body).secz

            bad_indices = np.argwhere(
                (obj_airmass >= airmass_limit) |
github panoptes / POCS / src / panoptes / pocs / scheduler / field.py View on Github external
from astroplan import FixedTarget
from astropy.coordinates import SkyCoord

from panoptes.pocs.base import PanBase


class Field(FixedTarget, PanBase):

    def __init__(self, name, position, equinox='J2000', *args, **kwargs):
        """ An object representing an area to be observed

        A `Field` corresponds to an `~astroplan.ObservingBlock` and contains information
        about the center of the field (represented by an `astroplan.FixedTarget`).

        Arguments:
            name {str} -- Name of the field, typically the name of object at
                center `position`.
            position {str} -- Center of field, can be anything accepted by
                `~astropy.coordinates.SkyCoord`.
            **kwargs {dict} -- Additional keywords to be passed to
                `astroplan.ObservingBlock`.

        """
github panoptes / POCS / pocs / scheduler / target.py View on Github external
from .observation import Observation

try:
    import seaborn
    seaborn.set()
except:
    matplotlib.use('Agg')
    plt.style.use('ggplot')


# ----------------------------------------------------------------------------
# Target Class
# ----------------------------------------------------------------------------


class Target(FixedTarget):

    """An object describing an astronomical target.

    An object representing a possible target which the scheduler is considering,
    also is the object which the scheduler will return when asked for a target
    to observe.
    """

    def __init__(self, target_config, cameras=None, **kwargs):
        """  A FixedTarget object that we want to gather data about.

        A `Target` represents not only the actual object in the night sky
        (via the `self.coord` astropy.SkyCoord attribute) but also the concept
        of a `visit`, which is a list of `Observation`s.

        """
github astropy / astroplan / dev / planning-example.py View on Github external
# `constraints` will be a boolean where True=observable. For a list of
# targets, observatories, or times, `constraints` may be a booleans array

# We will eventually need a more complicated method that minimizes a cost
# function when optimizing an observing schedule given the results of
# `is_observable`.

# ======================================================
# Other useful calculations wrt an observer and a target
#=======================================================

# calculate the distance in alt and az degrees between two targets at
# the given time (e.g. to calculate slew time)
sf = FixedTarget(SkyCoord('09d40m00.00s', '43d00m00.00s'), name='Sf')
sm = FixedTarget(SkyCoord('10d30m00.00s', '36d00m00.00s'), name='Sm')

# Coordinate arithmetic gives separations in RA, Dec, alt, az
dra, ddec = sf.ra - sm.ra, sf.dec - sm.dec
dalt = obs.altaz(time_obs, sf).alt - obs.altaz(time_obs, sm).alt
dazt = obs.altaz(time_obs, sf).az - obs.altaz(time_obs, sm).az
github astropy / astroplan / dev / planning-example.py View on Github external
# an upper limit, lower limit = 1.

# `constraints` will be a boolean where True=observable. For a list of
# targets, observatories, or times, `constraints` may be a booleans array

# We will eventually need a more complicated method that minimizes a cost
# function when optimizing an observing schedule given the results of
# `is_observable`.

# ======================================================
# Other useful calculations wrt an observer and a target
#=======================================================

# calculate the distance in alt and az degrees between two targets at
# the given time (e.g. to calculate slew time)
sf = FixedTarget(SkyCoord('09d40m00.00s', '43d00m00.00s'), name='Sf')
sm = FixedTarget(SkyCoord('10d30m00.00s', '36d00m00.00s'), name='Sm')

# Coordinate arithmetic gives separations in RA, Dec, alt, az
dra, ddec = sf.ra - sm.ra, sf.dec - sm.dec
dalt = obs.altaz(time_obs, sf).alt - obs.altaz(time_obs, sm).alt
dazt = obs.altaz(time_obs, sf).az - obs.altaz(time_obs, sm).az