Esempio n. 1
0
def convertToAngle(value, isHours=None):
    """
    convertToAngle ties to take any value and converts is to the right form in skyfield
    angles. if the value is a string, we convert it to float value. in case of isHours,
    we should have already a string, which represents hours inside. if the value is float
    and we expect to have hours, the float value is normally given in degrees, so we have
    to calculate the numbers in hours.

    :param value:
    :param isHours:
    :return: angle as skyfield angle
    """

    if isinstance(value, str):
        value = stringToDegree(value)
        if value is None:
            return None
    else:
        if isHours:
            value *= 24 / 360

    if isHours:
        angle = Angle(hours=value)
    else:
        angle = Angle(degrees=value)

    return angle
Esempio n. 2
0
    def transform_to_altaz(self, tf=None, sky=None, mount_set_icrs=None):
        # use ev. other refraction methods
        if sky is None:
            tem = pre = hum = 0.
        else:
            tem = sky.temperature
            pre = sky.pressure
            hum = sky.humidity

        ra = Angle(radians=tf.ra.radian * u.radian)
        dec = Angle(radians=tf.dec.radian * u.radian)
        star = Star(ra=ra, dec=dec)
        t = self.ts.utc(tf.obstime.datetime.replace(tzinfo=utc))

        if mount_set_icrs:
            # Apparent GCRS ("J2000.0") coordinates
            alt, az, distance = self.obs.at(t).observe(star).apparent().altaz()
        else:
            # is already apparent
            #
            alt, az, distance = self.obs.at(t).observe(star).apparent().altaz()

        aa = SkyCoord(az=az.to(u.radian),
                      alt=alt.to(u.radian),
                      unit=(u.radian, u.radian),
                      frame='altaz',
                      location=tf.location,
                      obstime=tf.obstime,
                      pressure=pre,
                      temperature=tem,
                      relative_humidity=hum)
        return aa
Esempio n. 3
0
def icrs_to_cirs(ra, dec, epoch, apparent=True):
    """Convert a set of positions from ICRS to CIRS at a given data.

    Parameters
    ----------
    ra, dec : float or np.ndarray
        Positions of source in ICRS coordinates including an optional
        redshift position.
    epoch : time_like
        Time to convert the positions to. Can be any type convertible to a
        time using `caput.time.ensure_unix`.
    apparent : bool
        Calculate the apparent position (includes abberation and deflection).

    Returns
    -------
    ra_cirs, dec_cirs : float or np.ndarray
        Arrays of the positions in *CIRS* coordiantes.
    """
    positions = Star(ra=Angle(degrees=ra), dec=Angle(degrees=dec))

    epoch = ctime.unix_to_skyfield_time(ctime.ensure_unix(epoch))

    earth = ctime.skyfield_wrapper.ephemeris["earth"]
    positions = earth.at(epoch).observe(positions)

    if apparent:
        positions = positions.apparent()

    ra_cirs, dec_cirs, _ = positions.cirs_radec(epoch)

    return ra_cirs._degrees, dec_cirs._degrees
Esempio n. 4
0
def test_J2000T0JNow_2():
    class Test:
        tt = 2458687
        ut1 = 1

    ra, dec = transform.J2000ToJNow(Angle(hours=12), Angle(degrees=180), Test())
    assert ra.hours != 0
    assert dec.degrees != 0
Esempio n. 5
0
def test_J2000T0AltAz_2():
    class Test:
        tt = 2458849.50000
        ut1 = 0.5

    loc = Topos('42.3583 N', '71.0636 W')
    alt, az = transform.J2000ToAltAz(Angle(hours=12), Angle(degrees=45), Test(), loc)
    assert alt.degrees != 0
    assert az.degrees != 0
    def radec_with_proper_motion(self, ra, de, pmra, pmde, verbose=False):
        """
        Calculate the

        INPUT:
        - ra in degrees
        - dec in degrees
        - pmra - in mas/yr
        - pmdec - in mas/yr

        OUTPUT:
        - Angle

        NOTES:
        - Built on Ryan's code
        """
        ra_ang = Angle(degrees=ra)
        de_ang = Angle(degrees=de)
        star_obj = Star(ra=ra_ang,
                        dec=de_ang,
                        ra_mas_per_year=pmra,
                        dec_mas_per_year=pmde)
        astrometric = self.earth.at(self.t).observe(star_obj)
        astrometric_old = self.earth.at(self.t_2000).observe(star_obj)
        ra_out, dec_out, dist_out = astrometric.radec()
        ra_out1, dec_out1, dist_out1 = astrometric_old.radec()
        ra_new = ra_out.to(u.degree).value
        de_new = dec_out.to(u.degree).value
        ra_old = ra_out1.to(u.degree).value
        de_old = dec_out1.to(u.degree).value
        raline = [ra_old, ra_new]
        deline = [de_old, de_new]
        cc = astropy.coordinates.SkyCoord(ra, de, unit=(u.degree, u.degree))
        cc_new = astropy.coordinates.SkyCoord(ra_new,
                                              de_new,
                                              unit=(u.degree, u.degree))
        cc_old = astropy.coordinates.SkyCoord(ra_old,
                                              de_old,
                                              unit=(u.degree, u.degree))
        self.cc_old = cc_old
        self.cc_new = cc_new
        self.ra_s_new = cc_new.ra.to_string(unit=u.hour, sep=':')
        self.de_s_new = cc_new.dec.to_string(unit=u.degree, sep=':')
        self.ra_s_old = cc_old.ra.to_string(unit=u.hour, sep=':')
        self.de_s_old = cc_old.dec.to_string(unit=u.degree, sep=':')

        if verbose:
            print("Coordinates at {:f}: RA={} DEC={}".format(
                self.epoch_old, self.ra_s_old, self.de_s_old))
            print("with  PMRA={} PMDEC={}".format(pmra, pmde))
            print("Coordinates at {:f}: RA={} DEC={}".format(
                self.epoch_new, self.ra_s_new, self.de_s_new))
            print("")
        return cc_new
Esempio n. 7
0
 def make_chart_sdss(self,
                     ra,
                     de,
                     pmra,
                     pmde,
                     name,
                     outdir='findercharts_1d/'):
     ra_ang = Angle(degrees=ra)
     de_ang = Angle(degrees=de)
     star_obj = Star(ra=ra_ang,
                     dec=de_ang,
                     ra_mas_per_year=pmra,
                     dec_mas_per_year=pmde)
     astrometric = self.earth.at(self.t).observe(star_obj)
     astrometric_old = self.earth.at(self.t_2000).observe(star_obj)
     ra_out, dec_out, dist_out = astrometric.radec()
     ra_out1, dec_out1, dist_out1 = astrometric_old.radec()
     ra_new = ra_out.to(u.degree).value
     de_new = dec_out.to(u.degree).value
     ra_old = ra_out1.to(u.degree).value
     de_old = dec_out1.to(u.degree).value
     raline = [ra_old, ra_new]
     deline = [de_old, de_new]
     cc = astropy.coordinates.SkyCoord(ra, de, unit=(u.degree, u.degree))
     cc_new = astropy.coordinates.SkyCoord(ra_new,
                                           de_new,
                                           unit=(u.degree, u.degree))
     cc_old = astropy.coordinates.SkyCoord(ra_old,
                                           de_old,
                                           unit=(u.degree, u.degree))
     fig = figure(figsize=(10, 12))
     fovrad = astropy.coordinates.Angle('0d4m0s')
     oo, oh = astroplan.plots.plot_finder_image(cc_old,
                                                reticle=True,
                                                survey='2MASS-K')
     oo.set_autoscale_on(False)
     oo.plot(raline, deline, transform=oo.get_transform('icrs'))
     oo.set_title(name, fontsize=20)
     ra_s = cc_new.ra.to_string(unit=u.hour, sep=':')
     de_s = cc_new.dec.to_string(unit=u.degree, sep=':')
     #ra_s = [alltargs_uniq.loc[i,'cc'].ra.to_string(unit=u.hour,sep=':') for i in ai]
     #oo.text(0,-.1,'TEST',transform=oo.transAxes)
     oo.text(0,
             -.1,
             'RA (ICRS): ' + ra_s,
             transform=oo.transAxes,
             fontsize=20)
     oo.text(0,
             -.15,
             'DEC (ICRS): ' + de_s,
             transform=oo.transAxes,
             fontsize=20)
     fig.savefig(outdir + name + '.pdf')
     close(fig)
Esempio n. 8
0
    def transform_to_hadec(self, tf=None, sky=None, mount_set_icrs=None):
        tem = sky.temperature
        pre = sky.pressure
        hum = sky.humidity

        ra = Angle(radians=tf.ra.radian * u.radian)
        dec = Angle(radians=tf.dec.radian * u.radian)
        star = Star(ra=ra, dec=dec)
        #HA= self.obs.sidereal_time() - star.ra
        #ha=SkyCoord(ra=HA,dec=star.dec, unit=(u.radian,u.radian), frame='cirs',location=tf.location,obstime=tf.obstime,pressure=pre,temperature=tem,relative_humidity=hum)
        self.lg.error('not  yet implemented')
        sys.exit(1)
Esempio n. 9
0
def test_solveDone_2(qtbot):
    result = {
        'success': False,
        'raJ2000S': Angle(hours=10),
        'decJ2000S': Angle(degrees=20),
        'angleS': 30,
        'scaleS': 1,
        'errorRMS_S': 3,
        'flippedS': False,
        'imagePath': 'test',
        'message': 'test',
    }

    app.astrometry.signals.done.connect(app.uiWindows['showImageW']['classObj'].solveDone)
    with qtbot.waitSignal(app.message) as blocker:
        suc = app.uiWindows['showImageW']['classObj'].solveDone(result=result)
        assert not suc
    assert ['Solving error: test', 2] == blocker.args
Esempio n. 10
0
    def get_alt_azimuth(self, calc_time, satellite_name):

        try:
            satellite_number = self.satellites[satellite_name]['Number']
            satellite = self.by_number[int(satellite_number)]
        except ValueError:
            return Angle(degrees=0), Angle(degrees=0), 0

        difference = satellite - home
        topocentric = difference.at(ts.tt_jd(calc_time))
        pos = topocentric.position.km
        alt, az, distance = topocentric.altaz()
        velocity = topocentric.velocity.km_per_s

        d = np.dot(velocity, pos) / np.linalg.norm(
            pos)  # slant velocity km/sec

        return alt, az, d
def calc_radec_w_proper_motion(ra, de, pmra, pmde, epoch=2018.):
    planets = load('/Users/gks/Dropbox/mypylib/notebooks/GIT/HETobs/de421.bsp')
    ts = load.timescale()
    earth = planets['earth']
    t = ts.utc(epoch)
    t_2000 = ts.utc(2000)
    ra_ang = Angle(degrees=ra)
    de_ang = Angle(degrees=de)
    star_obj = Star(ra=ra_ang,
                    dec=de_ang,
                    ra_mas_per_year=pmra,
                    dec_mas_per_year=pmde)
    astrometric = earth.at(t).observe(star_obj)
    ra_out, dec_out, dist_out = astrometric.radec()
    ra_new = ra_out.to(u.degree).value
    de_new = dec_out.to(u.degree).value
    print("Old:", ra, de)
    print("New:", ra_new, de_new)
    return ra_new, de_new
Esempio n. 12
0
def convertToHMS(ra):
    """
    takes the given RA value, which should be in HMS format (but different types) and
    convert it to solve-field readable string in HH:MM:SS

    :param ra: right ascension as Angle
    :return: converted value as string
    """

    if isinstance(ra, (float, int)):
        ra = Angle(hours=ra)

    if isinstance(ra, str):
        return ''

    t = Angle.signed_hms(ra)
    value = f'{t[1]:02.0f}:{t[2]:02.0f}:{t[3]:02.0f}'

    return value
Esempio n. 13
0
def moon_phases(moon, t0, t1):
    """Calculates times of the phases of the moon.
    
    This function searches between ``t0`` and ``t1`` for times when the moon's 
    geocentric ecliptic longitude minus that of the sun is:
        
        * 0 degrees for new moon
        * 90 degrees for first quarter
        * 180 degrees for full moon
        * 270 degrees for last quarter 
    
    Example
    -------
    >>> ephem = load('de430t.bsp')
    >>> moon = ephem['moon']
    >>> t0 = ts.utc(2017, 1)
    >>> t1 = ts.utc(2017, 2)
    >>> times, lon_diffs = moon_phases(moon, t0, t1)
    >>>
    >>> new_moons = times[lon_diffs.degrees==0]
    >>> first_quarters = times[lon_diffs.degrees==90]
    >>> full_moons = times[lon_diffs.degrees==180]
    >>> last_quarters = times[lon_diffs.degrees==270]
    
    Parameters
    ----------
    moon : Segment
        Vector representing the moon
    t0 : Time
        Time object of length 1 representing the start of the search interval
    t1 : Time
        Time object of length 1 representing the end of the search interval
        
    Returns
    -------
    times : Time
        Times of moon quarters
    longitude_diffs: Angle
        moon's ecliptic longitude - sun's ecliptic longitude at ``times``
        
    """
    earth = moon.ephemeris['earth']
    sun = moon.ephemeris['sun']

    f = partial(_ecliptic_lon_diff, earth, moon, sun)

    partition_edges = _divide_evenly(t0.tt, t1.tt, 29 * .2)

    jd0, jd1, targets, f0, f1, _ = _find_value(f, [0, 90, 180, 270],
                                               partition_edges,
                                               slope='positive')

    times = secant(f, jd0, jd1, targets, f0, f1)

    return ts.tt(jd=times), Angle(degrees=targets)
Esempio n. 14
0
def max_ecliptic_latitudes(secondary, primary, t0, t1):
    """Calculates data about extreme max and min ecliptic latitudes.

    This function searches between ``t0`` and ``t1``
    for times when `secondary`'s ecliptic latitude centered at ``primary`` is at a 
    local maximum, e.g., if ``primary`` is the sun, the ecliptic latitudes will 
    be heliocentric.

    Example
    -------
    >>> ephem = load('de430t.bsp')
    >>> venus = ephem['venus']
    >>> sun = ephem['sun']
    >>> t0 = ts.utc(2017)
    >>> t1 = ts.utc(2020)
    >>> times, lats = extreme_ecliptic_latitudes(venus, sun, t0, t1)
    >>> north_times = times[lats>0]
    >>> south_times = times[lats<0]
    
    Parameters
    ----------
    secondary : Segment or VectorSum
        Vector representing the object whose maximum ecliptic latitudes are 
        being found
    primary : Segment or VectorSum
        Vector representing the object orbited by `secondary`
    t0 : Time
        The start of the time range to search
    t1 : Time
        The end of the time range to search

    Returns
    -------
    times : Time
        Times of extreme ecliptic latitudes
    lats : Angle
        Ecliptic latitudes that correspond to `times`
    """

    period = _sidereal_period(secondary, primary)
    partition_edges = _divide_evenly(t0.tt, t1.tt, period * .2)

    f = partial(_ecliptic_lat, secondary, primary)

    jd0, jd1, minimum, f0, f1 = _find_extremes(f, partition_edges, find='any')

    if len(jd0) != 0:
        times = brent_min(f, jd0, jd1, minimum, f0, f1, tol=1e-15)
    else:
        times = array([])

    # TODO: Should brent_min retur f(x) to avoid this function call?
    lats = f(times)

    return ts.tt(jd=times), Angle(degrees=lats)
Esempio n. 15
0
def meridian_transits(observer, body, t0, t1):
    """Calculates times of upper and lower transits of the local meridian.
    
    This function searches between ``t0`` and ``t1`` for times when ``body``'s 
    local hour angle is 0h for an upper transit or 12h for a lower transit.

    Example
    -------
    >>> ephem = load('de430t.bsp')
    >>> sun = ephem['sun']
    >>> earth = ephem['earth']
    >>> greenwich = earth + Topos('51.5 N', '0 W')
    >>> t0 = ts.utc(2017, 1, 1)
    >>> t1 = ts.utc(2017, 1, 8)
    >>> times, hour_angles = meridian_transits(greenwich, mars, t0, t1)
    >>>
    >>> upper_transits = times[hour_angles.hours==0]
    >>> lower_transits = times[hour_angles.hours==12]
    
    Parameters
    ----------
    observer : VectorSum
        VectorSum of earth + Topos
    body : Segment or VectorSum
        Vector representing the object whose transits are being found.
    t0 : Time
        Time object of length 1 representing the start of the search interval
    t1 : Time
        Time object of length 1 representing the end of the search interval
        
    Returns
    -------
    times : Time
        Times of transits
    hour_angles : Angle
        Local Hour Angle of ``body`` at ``times``
    """
    if isinstance(observer, Topos):
        raise ValueError('`observer` should be a VectorSum of earth + Topos.')

    if isinstance(body, EarthSatellite) or (
            isinstance(body, VectorSum)
            and isinstance(body.positives[-1], EarthSatellite)):
        raise ValueError("meridian_transits doesn't support EarthSatellites.")

    f = partial(_lha, observer, body)
    partition_edges = _divide_evenly(t0.tt, t1.tt, .2)

    jd0, jd1, targets, f0, f1, _ = _find_value(f, [0, 180],
                                               partition_edges,
                                               slope='positive')

    times = secant(f, jd0, jd1, targets, f0, f1)

    return ts.tt(jd=times), Angle(degrees=targets, preference='hours')
Esempio n. 16
0
def convertToDMS(dec):
    """
    takes the given DEC value, which should be in DMS format (but different types) and
    convert it to solve-field readable string in sDD:MM:SS

    :param dec: declination as Angle
    :return: converted value as string
    """

    if isinstance(dec, (float, int)):
        dec = Angle(degrees=dec)

    if isinstance(dec, str):
        return ''

    t = Angle.signed_dms(dec)
    sign = '+' if dec.degrees > 0 else '-'
    value = f'{sign}{t[1]:02.0f}:{t[2]:02.0f}:{t[3]:02.0f}'

    return value
Esempio n. 17
0
def test_solveDone_4(qtbot):
    app.uiWindows['showImageW']['classObj'].ui.checkAutoSolve.setChecked(True)
    app.uiWindows['showImageW']['classObj'].ui.checkStackImages.setChecked(False)
    result = {
        'success': True,
        'raJ2000S': Angle(hours=10),
        'decJ2000S': Angle(degrees=20),
        'angleS': 30,
        'scaleS': 1,
        'errorRMS_S': 3,
        'flippedS': False,
        'imagePath': 'test',
        'solvedPath': 'test',
        'message': 'test',
    }

    app.astrometry.signals.done.connect(app.uiWindows['showImageW']['classObj'].solveDone)
    with qtbot.waitSignal(app.uiWindows['showImageW']['classObj'].signals.showImage):
        suc = app.uiWindows['showImageW']['classObj'].solveDone(result=result)
        assert suc
Esempio n. 18
0
def seasons(earth, t0, t1):
    """Calculates times of equinoxes and solstices.
    
    This function searches between ``t0`` and ``t1`` for times when the sun's 
    ecliptic longitude is:
        
        * 0 degrees for march equinoxes
        * 90 degrees for june solstices
        * 180 degrees for september equinoxes
        * 270 degrees for december solstices
    
    Example
    -------
    >>> ephem = load('de430t.bsp')
    >>> earth = ephem['earth']
    >>> t0 = ts.utc(2017)
    >>> t1 = ts.utc(2018)
    >>> times, lons = seasons(earth, t0, t1)
    >>>
    >>> march_equinoxes = times[lons.degrees==0]
    >>> june_solstices = times[lons.degrees==90]
    >>> sept_equinoxes = times[lons.degrees==180]
    >>> dec_solstices = times[lons.degrees==270]
    
    Parameters
    ----------
    earth : Segment
        Vector representing earth
    t0 : Time
        Time object of length 1 representing the start of the search interval
    t1 : Time
        Time object of length 1 representing the end of the search interval
        
    Returns
    -------
    times : Time
        Times of solstices
    longitudes : Angle
        sun's ecliptic longitude at ``times``
    """
    sun = earth.ephemeris['sun']

    f = partial(_ecliptic_lon, earth, sun)

    partition_edges = _divide_evenly(t0.tt, t1.tt, 365 * .2)

    jd0, jd1, targets, f0, f1, _ = _find_value(f, [0, 90, 180, 270],
                                               partition_edges,
                                               slope='positive')

    times = secant(f, jd0, jd1, targets, f0, f1)

    return ts.tt(jd=times), Angle(degrees=targets)
Esempio n. 19
0
def JNowToJ2000(ra, dec, timeJD):
    """

    :param ra:
    :param dec:
    :param timeJD:
    :return:
    """

    if not isinstance(ra, Angle):
        return Angle(hours=0), Angle(degrees=0)
    if not isinstance(dec, Angle):
        return Angle(hours=0), Angle(degrees=0)

    with _lock:
        ra = ra.radians
        dec = dec.radians

        ra = ERFA.anp(ra + ERFA.eo06a(timeJD.tt, 0.0))

        raConv, decConv, _ = ERFA.atic13(ra, dec, timeJD.ut1, 0.0)

        ra = Angle(radians=raConv, preference='hours')
        dec = Angle(radians=decConv, preference='degrees')
        return ra, dec
Esempio n. 20
0
def J2000ToAltAz(ra, dec, timeJD, location):
    """

    :param ra:
    :param dec:
    :param timeJD:
    :param location:
    :return:
    """

    if not isinstance(ra, Angle):
        return Angle(degrees=0), Angle(degrees=0)
    if not isinstance(dec, Angle):
        return Angle(degrees=0), Angle(degrees=0)

    with _lock:
        ra = ra.radians
        dec = dec.radians
        lat = location.latitude.radians
        lon = location.longitude.radians
        elevation = location.elevation.m

        aob, zob, hob, dob, rob, eo = ERFA.atco13(ra,
                                                  dec,
                                                  0.0,
                                                  0.0,
                                                  0.0,
                                                  0.0,
                                                  timeJD.ut1,
                                                  0.0,
                                                  0,
                                                  lon,
                                                  lat,
                                                  elevation,
                                                  0.0,
                                                  0.0,
                                                  0.0,
                                                  0.0,
                                                  0.0,
                                                  0.0)
        decConv = np.pi / 2 - zob

        ra = Angle(radians=aob, preference='degrees')
        dec = Angle(radians=decConv, preference='degrees')
        return ra, dec
Esempio n. 21
0
def J2000ToJNow(ra, dec, timeJD):
    """

    :param ra:
    :param dec:
    :param timeJD:
    :return:
    """

    if not isinstance(ra, Angle):
        return Angle(hours=0), Angle(degrees=0)
    if not isinstance(dec, Angle):
        return Angle(hours=0), Angle(degrees=0)

    with _lock:
        ra = ra.radians
        dec = dec.radians

        raConv, decConv, eo = ERFA.atci13(ra, dec, 0, 0, 0, 0, timeJD.ut1, 0)

        raConv = ERFA.anp(raConv - eo)
        ra = Angle(radians=raConv, preference='hours')
        dec = Angle(radians=decConv, preference='degrees')
        return ra, dec
Esempio n. 22
0
def test_convertToHMS_2():
    value = Angle(hours=-12.0)
    value = transform.convertToHMS(value)
    assert value == '12:00:00'
Esempio n. 23
0
def test_convertToHMS_1():
    parameter = Angle(hours=12)
    value = transform.convertToHMS(parameter)
    assert value == '12:00:00'
def test_position_angle():
    a = Angle(degrees=0), Angle(degrees=0)
    b = Angle(degrees=1), Angle(degrees=1)
    assert str(position_angle_of(a, b)) == '315deg 00\' 15.7"'
Esempio n. 25
0
def test_convertToDMS_1():
    parameter = Angle(degrees=60)
    value = transform.convertToDMS(parameter)
    assert value == '+60:00:00'
Esempio n. 26
0
 def make_chart_shift(self,
                      ra,
                      de,
                      pmra,
                      pmde,
                      name,
                      outdir='findercharts_2/'):
     # make the chart with the
     ra_ang = Angle(degrees=ra)
     de_ang = Angle(degrees=de)
     star_obj = Star(ra=ra_ang,
                     dec=de_ang,
                     ra_mas_per_year=pmra,
                     dec_mas_per_year=pmde)
     astrometric = self.earth.at(self.t).observe(star_obj)
     astrometric_1989 = self.earth.at(self.t_1989).observe(star_obj)
     ra_out, dec_out, dist_out = astrometric.radec()
     ra_out1, dec_out1, dist_out1 = astrometric_1989.radec()
     ra_new = ra_out.to(u.degree).value
     de_new = dec_out.to(u.degree).value
     ra_old = ra_out1.to(u.degree).value
     de_old = dec_out1.to(u.degree).value
     raline = [ra_new, ra_old]  #[ra_old,ra_new]
     deline = [de_new, de_old]  #[de_old,de_new]
     cc = astropy.coordinates.SkyCoord(ra, de, unit=(u.degree, u.degree))
     cc_new = astropy.coordinates.SkyCoord(ra_new,
                                           de_new,
                                           unit=(u.degree, u.degree))
     cc_old = astropy.coordinates.SkyCoord(ra_old,
                                           de_old,
                                           unit=(u.degree, u.degree))
     fig = figure(figsize=(10, 12))
     fovrad = astropy.coordinates.Angle('0d4m0s')
     if isfinite(pmra):
         #print 'pm finite'
         if max(abs(pmra), abs(pmde)) > 1000:
             fovrad = astropy.coordinates.Angle('0d8m0s')
         if max(abs(pmra), abs(pmde)) > 4000:
             print 'big radius'
             fovrad = astropy.coordinates.Angle('0d16m0s')
     oo, oh = astroplan.plots.plot_finder_image(cc_new,
                                                reticle=True,
                                                survey='DSS2 Red',
                                                fov_radius=fovrad)
     oo.set_autoscale_on(False)
     oo.plot(raline, deline, transform=oo.get_transform('icrs'))
     oo.set_title(name, fontsize=20)
     ra_s = cc_new.ra.to_string(unit=u.hour, sep=':')
     de_s = cc_new.dec.to_string(unit=u.degree, sep=':')
     #ra_s = [alltargs_uniq.loc[i,'cc'].ra.to_string(unit=u.hour,sep=':') for i in ai]
     #oo.text(0,-.1,'TEST',transform=oo.transAxes)
     oo.text(0,
             -.1,
             'RA (ICRS): ' + ra_s,
             transform=oo.transAxes,
             fontsize=20)
     oo.text(0,
             -.15,
             'DEC (ICRS): ' + de_s,
             transform=oo.transAxes,
             fontsize=20)
     #oo.text(0,-.2,'FOV radius: {}'.format(fovrad.arcsec)
     fig.savefig(outdir + name + '.pdf')
     close(fig)
     return cc_new
Esempio n. 27
0
from skyfield.api import Star, load, Angle
import pandas as pd
import numpy as np

ts = load.timescale()
t = ts.utc(2022, 1, 1)

eph = load('../../de421.bsp')
sun = eph['sun']
earth = eph['earth']

df = pd.read_csv('bs_hip_all_selected cols.csv').set_index('hip')
df = df.loc[orion_stars]

ra = Angle(degrees=df['ra'].values)
dec = Angle(degrees=df['dec'].values)

stars = Star(ra=ra, dec=dec)

star_positions = earth.at(t).observe(stars)

#========================================

import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from hypatie.plots import plot_radec, plot_altaz
from hypatie.transform import radec_to_altaz
from hypatie.data import cities

lon, lat = cities['strasbourg'][:2]
Esempio n. 28
0
def test_convertToDMS_2():
    value = Angle(degrees=-90.0)
    value = transform.convertToDMS(value)
    assert value == '-90:00:00'
Esempio n. 29
0
    #t = Time(2019.9, format='jyear')

    c1 = T_pos((t, t0, coord), pmra, pmdec, plx, vrad)

    Ricky_coord = SkyCoord(ra=ricky[0, 1],
                           dec=ricky[0, 4],
                           unit='deg',
                           frame='icrs')
    #print 'new - ricky:', c1.separation(Ricky_coord).arcsec[0] * 1000.

    #print 'new - ricky (acosd):', (c1.ra.deg[0] - Ricky_coord.ra.deg) * np.cos(coord.dec.rad) * 3E6
    #print 'new - ricky (d):', (c1.dec.deg[0] - Ricky_coord.dec.deg)*3E6

    from skyfield.api import load, Star, Angle
    lens = Star(ra=Angle(degrees=coord.ra.deg),
                dec=Angle(degrees=coord.dec.deg),
                ra_mas_per_year=pmra * 1000.,
                dec_mas_per_year=pmdec * 1000.,
                parallax_mas=plx * 1000.)
    ts = load.timescale()
    ts1 = ts.utc(t.jyear[0] - 15.)
    planets = load('de421.bsp')
    earth = planets['earth']
    astrometric = earth.at(ts1).observe(lens)
    rai, deci, distancesa = astrometric.radec()
    skyfield_coord = SkyCoord(ra=rai._degrees,
                              dec=deci._degrees,
                              unit='deg',
                              frame='icrs')
    #print 'skyfield - ricky:', skyfield_coord.separation(Ricky_coord).arcsec * 1000.
Esempio n. 30
0
 class Test:
     jdStart = 2458715.14771
     jdEnd = 2458715.15
     flip = False
     message = 'test'
     altitude = Angle(degrees=50)