skyfielders / python-skyfield

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

Find the Ascending Node of the Moon at a known time #556

Closed Almuten closed 3 years ago

Almuten commented 3 years ago

I found the following example:

t0 = ts.utc(2020, 4, 22) t1 = ts.utc(2020, 5, 22) t, y = almanac.find_discrete(t0, t1, almanac.moon_nodes(eph))

print(t.utc_iso()) print(y) print([almanac.MOON_NODES[yi] for yi in y])

Is it possible to solve the inverse problem, by a known time to find the longitude of the Ascending Node of the Moon? I saw an example of use,

position = (moon - earth).at(t) ecliptic = inertial_frames['ECLIPJ2000'] elements = osculating_elements_of(position, ecliptic) i = elements.longitude_of_ascending_node.degrees

but I need specific dates, far from 2000

brandon-rhodes commented 3 years ago

It should probably be possible, and there are probably several ways to approach the problem. So that we can choose between them: what’s the larger problem that knowing the longitude will help solve?

Almuten commented 3 years ago

There is no "larger" problem ). I am doing calculations of the positions of the planets and Nodes. And I found there is a "position" that I don't know how to calculate. A short example of calculating the longitude of the Moon's ascending node for an arbitrary date will be super!

brandon-rhodes commented 3 years ago

Hmm. Without any physical goal for the calculation, your choice will have to necessarily be arbitrary. The node is more or less a fiction between the moments when the Moon is actually crossing the ecliptic, and here are two possible approaches:

  1. Do a linear extrapolation between the most recent time the Moon crossed the ecliptic and the next time it crosses. Figure out what fraction of the time has passed from one crossing to the next, and use that to create an intermediate angle between the two.
  2. Use osculating elements (with the warning that I don't think they'll be very accurate for the Moon?) but instead of:
    ecliptic = inertial_frames['ECLIPJ2000']

    — try using the ecliptic of the date you're looking at:

    ecliptic = skyfield.framelib.ecliptic_frame.rotation_at(t)

I would probably do the linear extrapolation myself.

Almuten commented 3 years ago

Thank you so much! Started experiment )

voronY commented 3 years ago

Maybe it would help you: there is a function swe_nod_aps in Swiss Ephemeris which calculates mean and osculating Nodes [link removed]

brandon-rhodes commented 3 years ago

@voronY — Thanks for idea that another tool’s code could help @Almuten! I have removed the direct link, though, because the copyright message at the top of the file indicates that it is not compatible with Skyfield’s license, and I need to make sure none of us Skyfield contributors read the code, which could put us in danger of accidentally copying the code into Skyfield from memory later.

brandon-rhodes commented 3 years ago

@Almuten — I wanted to check back and see how your experiment went, so that we can hopefully get this issue closed. Thanks for any update you can provide!

Almuten commented 3 years ago

@Almuten — I wanted to check back and see how your experiment went, so that we can hopefully get this issue closed. Thanks for any update you can provide!

I took your advice. ecliptic = skyfield.framelib.ecliptic_frame.rotation_at(t)

The solution is super! Thank you!

brandon-rhodes commented 3 years ago

I'm glad it worked! I'll see about getting it added to the documentation somewhere.