def is_sun_up_at(t): """The function that this returns will expect a single argument that is a :class:`~skyfield.timelib.Time` and will return ``True`` if the sun is up or twilight has started, else ``False``.""" t._nutation_angles = iau2000b(t.tt) # Return `True` if the sun has risen by time `t`. return topos_at(t).observe( sun).apparent().altaz()[0].degrees > -degBelowHorizon
def is_planet_transit_at(t): """The function that this returns will expect a single argument that is a :class:`~skyfield.timelib.Time` and will return ``True`` if the moon is up or twilight has started, else ``False``.""" t._nutation_angles = iau2000b(t.tt) # Return `True` if the meridian is crossed by time `t`. position = earth.at(t).observe(planet_name) ra = position.apparent().radec(epoch='date')[0] #return t.gast > ra.hours # incorrect return (t.gast - ra.hours + 12) % 24 - 12 > 0
def moon_phase(t=None): """Return the phase of the moon at time `t`. 0 = New, 25 = Fisrt Quarter, 50 = Full, etc.""" if t is None: t = now() t._nutation_angles = iau2000b(t.tt) e = earth.at(t) _, mlon, _ = e.observe(moon).apparent().ecliptic_latlon('date') _, slon, _ = e.observe(sun).apparent().ecliptic_latlon('date') # phase = ((mlon.radians - slon.radians) // (tau / 8) % 8).astype(int) phase = ((mlon.radians - slon.radians) / (tau / 100) % 100) return round(phase, ROUNDING)
def is_target_up_at(t): """Return `True` if the target has risen by time `t`.""" t._nutation_angles = iau2000b(t.tt) return topos_at(t).observe( target).apparent().altaz()[0].degrees > -0.8333
def f(t): length = t.tt.shape[0] t._nutation_angles = iau2000b(t.tt) return sat.at(t).is_sunlit(eph)
f.rough_period = 0.001 T0 = time() t2, y2 = almanac.find_discrete(pass_start, pass_end, f, epsilon=half_second) print(time() - T0, 'seconds to find moment of entering shadow:') for ti, yi in zip(t2, y2): print(' ', ti.utc_jpl(), 'entered sunlight' if yi else 'entered shadow') one_second = 1.0 / 24.0 / 3600.0 tt = np.arange(pass_start.tt, pass_end.tt, one_second) T0 = time() t = ts.tt_jd(tt) t._nutation_angles = iau2000b(t.tt) satpos = (sat - topos).at(t) is_sunlit = satpos.is_sunlit(eph) DT = time() - T0 print( DT, 'to compute is_sunlit() for every second of {}-second pass'.format( len(tt))) T0 = time() alt, az, distance = satpos.altaz() DT = time() - T0 print(DT, 'to re-use the positions to compute altitude and azimuth') print(__doc__.rstrip())
def is_sun_up_at(t): """Return `True` if the sun has risen by time `t`.""" t._nutation_angles = iau2000b(t.tt) return topos_at(t).observe( sun).apparent().altaz()[0].degrees > -degrees
def get_iau2000b(time: Time): return iau2000b(time.tt)
def solar_term_at(t): """Return season 0 through 23 at time `t`.""" t._nutation_angles = iau2000b(t.tt) e = earth.at(t) _, slon, _ = e.observe(sun).apparent().ecliptic_latlon('date') return (slon.radians // (tau / 24) % 24).astype(int)
def _phase_degree_at(t): t._nutation_angles = iau2000b(t.tt) e = EARTH.at(t) _, mlon, _ = e.observe(obj).apparent().ecliptic_latlon('date') _, slon, _ = e.observe(SUN).apparent().ecliptic_latlon('date') return (mlon.degrees - slon.degrees) % 360
def _observe_at(t): t._nutation_angles = iau2000b(t.tt) return topos_at(t).observe(planet).apparent()
de421 = load('de421.bsp') earth = de421['earth'] ts = load.timescale() this_sat = EarthSatellite('1 00000U 21 0A 20146.43738583 .00000000 00000-0 00000-0 0 0000', '2 00000 0.2000 000.0000 0000000 0.0000 000.0000 14.88336848949720', 'Test_600kmAlt', ts) #100K times between 2022 and 2024 n_steps = 10000 jdrange = np.linspace(2459690.5,2460055.75,n_steps) utrange = ts.ut1_jd(jdrange) utrange._nutation_angles = iau2000b(utrange.tt) #Crab Nebula target_ra = 83.63308333 target_dec = 22.0145 #My RA is in degrees, hence the division by 15. target_pos = position_of_radec(target_ra / 15., target_dec) #Currently not optimized for speed bool_list = [] t_list = [] for this_ut in tqdm.tqdm(utrange): this_bool = this_sat.is_target_occulted(this_ut, target_pos, earth) dist_intersect = this_sat.intersect_line_with_sphere(this_ut, target_pos, earth)
def is_body_up_at(t): t._nutation_angles = iau2000b(t.tt) return observer.at(t).observe(target).apparent().altaz()[0].degrees > h