How to use the pymap3d.sidereal.datetime2sidereal function in pymap3d

To help you get started, we’ve selected a few pymap3d 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 scivision / pymap3d / tests / test_astropy.py View on Github external
def test_sidereal_vallado(time):
    tsr = pmd.datetime2sidereal(time, radians(lon), True)
    if isinstance(tsr, list):
        tsr = tsr[0]
    assert tsr == approx(sra, rel=1e-5)
github scivision / pymap3d / tests / test_astropy.py View on Github external
def test_sidereal(time):
    pytest.importorskip("astropy")
    # http://www.jgiesen.de/astro/astroJS/siderealClock/
    tsr = pmd.datetime2sidereal(time, radians(lon), False)
    if isinstance(tsr, list):
        tsr = tsr[0]
    assert tsr == approx(sra, rel=1e-5)
github scivision / pymap3d / pymap3d / eci.py View on Github external
z : "ndarray"
        target z ECEF coordinate
    """
    # %%
    x = np.atleast_1d(x)
    y = np.atleast_1d(y)
    z = np.atleast_1d(z)
    if not x.shape == y.shape == z.shape:
        raise ValueError("shapes of ECI x,y,z must be identical")

    useastropy = useastropy and Time is not None

    if useastropy:
        gst = Time(time).sidereal_time("apparent", "greenwich").radian
    else:
        gst = datetime2sidereal(time, 0.0)

    gst = np.atleast_1d(gst)
    if gst.ndim != 1:
        raise ValueError("GST must be scalar or vector in radians")
    if gst.size == 1:
        gst *= np.ones(x.size)
    if gst.size != x.size:
        raise ValueError("GST must be scalar or same length as positions")

    eci = np.column_stack((x.ravel(), y.ravel(), z.ravel()))
    ecef = np.empty((x.size, 3))
    for i in range(eci.shape[0]):
        ecef[i, :] = _rottrip(gst[i]) @ eci[i, :]

    xecef = ecef[:, 0].reshape(x.shape)
    yecef = ecef[:, 1].reshape(x.shape)
github scivision / pymap3d / pymap3d / vallado.py View on Github external
p.258-259
    """

    if abs(lat_deg) > 90:
        raise ValueError("-90 <= lat <= 90")

    az = radians(az_deg)
    el = radians(el_deg)
    lat = radians(lat_deg)
    lon = radians(lon_deg)
    # %% Vallado "algorithm 28" p 268
    dec = asin(sin(el) * sin(lat) + cos(el) * cos(lat) * cos(az))

    lha = atan2(-(sin(az) * cos(el)) / cos(dec), (sin(el) - sin(lat) * sin(dec)) / (cos(dec) * cos(lat)))

    lst = datetime2sidereal(time, lon)  # lon, ra in RADIANS

    """ by definition right ascension [0, 360) degrees """
    return degrees(lst - lha) % 360, degrees(dec)
github scivision / pymap3d / pymap3d / eci.py View on Github external
z : "ndarray"
        target z ECI coordinate
    """
    # %%
    x = np.atleast_1d(x)
    y = np.atleast_1d(y)
    z = np.atleast_1d(z)
    if not x.shape == y.shape == z.shape:
        raise ValueError("shapes of ECI x,y,z must be identical")

    useastropy = useastropy and Time is not None

    if useastropy:
        gst = Time(time).sidereal_time("apparent", "greenwich").radian
    else:
        gst = datetime2sidereal(time, 0.0)

    gst = np.atleast_1d(gst)
    if gst.ndim != 1:
        raise ValueError("GST must be scalar or vector in radians")
    if gst.size == 1:
        gst *= np.ones(x.size)
    if gst.size != x.size:
        raise ValueError("GST must be scalar or same length as positions")

    ecef = np.column_stack((x.ravel(), y.ravel(), z.ravel()))
    eci = np.empty((x.size, 3))
    for i in range(x.size):
        eci[i, :] = _rottrip(gst[i]).T @ ecef[i, :]  # this one is transposed

    xeci = eci[:, 0].reshape(x.shape)
    yeci = eci[:, 1].reshape(x.shape)
github scivision / pymap3d / pymap3d / vallado.py View on Github external
el_deg : "ndarray"
        elevation above horizon to point [degrees]


    from D. Vallado "Fundamentals of Astrodynamics and Applications "
       4th Edition Ch. 4.4 pg. 266-268
    """
    if abs(lat_deg) > 90:
        raise ValueError("-90 <= lat <= 90")

    ra = radians(ra_deg)
    dec = radians(dec_deg)
    lat = radians(lat_deg)
    lon = radians(lon_deg)

    lst = datetime2sidereal(time, lon)  # RADIANS
    # %% Eq. 4-11 p. 267 LOCAL HOUR ANGLE
    lha = lst - ra
    # %% #Eq. 4-12 p. 267
    el = asin(sin(lat) * sin(dec) + cos(lat) * cos(dec) * cos(lha))
    # %% combine Eq. 4-13 and 4-14 p. 268
    az = atan2(-sin(lha) * cos(dec) / cos(el), (sin(dec) - sin(el) * sin(lat)) / (cos(el) * cos(lat)))

    return degrees(az) % 360.0, degrees(el)