skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.43k stars 213 forks source link

ECEF to ECI conversion #165

Closed tmamedzadeh closed 6 years ago

tmamedzadeh commented 6 years ago

Is there ECEF to ECI conversion in Skyfield?

Now I use astropy, however it works too long:

      # Conversion to J2000    
      now = Time(date)
      itrs = coord.ITRS(p[0]*u.km, p[1]*u.km, p[2]*u.km, v[0]*u.km/u.s, v[1]*u.km/u.s, v[2]*u.km/u.s, obstime=now)
      gcrs = itrs.transform_to(coord.GCRS(obstime=now))
      p,v=gcrs.cartesian.xyz.value,gcrs.velocity.d_xyz.value
brandon-rhodes commented 6 years ago

Yes, there's a low-level function that does the conversion directly between vectors:

https://github.com/skyfielders/python-skyfield/blob/def9bf79e53ad3a8ad46a151ace42cc724c38af0/skyfield/positionlib.py#L405

The most common form of this conversion in Skyfield code is probably users who create Topos objects, that specify a longitude, latitude, and elevation which then gets turned into an GCRS vector when the .at() method is called.