Skip to content

Commit

Permalink
Merge pull request #355 from Carifio24/expose-grid-colors
Browse files Browse the repository at this point in the history
Expose various color settings and precession chart
  • Loading branch information
pkgw authored Jul 5, 2023
2 parents 3665ecb + d6a680a commit 225b413
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 9 deletions.
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"dependencies": {
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^5 || ^6",
"@wwtelescope/research-app": "^0.14.3",
"@wwtelescope/research-app": "^0.15.0",
"underscore": "^1"
},
"description": "AAS WorldWide Telescope from Python",
Expand Down Expand Up @@ -43,4 +43,4 @@
"pywwt-export": "npm run build && npm pack && node pywwt-export.js"
},
"version": "0.0.0-dev.0"
}
}
29 changes: 29 additions & 0 deletions pywwt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ def instruments(self):
False, help="Whether to show an altitude-azimuth grid " "(`bool`)"
).tag(wwt="showAltAzGrid", wwt_reset=True)

alt_az_grid_color = Color(
"magenta",
help="The color of the altitude-azimuth grid " "(`str` or " "`tuple`)",
).tag(wwt="altAzGridColor", wwt_reset=True)

alt_az_text = Bool(
False, help='Whether to show labels for the altitude-azimuth grid\'s text ' '(`bool`)'
).tag(wwt='showAltAzGridText', wwt_reset=True)
Expand Down Expand Up @@ -666,10 +671,18 @@ def instruments(self):
False, help="Whether to show the path of the ecliptic " "(`bool`)"
).tag(wwt="showEcliptic", wwt_reset=True)

ecliptic_color = Color(
"blue", help="The color of the ecliptic " "(`str` or `tuple`)"
).tag(wwt="eclipticColor", wwt_reset=True)

ecliptic_grid = Bool(
False, help="Whether to show a grid relative to the " "ecliptic plane (`bool`)"
).tag(wwt="showEclipticGrid", wwt_reset=True)

ecliptic_grid_color = Color(
"blue", help="The color of the ecliptic grid " "(`str` or `tuple`)"
).tag(wwt="eclipticGridColor", wwt_reset=True)

ecliptic_text = Bool(
False, help="Whether to show labels for the ecliptic grid " "(`bool`)"
).tag(wwt="showEclipticGridText", wwt_reset=True)
Expand All @@ -693,6 +706,10 @@ def instruments(self):
False, help="Whether to show a grid relative to the " "galactic plane (`bool`)"
).tag(wwt="showGalacticGrid", wwt_reset=True)

galactic_grid_color = Color(
"cyan", help="The color of the galactic grid " "(`str` or `tuple`)"
).tag(wwt="galacticGridColor", wwt_reset=True)

galactic_text = Bool(
False, help='Whether to show labels for the galactic grid\'s text ' '(`bool`)'
).tag(wwt='showGalacticGridText', wwt_reset=True)
Expand All @@ -701,6 +718,10 @@ def instruments(self):
wwt="showGrid", wwt_reset=True
)

grid_color = Color(
"white", help="The color of the equatorial grid " "(`str` or `tuple`)"
).tag(wwt="equatorialGridColor", wwt_reset=True)

grid_text = Bool(
False, help="Whether to show labels for the equatorial grid " "(`bool`)"
).tag(wwt="showEquatorialGridText", wwt_reset=True)
Expand Down Expand Up @@ -733,6 +754,14 @@ def instruments(self):
"(:class:`~astropy.units.Quantity`)",
).tag(wwt="locationLng", wwt_reset=True)

precession_chart = Bool(
False, help="Whether to show the precession chart " "(`bool`)"
).tag(wwt="showPrecessionChart", wwt_reset=True)

precession_chart_color = Color(
"orange", help="The color of the precession chart " "(`str` or `tuple`)"
).tag(wwt="precessionChartColor", wwt_reset=True)

# Validators / observers for the settings above that need custom support.

@observe("background")
Expand Down
Binary file added pywwt/tests/data/refimg_qt_full_step10/a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step10/b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step10/c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step10/d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pywwt/tests/data/refimg_qt_full_step9/g.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions pywwt/tests/test_qt_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,39 @@ def test_full(tmpdir, wwt_qt_client_isolated):
if msg:
failures.append(msg)

# Step 9

wwt.ecliptic = True
wwt.ecliptic_color = "#55AAEE"
wwt.grid_color = "#964B00"
wwt.alt_az_grid_color = (0, 1, 1)
wwt.ecliptic_grid_color = "orange"
wwt.galactic_grid_color = "red"

wait_for_test(wwt, WAIT_TIME, for_render=True)

msg = assert_widget_image(tmpdir, wwt, 'qt_full_step9.png', fail_now=False)
if msg:
failures.append(msg)

# Step 10
wwt.ecliptic = False
wwt.ecliptic_grid = False
wwt.alt_az_grid = False
wwt.grid = False
wwt.galactic_grid = False
wwt.precession_chart = True
wwt.precession_chart_color = (1, 0, 0)

coord = SkyCoord(100, 65, unit=('deg', 'deg'))
wwt.center_on_coordinates(coord, fov=60 * u.deg)

wait_for_test(wwt, WAIT_TIME, for_render=True)

msg = assert_widget_image(tmpdir, wwt, 'qt_full_step10.png', fail_now=False)
if msg:
failures.append(msg)

# Summarize

if failures:
Expand Down
30 changes: 23 additions & 7 deletions pywwt/tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
from astropy.coordinates import SkyCoord

DEGREES_TO_HOURS = 1. / 15.
STARDARD_WWT_SETTINGS = ['actualPlanetScale', 'showAltAzGrid', 'showaltAzGridText', 'showConstellationBoundries',
'constellationBoundryColor', 'constellationFigureColor', 'showConstellationFigures',
'showConstellationSelection', 'showConstellationLabels', 'showConstellationPictures',
'constellationSelectionColor', 'showCrosshairs', 'crosshairsColor', 'showEcliptic',
'showEclipticGrid', 'showEclipticGridText', 'showGalacticGrid', 'showGalacticGridText',
'galacticMode', 'showGrid', 'showEquatorialGridText', 'localHorizonMode', 'locationAltitude',
'locationLat', 'locationLng']
STARDARD_WWT_SETTINGS = ['actualPlanetScale', 'showAltAzGrid', 'showaltAzGridText', 'altAzGridColor',
'showConstellationBoundries', 'constellationBoundryColor', 'constellationFigureColor',
'showConstellationFigures', 'showConstellationSelection', 'showConstellationLabels',
'showConstellationPictures', 'constellationSelectionColor', 'showCrosshairs',
'crosshairsColor', 'showEcliptic', 'eclipticColor', 'showEclipticGrid',
'showEclipticGridText', 'eclipticGridColor', 'showGalacticGrid', 'showGalacticGridText',
'galacticGridColor', 'galacticMode', 'showGrid', 'showEquatorialGridText',
'equatorialGridColor', 'showPrecessionChart', 'precessionChartColor',
'localHorizonMode', 'locationAltitude', 'locationLat', 'locationLng']


class MockWWTWidget(BaseWWTWidget):
Expand Down Expand Up @@ -84,6 +86,7 @@ def test_widget_settings_serialization():
widget.actual_planet_scale = True
widget.alt_az_grid = False
widget.alt_az_text = False
widget.alt_az_grid_color = "#ff00ff"
widget.constellation_boundaries = True
widget.constellation_boundary_color = 'red'
widget.constellation_figure_color = '#24680b'
Expand All @@ -95,20 +98,27 @@ def test_widget_settings_serialization():
widget.crosshairs = True
widget.crosshairs_color = (128./255., 64./255., 16./255.)
widget.ecliptic = False
widget.ecliptic_color = "#ff0000"
widget.ecliptic_grid = True
widget.ecliptic_text = False
widget.ecliptic_grid_color = "#ffa500"
widget.galactic_grid = False
widget.galactic_text = False
widget.galactic_grid_color = "#55aaee"
widget.galactic_mode = True
widget.grid = False
widget.grid_text = False
widget.grid_color = "#583927"
widget.precession_chart = True
widget.precession_chart_color = "#ffff00"
widget.local_horizon_mode = True
widget.location_altitude = 7*u.m
widget.location_latitude = 12*u.deg
widget.location_longitude = -18*u.deg
expected_settings = {'actualPlanetScale': True,
'showAltAzGrid': False,
'showAltAzGridText': False,
'altAzGridColor': "#ff00ff",
'showConstellationBoundries': True,
'constellationBoundryColor': '#ff0000',
'constellationFigureColor': '#24680b',
Expand All @@ -120,13 +130,19 @@ def test_widget_settings_serialization():
'showCrosshairs': True,
'crosshairsColor': '#804010',
'showEcliptic': False,
'eclipticColor': "#ff0000",
'showEclipticGrid': True,
'showEclipticGridText': False,
'eclipticGridColor': "#ffa500",
'showGalacticGrid': False,
'showGalacticGridText': False,
'galacticGridColor': "#55aaee",
'galacticMode': True,
'showGrid': False,
'showEquatorialGridText': False,
'equatorialGridColor': "#583927",
'showPrecessionChart': True,
'precessionChartColor': "#ffff00",
'localHorizonMode': True,
'locationAltitude': 7,
'locationLat': 12.,
Expand Down

0 comments on commit 225b413

Please sign in to comment.