linecat 0.9.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.
Files changed (63) hide show
  1. linecat-0.9.0/LICENSE +21 -0
  2. linecat-0.9.0/PKG-INFO +171 -0
  3. linecat-0.9.0/README.md +132 -0
  4. linecat-0.9.0/pyproject.toml +61 -0
  5. linecat-0.9.0/setup.cfg +4 -0
  6. linecat-0.9.0/src/linecat/__init__.py +8 -0
  7. linecat-0.9.0/src/linecat/__main__.py +5 -0
  8. linecat-0.9.0/src/linecat/app_info.py +20 -0
  9. linecat-0.9.0/src/linecat/builtin.py +103 -0
  10. linecat-0.9.0/src/linecat/catalog_window.py +605 -0
  11. linecat-0.9.0/src/linecat/cdms.py +392 -0
  12. linecat-0.9.0/src/linecat/convert_dialog.py +99 -0
  13. linecat-0.9.0/src/linecat/data/docs/CDMS.pdf +0 -0
  14. linecat-0.9.0/src/linecat/data/docs/general [CDMS classic documentation].pdf +0 -0
  15. linecat-0.9.0/src/linecat/data/icons/app_icon.png +0 -0
  16. linecat-0.9.0/src/linecat/data/icons/app_image.png +0 -0
  17. linecat-0.9.0/src/linecat/data/molecules/CH3OH/CH3OH, vt=0-2.pdf +0 -0
  18. linecat-0.9.0/src/linecat/data/molecules/CH3OH/CH3OH.svg +1 -0
  19. linecat-0.9.0/src/linecat/data/molecules/CH3OH/c032504-5Q.cat +38743 -0
  20. linecat-0.9.0/src/linecat/data/molecules/NH3/NH3, v=0.pdf +0 -0
  21. linecat-0.9.0/src/linecat/data/molecules/NH3/NH3.svg +1 -0
  22. linecat-0.9.0/src/linecat/data/molecules/NH3/c017506.cat +346 -0
  23. linecat-0.9.0/src/linecat/data/molecules/OH/OH, v=0.pdf +0 -0
  24. linecat-0.9.0/src/linecat/data/molecules/OH/OH, v=1.pdf +0 -0
  25. linecat-0.9.0/src/linecat/data/molecules/OH/OH, v=2.pdf +0 -0
  26. linecat-0.9.0/src/linecat/data/molecules/OH/OH.svg +1 -0
  27. linecat-0.9.0/src/linecat/data/molecules/OH/c017507.cat +1028 -0
  28. linecat-0.9.0/src/linecat/data/molecules/OH/c017508.cat +831 -0
  29. linecat-0.9.0/src/linecat/data/molecules/OH/c017509.cat +722 -0
  30. linecat-0.9.0/src/linecat/data/molecules/SiO/SiO, v=0-10.pdf +0 -0
  31. linecat-0.9.0/src/linecat/data/molecules/SiO/SiO.svg +1 -0
  32. linecat-0.9.0/src/linecat/data/molecules/SiO/c044505.cat +1190 -0
  33. linecat-0.9.0/src/linecat/data/user_guide.pdf +0 -0
  34. linecat-0.9.0/src/linecat/diagram/__init__.py +5 -0
  35. linecat-0.9.0/src/linecat/diagram/elements.py +255 -0
  36. linecat-0.9.0/src/linecat/diagram/latex_cache.py +92 -0
  37. linecat-0.9.0/src/linecat/diagram/tab.py +191 -0
  38. linecat-0.9.0/src/linecat/diagram/table.py +162 -0
  39. linecat-0.9.0/src/linecat/diagram/window.py +715 -0
  40. linecat-0.9.0/src/linecat/filters.py +337 -0
  41. linecat-0.9.0/src/linecat/headers.py +103 -0
  42. linecat-0.9.0/src/linecat/launcher.py +317 -0
  43. linecat-0.9.0/src/linecat/main.py +179 -0
  44. linecat-0.9.0/src/linecat/molecule_box.py +117 -0
  45. linecat-0.9.0/src/linecat/molecules.py +190 -0
  46. linecat-0.9.0/src/linecat/update.py +162 -0
  47. linecat-0.9.0/src/linecat/update_ui.py +301 -0
  48. linecat-0.9.0/src/linecat/widgets.py +192 -0
  49. linecat-0.9.0/src/linecat.egg-info/PKG-INFO +171 -0
  50. linecat-0.9.0/src/linecat.egg-info/SOURCES.txt +61 -0
  51. linecat-0.9.0/src/linecat.egg-info/dependency_links.txt +1 -0
  52. linecat-0.9.0/src/linecat.egg-info/entry_points.txt +2 -0
  53. linecat-0.9.0/src/linecat.egg-info/requires.txt +11 -0
  54. linecat-0.9.0/src/linecat.egg-info/top_level.txt +1 -0
  55. linecat-0.9.0/tests/test_builtin.py +102 -0
  56. linecat-0.9.0/tests/test_cdms.py +11 -0
  57. linecat-0.9.0/tests/test_cli.py +89 -0
  58. linecat-0.9.0/tests/test_convert.py +70 -0
  59. linecat-0.9.0/tests/test_gui.py +351 -0
  60. linecat-0.9.0/tests/test_headers.py +28 -0
  61. linecat-0.9.0/tests/test_launcher.py +168 -0
  62. linecat-0.9.0/tests/test_molecules.py +32 -0
  63. linecat-0.9.0/tests/test_update.py +204 -0
linecat-0.9.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025–2026 Vahid Anari
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.
linecat-0.9.0/PKG-INFO ADDED
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: linecat
3
+ Version: 0.9.0
4
+ Summary: Line Catalog Explorer: filter CDMS spectral line catalogs and draw energy-level diagrams
5
+ Author-email: Vahid Anari <vahid.anari8@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/vahid-anari/linecat
8
+ Project-URL: Source, https://github.com/vahid-anari/linecat
9
+ Project-URL: Issues, https://github.com/vahid-anari/linecat/issues
10
+ Project-URL: Changelog, https://github.com/vahid-anari/linecat/blob/main/CHANGELOG.md
11
+ Keywords: spectroscopy,CDMS,line catalog,molecular lines,energy-level diagram,astronomy,PySide6
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: MacOS X
14
+ Classifier: Environment :: Win32 (MS Windows)
15
+ Classifier: Environment :: X11 Applications :: Qt
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
24
+ Classifier: Topic :: Scientific/Engineering :: Physics
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: PySide6>=6.5
29
+ Requires-Dist: matplotlib>=3.7
30
+ Requires-Dist: numpy>=1.24
31
+ Requires-Dist: pandas>=2.0
32
+ Requires-Dist: sciwidgets[table]~=0.10.4
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7; extra == "dev"
35
+ Requires-Dist: ruff; extra == "dev"
36
+ Requires-Dist: build; extra == "dev"
37
+ Requires-Dist: twine; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # linecat
41
+
42
+ [![tests](https://github.com/vahid-anari/linecat/actions/workflows/tests.yml/badge.svg)](https://github.com/vahid-anari/linecat/actions/workflows/tests.yml)
43
+ [![PyPI](https://img.shields.io/pypi/v/linecat)](https://pypi.org/project/linecat/)
44
+ [![Python](https://img.shields.io/pypi/pyversions/linecat)](https://pypi.org/project/linecat/)
45
+ ![License](https://img.shields.io/badge/license-MIT-green)
46
+
47
+ **linecat** (Line Catalog Explorer) is a desktop viewer for spectral line catalogs
48
+ such as [CDMS](https://cdms.astro.uni-koeln.de/). It loads a catalog converted
49
+ to CSV, filters the transitions by frequency range and by the quantum numbers of
50
+ the upper and lower states, shows the result in a table, exports the selection,
51
+ and draws an interactive energy-level diagram of the selected transitions
52
+ (with secondary transitions, hover information and a LaTeX/TikZ export).
53
+
54
+ Supported species: OH, CH3OH, SiO, NH3. Adding a species means adding its
55
+ quantum-number rules to `linecat/molecules.py`.
56
+
57
+ <img src="https://raw.githubusercontent.com/vahid-anari/linecat/main/docs/figures/main_window.png" width="700" alt="linecat main window: quantum-number filters, frequency range and the table of OH lines">
58
+
59
+ <img src="https://raw.githubusercontent.com/vahid-anari/linecat/main/docs/figures/diagram.png" width="700" alt="Energy-level diagram of the selected OH transitions with the transition table">
60
+
61
+ ## Installation
62
+
63
+ Python 3.10 or newer. With [pipx](https://pipx.pypa.io/) (its own environment, recommended):
64
+
65
+ ```
66
+ pipx install linecat
67
+ ```
68
+
69
+ or with pip, in an environment of your choice:
70
+
71
+ ```
72
+ pip install linecat
73
+ ```
74
+
75
+ To start it with a double-click, run once:
76
+
77
+ ```
78
+ linecat install-app
79
+ ```
80
+
81
+ This adds Line Catalog Explorer to your Applications folder (macOS), the Start menu
82
+ (Windows) or the applications menu (Linux), with its own icon. It starts the linecat
83
+ of the Python you ran the command with, and keeps working after updates.
84
+
85
+ To update, use Help → Check for Updates… in the app (it also checks quietly at
86
+ start-up) or `linecat update` in a terminal.
87
+
88
+ For development, install from a clone: `git clone https://github.com/vahid-anari/linecat.git`,
89
+ then `pip install -e ".[dev]"` in the folder; such a copy is updated with `git pull`.
90
+
91
+ ## Use
92
+
93
+ ```
94
+ linecat open the viewer
95
+ linecat my_catalog.csv open a catalog at start
96
+ linecat convert convert the shipped CDMS files into the current folder
97
+ linecat convert OH --catalogs my_cats --output-dir out convert your own .cat files
98
+ linecat update update from PyPI (asks first; --check only looks)
99
+ linecat install-app add the app to Applications / Start menu (--remove to undo)
100
+ linecat --version
101
+ ```
102
+
103
+ File → Open Built-in Catalog → OH / CH3OH / SiO / NH3 (⌘1–⌘4) opens a
104
+ catalog that ships with linecat; File → Open Catalog… loads any other CSV; the quantum-number filters and the
105
+ frequency range narrow the table; File → Export Table as CSV… writes what is
106
+ shown; Transitions → Show Energy-Level Diagram draws the selected lines
107
+ (hover for ν and τ, double-click a transition for the lines from its lower
108
+ level). Right-click a column header for colours, alignment, font and columns.
109
+
110
+ ## Catalogs
111
+
112
+ linecat ships, for OH, CH3OH, SiO and NH3, the CDMS `.cat` files, the CDMS
113
+ documentation of each entry (PDF) and a picture of the molecule, one folder per
114
+ species (`src/linecat/data/molecules/<SPECIES>/`); the main window shows them in
115
+ its Molecule box, and Help → CDMS Documentation opens the general CDMS
116
+ documents. On first start, and after every linecat update, it
117
+ converts them to read-only CSV files in the application-data folder
118
+ (macOS: `~/Library/Application Support/linecat/catalogs/`; File → Show
119
+ Built-in Catalogs Folder). If a file goes missing it is rebuilt. Your own
120
+ `.cat` files (a newer CDMS release, say) can be converted with File → Convert
121
+ CDMS Catalogs… or `linecat convert --catalogs DIR`.
122
+
123
+ The catalog data come from the Cologne Database for Molecular Spectroscopy
124
+ ([CDMS](https://cdms.astro.uni-koeln.de/)); please cite Müller et al. 2001,
125
+ A&A 370, L49; Müller et al. 2005, J. Mol. Struct. 742, 215; and Endres et al.
126
+ 2016, J. Mol. Spectrosc. 327, 95. The catalog format and the SPCAT program are
127
+ described by Pickett et al. 1998, J. Quant. Spectrosc. Radiat. Transfer 60, 883.
128
+ The CDMS documentation pages included with linecat are reproduced with credit
129
+ to CDMS.
130
+
131
+ ## Documentation
132
+
133
+ Help → User Guide opens the User Guide (PDF): the windows, the energy-level
134
+ diagram, converting catalogs, the command line, adding a species, and the
135
+ equations behind the derived columns. What changed in each version is in
136
+ [`CHANGELOG.md`](CHANGELOG.md).
137
+
138
+ ## Development
139
+
140
+ ```
141
+ pip install -e ".[dev]"
142
+ pytest
143
+ ```
144
+
145
+ The window tests run offscreen with the small catalog in `tests/data/`.
146
+ The User Guide sources are in `docs/` (`user_guide.tex`, with the equations in
147
+ `equations.tex`); after a change, `sh tools/build_docs.sh` rebuilds it into
148
+ `src/linecat/data/user_guide.pdf` (needs a TeX installation, e.g. MacTeX).
149
+ The screenshots in `docs/figures/` are taken by hand on a Mac (⌘⇧4, Space,
150
+ ⌥-click for a window without shadow). Pushing a tag `vX.Y.Z` publishes a
151
+ GitHub Release with that version's section of `CHANGELOG.md`.
152
+
153
+ ## Citing
154
+
155
+ If you use linecat in published work, please cite it; GitHub's **Cite this
156
+ repository** button gives the reference (from `CITATION.cff`). Please also
157
+ cite CDMS for the catalog data (see [Catalogs](#catalogs)).
158
+
159
+ ## License
160
+
161
+ MIT License. See [LICENSE](LICENSE).
162
+
163
+ ## Author
164
+
165
+ Vahid Anari ·
166
+ [GitHub](https://github.com/vahid-anari) ·
167
+ [LinkedIn](https://www.linkedin.com/in/vahid-anari/)
168
+
169
+ Related projects: [mbsolver](https://github.com/vahid-anari/mbsolver) ·
170
+ [sciwidgets](https://github.com/vahid-anari/sciwidgets) ·
171
+ [Maxwell Bloch Studio](https://github.com/vahid-anari/maxwell-bloch-studio)
@@ -0,0 +1,132 @@
1
+ # linecat
2
+
3
+ [![tests](https://github.com/vahid-anari/linecat/actions/workflows/tests.yml/badge.svg)](https://github.com/vahid-anari/linecat/actions/workflows/tests.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/linecat)](https://pypi.org/project/linecat/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/linecat)](https://pypi.org/project/linecat/)
6
+ ![License](https://img.shields.io/badge/license-MIT-green)
7
+
8
+ **linecat** (Line Catalog Explorer) is a desktop viewer for spectral line catalogs
9
+ such as [CDMS](https://cdms.astro.uni-koeln.de/). It loads a catalog converted
10
+ to CSV, filters the transitions by frequency range and by the quantum numbers of
11
+ the upper and lower states, shows the result in a table, exports the selection,
12
+ and draws an interactive energy-level diagram of the selected transitions
13
+ (with secondary transitions, hover information and a LaTeX/TikZ export).
14
+
15
+ Supported species: OH, CH3OH, SiO, NH3. Adding a species means adding its
16
+ quantum-number rules to `linecat/molecules.py`.
17
+
18
+ <img src="https://raw.githubusercontent.com/vahid-anari/linecat/main/docs/figures/main_window.png" width="700" alt="linecat main window: quantum-number filters, frequency range and the table of OH lines">
19
+
20
+ <img src="https://raw.githubusercontent.com/vahid-anari/linecat/main/docs/figures/diagram.png" width="700" alt="Energy-level diagram of the selected OH transitions with the transition table">
21
+
22
+ ## Installation
23
+
24
+ Python 3.10 or newer. With [pipx](https://pipx.pypa.io/) (its own environment, recommended):
25
+
26
+ ```
27
+ pipx install linecat
28
+ ```
29
+
30
+ or with pip, in an environment of your choice:
31
+
32
+ ```
33
+ pip install linecat
34
+ ```
35
+
36
+ To start it with a double-click, run once:
37
+
38
+ ```
39
+ linecat install-app
40
+ ```
41
+
42
+ This adds Line Catalog Explorer to your Applications folder (macOS), the Start menu
43
+ (Windows) or the applications menu (Linux), with its own icon. It starts the linecat
44
+ of the Python you ran the command with, and keeps working after updates.
45
+
46
+ To update, use Help → Check for Updates… in the app (it also checks quietly at
47
+ start-up) or `linecat update` in a terminal.
48
+
49
+ For development, install from a clone: `git clone https://github.com/vahid-anari/linecat.git`,
50
+ then `pip install -e ".[dev]"` in the folder; such a copy is updated with `git pull`.
51
+
52
+ ## Use
53
+
54
+ ```
55
+ linecat open the viewer
56
+ linecat my_catalog.csv open a catalog at start
57
+ linecat convert convert the shipped CDMS files into the current folder
58
+ linecat convert OH --catalogs my_cats --output-dir out convert your own .cat files
59
+ linecat update update from PyPI (asks first; --check only looks)
60
+ linecat install-app add the app to Applications / Start menu (--remove to undo)
61
+ linecat --version
62
+ ```
63
+
64
+ File → Open Built-in Catalog → OH / CH3OH / SiO / NH3 (⌘1–⌘4) opens a
65
+ catalog that ships with linecat; File → Open Catalog… loads any other CSV; the quantum-number filters and the
66
+ frequency range narrow the table; File → Export Table as CSV… writes what is
67
+ shown; Transitions → Show Energy-Level Diagram draws the selected lines
68
+ (hover for ν and τ, double-click a transition for the lines from its lower
69
+ level). Right-click a column header for colours, alignment, font and columns.
70
+
71
+ ## Catalogs
72
+
73
+ linecat ships, for OH, CH3OH, SiO and NH3, the CDMS `.cat` files, the CDMS
74
+ documentation of each entry (PDF) and a picture of the molecule, one folder per
75
+ species (`src/linecat/data/molecules/<SPECIES>/`); the main window shows them in
76
+ its Molecule box, and Help → CDMS Documentation opens the general CDMS
77
+ documents. On first start, and after every linecat update, it
78
+ converts them to read-only CSV files in the application-data folder
79
+ (macOS: `~/Library/Application Support/linecat/catalogs/`; File → Show
80
+ Built-in Catalogs Folder). If a file goes missing it is rebuilt. Your own
81
+ `.cat` files (a newer CDMS release, say) can be converted with File → Convert
82
+ CDMS Catalogs… or `linecat convert --catalogs DIR`.
83
+
84
+ The catalog data come from the Cologne Database for Molecular Spectroscopy
85
+ ([CDMS](https://cdms.astro.uni-koeln.de/)); please cite Müller et al. 2001,
86
+ A&A 370, L49; Müller et al. 2005, J. Mol. Struct. 742, 215; and Endres et al.
87
+ 2016, J. Mol. Spectrosc. 327, 95. The catalog format and the SPCAT program are
88
+ described by Pickett et al. 1998, J. Quant. Spectrosc. Radiat. Transfer 60, 883.
89
+ The CDMS documentation pages included with linecat are reproduced with credit
90
+ to CDMS.
91
+
92
+ ## Documentation
93
+
94
+ Help → User Guide opens the User Guide (PDF): the windows, the energy-level
95
+ diagram, converting catalogs, the command line, adding a species, and the
96
+ equations behind the derived columns. What changed in each version is in
97
+ [`CHANGELOG.md`](CHANGELOG.md).
98
+
99
+ ## Development
100
+
101
+ ```
102
+ pip install -e ".[dev]"
103
+ pytest
104
+ ```
105
+
106
+ The window tests run offscreen with the small catalog in `tests/data/`.
107
+ The User Guide sources are in `docs/` (`user_guide.tex`, with the equations in
108
+ `equations.tex`); after a change, `sh tools/build_docs.sh` rebuilds it into
109
+ `src/linecat/data/user_guide.pdf` (needs a TeX installation, e.g. MacTeX).
110
+ The screenshots in `docs/figures/` are taken by hand on a Mac (⌘⇧4, Space,
111
+ ⌥-click for a window without shadow). Pushing a tag `vX.Y.Z` publishes a
112
+ GitHub Release with that version's section of `CHANGELOG.md`.
113
+
114
+ ## Citing
115
+
116
+ If you use linecat in published work, please cite it; GitHub's **Cite this
117
+ repository** button gives the reference (from `CITATION.cff`). Please also
118
+ cite CDMS for the catalog data (see [Catalogs](#catalogs)).
119
+
120
+ ## License
121
+
122
+ MIT License. See [LICENSE](LICENSE).
123
+
124
+ ## Author
125
+
126
+ Vahid Anari ·
127
+ [GitHub](https://github.com/vahid-anari) ·
128
+ [LinkedIn](https://www.linkedin.com/in/vahid-anari/)
129
+
130
+ Related projects: [mbsolver](https://github.com/vahid-anari/mbsolver) ·
131
+ [sciwidgets](https://github.com/vahid-anari/sciwidgets) ·
132
+ [Maxwell Bloch Studio](https://github.com/vahid-anari/maxwell-bloch-studio)
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "linecat"
7
+ version = "0.9.0"
8
+ description = "Line Catalog Explorer: filter CDMS spectral line catalogs and draw energy-level diagrams"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Vahid Anari", email = "vahid.anari8@gmail.com" }]
13
+ requires-python = ">=3.10"
14
+ keywords = ["spectroscopy", "CDMS", "line catalog", "molecular lines", "energy-level diagram", "astronomy", "PySide6"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: MacOS X",
18
+ "Environment :: Win32 (MS Windows)",
19
+ "Environment :: X11 Applications :: Qt",
20
+ "Intended Audience :: Science/Research",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Topic :: Scientific/Engineering :: Astronomy",
28
+ "Topic :: Scientific/Engineering :: Physics",
29
+ ]
30
+ dependencies = [
31
+ "PySide6>=6.5",
32
+ "matplotlib>=3.7",
33
+ "numpy>=1.24",
34
+ "pandas>=2.0",
35
+ "sciwidgets[table]~=0.10.4",
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ dev = ["pytest>=7", "ruff", "build", "twine"]
40
+
41
+ [project.scripts]
42
+ linecat = "linecat.main:main"
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/vahid-anari/linecat"
46
+ Source = "https://github.com/vahid-anari/linecat"
47
+ Issues = "https://github.com/vahid-anari/linecat/issues"
48
+ Changelog = "https://github.com/vahid-anari/linecat/blob/main/CHANGELOG.md"
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"]
52
+
53
+ [tool.setuptools.package-data]
54
+ linecat = ["data/*.pdf", "data/molecules/*/*.cat", "data/molecules/*/*.pdf", "data/molecules/*/*.svg", "data/docs/*.pdf", "data/icons/*.png"]
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
58
+
59
+ [tool.ruff]
60
+ line-length = 120
61
+ target-version = "py310"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """linecat: viewer for spectral line catalogs."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("linecat")
7
+ except PackageNotFoundError:
8
+ __version__ = "0.0.0"
@@ -0,0 +1,5 @@
1
+ """``python -m linecat``: the same as the ``linecat`` command (used by the app launcher)."""
2
+
3
+ from linecat.main import main
4
+
5
+ raise SystemExit(main())
@@ -0,0 +1,20 @@
1
+ """Names and addresses of the app, used by the window, the launcher and the update check."""
2
+
3
+ from linecat import __version__
4
+
5
+ APP_NAME = "Line Catalog Explorer"
6
+ """Name shown to the user (window, splash, launcher)."""
7
+
8
+ APP_VERSION = __version__
9
+ """Installed version (``0.0.0`` when linecat is not installed as a package)."""
10
+
11
+ DIST_NAME = "linecat"
12
+ """Name of the package on PyPI."""
13
+
14
+ GITHUB_REPO = "vahid-anari/linecat"
15
+ """GitHub repository (``owner/name``); its Releases hold the release notes."""
16
+
17
+ PYPI_URL = f"https://pypi.org/project/{DIST_NAME}/"
18
+ PYPI_JSON_URL = f"https://pypi.org/pypi/{DIST_NAME}/json"
19
+ RELEASES_URL = f"https://github.com/{GITHUB_REPO}/releases"
20
+ RELEASES_API_URL = f"https://api.github.com/repos/{GITHUB_REPO}/releases?per_page=30"
@@ -0,0 +1,103 @@
1
+ """Built-in catalogs: the CDMS sources shipped with linecat, converted once into a per-user folder.
2
+
3
+ The `.cat` files live in the package (`linecat/data/molecules/<SPECIES>/`, next to the species'
4
+ CDMS documentation PDFs and its picture). Their CSVs are written
5
+ read-only to the user's application-data folder (on macOS
6
+ `~/Library/Application Support/linecat/catalogs/`), next to a stamp file holding the linecat
7
+ version that built them. `ensure_builtin_catalogs` rebuilds them when a CSV is missing or the
8
+ stamp differs, so a new converter version regenerates them by itself.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import os
14
+ import stat
15
+ from pathlib import Path
16
+ from typing import Callable
17
+
18
+ from linecat import __version__
19
+ from linecat.cdms import ConversionResult, convert_molecule_catalog
20
+ from linecat.molecules import REGISTRY
21
+
22
+ DATA_DIR = Path(__file__).resolve().parent / "data"
23
+ SOURCES_DIR = DATA_DIR / "molecules" # one folder per species: .cat files, documentation PDFs, <SPECIES>.svg
24
+ DOCS_DIR = DATA_DIR / "docs" # general CDMS documentation
25
+ ICONS_DIR = DATA_DIR / "icons"
26
+ APP_ICON = ICONS_DIR / "app_icon.png" # made by tools/make_icon.py
27
+ APP_IMAGE = ICONS_DIR / "app_image.png" # splash picture, made by tools/make_splash.py
28
+ STAMP_NAME = ".linecat-version"
29
+
30
+
31
+ def molecule_image(species: str) -> Path | None:
32
+ """The species' picture (`<SPECIES>.svg` in its folder), if there is one."""
33
+ path = SOURCES_DIR / species / f"{species}.svg"
34
+ return path if path.is_file() else None
35
+
36
+
37
+ def molecule_docs(species: str) -> list[Path]:
38
+ """The CDMS documentation PDFs of the species' entries, sorted by name."""
39
+ folder = SOURCES_DIR / species
40
+ return sorted(folder.glob("*.pdf")) if folder.is_dir() else []
41
+
42
+
43
+ def general_docs() -> list[Path]:
44
+ """The general CDMS documentation PDFs, sorted by name."""
45
+ return sorted(DOCS_DIR.glob("*.pdf")) if DOCS_DIR.is_dir() else []
46
+
47
+
48
+ def user_guide() -> Path:
49
+ """The User Guide PDF (built by tools/build_docs.sh)."""
50
+ return DATA_DIR / "user_guide.pdf"
51
+
52
+
53
+ def builtin_dir() -> Path:
54
+ """Folder that holds the built-in CSV catalogs (created on demand)."""
55
+ from PySide6.QtCore import QStandardPaths
56
+
57
+ base = QStandardPaths.writableLocation(QStandardPaths.GenericDataLocation)
58
+ return Path(base) / "linecat" / "catalogs"
59
+
60
+
61
+ def builtin_csv(species: str, folder: Path | None = None) -> Path:
62
+ """Path of the built-in CSV of ``species``."""
63
+ return (folder or builtin_dir()) / f"CDMS_{REGISTRY[species].species}.csv"
64
+
65
+
66
+ def builtin_is_current(folder: Path | None = None) -> bool:
67
+ """True when every species' CSV exists and was built by this linecat version."""
68
+ folder = folder or builtin_dir()
69
+ stamp = folder / STAMP_NAME
70
+ if not stamp.is_file() or stamp.read_text().strip() != __version__:
71
+ return False
72
+ return all(builtin_csv(code, folder).is_file() for code in REGISTRY)
73
+
74
+
75
+ def _remove(path: Path) -> None:
76
+ if path.exists():
77
+ os.chmod(path, stat.S_IWUSR | stat.S_IRUSR)
78
+ path.unlink()
79
+
80
+
81
+ def ensure_builtin_catalogs(
82
+ folder: Path | None = None,
83
+ progress: Callable[[str, int, int], None] | None = None,
84
+ ) -> list[ConversionResult]:
85
+ """Build the built-in CSVs if any is missing or out of date; return what was built (empty if nothing).
86
+
87
+ `progress` is called with (species, rows done, rows total), as for `cdms.convert_all`.
88
+ """
89
+ folder = folder or builtin_dir()
90
+ if builtin_is_current(folder):
91
+ return []
92
+ folder.mkdir(parents=True, exist_ok=True)
93
+ _remove(folder / STAMP_NAME)
94
+ results = []
95
+ for code in REGISTRY:
96
+ target = builtin_csv(code, folder)
97
+ _remove(target)
98
+ callback = (lambda done, total, code=code: progress(code, done, total)) if progress is not None else None
99
+ result = convert_molecule_catalog(code, outdir=folder, catalogs_dir=SOURCES_DIR, progress=callback)
100
+ os.chmod(result.path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) # read-only
101
+ results.append(result)
102
+ (folder / STAMP_NAME).write_text(__version__ + "\n")
103
+ return results