AttributeError: 'function' object has no attribute 'map' for find_eclipse_location()
Closed this issue · 1 comments
Hi,
I've just tried to rewrite the function find_eclipse_location for a specific work, but got this error :
Finding path of eclipse from 2026-08-12 00:00:00+00:00 to 2026-08-13 00:00:00+00:00
AttributeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 test = data_eclipse(datetime(2026, 8, 12, 0, 0, 0, tzinfo=timezone.utc),datetime(2026, 8, 13, 0, 0, 0, tzinfo=timezone.utc))
in data_eclipse(dt_min, dt_max)
5 dt_b = dt_max + timedelta(seconds=3600)
6 dts, lats, lons = [], [], []
----> 7 for tup in find_eclipse_location.map(gen_dts(dt_a, dt_b, 60)):
8 if tup is not None:
9 dt, lat, lon = tup
AttributeError: 'function' object has no attribute 'map'
I don't understand how can I fix it... Thanks in advance if you have a solution
PS : run the code on a Google Colab notebook, with native versions of astropy, scipy, etc
OK, I think it was a syntax error and the good one was :
for tup in find_eclipse_location(map(gen_dts(dt_a, dt_b, 60)))
I replaced it anyway by a list comprehension + generator mix. Instead of :
dts, lats, lons = [], [], []
for tup in find_eclipse_location.map(gen_dts(dt_a, dt_b, 60)):
if tup is not None:
dt, lat, lon = tup
dts.append(dt)
lats.append(lat)
lons.append(lon)
I prefered :
el = [e for e in (find_eclipse_location(d) for d in gen_dts(dt_a, dt_b, td_sec)) if e is not None]
dts = [t[0] for t in el]
lats = [t[1] for t in el]
lons = [t[2] for t in el]
This habit could be useful to deliver more concise functions. For example def gen_dts() :
def gen_dts(dt_a: datetime, dt_b: datetime, sec_delta: float) -> list[datetime]:
return [dt_a+timedelta(seconds=x) for x in range(0,(dt_b-dt_a).seconds,sec_delta)]
And I think there's a mistake line 47 :
sun_az = sun.transform_to(az)
moon_az = sun.transform_to(az)
It's moon_az = moon.transform_to(az), no ?
I close the ticket, have a nice day