[Python] Skyfield: observe x,y,z postion in ICRF

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a satellites x,y,z coordinates in the ICRF ref. frame. I know the lat, long and altitude of my observer (wgs84). Now, using skfield I want to get the vector from my observer to the satellite such that I can find the azimuth and elevation. I want to use the observe method to take light travel time into acount.

    This is what I have so far:

    from skyfield.api import load, wgs84
    from skyfield.positionlib import ICRF, Barycentric
    import numpy as np

    # Load ephemeris data
    ts = load.timescale()
    eph = load('de421.bsp')

    # Create a time object
    t = ts.utc(2023, 1, 1)
    jupiter = eph['jupiter barycenter']

    # Example: Converting between ICRF and Earth-centered frames


    # id Name
    # 0 SOLAR SYSTEM BARYCENTE
    # 3 EARTH BARYCENTER
    # 399 EARTH

    # vector sum of 2 vectors
    # SOLAR SYSTEM BARYCENTER -> EARTH BARYCENTER
    # EARTH BARYCENTER -> EARTH
    earth_ICRF = eph['earth']

    # vector from EARTH to antenna position
    # EARTH -> WGS84 latitude longitude altitude
    antenna_pos_earth = wgs84.latlon(47.397490, 8.550440, 499.5) # vector sum of 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER -> 399 EARTH

    # vector sum of 3 vectors
    # SOLAR SYSTEM BARYCENTER -> EARTH BARYCENTER
    # EARTH BARYCENTER -> EARTH
    # EARTH -> WGS84 latitude longitude altitude
    antenna_pos_ICRF = earth_ICRF + antenna_pos_earth



    # spacecraft ICRF coordinates in km and km/s
    x, y, z = 1000.0, 2000.0, 3000.0 # position in km
    vx, vy, vz = 1.0, 2.0, 3.0 # velocity in km/s

    # Create position vector (convert from km to au)
    position_au = np.array([x, y, z]) / 149597870.7 # Convert km to au
    velocity_au_per_day = np.array([vx, vy, vz]) * 86400 / 149597870.7 # Convert km/s to au/day

    position = Barycentric(position_au, velocity_au_per_day, t)

    print(antenna_pos_ICRF.at(t).observe(position))


    error

    line 49, in <module>
    print(antenna_pos_ICRF.at(t).observe(position))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    line 690, in observe
    p, v, t, light_time = body._observe_from_bcrs(self)
    ^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'Barycentric' object has no attribute '_observe_from_bcrs'

    Continue reading...

Compartilhe esta Página