rddac 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rddac-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sebastian Baum
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
rddac-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: rddac
3
+ Version: 1.0.0
4
+ Summary: Python package for the Real Deep Drawing and Cutting (RDDAC) Dataset
5
+ Author: Sebastian Baum, Pascal Heinzelmann
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/BaumSebastian/RDDAC
8
+ Project-URL: Documentation, https://rddac.readthedocs.io
9
+ Project-URL: Repository, https://github.com/BaumSebastian/RDDAC
10
+ Keywords: deep-drawing,sheet-metal,forming,dataset,experimental,measurement
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy>=1.24.0
23
+ Requires-Dist: pandas>=2.0.0
24
+ Requires-Dist: h5py>=3.8.0
25
+ Requires-Dist: matplotlib>=3.7.0
26
+ Requires-Dist: requests>=2.28.0
27
+ Requires-Dist: humanfriendly>=10.0
28
+ Requires-Dist: rich>=13.0.0
29
+ Requires-Dist: mlcroissant>=1.1.0
30
+ Requires-Dist: ddacs<4,>=3.2.1
31
+ Provides-Extra: torch
32
+ Requires-Dist: torch>=2.0; extra == "torch"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: black>=24.0.0; extra == "dev"
36
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
37
+ Requires-Dist: bumpver>=2023.1129; extra == "dev"
38
+ Requires-Dist: pre-commit>=3.6.0; extra == "dev"
39
+ Provides-Extra: docs
40
+ Requires-Dist: mkdocs>=1.5.0; extra == "docs"
41
+ Requires-Dist: mkdocs-material>=9.5.0; extra == "docs"
42
+ Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
43
+ Requires-Dist: mkdocs-macros-plugin>=1.0.0; extra == "docs"
44
+ Dynamic: license-file
45
+
46
+ <div align="center">
47
+ <img src="https://raw.githubusercontent.com/BaumSebastian/RDDAC/main/docs/images/icon/icon.png" width="150"/>
48
+ <h1>Real Deep Drawing and Cutting (RDDAC) Dataset</h1>
49
+ </div>
50
+
51
+ [![Code License: MIT](https://img.shields.io/badge/Code-MIT-yellow.svg)](LICENSE)
52
+ [![Dataset License: CC BY 4.0](https://img.shields.io/badge/Dataset-CC_BY_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
53
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
54
+ [![Documentation](https://readthedocs.org/projects/rddac/badge/?version=latest)](https://rddac.readthedocs.io)
55
+ [![DaRUS Repository](https://img.shields.io/badge/repository-DaRUS-green.svg)](https://darus.uni-stuttgart.de/dataset.xhtml?persistentId=doi:10.18419/DARUS-5589)
56
+ [![DOI](https://img.shields.io/badge/DOI-10.18419%2FDARUS--5589-blue.svg)](https://doi.org/10.18419/DARUS-5589)
57
+
58
+ <div align="center">
59
+
60
+ ![Measured point clouds after OP10 and OP20, colored by deviation from the matching DDACS simulation](https://raw.githubusercontent.com/BaumSebastian/RDDAC/main/docs/images/sim2real_sweep.gif)
61
+
62
+ *Measured point clouds of one experiment after deep drawing (OP10, left) and cutting (OP20, right), colored by the deviation from the matching DDACS simulation.*
63
+
64
+ </div>
65
+
66
+ **A large-scale experimental dataset of 9,000 physical deep-drawing and cutting experiments — the real-world counterpart to the [DDACS](https://ddacs.readthedocs.io) FEM simulations.** Each experiment forms a modified quadratic cup from DP600 dual-phase steel (deep drawing in OP10, cutting in OP20) and records press force signals, sheet-thickness and oil-film traverses, and high-resolution 3D laser scans of the part after each operation. Use it to quantify the simulation-to-reality gap, train models on real process data, or validate DDACS-trained surrogates against physical measurements.
67
+
68
+ | | |
69
+ |---|---|
70
+ | **Experiments** | 9,000 |
71
+ | **Total size** | ~87 GB (HDF5, lossless) |
72
+ | **Process steps per experiment** | 2 (OP10 deep drawing, OP20 cutting) |
73
+ | **Parameter space** | 2 geometries x 3 blankholder forces x 3 oil types (18 categories) |
74
+ | **Repetitions** | up to 500 per category |
75
+ | **Train / val / test** | 7,200 / 900 / 900 (predefined, seed 42) |
76
+ | **Matching simulations** | DDACS `rddac.zip` (~9 GB), fetched by `rddac download` |
77
+
78
+ **[Documentation](https://rddac.readthedocs.io)** · **[Dataset DOI](https://doi.org/10.18419/DARUS-5589)** · **[Paper](https://doi.org/10.1007/s12666-026-03870-5)**
79
+
80
+ The `rddac` package ships with the dataset and provides a Croissant native interface: one CLI for the download, one Python module for access, and an optional PyTorch `IterableDataset` for training.
81
+
82
+ ## Installation
83
+
84
+ ```bash
85
+ pip install rddac
86
+ ```
87
+
88
+ The PyTorch adapter is an optional extra. For hardware specific PyTorch builds (CUDA, ROCm, MPS), install PyTorch first from [pytorch.org](https://pytorch.org/get-started/locally/), then install the extra:
89
+
90
+ ```bash
91
+ pip install 'rddac[torch]'
92
+ ```
93
+
94
+ ## Download the dataset
95
+
96
+ ```bash
97
+ # Small sample bundle (~174 MB): manifest, CSV, and one experiment per category.
98
+ rddac download --small -y
99
+
100
+ # Full release (~87 GB), including the matching DDACS simulations (~9 GB).
101
+ rddac download
102
+
103
+ # Real measurements only (skip the simulations).
104
+ rddac download --no-sim
105
+ ```
106
+
107
+ ## Basic usage
108
+
109
+ ```python
110
+ import rddac
111
+
112
+ with rddac.open_h5(0) as f: # one experiment by id
113
+ force = f["force/data"][:] # (n, 8): time, load cells, temp, position, total force
114
+ sheet = f["sheet_thickness/data"][:] # (n, 2): sensor position, thickness
115
+ z10 = f["pointcloud/op10/z"][:] # (6400000,) flat scan buffer
116
+ ```
117
+
118
+ The public surface mirrors the [`ddacs`](https://ddacs.readthedocs.io) package one to one — `load`, `add_view`, `open_h5`, `inspect_h5`, `streaming.iter_view` / `export_to_numpy` / `load_export`, and the PyTorch `IterableDataset` share names, signatures, and semantics. Code written against DDACS ports by swapping the import:
119
+
120
+ ```python
121
+ # import ddacs as dataset_pkg # simulations
122
+ import rddac as dataset_pkg # real experiments
123
+
124
+ ds = dataset_pkg.load(data_dir="./data")
125
+ for record in dataset_pkg.streaming.iter_view("force-curve", data_dir="./data", dataset=ds):
126
+ ...
127
+ ```
128
+
129
+ See the [documentation](https://rddac.readthedocs.io) for the dataset reference (parameter space, HDF5 structure, Croissant manifest) and step-by-step tutorials from a first plot to PyTorch training.
130
+
131
+ ## Citation
132
+
133
+ ```bibtex
134
+ @dataset{baum2026rddac,
135
+ title={Real Deep Drawing and Cutting Dataset},
136
+ author={Baum, Sebastian and Heinzelmann, Pascal},
137
+ year={2026},
138
+ publisher={DaRUS},
139
+ doi={10.18419/DARUS-5589}
140
+ }
141
+
142
+ @article{baum2026deviation,
143
+ title={Statistical Analysis of Simulation to Reality Deviation in Deep Drawing with a Benchmark Dataset},
144
+ author={Baum, Sebastian and Heinzelmann, Pascal and Clau{\ss}, P. and others},
145
+ journal={Transactions of the Indian Institute of Metals},
146
+ volume={79},
147
+ pages={176},
148
+ year={2026},
149
+ doi={10.1007/s12666-026-03870-5}
150
+ }
151
+ ```
152
+
153
+ ## License
154
+
155
+ The dataset on DaRUS is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The `rddac` software is licensed under the MIT License — see [LICENSE](LICENSE).
rddac-1.0.0/README.md ADDED
@@ -0,0 +1,110 @@
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/BaumSebastian/RDDAC/main/docs/images/icon/icon.png" width="150"/>
3
+ <h1>Real Deep Drawing and Cutting (RDDAC) Dataset</h1>
4
+ </div>
5
+
6
+ [![Code License: MIT](https://img.shields.io/badge/Code-MIT-yellow.svg)](LICENSE)
7
+ [![Dataset License: CC BY 4.0](https://img.shields.io/badge/Dataset-CC_BY_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
8
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
9
+ [![Documentation](https://readthedocs.org/projects/rddac/badge/?version=latest)](https://rddac.readthedocs.io)
10
+ [![DaRUS Repository](https://img.shields.io/badge/repository-DaRUS-green.svg)](https://darus.uni-stuttgart.de/dataset.xhtml?persistentId=doi:10.18419/DARUS-5589)
11
+ [![DOI](https://img.shields.io/badge/DOI-10.18419%2FDARUS--5589-blue.svg)](https://doi.org/10.18419/DARUS-5589)
12
+
13
+ <div align="center">
14
+
15
+ ![Measured point clouds after OP10 and OP20, colored by deviation from the matching DDACS simulation](https://raw.githubusercontent.com/BaumSebastian/RDDAC/main/docs/images/sim2real_sweep.gif)
16
+
17
+ *Measured point clouds of one experiment after deep drawing (OP10, left) and cutting (OP20, right), colored by the deviation from the matching DDACS simulation.*
18
+
19
+ </div>
20
+
21
+ **A large-scale experimental dataset of 9,000 physical deep-drawing and cutting experiments — the real-world counterpart to the [DDACS](https://ddacs.readthedocs.io) FEM simulations.** Each experiment forms a modified quadratic cup from DP600 dual-phase steel (deep drawing in OP10, cutting in OP20) and records press force signals, sheet-thickness and oil-film traverses, and high-resolution 3D laser scans of the part after each operation. Use it to quantify the simulation-to-reality gap, train models on real process data, or validate DDACS-trained surrogates against physical measurements.
22
+
23
+ | | |
24
+ |---|---|
25
+ | **Experiments** | 9,000 |
26
+ | **Total size** | ~87 GB (HDF5, lossless) |
27
+ | **Process steps per experiment** | 2 (OP10 deep drawing, OP20 cutting) |
28
+ | **Parameter space** | 2 geometries x 3 blankholder forces x 3 oil types (18 categories) |
29
+ | **Repetitions** | up to 500 per category |
30
+ | **Train / val / test** | 7,200 / 900 / 900 (predefined, seed 42) |
31
+ | **Matching simulations** | DDACS `rddac.zip` (~9 GB), fetched by `rddac download` |
32
+
33
+ **[Documentation](https://rddac.readthedocs.io)** · **[Dataset DOI](https://doi.org/10.18419/DARUS-5589)** · **[Paper](https://doi.org/10.1007/s12666-026-03870-5)**
34
+
35
+ The `rddac` package ships with the dataset and provides a Croissant native interface: one CLI for the download, one Python module for access, and an optional PyTorch `IterableDataset` for training.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install rddac
41
+ ```
42
+
43
+ The PyTorch adapter is an optional extra. For hardware specific PyTorch builds (CUDA, ROCm, MPS), install PyTorch first from [pytorch.org](https://pytorch.org/get-started/locally/), then install the extra:
44
+
45
+ ```bash
46
+ pip install 'rddac[torch]'
47
+ ```
48
+
49
+ ## Download the dataset
50
+
51
+ ```bash
52
+ # Small sample bundle (~174 MB): manifest, CSV, and one experiment per category.
53
+ rddac download --small -y
54
+
55
+ # Full release (~87 GB), including the matching DDACS simulations (~9 GB).
56
+ rddac download
57
+
58
+ # Real measurements only (skip the simulations).
59
+ rddac download --no-sim
60
+ ```
61
+
62
+ ## Basic usage
63
+
64
+ ```python
65
+ import rddac
66
+
67
+ with rddac.open_h5(0) as f: # one experiment by id
68
+ force = f["force/data"][:] # (n, 8): time, load cells, temp, position, total force
69
+ sheet = f["sheet_thickness/data"][:] # (n, 2): sensor position, thickness
70
+ z10 = f["pointcloud/op10/z"][:] # (6400000,) flat scan buffer
71
+ ```
72
+
73
+ The public surface mirrors the [`ddacs`](https://ddacs.readthedocs.io) package one to one — `load`, `add_view`, `open_h5`, `inspect_h5`, `streaming.iter_view` / `export_to_numpy` / `load_export`, and the PyTorch `IterableDataset` share names, signatures, and semantics. Code written against DDACS ports by swapping the import:
74
+
75
+ ```python
76
+ # import ddacs as dataset_pkg # simulations
77
+ import rddac as dataset_pkg # real experiments
78
+
79
+ ds = dataset_pkg.load(data_dir="./data")
80
+ for record in dataset_pkg.streaming.iter_view("force-curve", data_dir="./data", dataset=ds):
81
+ ...
82
+ ```
83
+
84
+ See the [documentation](https://rddac.readthedocs.io) for the dataset reference (parameter space, HDF5 structure, Croissant manifest) and step-by-step tutorials from a first plot to PyTorch training.
85
+
86
+ ## Citation
87
+
88
+ ```bibtex
89
+ @dataset{baum2026rddac,
90
+ title={Real Deep Drawing and Cutting Dataset},
91
+ author={Baum, Sebastian and Heinzelmann, Pascal},
92
+ year={2026},
93
+ publisher={DaRUS},
94
+ doi={10.18419/DARUS-5589}
95
+ }
96
+
97
+ @article{baum2026deviation,
98
+ title={Statistical Analysis of Simulation to Reality Deviation in Deep Drawing with a Benchmark Dataset},
99
+ author={Baum, Sebastian and Heinzelmann, Pascal and Clau{\ss}, P. and others},
100
+ journal={Transactions of the Indian Institute of Metals},
101
+ volume={79},
102
+ pages={176},
103
+ year={2026},
104
+ doi={10.1007/s12666-026-03870-5}
105
+ }
106
+ ```
107
+
108
+ ## License
109
+
110
+ The dataset on DaRUS is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The `rddac` software is licensed under the MIT License — see [LICENSE](LICENSE).
@@ -0,0 +1,98 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rddac"
7
+ version = "1.0.0"
8
+ description = "Python package for the Real Deep Drawing and Cutting (RDDAC) Dataset"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Sebastian Baum"},
14
+ {name = "Pascal Heinzelmann"},
15
+ ]
16
+ keywords = ["deep-drawing", "sheet-metal", "forming", "dataset", "experimental", "measurement"]
17
+ classifiers = [
18
+ "Development Status :: 2 - Pre-Alpha",
19
+ "Intended Audience :: Science/Research",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Scientific/Engineering",
26
+ ]
27
+ dependencies = [
28
+ "numpy>=1.24.0",
29
+ "pandas>=2.0.0",
30
+ "h5py>=3.8.0",
31
+ "matplotlib>=3.7.0",
32
+ # CLI dependencies
33
+ "requests>=2.28.0",
34
+ "humanfriendly>=10.0",
35
+ "rich>=13.0.0",
36
+ # Croissant manifest access
37
+ "mlcroissant>=1.1.0",
38
+ # Shared dataset machinery (DatasetSpec, streaming, h5 access, spec-aware
39
+ # CLI) + the matching FEM simulations. <4: major bumps may remove API.
40
+ "ddacs>=3.2.1,<4",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ torch = ["torch>=2.0"]
45
+ dev = [
46
+ "pytest>=7.0.0",
47
+ "black>=24.0.0",
48
+ "ruff>=0.3.0",
49
+ "bumpver>=2023.1129",
50
+ "pre-commit>=3.6.0",
51
+ ]
52
+ docs = [
53
+ "mkdocs>=1.5.0",
54
+ "mkdocs-material>=9.5.0",
55
+ "mkdocstrings[python]>=0.24.0",
56
+ "mkdocs-macros-plugin>=1.0.0",
57
+ ]
58
+
59
+ [project.urls]
60
+ Homepage = "https://github.com/BaumSebastian/RDDAC"
61
+ Documentation = "https://rddac.readthedocs.io"
62
+ Repository = "https://github.com/BaumSebastian/RDDAC"
63
+
64
+ [project.scripts]
65
+ rddac = "rddac.cli:main"
66
+
67
+ [tool.setuptools.packages.find]
68
+ where = ["."]
69
+ include = ["rddac*"]
70
+
71
+ [tool.black]
72
+ line-length = 120
73
+ target-version = ["py310", "py311", "py312"]
74
+
75
+ [tool.ruff]
76
+ line-length = 120
77
+ target-version = "py310"
78
+
79
+ [tool.ruff.lint]
80
+ select = ["E", "F", "I", "W"]
81
+ ignore = ["E501"]
82
+
83
+ [tool.pytest.ini_options]
84
+ testpaths = ["tests"]
85
+ python_files = ["test_*.py"]
86
+ python_functions = ["test_*"]
87
+
88
+ [tool.bumpver]
89
+ current_version = "1.0.0"
90
+ version_pattern = "MAJOR.MINOR.PATCH"
91
+ commit_message = "Bump version {old_version} -> {new_version}"
92
+ commit = true
93
+ tag = true
94
+ push = false
95
+
96
+ [tool.bumpver.file_patterns]
97
+ "pyproject.toml" = ['version = "{version}"']
98
+ "rddac/__init__.py" = ['__version__ = "{version}"']
@@ -0,0 +1,66 @@
1
+ """RDDAC — Real Deep Drawing and Cutting Dataset.
2
+
3
+ Python interface for the RDDAC dataset (experimental measurements of sheet
4
+ metal forming; the physical counterpart to the DDACS simulations). Built on a
5
+ Croissant 1.1 manifest: `rddac.load()` returns an `mlcroissant.Dataset` whose
6
+ `records(view)` streams the data; `add_view`, `open_h5`, `inspect_h5` are
7
+ convenience helpers around the same manifest.
8
+
9
+ The public surface mirrors the `ddacs` package, so DDACS code ports by
10
+ swapping the import.
11
+
12
+ Examples:
13
+ >>> import rddac
14
+ >>> ds = rddac.load(data_dir="./data")
15
+ >>> for record in rddac.streaming.iter_view("force-curve", data_dir="./data"):
16
+ ... ...
17
+
18
+ >>> with rddac.open_h5(42, data_dir="./data") as f:
19
+ ... rddac.inspect_h5(f)
20
+
21
+ Note: prefer ``rddac.streaming.iter_view`` (or ``RDDACDataset``) over
22
+ ``ds.records(view)`` for the h5-backed views — mlcroissant's own records()
23
+ walks the full multi-GB zips per view and is impractically slow there.
24
+ """
25
+
26
+ __version__ = "1.0.0"
27
+
28
+ from . import streaming
29
+ from .croissant import add_view, load
30
+ from .h5_tools import inspect_h5, open_h5
31
+ from .spec import RDDAC_SPEC, DatasetSpec
32
+ from .visualization import (
33
+ plot_force,
34
+ plot_point_cloud,
35
+ plot_scan,
36
+ plot_traverse,
37
+ scan_to_pointcloud,
38
+ )
39
+
40
+ try:
41
+ from .pytorch import RDDACDataset
42
+ except ImportError:
43
+ pass
44
+
45
+ __all__ = [
46
+ "__version__",
47
+ # Dataset identity (consumed by the ddacs machinery via spec=)
48
+ "RDDAC_SPEC",
49
+ "DatasetSpec",
50
+ # Croissant entry point + helpers
51
+ "load",
52
+ "add_view",
53
+ # HDF5 helpers
54
+ "open_h5",
55
+ "inspect_h5",
56
+ # Streaming pipeline (offline iteration + numpy export)
57
+ "streaming",
58
+ # PyTorch (optional — only available if torch is installed)
59
+ "RDDACDataset",
60
+ # Visualization
61
+ "plot_scan",
62
+ "plot_point_cloud",
63
+ "plot_force",
64
+ "plot_traverse",
65
+ "scan_to_pointcloud",
66
+ ]
@@ -0,0 +1,166 @@
1
+ """RDDAC dataset CLI — a thin front-end over the ``ddacs`` CLI machinery.
2
+
3
+ Provides commands to view dataset information and download files from the RDDAC
4
+ (Real Deep Drawing and Cutting) dataset hosted on DaRUS. Because RDDAC is the
5
+ experimental counterpart to DDACS, the full download also fetches the matching
6
+ DDACS simulations (skip with --no-sim).
7
+
8
+ The info/download implementation is `ddacs.cli`'s, called with
9
+ ``spec=RDDAC_SPEC`` (requires ddacs >= 3.2.1). Only the parser (prog,
10
+ --no-sim) and the simulation leg live here.
11
+
12
+ Usage:
13
+ rddac info # Show dataset info and versions
14
+ rddac download # Real measurements + DDACS simulations
15
+ rddac download --no-sim # Real measurements only (skip simulations)
16
+ rddac download --small # Small sample bundle (quick start)
17
+ rddac download --files a.zip # Download specific files
18
+ rddac download --extract # Also extract zips next to the zip
19
+ rddac download --extract --remove-zip
20
+ rddac download --quiet # No output/progress; implies --yes
21
+
22
+ Zip files are kept by default so they remain readable in place via mlcroissant
23
+ (the Croissant manifest references zip members directly).
24
+ """
25
+
26
+ from __future__ import annotations
27
+
28
+ import argparse
29
+ import importlib.util
30
+ import os
31
+ import subprocess
32
+ import sys
33
+
34
+ from ddacs import cli as _ddacs_cli
35
+ from ddacs.cli import _dataset_title # noqa: F401 — identical helper, re-exported for tests
36
+ from rich.panel import Panel
37
+
38
+ from . import __version__
39
+ from .spec import (
40
+ DDACS_DATASET_DOI,
41
+ DDACS_SIM_FILE,
42
+ RDDAC_SPEC,
43
+ SIM_SUBDIR,
44
+ )
45
+
46
+ DEFAULT_VERSION = RDDAC_SPEC.default_version
47
+ DEFAULT_DATA_DIR = RDDAC_SPEC.default_data_dir
48
+ SMALL_TEST_FILES = list(RDDAC_SPEC.small_test_files)
49
+
50
+ console = _ddacs_cli.console # shared console: ddacs's --quiet handling applies
51
+
52
+
53
+ # ── small helpers kept for tests / tooling (dataset-agnostic) ─────────────────
54
+ def _file_info(file_meta: dict) -> tuple[str, int]:
55
+ """Original filename + size from a DaRUS file metadata entry."""
56
+ df = file_meta["dataFile"]
57
+ if "originalFileName" in df:
58
+ return df["originalFileName"], df.get("originalFileSize", df["filesize"])
59
+ return df["filename"], df["filesize"]
60
+
61
+
62
+ def _matches(file_meta: dict, names: list[str]) -> bool:
63
+ return _file_info(file_meta)[0] in names or file_meta["dataFile"]["filename"] in names
64
+
65
+
66
+ # ── commands ──────────────────────────────────────────────────────────────────
67
+ def cmd_info(args: argparse.Namespace) -> None:
68
+ """Display dataset information and available versions (via ddacs.cli)."""
69
+ _ddacs_cli.cmd_info(args, spec=RDDAC_SPEC)
70
+
71
+
72
+ def cmd_download(args: argparse.Namespace) -> None:
73
+ """Download RDDAC measurements (and, by default, the DDACS simulations)."""
74
+ _ddacs_cli.cmd_download(args, spec=RDDAC_SPEC)
75
+
76
+ # The DDACS simulations come along only on a full download (not --small /
77
+ # --files), unless explicitly skipped.
78
+ if not args.small and not args.files and not args.no_sim:
79
+ _download_simulations(args)
80
+
81
+
82
+ def _download_simulations(args: argparse.Namespace) -> int:
83
+ """Fetch the matching DDACS simulations by delegating to the `ddacs` CLI.
84
+
85
+ The download machinery is not duplicated here: if the `ddacs` package is
86
+ installed, its own CLI downloads `rddac.zip` into ``<out>/simulation``;
87
+ otherwise the user gets the exact command to run after installing it.
88
+
89
+ Returns the number of files fetched (0 when skipped or delegated-and-failed).
90
+ """
91
+ sim_dir = os.path.join(args.out, SIM_SUBDIR)
92
+ console.print()
93
+ console.print(Panel(
94
+ f"[bold]Source:[/bold] DDACS {DDACS_DATASET_DOI}\n[bold]File:[/bold] {DDACS_SIM_FILE}\n"
95
+ f"[bold]Destination:[/bold] {os.path.abspath(sim_dir)}\n"
96
+ "[dim]The matching FEM simulations. Skip with --no-sim.[/dim]",
97
+ title="DDACS simulation reference data", border_style="cyan"))
98
+
99
+ if importlib.util.find_spec("ddacs") is None:
100
+ console.print(
101
+ "[yellow]The `ddacs` package is not installed — skipping the simulations.[/yellow]\n"
102
+ "To fetch them later:\n"
103
+ " [bold]pip install ddacs[/bold]\n"
104
+ f" [bold]ddacs download --files {DDACS_SIM_FILE} metadata.json process_parameters.csv --out {sim_dir} -y[/bold]"
105
+ )
106
+ return 0
107
+
108
+ # Also fetch DDACS's manifest + parameter table so <out>/simulation is a
109
+ # self-contained DDACS data dir: ddacs.load(data_dir="<out>/simulation")
110
+ # resolves the DDACS manifest locally and cannot pick up RDDAC's
111
+ # metadata.json from the parent directory.
112
+ cmd = [sys.executable, "-m", "ddacs.cli", "download",
113
+ "--files", DDACS_SIM_FILE, "metadata.json", "process_parameters.csv",
114
+ "--out", sim_dir]
115
+ if args.yes:
116
+ cmd.append("-y")
117
+ if getattr(args, "quiet", False):
118
+ cmd.append("--quiet")
119
+ if args.extract:
120
+ cmd.append("--extract")
121
+ if args.remove_zip:
122
+ cmd.append("--remove-zip")
123
+ console.print(f"[dim]delegating to: {' '.join(cmd[2:])}[/dim]")
124
+ result = subprocess.run(cmd)
125
+ if result.returncode != 0:
126
+ console.print("[red]ddacs download failed.[/red]")
127
+ return 0
128
+ return 1
129
+
130
+
131
+ def main() -> None:
132
+ """CLI entry point for RDDAC dataset commands."""
133
+ parser = argparse.ArgumentParser(
134
+ prog="rddac", description="RDDAC Dataset CLI - Download experimental data from DaRUS")
135
+ parser.add_argument("-V", "--version", action="version", version=f"%(prog)s {__version__}")
136
+ parser.add_argument("--token", help="DaRUS API token (for draft access)")
137
+ sub = parser.add_subparsers(dest="command", help="Command")
138
+
139
+ sub.add_parser("info", help="Show dataset info and versions")
140
+
141
+ dl = sub.add_parser("download", help="Download dataset files")
142
+ dl.add_argument("version", nargs="?", default=DEFAULT_VERSION,
143
+ help=f"Dataset version (default: {DEFAULT_VERSION})")
144
+ dl.add_argument("--files", nargs="+", help="Specific filenames to download")
145
+ dl.add_argument("--small", action="store_true", help="Download the small sample bundle")
146
+ dl.add_argument("--no-sim", action="store_true",
147
+ help="Download only the real measurements (skip the DDACS simulations)")
148
+ dl.add_argument("--out", default=DEFAULT_DATA_DIR,
149
+ help=f"Output directory (default: {DEFAULT_DATA_DIR})")
150
+ dl.add_argument("-y", "--yes", action="store_true", help="Skip confirmation prompt")
151
+ dl.add_argument("-q", "--quiet", action="store_true",
152
+ help="No output or progress bars; implies --yes")
153
+ dl.add_argument("--extract", action="store_true", help="Extract downloaded zips into their directory")
154
+ dl.add_argument("--remove-zip", action="store_true", help="Delete zips after extraction (with --extract)")
155
+
156
+ args = parser.parse_args()
157
+ if args.command == "info":
158
+ cmd_info(args)
159
+ elif args.command == "download":
160
+ cmd_download(args)
161
+ else:
162
+ parser.print_help()
163
+
164
+
165
+ if __name__ == "__main__":
166
+ main()