loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
import requests

# Hit the Amentum Atmosphere API to calculate total mass density using both NRLMSISE and JB2008
hostname = "https://atmosphere.amentum.space/api/"

for endpoint in ["nrlmsise00", "jb2008"]:

  # assume midnight at Greenwich, arbitrary date
  payload = {
      'year' : 2013,
      'month' : 6,
      'day' : 16,
      'geodetic_latitude' : 51.47879,
      'geodetic_longitude' : 0,
      'altitude' : 100, # km
      'utc' : 0, # hours
  }

  # Only nrlmsise00 requires specification of indices, JB2008 fetches them automatically
  if endpoint == "nrlmsise00":
    payload.update(
      {
      'f107a' : 150, # nominal vals suggested by NRLMSISE-00 for alt <= 80 km 
      'f107' : 150, # SFU
      'ap' : 4,
      }
    )

  try:
    response = requests.get(hostname+endpoint, params=payload)
    response.raise_for_status()
  except requests.exceptions.HTTPError as e:  
    print(e)
    raise KeyboardInterrupt

  json_payload = response.json()
  print(f"Response for {endpoint} atmospheric model")
  print(json.dumps(json_payload, indent=4, sort_keys=True))