Skip to content

Commit

Permalink
Make pyds9 an extra
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jan 19, 2024
1 parent d4e504c commit fd9caaa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
16 changes: 11 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ lvmtools = 'lvmopstools.__main__:lvmopstools'
[tool.poetry.dependencies]
python = "^3.10,<3.13"
sdsstools = "^1.3.1"
pyds9 = "^1.8.1"
sdss-clu = "^2.2.2"
astropy = "^6.0.0"
click = "^8.1.7"
pyds9 = {version = "^1.8.1", optional = true}

[tool.poetry.group.dev.dependencies]
ipython = ">=8.0.0"
Expand All @@ -56,6 +56,9 @@ sphinx-autobuild = ">=2021.3.14"
sphinx-autodoc-typehints = "^1.23.2"
ruff = ">=0.1.0"

[tool.poetry.extras]
ds9 = ["pyds9"]

[tool.black]
line-length = 88
target-version = ['py312']
Expand Down
27 changes: 24 additions & 3 deletions src/lvmopstools/ds9.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
import pathlib
import re

import pyds9
from typing import TYPE_CHECKING

from clu import AMQPClient, AMQPReply


if TYPE_CHECKING:
from pyds9 import DS9


CAMERAS = [
"sci.west",
"sci.east",
Expand Down Expand Up @@ -95,9 +100,17 @@ async def handle_reply(reply: AMQPReply):
await asyncio.sleep(1)


def ds9_clear_frames(ds9: pyds9.DS9 | None = None, ds9_target: str = "DS9:*"):
def ds9_clear_frames(ds9: DS9 | None = None, ds9_target: str = "DS9:*"):
"""Clears all frames in DS9."""

try:
import pyds9
except ImportError:
raise ImportError(
"pyds9 is not installed. You can install it manually or run"
"pip install lvmopstools[ds9]"
)

if ds9 is None:
ds9 = pyds9.DS9(target=ds9_target)

Expand All @@ -108,7 +121,7 @@ def ds9_clear_frames(ds9: pyds9.DS9 | None = None, ds9_target: str = "DS9:*"):

def ds9_display_frames(
files: list[str | pathlib.Path] | dict[str, str | pathlib.Path | None],
ds9: pyds9.DS9 | None = None,
ds9: DS9 | None = None,
order=CAMERAS,
ds9_target: str = "DS9:*",
show_all_frames=True,
Expand All @@ -120,6 +133,14 @@ def ds9_display_frames(
):
"""Displays a series of images in DS9."""

try:
import pyds9
except ImportError:
raise ImportError(
"pyds9 is not installed. You can install it manually or run"
"pip install lvmopstools[ds9]"
)

if ds9 is None:
ds9 = pyds9.DS9(target=ds9_target)

Expand Down

0 comments on commit fd9caaa

Please sign in to comment.