1
$\begingroup$

I calculate the ra and decl or the stars as below. Can I add the sun's mean longitude L (=M+w) to:

ra, dec, distance = apparent.radec('date')

from skyfield.api import Star, load
from skyfield.data import hipparcos
with load.open(hipparcos.URL) as m:
    df = hipparcos.load_dataframe(m)
            
planets = load('de421.bsp')
earth = planets['earth']
ts = load.timescale()
t = ts.now()            
name_star=Star.from_dataframe(df.loc[hip[x]])           
apparent= earth.at(t).observe(name_star)            
ra, dec, distance = apparent.radec('date')
$\endgroup$
2
  • $\begingroup$ This question is not entirely clear to me. First what are "M+w". Secondly, the Sun's Mean longitude is quite independent quantality -- and basically a function of time alone; it is not related to whatever calculation of starts RA and DEC. So is your: how can we find the Mean Sun's longitude using skyfield? $\endgroup$
    – d_e
    Jul 15, 2022 at 12:33
  • 1
    $\begingroup$ You should probably describe what you're trying to do at a higher level. The code above won't compile. $\endgroup$ Jul 15, 2022 at 15:59

1 Answer 1

2
$\begingroup$

Thank you so much. Your comments made me look further, I found my answer in the code below. # # It was the mean_longitude (L) of of the sun I was after.

from skyfield.api import load
from skyfield.elementslib import osculating_elements_of

ts = load.timescale()
t = ts.utc(2022, 7, 19)

planets = load('de421.bsp')
earth = planets['earth']

sun = planets['sun']
position = (sun - earth).at(t)
elements = osculating_elements_of(position)
L=elements.mean_longitude.degrees
print('mean_longitude: {0:.9f} degrees'.format(L))
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .