As the instant of an object’s rising or setting is linked to the Earth’s rotation and the calendar, the correct time scale and calendar must be selected, depending on the requested date. The default behavior of the API is to use the UTC timescale and the Gregorian calendar.
Examples for the three main historical periods
The following example retrieves the rise, upper transit and set of the Sun on July 5th, 2020 for an observer located at Paris (48.8534°N,2.34880°E,39m). All data are expressed in the tiemscale UTC and the gregorian calendar.
Execute this command to retrieve the result encoded in the JSON format (Result of this command ).
wget "https://opale.imcce.fr/api/v1/phenomena/rts/10/2020-07-05/48.8534,2.3488,39"
Execute this script to retrieve the result encoded in the JSON format.
import json
import requests
apicall = "https://opale.imcce.fr/api/v1/phenomena/rts/10/2020-07-05/48.8534,2.3488,39"
response = requests.get( apicall )
print(response.json())
The timescale UT1, a timescale based on the observation of the Earth’s rotation, should be requested.
The following example retrieves the rise, upper transit and set of the the planet Jupiter on December 25th, 1789 for an observer located at Paris (48.8534°N,2.34880°E,39m).
Execute this command to retrieve the result encoded in the JSON format (Result of this command ).
wget "https://opale.imcce.fr/api/v1/phenomena/rts/5/1789-12-25/48.8534,2.3488,39?timescale=UT1"
Execute this script to retrieve the result encoded in the JSON format.
import json
import requests
apicall = "https://opale.imcce.fr/api/v1/phenomena/rts/5/1789-12-25/48.8534,2.3488,39?timescale=UT1"
response = requests.get( apicall )
print(response.json())
The timescale UT1, a timescale based on the observation of the Earth’s rotation, and the julian calendar should be requested. It follows the astronomical year numbering, which includes the year 0.
The following example retrieves the rise, upper transit and set of the Moon between June 21st and 25th, -99 (100 before era) for an observer located at Louxor (25.6872431°N,32.6396357°E).
Execute this command to retrieve the result encoded in the JSON format (Result of this command ).
wget "https://opale.imcce.fr/api/v1/phenomena/rts/301/julian,-0099-06-21/25.6872431,32.6396357?timescale=UT1&nbd=5"
Execute this script to retrieve the result encoded in the JSON format and print the content as a list of rise and set of the Moon.
import json
import requests
body = '301' # Moon
first_date='-0099-06-21'
number_of_day='5'
latitude='25.6872431'
longitude='32.6396357'
timescale='UT1'
calendar='julian'
##### call the API
apicall = "https://opale.imcce.fr/api/v1/phenomena/rts/"+body+"/"+calendar+","+first_date+"/"+latitude+","+longitude+"?timescale="+timescale+"&nbd="+number_of_day
print("url = ", apicall)
response = requests.get( apicall )
if (response.status_code!=200):
print(response.json())
raise Exception("invalid url")
##### print the result
answer = response.json()
data = answer['response']['data'][0][body]
print('calendar :', answer['response']['calendar'])
print('timescale :', answer['response']['timescale'])
for event in data:
# print the rise
for rise in event['rise']:
print('date of rise :', rise['date'], 'azimuth :', rise['coord'])
# print the upper transit
for rise in event['upperTransit']:
print('date of upper transit :', rise['date'], 'elevation :', rise['coord'])
# print the set
for set in event['set']:
print('date of set :', set['date'], 'azimuth :', set['coord'])