Marc Skov Madsen commited on
Commit
2602c55
·
1 Parent(s): 9258a80
app.py CHANGED
@@ -15,7 +15,11 @@ import panel as pn
15
  from holoviews.streams import RangeXY
16
  from numba import jit
17
 
18
- pn.extension("mathjax")
 
 
 
 
19
 
20
  DEFAULT_COLOR_MAP = [
21
  "#0b2f4c", # Deep blue
@@ -74,9 +78,7 @@ def create_fractal(min_x, max_x, min_y, max_y, image, iters):
74
  def get_fractal(x_range, y_range, iters=200, cmap="set1", width=1200, height=1200):
75
  (x0, x1), (y0, y1) = x_range, y_range
76
  image = np.zeros((width, height), dtype=np.uint8)
77
- return hv.Image(
78
- create_fractal(x0, x1, -y1, -y0, image, iters), bounds=(x0, y0, x1, y1), rtol=1e-9
79
- ).opts(
80
  colorbar=True,
81
  cmap=cmap,
82
  xlabel="Real",
@@ -115,7 +117,7 @@ cmap = pn.widgets.ColorMap(
115
  swatch_width=100,
116
  sizing_mode="stretch_width",
117
  name="Color Map",
118
- stylesheets=["div, div:hover {background: var(--panel-surface-color); color: current}"],
119
  )
120
  dmap = hv.DynamicMap(
121
  pn.bind(
 
15
  from holoviews.streams import RangeXY
16
  from numba import jit
17
 
18
+ pn.extension("mathjax", loading_indicator=True, defer_load=True, nthreads=3)
19
+
20
+ CMAP_CSS = (
21
+ "div, div:hover {background: var(--panel-surface-color); color: current}" if pn.config.theme == "dark" else ""
22
+ )
23
 
24
  DEFAULT_COLOR_MAP = [
25
  "#0b2f4c", # Deep blue
 
78
  def get_fractal(x_range, y_range, iters=200, cmap="set1", width=1200, height=1200):
79
  (x0, x1), (y0, y1) = x_range, y_range
80
  image = np.zeros((width, height), dtype=np.uint8)
81
+ return hv.Image(create_fractal(x0, x1, -y1, -y0, image, iters), bounds=(x0, y0, x1, y1), rtol=1e-9).opts(
 
 
82
  colorbar=True,
83
  cmap=cmap,
84
  xlabel="Real",
 
117
  swatch_width=100,
118
  sizing_mode="stretch_width",
119
  name="Color Map",
120
+ stylesheets=[],
121
  )
122
  dmap = hv.DynamicMap(
123
  pn.bind(
examples/01_getting_started.py DELETED
@@ -1,42 +0,0 @@
1
- # See also https://github.com/cds-astro/ipyaladin/blob/master/examples/01_Getting_Started.ipynb
2
- """# 🛸 Getting Started
3
-
4
- Displays an interactive sky view of the
5
- [Mars Viking MDIM21 survey](https://alasky.u-strasbg.fr/Planets/Mars_Viking_MDIM21/).
6
-
7
- Powered by \
8
- [ipyaladin](https://github.com/cds-astro/ipyaladin) and \
9
- [Panel](https://panel.holoviz.org/index.html).
10
-
11
- Check out the [**App Gallery**](./)
12
- """
13
-
14
- import panel as pn
15
- from ipyaladin import Aladin
16
-
17
- pn.extension("ipywidgets", sizing_mode="stretch_width")
18
-
19
- aladin = Aladin(
20
- target="159.2135528 -58.6241989",
21
- survey="https://alasky.u-strasbg.fr/Planets/Mars_Viking_MDIM21",
22
- fov=10,
23
- height=800,
24
- )
25
-
26
- panel = pn.panel(aladin, height=800)
27
-
28
- pn.template.FastListTemplate(
29
- site="ipyaladin and Panel",
30
- site_url="./",
31
- title="01 Getting Started",
32
- sidebar=[
33
- pn.pane.PNG(
34
- "https://avatars.githubusercontent.com/u/26145382?s=200&v=4",
35
- link_url="https://cds.unistra.fr/",
36
- ),
37
- __doc__,
38
- ],
39
- main=[panel],
40
- accent="#296bb5",
41
- main_layout=None,
42
- ).servable()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
examples/06_linked_widgets.py DELETED
@@ -1,57 +0,0 @@
1
- """# 🛸 Linked Widgets
2
-
3
- Displays 3 linked `Aladin` widgets. Try zoming or panning.
4
-
5
- Powered by \
6
- [ipyaladin](https://github.com/cds-astro/ipyaladin) and \
7
- [Panel](https://panel.holoviz.org/index.html).
8
-
9
- Check out the [**App Gallery**](./)
10
- """
11
-
12
- import panel as pn
13
- from ipyaladin import Aladin
14
- from ipywidgets import Box, Layout, widgets
15
-
16
- pn.extension("ipywidgets", sizing_mode="stretch_width")
17
-
18
- cosmetic_options = {"show_projection_control": False, "show_fullscreen_control": False}
19
-
20
- a = Aladin(layout=Layout(width="100%"), target="M 81", fov=0.3, **cosmetic_options)
21
- b = Aladin(layout=Layout(width="100%"), survey="P/DSS2/red", **cosmetic_options)
22
- c = Aladin(layout=Layout(width="100%"), survey="P/2MASS/color", **cosmetic_options)
23
-
24
- # synchronize target between 3 widgets
25
- widgets.jslink((a, "_target"), (b, "_target"))
26
- widgets.jslink((b, "_target"), (c, "_target"))
27
-
28
- # synchronize FoV (zoom level) between 3 widgets
29
- widgets.jslink((a, "_fov"), (b, "_fov"))
30
- widgets.jslink((b, "_fov"), (c, "_fov"))
31
-
32
- items = [a, b, c]
33
-
34
- box_layout = Layout(
35
- display="flex",
36
- flex_flow="column",
37
- align_items="stretch",
38
- border="solid",
39
- width="100%",
40
- )
41
- box = Box(children=items, layout=box_layout)
42
-
43
- pn.template.FastListTemplate(
44
- site="ipyaladin and Panel",
45
- site_url="./",
46
- title="Linked Widgets",
47
- sidebar=[
48
- pn.pane.PNG(
49
- "https://avatars.githubusercontent.com/u/26145382?s=200&v=4",
50
- link_url="https://cds.unistra.fr/",
51
- ),
52
- __doc__,
53
- ],
54
- main=[box],
55
- accent="#296bb5",
56
- main_layout=None,
57
- ).servable()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
examples/07_on_click_callback.py DELETED
@@ -1,93 +0,0 @@
1
- """# 🛸 On Click Callback
2
-
3
- Once all cells are executed, click anywhere to get the closest star name. Be patient and the associated photometric points appear after a few seconds.
4
-
5
- Powered by \
6
- [ipyaladin](https://github.com/cds-astro/ipyaladin) and \
7
- [Panel](https://panel.holoviz.org/index.html).
8
-
9
- Check out the [**App Gallery**](./)
10
- """
11
-
12
- import panel as pn
13
- import requests
14
- from ipyaladin import Aladin
15
- from ipywidgets import Layout
16
-
17
- pn.extension("ipywidgets", sizing_mode="stretch_width")
18
-
19
- LoadingIndicator = "Loading..."
20
-
21
- aladin = Aladin(
22
- layout=Layout(width="100%"),
23
- height=800,
24
- target="M 36",
25
- fov=0.3,
26
- show_fullscreen_control=False,
27
- )
28
- info = pn.pane.HTML("<h2>Click the widget</h2>")
29
- image = pn.pane.PNG(embed=True, sizing_mode="fixed")
30
- box = pn.Column(aladin, info, image)
31
-
32
-
33
- def process_result(data: dict) -> None:
34
- """Process the result of a click event on the Aladin widget.
35
-
36
- Parameters
37
- ----------
38
- data : dict
39
- The data returned by the click event.
40
- """
41
- box.loading = True
42
-
43
- info.value = ""
44
- ra = data["ra"]
45
- dec = data["dec"]
46
- query = (
47
- f"SELECT TOP 1 main_id, ra, dec, DISTANCE(POINT('ICRS', {ra}, {dec}), "
48
- f"POINT('ICRS', ra, dec)) as d FROM basic "
49
- f"WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', {ra}, {dec}, {aladin.fov.deg / 10}))=1 "
50
- "ORDER BY d ASC"
51
- )
52
-
53
- r = requests.get(
54
- "http://simbad.u-strasbg.fr/simbad/sim-tap/sync",
55
- params={
56
- "query": query,
57
- "request": "doQuery",
58
- "lang": "adql",
59
- "format": "json",
60
- "phase": "run",
61
- },
62
- )
63
- obj_name = ""
64
- obj_coo = None
65
- obj_data = r.json()["data"]
66
- if len(obj_data) == 0:
67
- return
68
-
69
- obj_name = obj_data[0][0]
70
- obj_coo = [obj_data[0][1], obj_data[0][2]]
71
-
72
- info.object = f"<h2>{obj_name}</h2><br><br>"
73
- image.object = f"https://cdsportal.u-strasbg.fr/cgi-bin/PhotVizPreview/plot?ra={obj_coo[0]}&dec={obj_coo[1]}&radius_arcsec=5&w=200&h=150&point_size=4"
74
- box.loading = False
75
-
76
-
77
- aladin.set_listener("click", process_result)
78
-
79
- pn.template.FastListTemplate(
80
- site="ipyaladin and Panel",
81
- site_url="./",
82
- title="On Click Callback",
83
- sidebar=[
84
- pn.pane.PNG(
85
- "https://avatars.githubusercontent.com/u/26145382?s=200&v=4",
86
- link_url="https://cds.unistra.fr/",
87
- ),
88
- __doc__,
89
- ],
90
- main=[box],
91
- accent="#296bb5",
92
- main_layout=None,
93
- ).servable()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
thumbnails/01_getting_started.png DELETED
Binary file (3.66 kB)
 
thumbnails/06_linked_widgets.png DELETED
Binary file (3.29 kB)
 
thumbnails/07_on_click_callback.png DELETED
Binary file (4.2 kB)