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
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "sam45",
"image": "ghcr.io/astral-sh/uv:python3.12-bookworm",
"runArgs": [
"--name=sam45"
],
"containerEnv": {
"UV_PROJECT_ENVIRONMENT": "/usr/local"
},
"postCreateCommand": "uv sync --frozen",
"customizations": {
"vscode": {
"extensions": [
"ms-python.black-formatter",
"ms-python.python",
"ms-toolsai.jupyter",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml"
],
"settings": {
"python.languageServer": "Pylance",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
}
}
}
}
19 changes: 19 additions & 0 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PyPI

on:
release:
types:
- created

jobs:
job:
name: PyPI
runs-on: ubuntu-latest
container: ghcr.io/astral-sh/uv:python3.12-bookworm
env:
UV_PROJECT_ENVIRONMENT: /usr/local
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- run: uv build && uv publish
31 changes: 31 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
job:
name: Test (${{ matrix.env }})
runs-on: ubuntu-latest
container: ghcr.io/astral-sh/uv:${{ matrix.env }}
env:
PYTHON_DIRS: sam45
UV_PROJECT_ENVIRONMENT: /usr/local
strategy:
fail-fast: false
matrix:
env:
- python3.10-bookworm
- python3.11-bookworm
- python3.12-bookworm
- python3.13-bookworm
- python3.14-bookworm
steps:
- uses: actions/checkout@v4
- run: uv sync --frozen
- run: black --check ${PYTHON_DIRS}
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[project]
name = "sam45"
version = "0.1.0"
description = "NRO/SAM45 log data reader"
readme = "README.md"
requires-python = ">=3.10,<3.15"
dependencies = [
"numpy>=2,<3",
"tomli>=2,<3",
]
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]

[[project.authors]]
name = "Akio Taniguchi"
email = "taniguchi.akio@gmail.com"

[project.license]
file = "LICENSE"

[project.urls]
repository = "https://github.com/astropenguin/sam45"

[dependency-groups]
dev = [
"black>=25,<26",
"ipython>=8,<10",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
5 changes: 5 additions & 0 deletions sam45/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__all__ = ["dtypes"]


# dependencies
from . import dtypes
32 changes: 32 additions & 0 deletions sam45/dtypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
__all__ = ["ctl", "obs", "dat", "end"]


# standard library
from importlib.resources import files
from tomli import loads


# dependencies
import numpy as np


def _get_dtype(name: str, /) -> np.dtype:
with (files("sam45") / "dtypes.toml").open() as f:
text = f.read()

consts = loads(text)["consts"]
dtype = loads(text.format(**consts))[name]
return np.dtype([(item["name"], item["dtype"]) for item in dtype])


ctl = _get_dtype("ctl")
"""Data type of the SAM45/CTL information."""

obs = _get_dtype("obs")
"""Data type of the SAM45/OBS information."""

dat = _get_dtype("dat")
"""Data type of the SAM45/DAT information."""

end = _get_dtype("end")
"""Data type of the SAM45/END information."""
Loading