Skip to content

Commit

Permalink
fall back to mirror if helioviewer.org is offline (fixes #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Jul 9, 2021
1 parent 33a57b9 commit 10b962f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gcs/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
from matplotlib.gridspec import GridSpec
from sunpy import log
from sunpy.coordinates import get_horizons_coord
from sunpy.io import read_file
from sunpy.map import Map
from sunpy.net import helioviewer

from gcs.geometry import gcs_mesh_sunpy, apex_radius
from gcs.utils.helioviewer import get_helioviewer_client
from gcs.utils.widgets import SliderAndTextbox

matplotlib.use('Qt5Agg')

hv = helioviewer.HelioviewerClient()
hv = get_helioviewer_client()

straight_vertices, front_vertices, circle_vertices = 10, 10, 20
filename = 'gcs_params.json'
draw_modes = ['off', 'point cloud', 'grid']
Expand Down
18 changes: 18 additions & 0 deletions gcs/utils/helioviewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from sunpy.net.helioviewer import HelioviewerClient


def get_helioviewer_client():
hv = HelioviewerClient()
if not _is_online(hv):
# fall back to mirror server
print("https://www.helioviewer.org/ seems to be offline,"
"switching to mirror at https://helioviewer.ias.u-psud.fr/")
hv = HelioviewerClient("https://helioviewer-api.ias.u-psud.fr/")
return hv


def _is_online(hv: HelioviewerClient):
try:
return hv.is_online()
except:
return False

0 comments on commit 10b962f

Please sign in to comment.