Skip to content

Rare and random HTTP 503 errors from JPL Horizon on parallax models #78

@ketozhang

Description

@ketozhang

Less than 1% of the times when I am running a model with parallax (letting pyLIMA fetch ephemerides for me), I get errors from JPL Horizon.

The culprit might be here where too many queries are made to JPL:

if distances.min() < 0.002: # Low orbits
# adding exact telescopes dates
DATES = [dates.tolist()]
RA = [ra.tolist()]
DEC = [dec.tolist()]
DISTANCES = [distances.tolist()]
start = 0
while start < len(time_to_treat): # Split the time request in chunk of 50.
end = start + 50
obj = Horizons(id=body, location=OBSERVATORY_ID,
epochs=time_to_treat[start:end])
ephemerides = obj.ephemerides()
dates = ephemerides['datetime_jd'].data.data
ra = ephemerides['RA'].data.data
dec = ephemerides['DEC'].data.data
distances = ephemerides['delta'].data.data
DATES.append(dates)
RA.append(ra)
DEC.append(dec)
DISTANCES.append(distances)
start = end
dates = np.concatenate(DATES)
ra = np.concatenate(RA)
dec = np.concatenate(DEC)
distances = np.concatenate(DISTANCES)

However, it is also likely because I am running many models at the same time overloading the Horizon servers.


A fix that satisfies both issue is to add a "retry with backoff" algorithm (try to query again after waiting an exponentially increasing time)

It should be added to either here...

from pyLIMA.parallax import JPL_ephemerides
spacecraft_positions = \
JPL_ephemerides.horizons_API(satellite_name, time_to_treat,
observatory='Geocentric')[1]

or as part of JPL_ephemerides.horizons_API itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions