Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ keywords:
- single-dish
- submillimeter
license: MIT
version: 0.4.0
date-released: '2026-02-24'
version: 0.5.0
date-released: '2026-03-09'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.18709559-cornflowerblue?style=flat-square)](https://doi.org/10.5281/zenodo.18709559)
[![Tests](https://img.shields.io/github/actions/workflow/status/finerreceiver/drs4/tests.yaml?label=Tests&style=flat-square)](https://github.com/finerreceiver/drs4/actions)

Control and data acquisition for FINER/DRS4
Control and data acquisition software for FINER/DRS4

## Installation

Expand Down
9 changes: 7 additions & 2 deletions docs/_static/switcher.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[
{
"name": "0.4.0 (latest)",
"version": "0.4.0",
"name": "0.5.0 (latest)",
"version": "0.5.0",
"url": "https://finerreceiver.github.io/drs4/"
},
{
"name": "0.4.0",
"version": "0.4.0",
"url": "https://finerreceiver.github.io/drs4/0.4.0/"
},
{
"name": "0.3.0",
"version": "0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion docs/build
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export LC_ALL=C.UTF-8

sphinx-apidoc -efMT -d 2 -o docs/_apidoc drs4
sphinx-build -a -b html docs docs/_build
sphinx-build -a -b html docs docs/_build/0.4.0
sphinx-build -a -b html docs docs/_build/0.5.0
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
],
"switcher": {
"json_url": "https://finerreceiver.github.io/drs4/_static/switcher.json",
"version_match": "0.4.0",
"version_match": "0.5.0",
},
}
2 changes: 1 addition & 1 deletion drs4/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ["ctrl", "daq", "qlook", "obs", "specs", "utils"]
__version__ = "0.4.0"
__version__ = "0.5.0"


# standard library
Expand Down
23 changes: 12 additions & 11 deletions drs4/ctrl/cw.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ def on(
else:
raise ValueError("Signal sideband must be USB|LSB.")

LOGGER.info("(")
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.info("(")
LOGGER.debug(")")

send_commands(
[
Expand Down Expand Up @@ -128,12 +128,12 @@ def off(
if sg_port is None:
sg_port = int(getenv(ENV_SG_PORT, ""))

LOGGER.info("(")
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.info(")")
LOGGER.debug(")")

send_commands(
"OUTP OFF",
Expand Down Expand Up @@ -166,16 +166,17 @@ def status(
if sg_port is None:
sg_port = int(getenv(ENV_SG_PORT, ""))

LOGGER.info("(")
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.info(")")
LOGGER.debug(")")

send_commands(
for message in send_commands(
["AMPL?", "FREQ?", "OUTP?"],
host=sg_host,
port=sg_port,
timeout=timeout,
)
):
LOGGER.info(message)
37 changes: 28 additions & 9 deletions drs4/ctrl/scpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def recv(


def connect(
host: str, port: int, timeout: float | None = DEFAULT_TIMEOUT
host: str,
port: int,
/,
*,
timeout: float | None = DEFAULT_TIMEOUT,
) -> CustomSocket:
"""Connect to an SCPI server and returns a custom socket object.

Expand Down Expand Up @@ -89,19 +93,20 @@ def connect(
sock = CustomSocket(AF_INET, SOCK_STREAM)
sock.settimeout(timeout)
sock.connect((host, port))

return sock


def send_commands(
commands: IO[str] | Sequence[str] | str,
/,
*,
host: str,
port: int,
timeout: float | None = DEFAULT_TIMEOUT,
encoding: str = DEFAULT_ENCODING,
autorecv: bool = DEFAULT_AUTORECV,
bufsize: int = DEFAULT_BUFSIZE,
) -> None:
) -> tuple[str, ...]:
"""Send SCPI command(s) to a server.

Args:
Expand All @@ -115,7 +120,7 @@ def send_commands(
bufsize: Maximum byte size for receiving a message.

Returns:
This function returns nothing.
Tuple of the received messages.

Examples:
To send an SCPI command to the server::
Expand All @@ -137,26 +142,32 @@ def send_commands(
if isinstance(commands, str):
commands = (commands,)

with connect(host, port, timeout) as sock:
with connect(host, port, timeout=timeout) as sock:
messages: list[str] = []

for command in commands:
if not command or command.startswith("#"):
continue

sock.send(command.strip(), encoding=encoding)

if autorecv and command.endswith("?"):
sock.recv(bufsize)
messages.append(sock.recv(bufsize))

return tuple(messages)


def send_commands_in(
path: StrPath,
/,
*,
host: str,
port: int,
timeout: float | None = DEFAULT_TIMEOUT,
encoding: str = DEFAULT_ENCODING,
autorecv: bool = DEFAULT_AUTORECV,
bufsize: int = DEFAULT_BUFSIZE,
) -> None:
) -> tuple[str, ...]:
"""Send SCPI command(s) written in a file to a server.

Args:
Expand All @@ -169,7 +180,7 @@ def send_commands_in(
bufsize: Maximum byte size for receiving a message.

Returns:
This function returns nothing.
Tuple of the received messages.

Examples:
If a text file, commands.txt, has SCPI commands::
Expand All @@ -191,4 +202,12 @@ def send_commands_in(
LOGGER.debug(")")

with open(path, encoding=encoding) as f:
send_commands(f, host, port, timeout, encoding, autorecv, bufsize)
return send_commands(
f,
host=host,
port=port,
timeout=timeout,
encoding=encoding,
autorecv=autorecv,
bufsize=bufsize,
)
6 changes: 3 additions & 3 deletions drs4/ctrl/self.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ def set_gain(

return

LOGGER.info("(")
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.info(")")
LOGGER.debug(")")

if chassis not in get_args(Chassis):
raise ValueError("Chassis number must be 1|2.")
Expand Down
6 changes: 3 additions & 3 deletions drs4/daq/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def cross(
if zarr_if2 is None:
zarr_if2 = ZARR_FORMAT.format(obsid, chassis, 2)

LOGGER.info("(")
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.info(")")
LOGGER.debug(")")

if append and overwrite:
raise ValueError("Append and overwrite cannot be enabled at once.")
Expand Down
10 changes: 5 additions & 5 deletions drs4/daq/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ def auto(
if zarr_if2 is None:
zarr_if2 = ZARR_FORMAT.format(obsid, chassis, 2)

LOGGER.info("(")
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.info(")")
LOGGER.debug(")")

if append and overwrite:
raise ValueError("Append and overwrite cannot be enabled at once.")
Expand Down Expand Up @@ -336,7 +336,7 @@ def dump(
sock.settimeout(timeout)

# start dumping
LOGGER.info(f"{prefix} Start dumping data.")
LOGGER.debug(f"{prefix} Start dumping data.")

while cancel is None or not cancel.is_set():
frame, _ = sock.recvfrom(VDIF_FRAME_BYTES)
Expand All @@ -348,4 +348,4 @@ def dump(
LOGGER.warning(f"{prefix} Truncated frame.")

# finish dumping
LOGGER.info(f"{prefix} Finish dumping data.")
LOGGER.debug(f"{prefix} Finish dumping data.")
2 changes: 1 addition & 1 deletion drs4/qlook/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(
LOGGER.debug("(")

for key, val in locals().items():
LOGGER.info(f" {key}: {val!r}")
LOGGER.debug(f" {key}: {val!r}")

LOGGER.debug(")")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "drs4"
version = "0.4.0"
version = "0.5.0"
description = "Control and data acquisition software for FINER/DRS4"
readme = "README.md"
keywords = [
Expand Down
Loading