sd-dougu 0.0.1__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.
sd_dougu-0.0.1/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Mogsoft
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: sd-dougu
3
+ Version: 0.0.1
4
+ Summary: Toolkit for Single Dish RAPDS Development and Processing
5
+ Author-email: Joshua Hoskins <joshua.hoskins@nao.ac.jp>
6
+ Requires-Python: <3.15,>=3.13
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: xarray
10
+ Requires-Dist: toolviper
11
+ Requires-Dist: graphviper
12
+ Provides-Extra: zarr
13
+ Requires-Dist: astropy; extra == "zarr"
14
+ Requires-Dist: toolviper>=0.1.3; extra == "zarr"
15
+ Requires-Dist: s3fs; extra == "zarr"
16
+ Requires-Dist: scipy; extra == "zarr"
17
+ Requires-Dist: xarray; extra == "zarr"
18
+ Requires-Dist: zarr<4,>=3; extra == "zarr"
19
+ Requires-Dist: numcodecs>=0.16; extra == "zarr"
20
+ Requires-Dist: pyarrow; extra == "zarr"
21
+ Requires-Dist: psutil; extra == "zarr"
22
+ Provides-Extra: asdm
23
+ Requires-Dist: astropy; extra == "asdm"
24
+ Requires-Dist: pyasdm; extra == "asdm"
25
+ Requires-Dist: toolviper; extra == "asdm"
26
+ Requires-Dist: xarray; extra == "asdm"
27
+ Provides-Extra: interactive
28
+ Requires-Dist: astropy; extra == "interactive"
29
+ Requires-Dist: toolviper; extra == "interactive"
30
+ Requires-Dist: s3fs; extra == "interactive"
31
+ Requires-Dist: scipy; extra == "interactive"
32
+ Requires-Dist: xarray; extra == "interactive"
33
+ Requires-Dist: zarr<4,>=3; extra == "interactive"
34
+ Requires-Dist: numcodecs>=0.16; extra == "interactive"
35
+ Requires-Dist: pyarrow; extra == "interactive"
36
+ Requires-Dist: psutil; extra == "interactive"
37
+ Requires-Dist: matplotlib; extra == "interactive"
38
+ Requires-Dist: prettytable; extra == "interactive"
39
+ Requires-Dist: jupyterlab; extra == "interactive"
40
+ Requires-Dist: ipykernel; extra == "interactive"
41
+ Requires-Dist: ipympl; extra == "interactive"
42
+ Requires-Dist: ipython; extra == "interactive"
43
+ Requires-Dist: jupyter-client; extra == "interactive"
44
+ Dynamic: license-file
45
+
46
+ # dougu
47
+ Toolbox for Single Dish Radio Astronomy
@@ -0,0 +1,2 @@
1
+ # dougu
2
+ Toolbox for Single Dish Radio Astronomy
@@ -0,0 +1,87 @@
1
+ [project]
2
+ name = "sd-dougu"
3
+ version = "v0.0.1"
4
+
5
+ description = "Toolkit for Single Dish RAPDS Development and Processing"
6
+ authors = [
7
+ {name = "Joshua Hoskins", email="joshua.hoskins@nao.ac.jp"}
8
+ ]
9
+ license = {file = "LICENSE.txt"}
10
+ readme = "README.md"
11
+ requires-python = ">= 3.13, < 3.15"
12
+
13
+ dependencies = [
14
+ "xarray",
15
+ "toolviper",
16
+ "graphviper"
17
+ ]
18
+
19
+ [build-system]
20
+ requires = ["setuptools >= 77.0.3", "wheel"]
21
+ build-backend = "setuptools.build_meta"
22
+
23
+ [project.optional-dependencies]
24
+ zarr = [
25
+ "astropy",
26
+ "toolviper>=0.1.3",
27
+ "s3fs",
28
+ "scipy",
29
+ "xarray",
30
+ "zarr>=3,<4",
31
+ # numcodecs < 0.16 copies each Blosc-compressed chunk out of a full-size
32
+ # output buffer, so every zarr chunk write peaks at uncompressed plus
33
+ # compressed size. 0.16 resizes the buffer in place.
34
+ "numcodecs>=0.16",
35
+ "pyarrow",
36
+ "psutil" # psutil is needed so large FITS images are not loaded into memory
37
+ ]
38
+
39
+ asdm = [
40
+ "astropy",
41
+ "pyasdm",
42
+ "toolviper",
43
+ "xarray",
44
+ ]
45
+
46
+ interactive = [
47
+ "astropy",
48
+ "toolviper",
49
+ "s3fs",
50
+ "scipy",
51
+ "xarray",
52
+ "zarr>=3,<4",
53
+ "numcodecs>=0.16", # see the zarr extra
54
+ "pyarrow",
55
+ "psutil",
56
+ "matplotlib",
57
+ "prettytable",
58
+ "jupyterlab",
59
+ "ipykernel",
60
+ "ipympl",
61
+ "ipython",
62
+ "jupyter-client",
63
+ ]
64
+
65
+ [tool.ruff]
66
+ target-version = "py311"
67
+ # reviews/ holds archival schema-review notebooks (kept with their historical
68
+ # stored outputs); they are records, not maintained code -- don"t lint/format.
69
+ extend-exclude = ["reviews"]
70
+
71
+ [tool.ruff.lint]
72
+ # Ruff replaces isort + black (layout via `ruff format`, import sorting via the
73
+ # "I" rules) and also lints for real defects and best practices:
74
+ # E4/E7/E9 -- pycodestyle errors (import placement, statement syntax, runtime)
75
+ # F -- pyflakes: undefined names, unused imports, unused variables
76
+ # B -- flake8-bugbear: likely bugs (mutable defaults, loop captures, ...)
77
+ # UP -- pyupgrade: outdated syntax/typing (mirrors the pyupgrade hook)
78
+ select = ["E4", "E7", "E9", "F", "B", "UP", "I"]
79
+ # E741 (ambiguous variable name l/I/O): l and m are the standard radio-astronomy
80
+ # direction-cosine coordinate names in the image schema and must keep those names.
81
+ ignore = ["E741"]
82
+
83
+ [tool.ruff.lint.per-file-ignores]
84
+ # Tutorial/guide notebooks introduce imports cell-by-cell as the narrative
85
+ # needs them (E402), and use try-import cells to probe for/install packages
86
+ # (F401); that is deliberate style, not an error.
87
+ "*.ipynb" = ["E402", "F401"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,175 @@
1
+ import dataclasses
2
+
3
+ import dask
4
+ import operator
5
+
6
+ import toolviper
7
+
8
+ import xarray as xr
9
+ import graphviper.graph_tools as graph_tools
10
+ import toolviper.utils.logger as logger
11
+
12
+ from graphviper.graph_tools.generate_dask_workflow import generate_dask_workflow
13
+
14
+
15
+ class Graph:
16
+ def __init__(self):
17
+ self._nodes = {}
18
+
19
+ self._node_mapping = None
20
+ self._coordinates = None
21
+ self._graph = None
22
+ self._dataset = None
23
+
24
+ def __getitem__(self, item):
25
+
26
+ # convert to a list so we can parse the input
27
+ item = list(item)
28
+ trees = {
29
+ key: value
30
+ for key, value in zip(item, list(operator.itemgetter(*item)(self._dataset)))
31
+ }
32
+
33
+ return xr.DataTree.from_dict(data=trees)
34
+
35
+ def filter(self, leaves=None):
36
+ drop = set(self._dataset.keys()) ^ set(leaves)
37
+
38
+ logger.info(f"Dropping nodes: {drop}")
39
+ self._dataset = self._dataset.drop_nodes(names=drop)
40
+
41
+ @classmethod
42
+ def from_dataset(cls, dataset):
43
+ logger.info("Creating graph from dataset ...")
44
+ graph = cls()
45
+ graph._dataset = dataset
46
+ return graph
47
+
48
+ def build_node(self, ps_partition=None):
49
+ """Builds a node from the dataset and coordinates"""
50
+ if self._coordinates is None:
51
+ raise ValueError("Coordinates must be set before building node")
52
+
53
+ if self._dataset is None:
54
+ raise ValueError("Dataset must be set before building node")
55
+
56
+ self._node_mapping = (
57
+ graph_tools.coordinate_utils.interpolate_data_coords_onto_parallel_coords(
58
+ self._coordinates, self._dataset, ps_partition=ps_partition
59
+ )
60
+ )
61
+
62
+ def make_coordinates(self, coords):
63
+ self._coordinates = dict.fromkeys(coords)
64
+
65
+ for coord in coords:
66
+ if coord == "antenna_name":
67
+ logger.info("Making antenna coordinate ...")
68
+ xds = self._dataset.xr_ps.get_combined_antenna_xds()
69
+ self._coordinates[coord] = (
70
+ graph_tools.coordinate_utils.make_parallel_coord(
71
+ coord=xds.antenna_name, n_chunks=xds.antenna_name.shape[0]
72
+ )
73
+ )
74
+
75
+ elif coord == "field_name":
76
+ logger.info("Making field coordinate ...")
77
+ xds = self._dataset.xr_ps.get_combined_field_and_source_xds()
78
+ self._coordinates[coord] = (
79
+ graph_tools.coordinate_utils.make_parallel_coord(
80
+ coord=xds.field_name, n_chunks=xds.field_name.shape[0]
81
+ )
82
+ )
83
+
84
+ elif coord == "polarization":
85
+ logger.info("Making polarization coordinate ...")
86
+ xds = self._dataset.xr_ps.get_combined_field_and_source_xds()
87
+ self._coordinates[coord] = (
88
+ graph_tools.coordinate_utils.make_parallel_coord(
89
+ coord=xds.polarization,
90
+ n_chunks=xds.polarization.values.shape[0],
91
+ )
92
+ )
93
+
94
+ else:
95
+ logger.error(f"Coordinate {coord} not found in dataset.")
96
+
97
+ def map(self, function, parameters=None, connect=None, make_workflow=False):
98
+
99
+ name = function.__name__
100
+
101
+ self._graph = graph_tools.map(
102
+ input_data=self._dataset,
103
+ node_task_data_mapping=self._node_mapping,
104
+ node_task=function,
105
+ input_params=parameters,
106
+ previous=self._nodes[connect].result if connect is not None else None,
107
+ )
108
+
109
+ if parameters is None:
110
+ parameters = {}
111
+
112
+ if make_workflow:
113
+ self._graph = generate_dask_workflow(self._graph)
114
+
115
+ self._nodes[name] = GraphNode(
116
+ parameters=parameters,
117
+ function=function,
118
+ previous=None if connect is None else self._nodes[connect].result,
119
+ result=self._graph,
120
+ )
121
+
122
+ def reduce(self, function, parameters=None, connect=None, mode="tree"):
123
+ name = function.__name__
124
+
125
+ graph_tools.reduce(
126
+ graph=self._graph,
127
+ reduce_node_task=function,
128
+ input_params=parameters,
129
+ mode=mode,
130
+ )
131
+
132
+ self._graph = generate_dask_workflow(self._graph)
133
+
134
+ self._nodes[name] = GraphNode(
135
+ parameters=parameters,
136
+ function=function,
137
+ previous=None if connect is None else self._nodes[connect].result,
138
+ result=self._graph,
139
+ )
140
+
141
+ def reset(self):
142
+ self._nodes = {}
143
+ self._graph = None
144
+ # self._dataset = None
145
+ self._coordinates = None
146
+ self._node_mapping = None
147
+
148
+ def compute(self):
149
+ return dask.compute(self._graph)
150
+
151
+ @property
152
+ def datatree(self):
153
+ return self._dataset
154
+
155
+ @property
156
+ def coordinates(self):
157
+ return toolviper.utils.display.DataDict.html(self._coordinates)
158
+
159
+ @property
160
+ def node_mapping(self):
161
+ return toolviper.utils.display.DataDict.html(self._node_mapping)
162
+
163
+ @property
164
+ def graph(self):
165
+ return self._graph
166
+
167
+
168
+ @dataclasses.dataclass
169
+ class GraphNode:
170
+ """A class representing a node in a graph."""
171
+
172
+ parameters: dict
173
+ function: callable
174
+ result: dict | list | None
175
+ previous: dict | list | None
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: sd-dougu
3
+ Version: 0.0.1
4
+ Summary: Toolkit for Single Dish RAPDS Development and Processing
5
+ Author-email: Joshua Hoskins <joshua.hoskins@nao.ac.jp>
6
+ Requires-Python: <3.15,>=3.13
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: xarray
10
+ Requires-Dist: toolviper
11
+ Requires-Dist: graphviper
12
+ Provides-Extra: zarr
13
+ Requires-Dist: astropy; extra == "zarr"
14
+ Requires-Dist: toolviper>=0.1.3; extra == "zarr"
15
+ Requires-Dist: s3fs; extra == "zarr"
16
+ Requires-Dist: scipy; extra == "zarr"
17
+ Requires-Dist: xarray; extra == "zarr"
18
+ Requires-Dist: zarr<4,>=3; extra == "zarr"
19
+ Requires-Dist: numcodecs>=0.16; extra == "zarr"
20
+ Requires-Dist: pyarrow; extra == "zarr"
21
+ Requires-Dist: psutil; extra == "zarr"
22
+ Provides-Extra: asdm
23
+ Requires-Dist: astropy; extra == "asdm"
24
+ Requires-Dist: pyasdm; extra == "asdm"
25
+ Requires-Dist: toolviper; extra == "asdm"
26
+ Requires-Dist: xarray; extra == "asdm"
27
+ Provides-Extra: interactive
28
+ Requires-Dist: astropy; extra == "interactive"
29
+ Requires-Dist: toolviper; extra == "interactive"
30
+ Requires-Dist: s3fs; extra == "interactive"
31
+ Requires-Dist: scipy; extra == "interactive"
32
+ Requires-Dist: xarray; extra == "interactive"
33
+ Requires-Dist: zarr<4,>=3; extra == "interactive"
34
+ Requires-Dist: numcodecs>=0.16; extra == "interactive"
35
+ Requires-Dist: pyarrow; extra == "interactive"
36
+ Requires-Dist: psutil; extra == "interactive"
37
+ Requires-Dist: matplotlib; extra == "interactive"
38
+ Requires-Dist: prettytable; extra == "interactive"
39
+ Requires-Dist: jupyterlab; extra == "interactive"
40
+ Requires-Dist: ipykernel; extra == "interactive"
41
+ Requires-Dist: ipympl; extra == "interactive"
42
+ Requires-Dist: ipython; extra == "interactive"
43
+ Requires-Dist: jupyter-client; extra == "interactive"
44
+ Dynamic: license-file
45
+
46
+ # dougu
47
+ Toolbox for Single Dish Radio Astronomy
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/dougu/graph/graph.py
5
+ src/sd_dougu.egg-info/PKG-INFO
6
+ src/sd_dougu.egg-info/SOURCES.txt
7
+ src/sd_dougu.egg-info/dependency_links.txt
8
+ src/sd_dougu.egg-info/requires.txt
9
+ src/sd_dougu.egg-info/top_level.txt
@@ -0,0 +1,38 @@
1
+ xarray
2
+ toolviper
3
+ graphviper
4
+
5
+ [asdm]
6
+ astropy
7
+ pyasdm
8
+ toolviper
9
+ xarray
10
+
11
+ [interactive]
12
+ astropy
13
+ toolviper
14
+ s3fs
15
+ scipy
16
+ xarray
17
+ zarr<4,>=3
18
+ numcodecs>=0.16
19
+ pyarrow
20
+ psutil
21
+ matplotlib
22
+ prettytable
23
+ jupyterlab
24
+ ipykernel
25
+ ipympl
26
+ ipython
27
+ jupyter-client
28
+
29
+ [zarr]
30
+ astropy
31
+ toolviper>=0.1.3
32
+ s3fs
33
+ scipy
34
+ xarray
35
+ zarr<4,>=3
36
+ numcodecs>=0.16
37
+ pyarrow
38
+ psutil
@@ -0,0 +1 @@
1
+ dougu