I want only first and last value I mean 2021-01-30 15:51:47 -2.0665672163030704e-06 and 2021-01-30 15:51:51 -1.0708335011265263e-05 also this code provide date of every second but I want result in every minute.
from datetime import datetime, timedelta
from astropy.time import Time
start_date_time = datetime(2021, 1, 30, 15, 00, 00)
end_date_time = datetime(2021,1, 30,16,00,00)
time_diff = int((end_date_time -
start_date_time).total_seconds())
for i in range(time_diff):
day = (start_date_time + timedelta(0, i))
dt = Time(day)
jd =dt.jd
# print(day,jd)
eph = swe.calc_ut(jd,2)[0][3]
if eph < 0:
print(dt,eph)
Output -
2021-01-30 15:51:47 -2.0665672163030704e-06
2021-01-30 15:51:48 -4.222647236587894e-06
2021-01-30 15:51:49 -6.384221081802716e-06
2021-01-30 15:51:50 -8.565878651309763e-06
2021-01-30 15:51:51 -1.0708335011265263e-05
with the comment above, you can specify the keyword in timedelta like this:
for i in [0, time_diff]:
day = (start_date_time + timedelta(minutes=i))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.