<h3>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.</h3>
<pre><code>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))
</code></pre>

CC BY-SA 4.0
2022-07-19T09:57:12.367Z
2022-07-19T21:24:04.367Z
2022-07-19T21:24:04.367Z
sybe
<p>I calculate the ra and decl or the stars as below.
Can I add the sun's mean longitude L (=M+w) to:</p>
<pre><code>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')
</code></pre>

CC BY-SA 4.0
2022-07-15T12:33:24.177Z
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?
d_e
CC BY-SA 4.0
2022-07-15T15:59:24.437Z
You should probably describe what you're trying to do at a higher level.  The code above won't compile.
Greg Miller
<star><the-sun><python><skyfield><hipparcos>
python skyfield hipparcos sun mean longitude (L)
sybe
# python skyfield hipparcos sun mean longitude (L)

(Asked by: username_0 on 2022-07-15)

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')

```

**Tags:** star, the-sun, python, skyfield, hipparcos

> **Comments:**
> **username_1**: 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?  
> **username_2**: You should probably describe what you're trying to do at a higher level.  The code above won't compile.  

---

## 1 answers

### Answer by username_0 on 2022-07-19. Score: 2

### 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))

```


---

