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
16 changes: 8 additions & 8 deletions drs4/cal/dsbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# standard library
from logging import getLogger
from typing import Optional, Union, get_args
from typing import get_args

# dependencies
import xarray as xr
Expand All @@ -18,19 +18,19 @@


def set_gain(
ms: Optional[Union[xr.Dataset, StrPath]] = None,
ms: xr.Dataset | StrPath | None = None,
/,
*,
# for measurement (required)
chassis: Optional[Chassis] = None,
interface: Optional[Interface] = None,
chassis: Chassis | None = None,
interface: Interface | None = None,
ones: bool = False,
zeros: bool = False,
# for connection (optional)
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
workdir: Optional[StrPath] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
workdir: StrPath | None = None,
) -> None:
"""Set a gain file (DRS4 MS file) to DRS4.

Expand Down
25 changes: 12 additions & 13 deletions drs4/ctrl/cw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# standard library
from logging import getLogger
from os import getenv
from typing import Optional

# constants
LOGGER = getLogger(__name__)
Expand Down Expand Up @@ -33,13 +32,13 @@ def on(
signal_sb: SideBand,
signal_chan: Channel,
# for measurement (optional)
lo_freq: Optional[float] = None,
lo_mult: Optional[int] = None,
sg_ampl: Optional[float] = None,
lo_freq: float | None = None,
lo_mult: int | None = None,
sg_ampl: float | None = None,
# for connection (optional)
sg_host: Optional[str] = None,
sg_port: Optional[int] = None,
timeout: Optional[float] = None,
sg_host: str | None = None,
sg_port: int | None = None,
timeout: float | None = None,
) -> None:
"""Start outputting the CW signal after setting the SG amplitude and frequency.

Expand Down Expand Up @@ -109,9 +108,9 @@ def on(
def off(
*,
# for connection (optional)
sg_host: Optional[str] = None,
sg_port: Optional[int] = None,
timeout: Optional[float] = None,
sg_host: str | None = None,
sg_port: int | None = None,
timeout: float | None = None,
) -> None:
"""Stop outputting the CW signal.

Expand Down Expand Up @@ -147,9 +146,9 @@ def off(
def status(
*,
# for connection (optional)
sg_host: Optional[str] = None,
sg_port: Optional[int] = None,
timeout: Optional[float] = None,
sg_host: str | None = None,
sg_port: int | None = None,
timeout: float | None = None,
) -> None:
"""Show the status of CW signal in the logger.

Expand Down
12 changes: 6 additions & 6 deletions drs4/ctrl/scpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# standard library
from logging import getLogger
from socket import socket, AF_INET, SOCK_STREAM
from typing import IO, Optional, Sequence, Union
from typing import IO, Sequence

# dependencies
from ..utils import StrPath
Expand All @@ -15,7 +15,7 @@
DEFAULT_ENCODING: str = "ascii"
DEFAULT_END: str = "\n"
DEFAULT_FLAGS: int = 0
DEFAULT_TIMEOUT: Optional[float] = None
DEFAULT_TIMEOUT: float | None = None
LOGGER = getLogger(__name__)


Expand Down Expand Up @@ -54,7 +54,7 @@ def recv(


def connect(
host: str, port: int, timeout: Optional[float] = 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 @@ -94,10 +94,10 @@ def connect(


def send_commands(
commands: Union[IO[str], Sequence[str], str],
commands: IO[str] | Sequence[str] | str,
host: str,
port: int,
timeout: Optional[float] = DEFAULT_TIMEOUT,
timeout: float | None = DEFAULT_TIMEOUT,
encoding: str = DEFAULT_ENCODING,
autorecv: bool = DEFAULT_AUTORECV,
bufsize: int = DEFAULT_BUFSIZE,
Expand Down Expand Up @@ -152,7 +152,7 @@ def send_commands_in(
path: StrPath,
host: str,
port: int,
timeout: Optional[float] = DEFAULT_TIMEOUT,
timeout: float | None = DEFAULT_TIMEOUT,
encoding: str = DEFAULT_ENCODING,
autorecv: bool = DEFAULT_AUTORECV,
bufsize: int = DEFAULT_BUFSIZE,
Expand Down
46 changes: 23 additions & 23 deletions drs4/ctrl/self.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from logging import getLogger
from os import getenv
from subprocess import PIPE, CompletedProcess, run as sprun
from typing import Optional, Union, overload
from typing import overload

# dependencies
from ..specs.common import ENV_CTRL_ADDR, ENV_CTRL_USER, Chassis
Expand All @@ -24,9 +24,9 @@
def run(
*commands: str,
chassis: Chassis,
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
workdir: StrPath = PATH_CMD_DIR,
) -> StrCP: ...

Expand All @@ -35,9 +35,9 @@ def run(
def run(
*commands: str,
chassis: None = None,
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
workdir: StrPath = PATH_CMD_DIR,
) -> tuple[StrCP, StrCP]: ...

Expand All @@ -46,12 +46,12 @@ def run(
# for connection (required)
*commands: str,
# for connection (optional)
chassis: Optional[Chassis] = None,
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
chassis: Chassis | None = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
workdir: StrPath = PATH_CMD_DIR,
) -> Union[StrCP, tuple[StrCP, StrCP]]:
) -> StrCP | tuple[StrCP, StrCP]:
"""Run commands in DRS4.

Args:
Expand Down Expand Up @@ -140,9 +140,9 @@ def send(
/,
*,
chassis: Chassis,
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
) -> StrCP: ...


Expand All @@ -153,9 +153,9 @@ def send(
/,
*,
chassis: None = None,
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
) -> tuple[StrCP, StrCP]: ...


Expand All @@ -166,11 +166,11 @@ def send(
/,
*,
# for connection (optional)
chassis: Optional[Chassis] = None,
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
) -> Union[StrCP, tuple[StrCP, StrCP]]:
chassis: Chassis | None = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
) -> StrCP | tuple[StrCP, StrCP]:
"""Send a file to DRS4.

Args:
Expand Down
24 changes: 12 additions & 12 deletions drs4/daq/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from logging import getLogger
from os import getenv
from pathlib import Path
from typing import Optional, Union, get_args
from typing import get_args

# dependencies
import xarray as xr
Expand Down Expand Up @@ -50,27 +50,27 @@ def cross(
freq_range_if1: FreqRange = "inner",
freq_range_if2: FreqRange = "outer",
integ_time: IntegTime = 100,
signal_if: Optional[Interface] = None,
signal_sb: Optional[SideBand] = None,
signal_chan: Optional[Channel] = None,
signal_if: Interface | None = None,
signal_sb: SideBand | None = None,
signal_chan: Channel | None = None,
# for file saving (optional)
append: bool = False,
integrate: bool = False,
join: XarrayJoin = "inner",
overwrite: bool = False,
progress: bool = False,
workdir: Optional[StrPath] = None,
zarr_if1: Optional[StrPath] = None,
zarr_if2: Optional[StrPath] = None,
workdir: StrPath | None = None,
zarr_if1: StrPath | None = None,
zarr_if2: StrPath | None = None,
# for DRS4 settings (optional)
dsp_mode: DSPMode = "IQ",
gain_if1: Optional[Union[xr.Dataset, StrPath]] = None,
gain_if2: Optional[Union[xr.Dataset, StrPath]] = None,
gain_if1: xr.Dataset | StrPath | None = None,
gain_if2: xr.Dataset | StrPath | None = None,
settings: bool = True,
# for connection (optional)
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
) -> tuple[Path, Path]:
""""""
obsid = datetime.now(timezone.utc).strftime(OBSID_FORMAT)
Expand Down
40 changes: 20 additions & 20 deletions drs4/daq/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
from threading import Event
from time import sleep
from typing import Optional, Union, get_args
from typing import get_args

# dependencies
import xarray as xr
Expand Down Expand Up @@ -64,32 +64,32 @@ def auto(
freq_range_if1: FreqRange = "inner",
freq_range_if2: FreqRange = "outer",
integ_time: IntegTime = 100,
signal_if: Optional[Interface] = None,
signal_sb: Optional[SideBand] = None,
signal_chan: Optional[Channel] = None,
signal_if: Interface | None = None,
signal_sb: SideBand | None = None,
signal_chan: Channel | None = None,
# for file saving (optional)
append: bool = False,
integrate: bool = False,
join: XarrayJoin = "inner",
overwrite: bool = False,
progress: bool = False,
workdir: Optional[StrPath] = None,
zarr_if1: Optional[StrPath] = None,
zarr_if2: Optional[StrPath] = None,
workdir: StrPath | None = None,
zarr_if1: StrPath | None = None,
zarr_if2: StrPath | None = None,
# for DRS4 settings (optional)
dsp_mode: DSPMode = "SB",
gain_if1: Optional[Union[xr.Dataset, StrPath]] = None,
gain_if2: Optional[Union[xr.Dataset, StrPath]] = None,
gain_if1: xr.Dataset | StrPath | None = None,
gain_if2: xr.Dataset | StrPath | None = None,
settings: bool = True,
# for connection (optional)
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
dest_addr: Optional[str] = None,
dest_port1: Optional[int] = None,
dest_port2: Optional[int] = None,
dest_port3: Optional[int] = None,
dest_port4: Optional[int] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
dest_addr: str | None = None,
dest_port1: int | None = None,
dest_port2: int | None = None,
dest_port3: int | None = None,
dest_port4: int | None = None,
timeout: float | None = None,
) -> tuple[Path, Path]:
""""""
obsid = datetime.now(timezone.utc).strftime(OBSID_FORMAT)
Expand Down Expand Up @@ -301,7 +301,7 @@ def auto(


def dump(
vdif: Union[Path, str],
vdif: StrPath,
/,
*,
# for connection (required)
Expand All @@ -310,8 +310,8 @@ def dump(
# for connection (optional)
group: str = GROUP,
# for file saving (optional)
cancel: Optional[Event] = None,
timeout: Optional[float] = None,
cancel: Event | None = None,
timeout: float | None = None,
progress: bool = False,
overwrite: bool = False,
) -> None:
Expand Down
11 changes: 5 additions & 6 deletions drs4/qlook/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from os.path import getmtime
from pathlib import Path
from subprocess import PIPE, run as sprun
from typing import Optional

# dependencies
import matplotlib.pyplot as plt
Expand All @@ -33,13 +32,13 @@ def run(
# for connection (required)
chassis: Chassis,
# for connection (optional)
ctrl_addr: Optional[str] = None,
ctrl_user: Optional[str] = None,
timeout: Optional[float] = None,
ctrl_addr: str | None = None,
ctrl_user: str | None = None,
timeout: float | None = None,
# for plotting (optional)
figsize: Optional[tuple[int, int]] = (12, 6),
figsize: tuple[int, int] | None = (12, 6),
interval: int = 10,
workdir: Optional[StrPath] = None,
workdir: StrPath | None = None,
) -> None:
"""Display current auto-spectra and bit distributions of DRS4.

Expand Down
Loading