Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import warnings
- warnings.filterwarnings("ignore")
- from typing import Callable
- import pytz
- import skyfield.searchlib
- from skyfield import api, timelib
- from skyfield.jpllib import SpiceKernel, ChebyshevPosition
- from skyfield.vectorlib import VectorSum
- from skyfield.framelib import ecliptic_frame
- def ecliptic_longitude_exceeds(
- longitude: float,
- target: str|VectorSum|ChebyshevPosition,
- ephemeris: SpiceKernel) -> Callable[[timelib.Time], np.array]:
- """
- Creates functions that check whether target ecliptic longitude exceeds
- value at a specified time
- :param longitude: Ecliptic Longitude in decimal degrees
- :param target: Object to be checked
- :param ephemeris: Ephemeris to be used.
- :return: find_discrete-compatible function
- """
- # Change to observe from Earth instead of the Sun
- earth = ephemeris['earth']
- target = ephemeris[target] if isinstance(target, str) else target
- def function(time: timelib.Time) -> np.array:
- """
- :param time: Time of Observation
- :return: Array of booleans indicating whether ecliptic longitude > longitude
- """
- observation = earth.at(time).observe(target).apparent() # Observe from Earth
- observed_longitude = observation.frame_latlon(ecliptic_frame)[1]
- # Use the suggested formula to check longitude exceeds
- return ((observed_longitude.degrees - longitude) // 180).astype(int) % 2
- # Use a step_days of ~1/4 of the expected period
- function.step_days = 25 # Adjust this value as needed
- return function
- def main():
- ephemeris = api.load('de441.bsp')
- ts = api.load.timescale()
- utc = pytz.timezone("UTC")
- #start, stop = ts.utc(2023), ts.utc(2024)
- start = ts.utc(2023, 10, 1) # April 1, 2023
- stop = ts.utc(2023, 12, 31) # June 30, 2024
- moon_exceeds = ecliptic_longitude_exceeds(
- longitude=24.5, target="moon", ephemeris=ephemeris
- )
- times, states = skyfield.searchlib.find_discrete(start, stop, moon_exceeds)
- # Filter longitude_times by in_state == 0
- longitude_times = [time for time, in_state in zip(times.astimezone(utc), states) if not in_state]
- print('\n'.join(str(lt) for lt in longitude_times))
- if __name__ == '__main__':
- main()
- I started with 15 days and increased by 1 day at a time until i got only one date but its not where it should be
- python skyfieldnode1.py
- 2023-11-24 11:02:49.675913+00:00
- ./swetest -pt -b17.11.2023 -ut22:43
- ./swetest -pt -b17.11.2023 -ut22:43
- date (dmy) 17.11.2023 greg. 22:43:00 UT version 2.10.03
- UT: 2460266.446527778 delta t: 69.109781 sec
- TT: 2460266.447327659
- Epsilon (t/m) 23°26'18.3245 23°26'10.2223
- Nutation -0° 0' 7.8330 0° 0' 8.1021
- true Node 24°29'59.7465 0° 0' 0.0000 0.002502442 -0° 3'35.2933
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement