Esempio n. 1
0
def format_observatories(observatories):
    """

    A function that takes an input containing observatory information and
    formally casts it into a list of Observer objects.

    TO IMPLEMENT:
        Only takes a list of dictionaries as input, consider generalizing -
            IMPLEMENTED, BUT COULD BE BETTER

    Args:
        observatories: List of dictionaries, with each dictionary containing
            the information necessary to initialize an Observer object

                {'name' key : string value,
                 'location' key : EarthLocation value}

    Returns:
        List of Observer objects

    """
    if type(observatories) is list:
        return [
            Observer(location=observatory.get('location'),
                     name=observatory.get('name'))
            for observatory in observatories
        ]

    elif type(observatories) is dict:
        return Observer(location=observatories.get('location'),
                        name=observatories.get('name'))
Esempio n. 2
0
def print_parangs(name, beg_time, end_time, coord_ra, coord_dec, timezone):
    """
    Prints the parallactic angle range given the start and end observing
    times (in UCT/GMT), the telescope name and the celestial target
    coordinates.

    Currently accepted telescope names : uGMRT or MeerKAT (case insensitive)

    The beg time and end time should be in the format '2020-01-01T00:00:00'

    The target coordinates must be in HMS DMS (i.e., 00h00m00s +00d00m00s)
    """

    from astroplan import Observer
    import astropy.units as u
    from astropy.coordinates import SkyCoord
    from astropy.time import Time

    import numpy as np

    if name.lower() == 'ugmrt' or name.lower() == 'gmrt':
        obs = Observer(longitude='74d02m59s',
                       latitude='19d05m47s',
                       elevation=0 * u.m,
                       name='uGMRT',
                       timezone=timezone)
    elif name.lower() == 'meerkat':
        obs = Observer(longitude='21d24m40s',
                       latitude='-30d43m16s',
                       elevation=0 * u.m,
                       name='MeerKAT',
                       timezone=timezone)
    elif name.lower() == 'alma':
        obs = Observer(longitude='67d45m12s',
                       latitude='-23d01m09s',
                       elevation=0 * u.m,
                       name='ALMA',
                       timezone=timezone)
    else:
        raise NotImplementedError("Unknown telescope name")

    coord = SkyCoord(coord_ra, coord_dec)

    beg_time = Time(beg_time)
    end_time = Time(end_time)

    parang_beg = np.rad2deg(obs.parallactic_angle(beg_time, coord))
    parang_end = np.rad2deg(obs.parallactic_angle(end_time, coord))

    print("Beginning parallactic angle {:.3f}".format(parang_beg))
    print("Ending parallactic angle {:.3f}".format(parang_end.deg))

    print("Parang delta {:.3f}".format(parang_end - parang_beg))
Esempio n. 3
0
def date2dict_times(date):
    day = Time(date, format='iso')

    longitude = '78d57m53s'
    latitude = '32d46m44s'
    elevation = 4500 * u.m
    location = EarthLocation.from_geodetic(longitude, latitude, elevation)
    iaohanle = Observer(location=location,
                        name="IAO",
                        timezone='Asia/Kolkata',
                        description="GROWTH-India 70cm telescope")

    sunset_iao = iaohanle.sun_set_time(day, which='next')
    sunrise_iao = iaohanle.sun_rise_time(day, which='next')
    twelve_twil_eve_iao = iaohanle.twilight_evening_nautical(day, which='next')
    eighteen_twil_eve_iao = iaohanle.twilight_evening_astronomical(
        day, which='next')
    twelve_twil_morn_iao = iaohanle.twilight_morning_nautical(day,
                                                              which='next')
    eighteen_twil_morn_iao = iaohanle.twilight_morning_astronomical(
        day, which='next')

    dict_times = OrderedDict()
    dict_times['Sunset '] = time2utc_ist(sunset_iao)
    dict_times['Sunrise '] = time2utc_ist(sunrise_iao)
    dict_times['Twelve degree Evening Twilight '] = time2utc_ist(
        twelve_twil_eve_iao)
    dict_times['Eighteen degree Evening Twilight '] = time2utc_ist(
        eighteen_twil_eve_iao)
    dict_times['Twelve degree Morning Twilight '] = time2utc_ist(
        twelve_twil_morn_iao)
    dict_times['Eighteen degree Morning Twilight '] = time2utc_ist(
        eighteen_twil_morn_iao)
    return dict_times
Esempio n. 4
0
    def nautical_twilight(self,
                          date_obs,
                          site_longitude=30.335555,
                          site_latitude=36.824166,
                          site_elevation=2500,
                          site_name="tug",
                          time_zone="Europe/Istanbul",
                          which="next"):

        # TUG's location info settings
        tug = Observer(longitude=site_longitude * u.deg,
                       latitude=site_latitude * u.deg,
                       elevation=site_elevation * u.m,
                       name=site_name,
                       timezone=time_zone)

        # convert date astropy date format
        astropy_time = Time(date_obs)

        # evening tw calculate
        et = tug.twilight_evening_nautical(astropy_time, which=which)

        # morning tw calculate
        mt = tug.twilight_morning_nautical(astropy_time, which=which)

        # localized time conversion
        return (tug.astropy_time_to_datetime(mt),
                tug.astropy_time_to_datetime(et))
Esempio n. 5
0
def simple_track(ra, dec, frame, time, input_lat, input_lon, alt, plot,
                 alt_limit):
    prototype_dish = EarthLocation(lat=input_lat * u.deg,
                                   lon=input_lon * u.deg,
                                   height=alt * u.m)
    sc = SkyCoord(ra,
                  dec,
                  unit='deg',
                  frame=frame,
                  equinox="J2000",
                  obstime=time[0],
                  location=prototype_dish)
    sc = sc.transform_to('icrs')
    prototype_dish_observer = Observer(location=prototype_dish)

    source_altaz = sc.transform_to(AltAz(obstime=time,
                                         location=prototype_dish))
    for i in range(len(source_altaz)):
        if source_altaz[i].alt.deg > alt_limit:
            print("{0} {1:3.8f} {2:3.8f} {3} {4}".format(
                time[i].mjd,
                source_altaz[i].az.deg,
                source_altaz[i].alt.deg,
                1,
                prototype_dish_observer.parallactic_angle(time=time[i],
                                                          target=sc).deg,
                file=sys.stdout,
                flush=True))
        else:
            break
    if plot == 1:
        plt.scatter(source_altaz.az.deg, source_altaz.alt.deg)
        plt.show()
def culmination_time_utc_astroplan(source_name, date, print_or_not):
    """
    Calculates culmination time in UTC with astroplan library
    """
    # Coordinates of UTR-2 radio telescope
    longitude = '36d56m27.560s'
    latitude = '+49d38m10.310s'
    elevation = 156 * u.m
    observatory = 'UTR-2, Ukraine'
    utr2_location = EarthLocation.from_geodetic(longitude, latitude, elevation)

    if print_or_not == 1:
        print('\n  Observatory:', observatory, '\n')
        print('  Coordinates: \n  * Longitude: ',
              str(utr2_location.lon).replace("d", "\u00b0 ").replace("m", "\' ").replace("s", "\'\' "),
              ' \n  * Latitude:   ' + str(utr2_location.lat).replace("d", "\u00b0 ").replace("m", "\' ").replace("s", "\'\' ") + '\n')
        print('  Source:', source_name, '\n')

    observer = Observer(location=utr2_location, name='Volokhiv Yar', timezone='UTC')

    alt, az = catalogue_sources(source_name)
    coordinates = SkyCoord(alt, az, frame='icrs')

    target = FixedTarget(coord=coordinates, name="target")
    date_of_obs = Time(date, scale='utc')
    culmination = observer.target_meridian_transit_time(date_of_obs, target, which='next')
    culm_time = culmination.to_datetime().time()

    culm_time = date + ' ' + str(culm_time)[0:8]

    if print_or_not == 1:
        print('  Culmination time:', culm_time, ' UTC \n')

    return culm_time
Esempio n. 7
0
def rise_time(obsnight, coords, tel=None):

    import time
    tstart = time.time()

    tme = Time(str(obsnight.obs_date).split()[0])
    sc = SkyCoord('%s %s' % (coords[0], coords[1]), unit=(u.hourangle, u.deg))

    location = EarthLocation.from_geodetic(
        obsnight.resource.telescope.longitude * u.deg,
        obsnight.resource.telescope.latitude * u.deg,
        obsnight.resource.telescope.elevation * u.m)
    tel = Observer(location=location, timezone="UTC")

    target_rise_time = tel.target_rise_time(tme,
                                            sc,
                                            horizon=18 * u.deg,
                                            which="previous")

    if target_rise_time:
        returnstarttime = target_rise_time.isot.split('T')[-1]
    else:
        returnstarttime = None

    print(time.time() - tstart)

    return (returnstarttime)
Esempio n. 8
0
def tel_move(RA, DEC, n, COLOR, s):
    #initialize  and update position coordinates
    location = EarthLocation.from_geodetic(lon=-111.5947 * u.deg,
                                           lat=31.95844 * u.deg,
                                           height=2097.024 * u.m)
    kittpeak = Observer(location=location, name='kitt peak')
    coord = SkyCoord(ra=RA * u.deg, dec=DEC * u.deg, unit='deg', frame='icrs')
    time = thetime('2018-4-6 00:00:00')
    times = time + (n * u.second)
    lst = kittpeak.local_sidereal_time(times)
    ha = (lst.hour - (RA / 15.0)
          )  # given in hours, converted to degrees later for PA calc
    frame = AltAz(obstime=times, location=location)
    new_coord = coord.transform_to(frame)
    alt = new_coord.alt.degree
    az = new_coord.az.degree

    # parallactic angle calculation -----------------------------------------------------------------------------------
    sina = np.sin(np.radians(ha * 15.0))
    cosa = (np.tan(np.radians(31.95844)) * np.cos(np.radians(DEC))) - (
        np.sin(np.radians(DEC)) * np.cos(np.radians(ha * 15.0)))
    pa = np.degrees(np.arctan2(sina, cosa))

    #s.send(message.encode('utf-8'))
    packer = struct.Struct('d d d d d d d')
    data = packer.pack(pa, slew_flag, alt, az, ra, dec, othertime.time())
    s.send(data)
    return s
    def __init__(self, targets, tzinfo='Australia/Sydney', portal_htmls=[]):
        ### target and calibrators
        if not isinstance(targets, Sequence):
            targets = [targets]
            
        self.targets = targets
        self.calibrator = [FixedTarget(name='1934-638', coord=SkyCoord('19h39m25.026s -63d42m45.63s')),
                           FixedTarget(name='0823-500', coord=SkyCoord('08h25m26.869s -50d10m38.49s'))]
        ### observer
        ATCA_loc = (149.5501388*u.deg,-30.3128846*u.deg,237*u.m)
        location = EarthLocation.from_geodetic(*ATCA_loc)

        self.observer = Observer(name='ATCA',
                                 location=location,
                                 timezone=timezone('Australia/Sydney'))
        time_now = datetime.now(timezone(tzinfo))
        self.utcoffset = time_now.utcoffset()
        self.tzinfo = tzinfo
        
        if len(portal_htmls) == 0:
            self.portal_tz = None
            self.portal_sched = None
        else:
            atca_scheds = ATCA_sched(portal_htmls)
            self.portal_tz = atca_scheds.timezone
            self.portal_sched = atca_scheds.schedules
            
            ### portal utcoffset
            portal_now = datetime.now(timezone(self.portal_tz))
            self.portal_utcoffset = portal_now.utcoffset()
Esempio n. 10
0
def get_info_of_target(target, *args, **kwargs):
    ra = target.ra
    dec = target.dec
    coords = SkyCoord(ra=ra, dec=dec, unit=(u.degree, u.degree))
    hanle = EarthLocation(lat=32.77889 * u.degree,
                          lon=78.96472 * u.degree,
                          height=4500 * u.m)
    iao = Observer(location=hanle, name="GIT", timezone="Asia/Kolkata")
    twilight_prime = iao.sun_rise_time(
        Time(datetime.utcnow()),
        which="next",
        horizon=sunrise_horizon * u.degree) - 12 * u.hour
    targets_rise_time = iao.target_rise_time(twilight_prime,
                                             coords,
                                             which="nearest",
                                             horizon=horizon * u.degree)
    targets_set_time = iao.target_set_time(targets_rise_time,
                                           coords,
                                           which="next",
                                           horizon=horizon * u.degree)
    rise_time_IST = (targets_rise_time + 5.5 * u.hour).isot
    set_time_IST = (targets_set_time + 5.5 * u.hour).isot
    tend = targets_set_time
    mooncoords = get_moon(tend, hanle)
    sep = mooncoords.separation(coords)
    print(target.name, rise_time_IST, set_time_IST, sep)
def site_information(UhaveE_ID, longitude, latitude, altitude):
    site_inf = Observer(longitude=longitude * u.deg,
                        latitude=latitude * u.deg,
                        elevation=altitude * u.m,
                        name=UhaveE_ID)
    # u.deg set the unit to degree
    return site_inf
Esempio n. 12
0
def test_months_observable():
    obs = Observer(latitude=0 * u.deg, longitude=0 * u.deg, elevation=0 * u.m)

    coords = [
        SkyCoord(ra=0 * u.hourangle, dec=0 * u.deg),
        SkyCoord(ra=6 * u.hourangle, dec=0 * u.deg),
        SkyCoord(ra=12 * u.hourangle, dec=0 * u.deg),
        SkyCoord(ra=18 * u.hourangle, dec=0 * u.deg)
    ]
    targets = [FixedTarget(coord=coord) for coord in coords]
    constraints = [
        AltitudeConstraint(min=80 * u.deg),
        AtNightConstraint.twilight_astronomical()
    ]
    time_range = Time(['2014-01-01', '2014-12-31'])
    months = months_observable(constraints, obs, targets, time_range)

    should_be = [
        set({7, 8, 9, 10, 11, 12}),
        set({1, 2, 3, 10, 11, 12}),
        set({1, 2, 3, 4, 5, 6}),
        set({4, 5, 6, 7, 8, 9})
    ]

    assert months == should_be
Esempio n. 13
0
def add_obsairmass_df_comp_obs(df_comp_obs, site_dict, df_comps, df_images):
    observer = Observer(longitude=site_dict['longitude'] * u.deg,
                        latitude=site_dict['latitude'] * u.deg,
                        elevation=site_dict['elevation'] * u.m)
    df_comp_obs['ObsAirmass'] = None
    skycoord_dict = {
        comp_id: SkyCoord(ra=ra_deg * u.deg, dec=dec_deg * u.deg)
        for (comp_id, ra_deg, dec_deg
             ) in zip(df_comps.index, df_comps['RA_deg'], df_comps['Dec_deg'])
    }
    altaz_frame_dict = {
        filename: observer.altaz(Time(jd_mid, format='jd'))
        for (filename,
             jd_mid) in zip(df_images['FITSfile'], df_images['JD_mid'])
    }
    print('ObsAirmasses: ', end='', flush=True)
    done_count = 0
    for obs, filename, comp_id in zip(df_comp_obs.index,
                                      df_comp_obs['FITSfile'],
                                      df_comp_obs['CompID']):
        alt = skycoord_dict[comp_id].transform_to(
            altaz_frame_dict[filename]).alt.value
        df_comp_obs.loc[obs,
                        'ObsAirmass'] = 1.0 / sin(alt / DEGREES_PER_RADIAN)
        done_count += 1
        if done_count % 100 == 0:
            print('.', end='', flush=True)
    print('\nObsAirmasses written to df_comp_obs:', str(len(df_comp_obs)))
Esempio n. 14
0
def observer(config):
    loc = config['location']
    location = EarthLocation(lon=loc['longitude'],
                             lat=loc['latitude'],
                             height=loc['elevation'])
    return Observer(location=location,
                    name="Test Observer",
                    timezone=loc['timezone'])
Esempio n. 15
0
def main():
    #define observer located at ckoirama observatory
    location = EarthLocation.from_geodetic(-69.930544 * u.deg,
                                           -24.089385 * u.deg, 980 * u.m)
    ckoirama = Observer(location=location,
                        name="Ckoirama",
                        timezone="Chile/Continental")
    time = Time('2018-05-06 12:00:00')
Esempio n. 16
0
def compute_is_up(name, time):
    '''
    Computes what V<11 objects in a catalog are up right now.

    args:
        name (str): one in: ['messier', 'ngc']
        time (str): in 24hr format, e.g. "2017-04-17 21:00:00"

    returns:
        catalog with is_up calculated, sorted by v_mag.
    '''

    import datetime
    from astropy.time import Time
    from astroplan import FixedTarget
    from astropy.coordinates import SkyCoord
    from astroplan import Observer, FixedTarget, AltitudeConstraint, \
        AtNightConstraint, is_observable, is_always_observable, \
        months_observable

    assert name in ['messier', 'ngc']

    if name == 'messier':
        data_path = '../data/catalogs/messier.csv'
    elif name == 'ngc':
        data_path = '../data/catalogs/ngc.csv'

    df = pd.read_csv(data_path)
    # The search & target creation is slow for >~thousands of FixedTargets. NGC
    # catalog is 13226 objects. Take those with v_mag<11, since from Peyton we
    # likely won't go fainter.
    df = df.sort_values('v_mag')
    df = df[df['v_mag']<11]

    peyton = Observer(longitude=74.65139*u.deg, latitude=40.34661*u.deg,
        elevation=62*u.m, name='Peyton', timezone='US/Eastern')

    if name == 'ngc':
        ras = np.array(df['ra'])*u.hourangle
        decs = np.array(df['dec'])*u.degree
        names = np.array(df['ngc_id'])
    elif name == 'messier':
        ras = np.array(df['ra'])*u.hourangle
        decs = np.array(df['dec'])*u.degree
        names = np.array(df['messier_id'])

    targets = [FixedTarget(SkyCoord(ra=r, dec=d), name=n) for r, d, n in
            tuple(zip(ras, decs, names))]

    constraints = [AltitudeConstraint(10*u.deg, 82*u.deg),
            AtNightConstraint(max_solar_altitude=-3.*u.deg)]

    t_obs = Time(time)
    is_up = is_observable(constraints, peyton, targets, times=t_obs)

    df['is_up'] = is_up

    return df
Esempio n. 17
0
    def __init__(self,
                 name,
                 codename,
                 network,
                 location,
                 freqs_sefds,
                 min_elevation=20 * u.deg,
                 fullname=None,
                 all_networks=None,
                 country='',
                 diameter=''):
        """Initializes a station. The given name must be the name of the station that
        observes, with the typical 2-letter format used in the EVN (with exceptions).

        Inputs
        - name : str
            Name of the observer (the station that is going to observe).
        - codename : str
            A code for the name of the station. It can be the same as name.
        - network : str
            Name of the network to which the station belongs.
        - location : EarthLocation
            Position of the observer on Earth.
        - freqs_sefds : dict
            Dictionary with all frequencies the station can observe, and as values
            the SEFD at each frequency.
        - min_elevation : Quantity
            Minimum elevation that the station can observe a source. If no units
            provided, degrees are assumed. By default it 20 degrees.
        - fullname : str [OPTIONAL]
            Full name of the station. If not given, `name` is assumed.
        - all_networks : str [OPTIONAL]
            Networks where the station can participate (free style).
        - country : str [OPTIONAL]
            Country where the station is placed.
        """
        self.observer = Observer(name=name.replace('_', ' '),
                                 location=location)
        self._codename = codename
        self._network = network
        self._freqs_sefds = freqs_sefds
        if (type(min_elevation) is float) or (type(min_elevation) is int):
            self._min_elev = min_elevation * u.deg
        else:
            self._min_elev = min_elevation

        if fullname is None:
            self._fullname = name
        else:
            self._fullname = fullname

        if all_networks is None:
            self._all_networks = network
        else:
            self._all_networks = all_networks

        self._country = country
        self._diameter = diameter
Esempio n. 18
0
def goto_north():
    """Observer for GOTO-North on La Palma."""
    lapalma = EarthLocation(lon=-17.8947 * u.deg,
                            lat=28.7636 * u.deg,
                            height=2396 * u.m)
    telescope = Observer(name='goto_north',
                         location=lapalma,
                         timezone='Atlantic/Canary')
    return telescope
Esempio n. 19
0
def goto_south():
    """Observer for a (theoretical) GOTO-South in Melbourne."""
    clayton = EarthLocation(lon=145.131389 * u.deg,
                            lat=-37.910556 * u.deg,
                            height=50 * u.m)
    telescope = Observer(name='goto_south',
                         location=clayton,
                         timezone='Australia/Melbourne')
    return telescope
Esempio n. 20
0
def _get_observer_tzinfo(session_plan):
    loc_name, latitude, longitude, elevation = _get_location_info_from_session_plan(
        session_plan)
    loc_coords = EarthLocation.from_geodetic(
        longitude * u.deg, latitude * u.deg,
        elevation * u.m if elevation else 0)
    tz_info = _get_session_plan_tzinfo(session_plan)
    observer = Observer(name=loc_name, location=loc_coords, timezone=tz_info)
    return observer, tz_info
Esempio n. 21
0
    def _setup_location(self):
        """
        Sets up the site and location details for the observatory

        Note:
            These items are read from the 'site' config directive and include:
                * name
                * latitude
                * longitude
                * timezone
                * presseure
                * elevation
                * horizon

        """
        self.logger.debug('Setting up site details of observatory')

        try:
            config_site = self.config.get('location')

            name = config_site.get('name', 'Nameless Location')

            latitude = config_site.get('latitude')
            longitude = config_site.get('longitude')

            timezone = config_site.get('timezone')
            utc_offset = config_site.get('utc_offset')

            pressure = config_site.get('pressure', 0.680) * u.bar
            elevation = config_site.get('elevation', 0 * u.meter)
            horizon = config_site.get('horizon', 30 * u.degree)
            twilight_horizon = config_site.get('twilight_horizon',
                                               -18 * u.degree)

            self.location = {
                'name': name,
                'latitude': latitude,
                'longitude': longitude,
                'elevation': elevation,
                'timezone': timezone,
                'utc_offset': utc_offset,
                'pressure': pressure,
                'horizon': horizon,
                'twilight_horizon': twilight_horizon,
            }
            self.logger.debug("Location: {}".format(self.location))

            # Create an EarthLocation for the mount
            self.earth_location = EarthLocation(lat=latitude,
                                                lon=longitude,
                                                height=elevation)
            self.observer = Observer(location=self.earth_location,
                                     name=name,
                                     timezone=timezone)
        except Exception:
            raise error.PanError(msg='Bad site information')
Esempio n. 22
0
 def get_location(self):
     location_cfg = self.config.get('location', None)
     location = EarthLocation(
         lat=location_cfg['latitude'],
         lon=location_cfg['longitude'],
         height=location_cfg['elevation'],
     )
     return Observer(location=location,
                     name=location_cfg['name'],
                     timezone=location_cfg['timezone'])
Esempio n. 23
0
    def get_sunset_sunrise(self, time):
        """
      Returns the sunset and sunrise times of the night containing the time provided
      time is a astropy Time object
      The sunset and sunrise times are returns as an astropy Time object with the same
      settings as the provided Time object.
      """
        observer = Observer(location=self.get_EarthLocation())
        sunset = observer.sun_set_time(time, which='nearest')
        sunrise = observer.sun_rise_time(time, which='nearest')

        return sunset, sunrise
Esempio n. 24
0
def main():
    #define observer located at ckoirama observatory
    location = EarthLocation.from_geodetic(-69.930544 * u.deg,
                                           -24.089385 * u.deg, 980 * u.m)
    ckoirama = Observer(location=location,
                        name="Ckoirama",
                        timezone="Chile/Continental")
    #ask user for target coordinates
    coord, coord_unit = get_coordinates()
    #ask user for observation date
    time = get_date()
    visibility(ckoirama, coord, time, unit=coord_unit)
Esempio n. 25
0
def choose_loc(location):
    loc_list = {
        "COJ":
        Observer(longitude=149.071111 * u.deg,
                 latitude=-31.273333 * u.deg,
                 elevation=1116 * u.m,
                 name="Siding Spring Observatory"),
        "CPT":
        Observer(longitude=20.81 * u.deg,
                 latitude=-32.38 * u.deg,
                 elevation=1760 * u.m,
                 name="South African Astronomical Observatory"),
        "TFN":
        Observer(longitude=-16.509722 * u.deg,
                 latitude=28.3 * u.deg,
                 elevation=2330 * u.m,
                 name="Teide Observatory"),
        "LSC":
        Observer(longitude=-70.804722 * u.deg,
                 latitude=-30.1675 * u.deg,
                 elevation=2198 * u.m,
                 name="Cerro Tololo Interamerican Observatory"),
        "ELP":
        Observer(longitude=-104.02 * u.deg,
                 latitude=30.67 * u.deg,
                 elevation=2070 * u.m,
                 name="McDonald Observatory"),
        "OGG":
        Observer(longitude=-156.256111 * u.deg,
                 latitude=20.7075 * u.deg,
                 elevation=3055 * u.m,
                 name="Haleakala Observatory"),
        "TLV":
        Observer(longitude=34.763333 * u.deg,
                 latitude=30.595833 * u.deg,
                 elevation=875 * u.m,
                 name="Wise Observatory"),
        "NGQ":
        Observer(longitude=80.016667 * u.deg,
                 latitude=32.316667 * u.deg,
                 elevation=5100 * u.m,
                 name="Ali Observatory")
    }

    if location in loc_list:
        return loc_list[location]
Esempio n. 26
0
 def __init__(self, index, lon, lat, name):
     global arr
     self.index = index
     self.lon = lon
     self.lat = lat
     self.name = name
     self.elocation = EarthLocation(lat=lat * u.deg,
                                    lon=lon * u.deg,
                                    height=100 * u.m)
     self.transformed = []
     self.observer = Observer(location=self.elocation,
                              name=name)  #### timezone fix
     for i in range(len(arr)):
         self.transformed.append(arr[i].transform_to(
             AltAz(obstime=reftime, location=self.elocation)))
Esempio n. 27
0
def JD2HJD(JD, ra, dec):
    # JD2HJD for Kittpeak!
    location = EarthLocation.from_geodetic(-111.5967 * u.deg, 31.9583 * u.deg,
                                           2096 * u.m)
    kp = Observer(location=location, name="Kitt Peak", timezone="US/Arizona")

    # convert JD to HJD
    target = coord.SkyCoord(ra * u.deg, dec * u.deg, frame='icrs')
    #tsite = coord.EarthLocation.of_site(site)
    times = Time(JD, format='jd', scale='utc', location=location)
    ltt_helio = times.light_travel_time(target, 'heliocentric')

    HJD = JD + ltt_helio

    return HJD
Esempio n. 28
0
def defineCAHA():
    """
    Define Calar Alto observational site.

    Parameters
    ----------
    None

    Returns
    -------
    CAHA : astroplan Observer object
        Calar Alto Observatory, Spain
    """
    return Observer(longitude=Angle('-2d32.8m'), latitude=Angle('37d13.4m'),
                    elevation=2168*u.m, name="CAHA", timezone="Europe/Madrid")
 def __getattr__(self, attr):
     #logging.info(f'{self.__dict__}')
     # see if they are asking for observer which
     # we construct on the fly from 'real' config items
     if attr == 'observer':
         if self._data_complete():
             return Observer(longitude=self.longitude * u.deg,
                             latitude=self.latitude * u.deg,
                             elevation=self.altitude * u.m,
                             timezone=self.timezone,
                             name=self.obsname)
         else:
             return None
     else:
         return super().__getattribute__(attr)
Esempio n. 30
0
    def sortie_graphique(self, etoile_cible, date_obs, observatoire):
        matplotlib.rcParams['backend'] = 'Qt5Agg'
        # Etoiles
        etoile = FixedTarget(etoile_cible['equat'], name=etoile_cible['nom'])

        # Intervalle de temps
        temps_obs = Time(date_obs)
        debut = temps_obs - TimeDelta(10800.0, format='sec')
        fin = temps_obs + TimeDelta(10800.0, format='sec')
        delta_t = fin - debut
        intervalle_temps_1 = debut + delta_t * np.linspace(0, 1, 75)
        intervalle_temps_2 = debut + delta_t * np.linspace(0, 1, 11)

        # Observatoire
        obs = Observer(location=observatoire, timezone="UTC")

        # Masse d'air
        if self.graph1 is None:
            self.fig1, self.graph1 = plt.subplots()
        else:
            self.graph1.clear()
        plot_airmass(etoile,
                     obs,
                     intervalle_temps_1,
                     ax=self.graph1,
                     altitude_yaxis=True,
                     max_region=2.0)
        self.graph1.legend(shadow=True, loc='best')
        plt.tight_layout()

        # Carte
        # Il faut obligatoirement que le graphique soit en mode polaire avant l'appel à plot_sky
        if self.graph2 is None:
            self.fig2, self.graph2 = plt.subplots(
                subplot_kw=dict([('projection', 'polar')]))
        else:
            self.graph2.clear()
        style = {'marker': '.'}
        plot_sky(etoile,
                 obs,
                 intervalle_temps_2,
                 ax=self.graph2,
                 style_kwargs=style)
        self.graph2.legend(shadow=True, loc='best')
        plt.tight_layout()

        plt.show(block=False)
        plt.pause(.1)