exomol-opacity 0.1.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.
@@ -0,0 +1,4 @@
1
+ include README.md requirements.txt calculate_opacity.py plot_opacity.py run_opacity.py
2
+ recursive-include exomol_opacity *.py *.cpp *.hpp
3
+ recursive-include tests *.py
4
+ global-exclude *.pyc .DS_Store
@@ -0,0 +1,238 @@
1
+ Metadata-Version: 2.4
2
+ Name: exomol-opacity
3
+ Version: 0.1.0
4
+ Summary: Independent LTE molecular opacity calculations and plots from ExoMol line lists
5
+ Author: Nikolas Valsamidis
6
+ Keywords: opacity,spectroscopy,exomol,astrophysics,molecular-spectra
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Programming Language :: C++
12
+ Classifier: Operating System :: MacOS
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: numpy>=1.24
19
+ Requires-Dist: matplotlib>=3.7
20
+ Requires-Dist: requests>=2.28
21
+
22
+ # exomol-opacity
23
+
24
+ Calculate wavelength-dependent molecular absorption cross sections and pure-species
25
+ mass opacities from downloaded ExoMol line lists. Includes a Python API, command-line
26
+ calculator, and plotting tool. This is an independent project, not an official
27
+ ExoMol software release.
28
+
29
+ ## Installation
30
+
31
+ Requires Python 3.11 or newer. Calculations support macOS and Linux, including Linux
32
+ under WSL on Windows. A C++17 compiler and bzip2 development headers/library are
33
+ needed to compile the bundled engine on the first calculation.
34
+
35
+ macOS (if Command Line Tools are not already installed):
36
+
37
+ ```bash
38
+ xcode-select --install
39
+ ```
40
+
41
+ Debian/Ubuntu:
42
+
43
+ ```bash
44
+ sudo apt-get install g++ libbz2-dev
45
+ ```
46
+
47
+ Install the Python package and its Python dependencies:
48
+
49
+ ```bash
50
+ python -m pip install exomol-opacity
51
+ ```
52
+
53
+ Native Windows calculation is not supported; use WSL. Plotting saved NPZ spectra
54
+ needs only the Python dependencies, without a compiler or network connection.
55
+
56
+ ## Quick start
57
+
58
+ Calculate H3+ spectra and open separate plot windows:
59
+
60
+ ```bash
61
+ exomol-opacity 'H3+' --temperatures 300 1000 --plot
62
+ ```
63
+
64
+ Above the H3+ MiZATeP stated 5000 K maximum, calculation continues with a warning:
65
+
66
+ ```bash
67
+ exomol-opacity 'H3+' --temperatures 6000 --plot
68
+ ```
69
+
70
+ Specify where files are stored, or export plots without interactive windows:
71
+
72
+ ```bash
73
+ exomol-opacity CO --temperatures 300 --output-dir ./co_results --plot --no-show
74
+ ```
75
+
76
+ By default, downloads, compiled engines and results are stored under
77
+ `./opacity_output` in the current working directory. They are never written into
78
+ the installed Python package. The first run downloads original ExoMol data;
79
+ line lists can require gigabytes of disk space. Subsequent matching calculations
80
+ reuse checked local files. Internet access is needed for uncached source data.
81
+ The ExoMol line lists themselves are not included in this distribution.
82
+
83
+ ## Python API
84
+
85
+ ```python
86
+ from exomol_opacity import calculate_opacity, plot_opacity
87
+
88
+ paths = calculate_opacity(
89
+ molecule="H3+",
90
+ temperatures=[300, 1000, 6000],
91
+ wavelength_range=(0.4, 100), # micrometres; or "all"
92
+ resolution=10000,
93
+ output_root="./my_opacity_results",
94
+ )
95
+ plot_opacity(paths, show=True, save=True)
96
+ ```
97
+
98
+ `calculate_opacity` returns paths to saved NPZ spectra. Each spectrum also has a
99
+ CSV table and JSON metadata file. Temperatures are in kelvin; wavelength-bin
100
+ resolving power is approximately lambda/delta-lambda.
101
+
102
+ ## Running the source folder
103
+
104
+ To work from the source distribution instead of installing from PyPI:
105
+
106
+ ```bash
107
+ python -m pip install -r requirements.txt
108
+ python run_opacity.py
109
+ ```
110
+
111
+ Edit the molecule and temperatures at the top of `run_opacity.py`. The source
112
+ wrappers preserve storage inside the source folder. The engine sources live in
113
+ `exomol_opacity/src/` and are included in both the wheel and source distribution.
114
+
115
+ ## Choosing a Molecule
116
+
117
+ The editable `run_opacity.py` source example uses `WAVELENGTH_RANGE = "all"`. This downloads every primary
118
+ transition file for the selected dataset, scans the actual upper-minus-lower-state
119
+ line positions, and covers all positive-frequency absorption lines with a margin
120
+ for Doppler wings. It applies no line-strength threshold. The limits are cached
121
+ per transition file, keyed to source checksums and scanner code. Zero-probability
122
+ or zero-statistical-weight entries cannot produce absorption and do not set limits.
123
+ Lines with negligible thermal populations can still be invisible in a given plot.
124
+ The numerical range, line counts, and selection mode are recorded in the results.
125
+
126
+ The initial scan adds work and may require very large downloads. It does not mix
127
+ isotopologues or add supplementary datasets. For a restricted range, use a pair
128
+ such as `WAVELENGTH_RANGE = (0.46, 100)` instead. Command-line equivalent:
129
+
130
+ ```bash
131
+ exomol-opacity CO --wavelength-range all --resolution 100000 --plot
132
+ ```
133
+
134
+ Presets select the original datasets for H3+ (MiZATeP), H3O+ (eXeL), CO
135
+ (Li2015), CO2 (UCL-4000), and SiO (SiOUVenIR). These are deliberate presets,
136
+ not a claim that each is the newest available dataset. Select other ExoMol
137
+ isotopologues/datasets explicitly when needed:
138
+
139
+ ```bash
140
+ exomol-opacity H2O --list
141
+ exomol-opacity CO --temperatures 100 300 1000 --wavelength-range 1 30 --resolution 100000 --plot
142
+ ```
143
+
144
+ For a molecule without a preset, use the isotopologue and dataset names from
145
+ `--list` with `--isotopologue NAME --dataset NAME`. If there is exactly one
146
+ available choice, it is selected automatically. Ambiguous choices are never
147
+ silently resolved to an arbitrary isotope. The master catalogue is cached too.
148
+
149
+ The reader supports ExoMol datasets with a JSON definition, partition table,
150
+ and standard bzip2-compressed states/transitions files. It discovers the
151
+ transition blocks from the official dataset page and checks their count.
152
+ Supplementary lists such as CO quadrupole transitions are not mixed into the
153
+ primary dataset. Other file layouts fail explicitly rather than producing a partial calculation.
154
+ This is not a universal reader for HITRAN, arbitrary CSVs, or every molecule.
155
+
156
+ ## Cache and Results
157
+
158
+ Paths below are relative to your output directory (`./opacity_output` by default).
159
+
160
+ - `cache/MOLECULE/ISOTOPOLOGUE/DATASET/cache.json`: local download inventory.
161
+ - That same folder contains the source files and individual SHA-256 receipts.
162
+ - Completed source files are checked and reused without contacting the server.
163
+ - Interrupted downloads use `.part` files and resume when the server supports it.
164
+ - `results/MOLECULE/ISOTOPOLOGUE/DATASET/SETTINGS_ID/`: CSV, NPZ, and JSON spectra.
165
+ - `figures/` within that results folder contains the PNG and PDF plots.
166
+ - Different temperatures, ranges, resolutions, source data, or calculation code
167
+ get separate result folders. Identical completed calculations are reused.
168
+
169
+ The cache is pinned for reproducibility: it does not silently update a dataset.
170
+ Remove the relevant cached files and their receipts to intentionally download
171
+ fresh versions. Do not edit source files in the cache. A lock prevents two runs
172
+ from writing the same molecule cache at once.
173
+
174
+ ## Plot Existing Results
175
+
176
+ No compiler, source line lists, or internet connection is needed to plot saved
177
+ NPZ spectra. Install `exomol-opacity` and share the desired results folder.
178
+
179
+ ```bash
180
+ exomol-opacity-plot "opacity_output/results/CO/12C-16O/Li2015/SETTINGS_ID"
181
+ ```
182
+
183
+ Replace SETTINGS_ID with the folder printed by the calculation. Add `--no-show`
184
+ to save figures without opening windows, or `--no-save` to only display them.
185
+ Use `--quantity mass-opacity` for pure-isotopologue mass opacity.
186
+ Plots show the upper 14 orders of magnitude, as in the H3+ figures; saved spectra
187
+ retain the full calculated values.
188
+
189
+ ## Physical Scope
190
+
191
+ The calculation retains the original H3+ engine: LTE populations, Einstein-A
192
+ line strengths, thermal Doppler profiles, and analytic integrals over logarithmic
193
+ wavenumber bins. It does not add pressure broadening, continuum opacity, natural
194
+ isotope mixtures, or instrumental broadening. Bin resolution is approximately
195
+ lambda/delta-lambda; changing it requires recalculation.
196
+
197
+ Cross sections are cm^2 per molecule. Mass opacity is cm^2 per gram of the pure
198
+ chosen isotopologue, not per gram of an atmospheric mixture. Zero kelvin means
199
+ the formal ground-state, zero-Doppler-width limit. Positive temperatures use the
200
+ published partition table; H3+ MiZATeP retains the direct state sum used in the
201
+ original calculation to avoid low-temperature rounding. Requests above the dataset's
202
+ stated maximum temperature are allowed with a warning before large downloads.
203
+ The warning explains that line-list completeness and opacity accuracy are not
204
+ established above that limit; this includes H3+ MiZATeP above 5000 K. The dataset
205
+ limit and an above-limit flag are saved in each spectrum's metadata, with the
206
+ warning also recorded for affected spectra and in `calculation.json`.
207
+ For example, `exomol-opacity 'H3+' --temperatures 6000 --plot`
208
+ calculates a 6000 K spectrum with a warning. The H3+ partition function is still
209
+ computed from the available states; extending the temperature does not add
210
+ missing states or transitions. For other datasets using a partition table,
211
+ temperatures must still be covered by that table; it is not extrapolated.
212
+ Explicit short-wavelength requests are checked before large downloads.
213
+ The original H3+ 0.4--100 micron range remains available as an explicit range;
214
+ `"all"` instead uses the actual line positions, even outside metadata boundaries.
215
+ Dataset coverage does not guarantee
216
+ line-list completeness at every wavelength or temperature.
217
+
218
+ Source: https://www.exomol.com/ (original source URLs and checksums accompany results).
219
+
220
+ ## Tests
221
+
222
+ ```bash
223
+ python -m unittest discover -s tests -v
224
+ ```
225
+
226
+ ## Development
227
+
228
+ ```bash
229
+ python -m unittest discover -s tests -v
230
+ python -m pip install build twine
231
+ python -m build
232
+ python -m twine check dist/*
233
+ ```
234
+
235
+ ## License
236
+
237
+ No software license has been specified for this release. ExoMol data are downloaded
238
+ separately and remain subject to their own terms and citation requirements.
@@ -0,0 +1,217 @@
1
+ # exomol-opacity
2
+
3
+ Calculate wavelength-dependent molecular absorption cross sections and pure-species
4
+ mass opacities from downloaded ExoMol line lists. Includes a Python API, command-line
5
+ calculator, and plotting tool. This is an independent project, not an official
6
+ ExoMol software release.
7
+
8
+ ## Installation
9
+
10
+ Requires Python 3.11 or newer. Calculations support macOS and Linux, including Linux
11
+ under WSL on Windows. A C++17 compiler and bzip2 development headers/library are
12
+ needed to compile the bundled engine on the first calculation.
13
+
14
+ macOS (if Command Line Tools are not already installed):
15
+
16
+ ```bash
17
+ xcode-select --install
18
+ ```
19
+
20
+ Debian/Ubuntu:
21
+
22
+ ```bash
23
+ sudo apt-get install g++ libbz2-dev
24
+ ```
25
+
26
+ Install the Python package and its Python dependencies:
27
+
28
+ ```bash
29
+ python -m pip install exomol-opacity
30
+ ```
31
+
32
+ Native Windows calculation is not supported; use WSL. Plotting saved NPZ spectra
33
+ needs only the Python dependencies, without a compiler or network connection.
34
+
35
+ ## Quick start
36
+
37
+ Calculate H3+ spectra and open separate plot windows:
38
+
39
+ ```bash
40
+ exomol-opacity 'H3+' --temperatures 300 1000 --plot
41
+ ```
42
+
43
+ Above the H3+ MiZATeP stated 5000 K maximum, calculation continues with a warning:
44
+
45
+ ```bash
46
+ exomol-opacity 'H3+' --temperatures 6000 --plot
47
+ ```
48
+
49
+ Specify where files are stored, or export plots without interactive windows:
50
+
51
+ ```bash
52
+ exomol-opacity CO --temperatures 300 --output-dir ./co_results --plot --no-show
53
+ ```
54
+
55
+ By default, downloads, compiled engines and results are stored under
56
+ `./opacity_output` in the current working directory. They are never written into
57
+ the installed Python package. The first run downloads original ExoMol data;
58
+ line lists can require gigabytes of disk space. Subsequent matching calculations
59
+ reuse checked local files. Internet access is needed for uncached source data.
60
+ The ExoMol line lists themselves are not included in this distribution.
61
+
62
+ ## Python API
63
+
64
+ ```python
65
+ from exomol_opacity import calculate_opacity, plot_opacity
66
+
67
+ paths = calculate_opacity(
68
+ molecule="H3+",
69
+ temperatures=[300, 1000, 6000],
70
+ wavelength_range=(0.4, 100), # micrometres; or "all"
71
+ resolution=10000,
72
+ output_root="./my_opacity_results",
73
+ )
74
+ plot_opacity(paths, show=True, save=True)
75
+ ```
76
+
77
+ `calculate_opacity` returns paths to saved NPZ spectra. Each spectrum also has a
78
+ CSV table and JSON metadata file. Temperatures are in kelvin; wavelength-bin
79
+ resolving power is approximately lambda/delta-lambda.
80
+
81
+ ## Running the source folder
82
+
83
+ To work from the source distribution instead of installing from PyPI:
84
+
85
+ ```bash
86
+ python -m pip install -r requirements.txt
87
+ python run_opacity.py
88
+ ```
89
+
90
+ Edit the molecule and temperatures at the top of `run_opacity.py`. The source
91
+ wrappers preserve storage inside the source folder. The engine sources live in
92
+ `exomol_opacity/src/` and are included in both the wheel and source distribution.
93
+
94
+ ## Choosing a Molecule
95
+
96
+ The editable `run_opacity.py` source example uses `WAVELENGTH_RANGE = "all"`. This downloads every primary
97
+ transition file for the selected dataset, scans the actual upper-minus-lower-state
98
+ line positions, and covers all positive-frequency absorption lines with a margin
99
+ for Doppler wings. It applies no line-strength threshold. The limits are cached
100
+ per transition file, keyed to source checksums and scanner code. Zero-probability
101
+ or zero-statistical-weight entries cannot produce absorption and do not set limits.
102
+ Lines with negligible thermal populations can still be invisible in a given plot.
103
+ The numerical range, line counts, and selection mode are recorded in the results.
104
+
105
+ The initial scan adds work and may require very large downloads. It does not mix
106
+ isotopologues or add supplementary datasets. For a restricted range, use a pair
107
+ such as `WAVELENGTH_RANGE = (0.46, 100)` instead. Command-line equivalent:
108
+
109
+ ```bash
110
+ exomol-opacity CO --wavelength-range all --resolution 100000 --plot
111
+ ```
112
+
113
+ Presets select the original datasets for H3+ (MiZATeP), H3O+ (eXeL), CO
114
+ (Li2015), CO2 (UCL-4000), and SiO (SiOUVenIR). These are deliberate presets,
115
+ not a claim that each is the newest available dataset. Select other ExoMol
116
+ isotopologues/datasets explicitly when needed:
117
+
118
+ ```bash
119
+ exomol-opacity H2O --list
120
+ exomol-opacity CO --temperatures 100 300 1000 --wavelength-range 1 30 --resolution 100000 --plot
121
+ ```
122
+
123
+ For a molecule without a preset, use the isotopologue and dataset names from
124
+ `--list` with `--isotopologue NAME --dataset NAME`. If there is exactly one
125
+ available choice, it is selected automatically. Ambiguous choices are never
126
+ silently resolved to an arbitrary isotope. The master catalogue is cached too.
127
+
128
+ The reader supports ExoMol datasets with a JSON definition, partition table,
129
+ and standard bzip2-compressed states/transitions files. It discovers the
130
+ transition blocks from the official dataset page and checks their count.
131
+ Supplementary lists such as CO quadrupole transitions are not mixed into the
132
+ primary dataset. Other file layouts fail explicitly rather than producing a partial calculation.
133
+ This is not a universal reader for HITRAN, arbitrary CSVs, or every molecule.
134
+
135
+ ## Cache and Results
136
+
137
+ Paths below are relative to your output directory (`./opacity_output` by default).
138
+
139
+ - `cache/MOLECULE/ISOTOPOLOGUE/DATASET/cache.json`: local download inventory.
140
+ - That same folder contains the source files and individual SHA-256 receipts.
141
+ - Completed source files are checked and reused without contacting the server.
142
+ - Interrupted downloads use `.part` files and resume when the server supports it.
143
+ - `results/MOLECULE/ISOTOPOLOGUE/DATASET/SETTINGS_ID/`: CSV, NPZ, and JSON spectra.
144
+ - `figures/` within that results folder contains the PNG and PDF plots.
145
+ - Different temperatures, ranges, resolutions, source data, or calculation code
146
+ get separate result folders. Identical completed calculations are reused.
147
+
148
+ The cache is pinned for reproducibility: it does not silently update a dataset.
149
+ Remove the relevant cached files and their receipts to intentionally download
150
+ fresh versions. Do not edit source files in the cache. A lock prevents two runs
151
+ from writing the same molecule cache at once.
152
+
153
+ ## Plot Existing Results
154
+
155
+ No compiler, source line lists, or internet connection is needed to plot saved
156
+ NPZ spectra. Install `exomol-opacity` and share the desired results folder.
157
+
158
+ ```bash
159
+ exomol-opacity-plot "opacity_output/results/CO/12C-16O/Li2015/SETTINGS_ID"
160
+ ```
161
+
162
+ Replace SETTINGS_ID with the folder printed by the calculation. Add `--no-show`
163
+ to save figures without opening windows, or `--no-save` to only display them.
164
+ Use `--quantity mass-opacity` for pure-isotopologue mass opacity.
165
+ Plots show the upper 14 orders of magnitude, as in the H3+ figures; saved spectra
166
+ retain the full calculated values.
167
+
168
+ ## Physical Scope
169
+
170
+ The calculation retains the original H3+ engine: LTE populations, Einstein-A
171
+ line strengths, thermal Doppler profiles, and analytic integrals over logarithmic
172
+ wavenumber bins. It does not add pressure broadening, continuum opacity, natural
173
+ isotope mixtures, or instrumental broadening. Bin resolution is approximately
174
+ lambda/delta-lambda; changing it requires recalculation.
175
+
176
+ Cross sections are cm^2 per molecule. Mass opacity is cm^2 per gram of the pure
177
+ chosen isotopologue, not per gram of an atmospheric mixture. Zero kelvin means
178
+ the formal ground-state, zero-Doppler-width limit. Positive temperatures use the
179
+ published partition table; H3+ MiZATeP retains the direct state sum used in the
180
+ original calculation to avoid low-temperature rounding. Requests above the dataset's
181
+ stated maximum temperature are allowed with a warning before large downloads.
182
+ The warning explains that line-list completeness and opacity accuracy are not
183
+ established above that limit; this includes H3+ MiZATeP above 5000 K. The dataset
184
+ limit and an above-limit flag are saved in each spectrum's metadata, with the
185
+ warning also recorded for affected spectra and in `calculation.json`.
186
+ For example, `exomol-opacity 'H3+' --temperatures 6000 --plot`
187
+ calculates a 6000 K spectrum with a warning. The H3+ partition function is still
188
+ computed from the available states; extending the temperature does not add
189
+ missing states or transitions. For other datasets using a partition table,
190
+ temperatures must still be covered by that table; it is not extrapolated.
191
+ Explicit short-wavelength requests are checked before large downloads.
192
+ The original H3+ 0.4--100 micron range remains available as an explicit range;
193
+ `"all"` instead uses the actual line positions, even outside metadata boundaries.
194
+ Dataset coverage does not guarantee
195
+ line-list completeness at every wavelength or temperature.
196
+
197
+ Source: https://www.exomol.com/ (original source URLs and checksums accompany results).
198
+
199
+ ## Tests
200
+
201
+ ```bash
202
+ python -m unittest discover -s tests -v
203
+ ```
204
+
205
+ ## Development
206
+
207
+ ```bash
208
+ python -m unittest discover -s tests -v
209
+ python -m pip install build twine
210
+ python -m build
211
+ python -m twine check dist/*
212
+ ```
213
+
214
+ ## License
215
+
216
+ No software license has been specified for this release. ExoMol data are downloaded
217
+ separately and remain subject to their own terms and citation requirements.
@@ -0,0 +1,6 @@
1
+ """Compatibility entry point for running the calculator from this folder."""
2
+ from pathlib import Path
3
+ from exomol_opacity.calculation import calculate_opacity, main
4
+
5
+ if __name__ == "__main__":
6
+ main(default_output_root=Path(__file__).resolve().parent)
@@ -0,0 +1,6 @@
1
+ """Independent LTE molecular opacity calculations from ExoMol line lists."""
2
+ from .calculation import calculate_opacity
3
+ from .plotting import plot_opacity
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["calculate_opacity", "plot_opacity", "__version__"]
@@ -0,0 +1,4 @@
1
+ from .calculation import main
2
+
3
+ if __name__ == "__main__":
4
+ main()