diskmelts 2.1.1__tar.gz → 2.1.2__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 (67) hide show
  1. {diskmelts-2.1.1/src/diskmelts.egg-info → diskmelts-2.1.2}/PKG-INFO +15 -6
  2. {diskmelts-2.1.1 → diskmelts-2.1.2}/README.md +14 -5
  3. {diskmelts-2.1.1 → diskmelts-2.1.2}/pyproject.toml +1 -1
  4. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/fitting.py +3 -3
  5. diskmelts-2.1.2/src/diskmelts/models/Trained_model/C3H4_single_v2/net_C3H4_forward.pt +0 -0
  6. diskmelts-2.1.2/src/diskmelts/models/Trained_model/C6H6_single_v2/net_C6H6_forward.pt +0 -0
  7. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/plotting.py +4 -0
  8. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/v2_fitting.py +4 -3
  9. {diskmelts-2.1.1 → diskmelts-2.1.2/src/diskmelts.egg-info}/PKG-INFO +15 -6
  10. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts.egg-info/SOURCES.txt +2 -0
  11. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_dev_v2_fitting_grids.py +24 -4
  12. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_io.py +25 -0
  13. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_v2_package_assets.py +19 -0
  14. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_workflows.py +17 -4
  15. {diskmelts-2.1.1 → diskmelts-2.1.2}/LICENSE +0 -0
  16. {diskmelts-2.1.1 → diskmelts-2.1.2}/setup.cfg +0 -0
  17. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/__init__.py +0 -0
  18. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/__init__.py +0 -0
  19. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/_api.py +0 -0
  20. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/_core.py +0 -0
  21. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/cont_ranges.csv +0 -0
  22. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/cont_ranges_PPan.csv +0 -0
  23. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/carbon_extended.csv +0 -0
  24. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/carbon_extended.json +0 -0
  25. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/carbon_rich.csv +0 -0
  26. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/carbon_rich.json +0 -0
  27. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/ttauri.csv +0 -0
  28. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/ttauri.json +0 -0
  29. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/water.csv +0 -0
  30. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/consub/regions/water.json +0 -0
  31. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/13C12CH2_single_v2/net_13C12CH2_forward.pt +0 -0
  32. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/13CO2_single_v2/net_13CO2_forward.pt +0 -0
  33. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/C2H2_single_v2/net_C2H2_forward.pt +0 -0
  34. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/C2H4_single_v2/net_C2H4_forward.pt +0 -0
  35. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/C2H6_single_v2/net_C2H6_forward.pt +0 -0
  36. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/C2HD_single_v2/net_C2HD_forward.pt +0 -0
  37. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/C4H2_single_v2/net_C4H2_forward.pt +0 -0
  38. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/CH4_single_v2/net_CH4_forward.pt +0 -0
  39. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/CO17O_single_v2/net_CO17O_forward.pt +0 -0
  40. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/CO18O_single_v2/net_CO18O_forward.pt +0 -0
  41. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/CO2_single_v2/net_CO2_forward.pt +0 -0
  42. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/H2O_wavelength_bank_v2_fixed/H2O_model_bank.json +0 -0
  43. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/H2O_wavelength_bank_v2_fixed/net_H2O_w13p5to19p2_n13to19_t100to1400.pt +0 -0
  44. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/H2O_wavelength_bank_v2_fixed/net_H2O_w19to25_n13to19_t100to1400.pt +0 -0
  45. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/H2O_wavelength_bank_v2_fixed/net_H2O_w4p9to7p4_n13to19_t100to1400.pt +0 -0
  46. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/H2O_wavelength_bank_v2_fixed/net_H2O_w7p2to11p2_n13to19_t100to1400.pt +0 -0
  47. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/H2O_wavelength_bank_v2_fixed/net_H2O_w9p9to15p1_n13to19_t100to1400.pt +0 -0
  48. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/HC3N_single_v2/net_HC3N_forward.pt +0 -0
  49. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/models/Trained_model/HCN_single_v2/net_HCN_forward.pt +0 -0
  50. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/trainmodel.py +0 -0
  51. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/v2_grid_fitting.py +0 -0
  52. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/v2_paper_comparison.py +0 -0
  53. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/v2_read_plot.py +0 -0
  54. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts/validation.py +0 -0
  55. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts.egg-info/dependency_links.txt +0 -0
  56. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts.egg-info/requires.txt +0 -0
  57. {diskmelts-2.1.1 → diskmelts-2.1.2}/src/diskmelts.egg-info/top_level.txt +0 -0
  58. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_consub_package.py +0 -0
  59. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_detection.py +0 -0
  60. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_dev_v2_fitting_distance.py +0 -0
  61. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_dev_v2_read_plot.py +0 -0
  62. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_imports.py +0 -0
  63. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_mlp.py +0 -0
  64. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_model_bank.py +0 -0
  65. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_shared_area_fitting.py +0 -0
  66. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_smoke.py +0 -0
  67. {diskmelts-2.1.1 → diskmelts-2.1.2}/tests/test_water_training.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diskmelts
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Machine-learning Enabled Line fitting Tool for Spectra of protoplanetary disks
5
5
  Author: Chengyan Xie, Dingshan Deng
6
6
  License-Expression: MIT
@@ -49,7 +49,8 @@ density (`logN`), and emitting area scaling (`A`) from observed spectra.
49
49
 
50
50
  ## Installation
51
51
 
52
- DiskMELTS 2.1.1 is available on [PyPI](https://pypi.org/project/diskmelts/).
52
+ DiskMELTS is available on [PyPI](https://pypi.org/project/diskmelts/).
53
+ The C6H6 and C3H4 checkpoints are included starting with version 2.1.2.
53
54
  With Python 3.9 or newer, install it from any directory. These commands use
54
55
  `python` in an activated environment; the
55
56
  [installation guide](https://diskmelts.readthedocs.io/en/latest/installation.html)
@@ -196,9 +197,9 @@ plotting.
196
197
 
197
198
  ## Training and validation data
198
199
 
199
- `Model_grids/` and `Pretrain_grid/` are intentionally ignored by Git because
200
- they contain the full local training data. The generated checkpoint directories
201
- under the top-level `Trained_model/` are also optional; the package bundles
200
+ Generated data under `Model_grids/` and `Pretrain_grid/` are intentionally
201
+ ignored by Git because they contain the full local training data. Generated
202
+ checkpoint directories under the top-level `Trained_model/` are also optional; the package bundles
202
203
  only the production checkpoints needed for v2 fitting. To run
203
204
  `examples/dev_v2_pt_validation.py` or
204
205
  `notebooks/Example_Training_Validation.ipynb`, place the complete model grids
@@ -209,7 +210,8 @@ The maintained v2 workflow uses a hybrid design after restricting the expanded
209
210
  IRIS grids to the intended physical domain. H2O uses five overlapping
210
211
  wavelength checkpoints covering 4.9–25.0 µm, all sharing `T=100–1400 K` and
211
212
  `logN=13–19`. Primary carbon-bearing and rarer molecules use one checkpoint
212
- each, the same temperature range, and `logN=13–19.5`.
213
+ each and `logN=13–19.5`; C6H6 is limited to `T=100–675 K`, while the others
214
+ use `T=100–1400 K`.
213
215
  The new C2HD checkpoint spans 11.5–20.5 µm to include its 19 µm band;
214
216
  CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
215
217
  11.5–17 µm. To retrain these four grids, run:
@@ -218,6 +220,13 @@ CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
218
220
  DISKMELTS_MOLECULES=13C12CH2,C2HD,CO17O,CO18O python examples/dev_v2_pt_validation.py
219
221
  ```
220
222
 
223
+ C6H6 and C3H4 also have bundled fitting checkpoints. The C6H6 checkpoint
224
+ covers 13–17 µm and 100–675 K; C3H4 covers 15–18 µm and 100–1400 K. Load
225
+ either by name with `load_fitting_models`. Direct grid fitting
226
+ uses the same names with local `Model_grids/C6H6/` and `Model_grids/C3H4/`
227
+ files. See the [training guide](https://diskmelts.readthedocs.io/en/latest/training.html)
228
+ for peak audits and retraining commands.
229
+
221
230
  Five to ten percent of complete `(T, logN)` grid spectra are excluded before
222
231
  PCA or neural-network training. They are used to select the PCA dimension and
223
232
  to validate spectral reconstruction and full parameter fitting. The
@@ -10,7 +10,8 @@ density (`logN`), and emitting area scaling (`A`) from observed spectra.
10
10
 
11
11
  ## Installation
12
12
 
13
- DiskMELTS 2.1.1 is available on [PyPI](https://pypi.org/project/diskmelts/).
13
+ DiskMELTS is available on [PyPI](https://pypi.org/project/diskmelts/).
14
+ The C6H6 and C3H4 checkpoints are included starting with version 2.1.2.
14
15
  With Python 3.9 or newer, install it from any directory. These commands use
15
16
  `python` in an activated environment; the
16
17
  [installation guide](https://diskmelts.readthedocs.io/en/latest/installation.html)
@@ -157,9 +158,9 @@ plotting.
157
158
 
158
159
  ## Training and validation data
159
160
 
160
- `Model_grids/` and `Pretrain_grid/` are intentionally ignored by Git because
161
- they contain the full local training data. The generated checkpoint directories
162
- under the top-level `Trained_model/` are also optional; the package bundles
161
+ Generated data under `Model_grids/` and `Pretrain_grid/` are intentionally
162
+ ignored by Git because they contain the full local training data. Generated
163
+ checkpoint directories under the top-level `Trained_model/` are also optional; the package bundles
163
164
  only the production checkpoints needed for v2 fitting. To run
164
165
  `examples/dev_v2_pt_validation.py` or
165
166
  `notebooks/Example_Training_Validation.ipynb`, place the complete model grids
@@ -170,7 +171,8 @@ The maintained v2 workflow uses a hybrid design after restricting the expanded
170
171
  IRIS grids to the intended physical domain. H2O uses five overlapping
171
172
  wavelength checkpoints covering 4.9–25.0 µm, all sharing `T=100–1400 K` and
172
173
  `logN=13–19`. Primary carbon-bearing and rarer molecules use one checkpoint
173
- each, the same temperature range, and `logN=13–19.5`.
174
+ each and `logN=13–19.5`; C6H6 is limited to `T=100–675 K`, while the others
175
+ use `T=100–1400 K`.
174
176
  The new C2HD checkpoint spans 11.5–20.5 µm to include its 19 µm band;
175
177
  CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
176
178
  11.5–17 µm. To retrain these four grids, run:
@@ -179,6 +181,13 @@ CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
179
181
  DISKMELTS_MOLECULES=13C12CH2,C2HD,CO17O,CO18O python examples/dev_v2_pt_validation.py
180
182
  ```
181
183
 
184
+ C6H6 and C3H4 also have bundled fitting checkpoints. The C6H6 checkpoint
185
+ covers 13–17 µm and 100–675 K; C3H4 covers 15–18 µm and 100–1400 K. Load
186
+ either by name with `load_fitting_models`. Direct grid fitting
187
+ uses the same names with local `Model_grids/C6H6/` and `Model_grids/C3H4/`
188
+ files. See the [training guide](https://diskmelts.readthedocs.io/en/latest/training.html)
189
+ for peak audits and retraining commands.
190
+
182
191
  Five to ten percent of complete `(T, logN)` grid spectra are excluded before
183
192
  PCA or neural-network training. They are used to select the PCA dimension and
184
193
  to validate spectral reconstruction and full parameter fitting. The
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "diskmelts"
7
- version = "2.1.1"
7
+ version = "2.1.2"
8
8
  description = "Machine-learning Enabled Line fitting Tool for Spectra of protoplanetary disks"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1347,14 +1347,14 @@ def save_fitted_comparison(csv_path, source_name, all_fits):
1347
1347
 
1348
1348
  def _v(comp, key):
1349
1349
  if comp not in all_params:
1350
- return ''
1350
+ return np.nan
1351
1351
  return round(all_params[comp][key], 4)
1352
1352
 
1353
1353
  def _e(comp, key, which):
1354
1354
  if comp not in all_unc:
1355
- return ''
1355
+ return np.nan
1356
1356
  v = all_unc[comp].get(key, {}).get(which, float('nan'))
1357
- return round(v, 4) if np.isfinite(v) else ''
1357
+ return round(v, 4) if np.isfinite(v) else np.nan
1358
1358
 
1359
1359
  row = {
1360
1360
  'Source': source_name,
@@ -43,6 +43,8 @@ _MOL_LABEL = {
43
43
  'C2HD': r'C$_2$HD',
44
44
  'CO17O': r'C$^{16}$O$^{17}$O',
45
45
  'CO18O': r'C$^{16}$O$^{18}$O',
46
+ 'C6H6': r'C$_6$H$_6$',
47
+ 'C3H4': r'C$_3$H$_4$',
46
48
  }
47
49
 
48
50
  _MOL_COLOR = {
@@ -64,6 +66,8 @@ _MOL_COLOR = {
64
66
  'C2HD': 'teal',
65
67
  'CO17O': 'slateblue',
66
68
  'CO18O': 'goldenrod',
69
+ 'C6H6': 'darkorange',
70
+ 'C3H4': 'purple',
67
71
  }
68
72
 
69
73
  # ---------------------------------------------------------------------------
@@ -34,7 +34,8 @@ CARBON_RANGES = {
34
34
  'HC3N': (13.0, 18.0), 'C2H6': (9.0, 15.0),
35
35
  'C2H4': (8.0, 14.0), 'CH4': (5.0, 9.0),
36
36
  'C2HD': (11.5, 20.5), 'CO17O': (13.0, 18.0),
37
- 'CO18O': (13.0, 18.0),
37
+ 'CO18O': (13.0, 18.0), 'C6H6': (13.0, 17.0),
38
+ 'C3H4': (15.0, 18.0),
38
39
  }
39
40
  MODEL_SPECS = {
40
41
  'H2O': {
@@ -49,9 +50,9 @@ MODEL_SPECS = {
49
50
  mol: {
50
51
  'path': f'Trained_model/{mol}_single_v2/net_{mol}_forward.pt',
51
52
  'wavelength_ranges': (wav_range,),
52
- 'T_bounds': (100.0, 1400.0),
53
+ 'T_bounds': (100.0, 675.0) if mol == 'C6H6' else (100.0, 1400.0),
53
54
  'logN_bounds': (13.0, 19.5),
54
- 'n_pca': 30,
55
+ 'n_pca': 75 if mol == 'C3H4' else 30,
55
56
  'hidden': (64, 128, 64),
56
57
  }
57
58
  for mol, wav_range in CARBON_RANGES.items()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diskmelts
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Machine-learning Enabled Line fitting Tool for Spectra of protoplanetary disks
5
5
  Author: Chengyan Xie, Dingshan Deng
6
6
  License-Expression: MIT
@@ -49,7 +49,8 @@ density (`logN`), and emitting area scaling (`A`) from observed spectra.
49
49
 
50
50
  ## Installation
51
51
 
52
- DiskMELTS 2.1.1 is available on [PyPI](https://pypi.org/project/diskmelts/).
52
+ DiskMELTS is available on [PyPI](https://pypi.org/project/diskmelts/).
53
+ The C6H6 and C3H4 checkpoints are included starting with version 2.1.2.
53
54
  With Python 3.9 or newer, install it from any directory. These commands use
54
55
  `python` in an activated environment; the
55
56
  [installation guide](https://diskmelts.readthedocs.io/en/latest/installation.html)
@@ -196,9 +197,9 @@ plotting.
196
197
 
197
198
  ## Training and validation data
198
199
 
199
- `Model_grids/` and `Pretrain_grid/` are intentionally ignored by Git because
200
- they contain the full local training data. The generated checkpoint directories
201
- under the top-level `Trained_model/` are also optional; the package bundles
200
+ Generated data under `Model_grids/` and `Pretrain_grid/` are intentionally
201
+ ignored by Git because they contain the full local training data. Generated
202
+ checkpoint directories under the top-level `Trained_model/` are also optional; the package bundles
202
203
  only the production checkpoints needed for v2 fitting. To run
203
204
  `examples/dev_v2_pt_validation.py` or
204
205
  `notebooks/Example_Training_Validation.ipynb`, place the complete model grids
@@ -209,7 +210,8 @@ The maintained v2 workflow uses a hybrid design after restricting the expanded
209
210
  IRIS grids to the intended physical domain. H2O uses five overlapping
210
211
  wavelength checkpoints covering 4.9–25.0 µm, all sharing `T=100–1400 K` and
211
212
  `logN=13–19`. Primary carbon-bearing and rarer molecules use one checkpoint
212
- each, the same temperature range, and `logN=13–19.5`.
213
+ each and `logN=13–19.5`; C6H6 is limited to `T=100–675 K`, while the others
214
+ use `T=100–1400 K`.
213
215
  The new C2HD checkpoint spans 11.5–20.5 µm to include its 19 µm band;
214
216
  CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
215
217
  11.5–17 µm. To retrain these four grids, run:
@@ -218,6 +220,13 @@ CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
218
220
  DISKMELTS_MOLECULES=13C12CH2,C2HD,CO17O,CO18O python examples/dev_v2_pt_validation.py
219
221
  ```
220
222
 
223
+ C6H6 and C3H4 also have bundled fitting checkpoints. The C6H6 checkpoint
224
+ covers 13–17 µm and 100–675 K; C3H4 covers 15–18 µm and 100–1400 K. Load
225
+ either by name with `load_fitting_models`. Direct grid fitting
226
+ uses the same names with local `Model_grids/C6H6/` and `Model_grids/C3H4/`
227
+ files. See the [training guide](https://diskmelts.readthedocs.io/en/latest/training.html)
228
+ for peak audits and retraining commands.
229
+
221
230
  Five to ten percent of complete `(T, logN)` grid spectra are excluded before
222
231
  PCA or neural-network training. They are used to select the PCA dimension and
223
232
  to validate spectral reconstruction and full parameter fitting. The
@@ -34,7 +34,9 @@ src/diskmelts/models/Trained_model/C2H2_single_v2/net_C2H2_forward.pt
34
34
  src/diskmelts/models/Trained_model/C2H4_single_v2/net_C2H4_forward.pt
35
35
  src/diskmelts/models/Trained_model/C2H6_single_v2/net_C2H6_forward.pt
36
36
  src/diskmelts/models/Trained_model/C2HD_single_v2/net_C2HD_forward.pt
37
+ src/diskmelts/models/Trained_model/C3H4_single_v2/net_C3H4_forward.pt
37
38
  src/diskmelts/models/Trained_model/C4H2_single_v2/net_C4H2_forward.pt
39
+ src/diskmelts/models/Trained_model/C6H6_single_v2/net_C6H6_forward.pt
38
40
  src/diskmelts/models/Trained_model/CH4_single_v2/net_CH4_forward.pt
39
41
  src/diskmelts/models/Trained_model/CO17O_single_v2/net_CO17O_forward.pt
40
42
  src/diskmelts/models/Trained_model/CO18O_single_v2/net_CO18O_forward.pt
@@ -14,12 +14,13 @@ from diskmelts.v2_grid_fitting import (
14
14
  )
15
15
 
16
16
 
17
- def _small_grid(tmp_path):
18
- grid_dir = tmp_path / 'grids' / 'C2H2'
17
+ def _small_grid(tmp_path, molecule='C2H2', wavelength_range=(11.0, 13.0)):
18
+ grid_dir = tmp_path / 'grids' / molecule
19
19
  grid_dir.mkdir(parents=True)
20
- wav = np.linspace(11.0, 13.0, 60)
20
+ lo, hi = wavelength_range
21
+ wav = np.linspace(lo, hi, 60)
21
22
  basis = np.stack([np.exp(-((wav - center) / 0.09) ** 2)
22
- for center in (11.3, 12.0, 12.7)])
23
+ for center in (lo + 0.3, (lo + hi) / 2, hi - 0.3)])
23
24
 
24
25
  def spectrum(T, logN):
25
26
  return 0.01 * (basis[0] + (1 + (T - 100) / 25) * basis[1]
@@ -33,6 +34,25 @@ def _small_grid(tmp_path):
33
34
  return wav, spectrum
34
35
 
35
36
 
37
+ @pytest.mark.parametrize('molecule,wavelength_range', [
38
+ ('C6H6', (13.0, 17.0)),
39
+ ('C3H4', (15.0, 18.0)),
40
+ ])
41
+ def test_new_molecules_fit_from_direct_grids(tmp_path, molecule,
42
+ wavelength_range):
43
+ wav, spectrum = _small_grid(tmp_path, molecule, wavelength_range)
44
+ observed = spectrum(113.0, 13.07)
45
+ fit = fit_grid_stage(
46
+ wav, observed, molecule, wavelength_range, wavelength_range,
47
+ grid_root=tmp_path / 'grids', T_bounds=(100, 150),
48
+ logN_bounds=(13, 13.25), sigma=1e-4,
49
+ maxiter=20, popsize=5, n_refine=2,
50
+ )
51
+ assert molecule in fit['params']
52
+ assert np.isfinite(fit['model_flux']).all()
53
+ assert np.linalg.norm(fit['residual']) < np.linalg.norm(observed)
54
+
55
+
36
56
  def test_grid_fit_and_saved_errors(tmp_path):
37
57
  wav, spectrum = _small_grid(tmp_path)
38
58
  distance_pc = 177.0
@@ -1,5 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import warnings
4
+
3
5
  import numpy as np
4
6
  import pandas as pd
5
7
  import pytest
@@ -53,3 +55,26 @@ def test_save_running_spectrum(tmp_path):
53
55
  assert list(df.columns) == ["wave", "residual", "cumulative_model"]
54
56
  assert len(df) == 50
55
57
  assert df["wave"].iloc[0] == pytest.approx(11.0)
58
+
59
+
60
+ def test_save_fitted_comparison_updates_missing_numeric_fields(tmp_path):
61
+ pytest.importorskip("torch")
62
+ from diskmelts import save_fitted_comparison
63
+
64
+ path = tmp_path / "comparison.csv"
65
+ water = {"water": {"params": {
66
+ "H2O_warm": {"logN": 17.0, "T": 400.0, "log10A": 1.0},
67
+ }}}
68
+ carbon = {"carbon": {"params": {
69
+ "C2H2": {"logN": 18.0, "T": 600.0, "log10A": 2.0},
70
+ }}}
71
+ save_fitted_comparison(path, "source", water)
72
+ with warnings.catch_warnings():
73
+ warnings.simplefilter("error", FutureWarning)
74
+ save_fitted_comparison(path, "source", carbon)
75
+
76
+ df = pd.read_csv(path)
77
+ assert len(df) == 1
78
+ assert pd.isna(df.loc[0, "H2O_N_warm"])
79
+ assert pd.isna(df.loc[0, "C2H2_N_err_low"])
80
+ assert df.loc[0, "C2H2_N"] == pytest.approx(18.0)
@@ -23,3 +23,22 @@ def test_bundled_model_fit_without_grids(tmp_path, monkeypatch):
23
23
  assert fit['params']['C2H2']['logN'] == pytest.approx(16, abs=0.02)
24
24
  with pytest.raises(ValueError, match='grid_root is required'):
25
25
  fit_grid_stage(wave, flux, 'C2H2', (13.5, 14.1), (13.5, 14.1))
26
+
27
+
28
+ @pytest.mark.parametrize('molecule,window', [
29
+ ('C6H6', (14.5, 15.2)),
30
+ ('C3H4', (15.68, 15.85)),
31
+ ])
32
+ def test_new_bundled_molecules_fit_without_grids(tmp_path, monkeypatch,
33
+ molecule, window):
34
+ monkeypatch.chdir(tmp_path)
35
+ models = load_fitting_models(molecule)
36
+ wave = np.linspace(*window, 100)
37
+ flux = generate_spectrum(500, 16, 1.0, models[molecule], obs_wav=wave)
38
+ fit = fit_stage(
39
+ wave, flux, molecule, window, window, models,
40
+ n_samples=64, n_refine=2, n_top=2, seed=4,
41
+ )
42
+ assert molecule in fit['params']
43
+ assert np.isfinite(fit['model_flux']).all()
44
+ assert np.linalg.norm(fit['residual']) < np.linalg.norm(flux)
@@ -30,6 +30,14 @@ def test_notebook_code_cells_compile(path):
30
30
  compile("".join(cell["source"]), f"{path.name}:cell-{index}", "exec")
31
31
 
32
32
 
33
+ @pytest.mark.parametrize("path", [FITTING_NOTEBOOK, TRAINING_NOTEBOOK])
34
+ def test_notebook_rejects_incompatible_sklearn(path, monkeypatch):
35
+ sklearn = pytest.importorskip("sklearn")
36
+ monkeypatch.setattr(sklearn, "__version__", "0.0")
37
+ with pytest.raises(RuntimeError, match="require scikit-learn 1.8.0"):
38
+ exec(_code_cell(_notebook(path), 1), {})
39
+
40
+
33
41
  @pytest.mark.parametrize("start_dir", [ROOT, ROOT / "notebooks"])
34
42
  def test_consub_notebook_reads_public_usco_csv(monkeypatch, start_dir):
35
43
  raw_dir = ROOT / "Realobs_data" / "Raw_data"
@@ -46,6 +54,9 @@ def test_consub_notebook_reads_public_usco_csv(monkeypatch, start_dir):
46
54
  @pytest.mark.parametrize("start_dir", [ROOT, ROOT / "notebooks"])
47
55
  def test_fitting_notebook_resolves_committed_assets(monkeypatch, start_dir):
48
56
  pytest.importorskip("torch")
57
+ sklearn = pytest.importorskip("sklearn")
58
+ # This test checks paths and stage settings; the version guard is tested above.
59
+ monkeypatch.setattr(sklearn, "__version__", "1.8.0")
49
60
  notebook = _notebook(FITTING_NOTEBOOK)
50
61
  namespace = {}
51
62
 
@@ -65,6 +76,8 @@ def test_fitting_notebook_resolves_committed_assets(monkeypatch, start_dir):
65
76
  @pytest.mark.parametrize("start_dir", [ROOT, ROOT / "notebooks"])
66
77
  def test_training_notebook_resolves_local_data_locations(monkeypatch, start_dir):
67
78
  pytest.importorskip("torch")
79
+ sklearn = pytest.importorskip("sklearn")
80
+ monkeypatch.setattr(sklearn, "__version__", "1.8.0")
68
81
  notebook = _notebook(TRAINING_NOTEBOOK)
69
82
  namespace = {}
70
83
 
@@ -83,11 +96,11 @@ def test_production_checkpoint_files_are_bundled():
83
96
  from diskmelts import MODEL_SPECS
84
97
  from diskmelts.v2_fitting import MODEL_ROOT
85
98
 
86
- assert len(MODEL_SPECS) == 14
99
+ assert len(MODEL_SPECS) == 16
87
100
  for molecule, spec in MODEL_SPECS.items():
88
101
  path = MODEL_ROOT / spec['path']
89
102
  assert path.is_file(), f'missing bundled checkpoint for {molecule}: {path}'
90
- assert len(list(MODEL_ROOT.rglob('*.pt'))) == 18
103
+ assert len(list(MODEL_ROOT.rglob('*.pt'))) == 20
91
104
 
92
105
 
93
106
  def test_new_grid_checkpoints_load_and_generate_finite_spectra():
@@ -95,7 +108,7 @@ def test_new_grid_checkpoints_load_and_generate_finite_spectra():
95
108
  from diskmelts import load_fitting_models
96
109
  from diskmelts.fitting import generate_spectrum
97
110
 
98
- molecules = ('13C12CH2', 'C2HD', 'CO17O', 'CO18O')
111
+ molecules = ('13C12CH2', 'C2HD', 'CO17O', 'CO18O', 'C6H6', 'C3H4')
99
112
  models = load_fitting_models(molecules)
100
113
  for molecule in molecules:
101
114
  flux = generate_spectrum(400., 16., 1., models[molecule])
@@ -111,7 +124,7 @@ def test_gitignore_separates_fitting_assets_from_training_data():
111
124
  if line.strip() and not line.lstrip().startswith("#")
112
125
  }
113
126
 
114
- for pattern in ('/Model_grids/', '/Pretrain_grid/', '/Trained_model/',
127
+ for pattern in ('/Model_grids/*', '/Pretrain_grid/', '/Trained_model/',
115
128
  '/0-Consub/',
116
129
  '/docs/_build/', '/realobs_results/', '/figures/*'):
117
130
  assert pattern in patterns
File without changes
File without changes
File without changes
File without changes