DiskMELTS
DiskMELTS (Machine-learning Enabled Line fitting Tool for Spectra) is a
package for continuum subtraction and fitting molecular emission in JWST
mid-infrared spectra of protoplanetary disks. Its fitting workflow loads
pretrained molecular surrogate models and retrieves temperature (T), column
density (logN), and emitting area scaling (A) from observed spectra.
Documentation: diskmelts.readthedocs.io
Installation
DiskMELTS 2.1.1 is available on PyPI.
With Python 3.9 or newer, install it from any directory. These commands use
python in an activated environment; the
installation guide
shows how to create one on macOS, Linux, Windows, or Conda:
python -m pip install diskmelts
python -c "import diskmelts; print('DiskMELTS is ready')"
Optional features can be installed in the same way:
python -m pip install "diskmelts[io]" # FITS input
python -m pip install "diskmelts[io,notebooks]" # FITS input and JupyterLab
The pip package includes the production checkpoints and continuum reference
tables. Full slab grids for training and direct-grid fitting are separate
downloads; pass their local path as grid_root.
Example notebooks and spectra can be downloaded from the repository when
needed; they are not installed by pip.
Runtime dependencies
| Package | Purpose |
|---|---|
torch |
Pretrained model inference |
numpy |
Array operations |
pandas |
CSV I/O |
scipy |
L-BFGS-B optimizer, NNLS, Sobol sampling |
scikit-learn |
Model scaling and PCA metadata |
matplotlib |
Plotting |
Continuum subtraction
Try the continuum subtraction notebook
with the included raw Upper Sco J16120505 spectrum. It demonstrates the
five-array result and a plot; change RAW_CSV to another file in
Realobs_data/Raw_data/ to process another source.
For a CSV with wave,flux,err columns (wavelength in µm and flux/error in the
same units):
import diskmelts
wav, flux, error = diskmelts.consub.read_spectrum("raw_spectrum.csv")
wav, consub, err, cont, contOrig = diskmelts.consub.calculate(
wav, flux, error, preset="ttauri", exclude=[[12, 13]],
)
fig = diskmelts.consub.plot(
wav, consub, err, cont, contOrig, ranges=[(5, 12), (12, 25)], savedir=None,
)
calculate() returns five NumPy arrays. plot() displays the raw spectrum,
continuum, and residual; savedir="figures/consub" also writes continuum.png.
Its error and contOrig inputs may be None.
Presets are water, ttauri, carbon_rich, and carbon_extended.
Use preset=None, linefreefile="windows.csv" for custom xmin,xmax windows.
With preset=None, linefreefile=None (or ""), fitting uses all nonexcluded
pixels and skips the line-free correction, so cont equals contOrig.
Reference tables are bundled; normal continuum subtraction needs no model grids.
The private 0-Consub/ experiment directory is excluded from Git and is not
required by the installed package. Its runtime code and reference tables are
maintained under src/diskmelts/consub/.
The distributed tests in tests/ exercise the installed continuum API and
bundled references without that private directory.
Returned err represents measurement/noise error, not correlated continuum
uncertainty. Broad excluded intervals require inspection. See the
continuum guide for presets, regional box sizes,
special regions, FITS input, saving CSVs, and uncertainty diagnostics.
Quick fitting example
Use a continuum-subtracted CSV with a header and wave,flux as its first two
columns, with wavelength in µm and flux in Jy. For a runnable example without
cloning the repository, download the
J16120505 spectrum
as j16120505_contsub.csv, or run:
curl -L -o j16120505_contsub.csv https://raw.githubusercontent.com/wddlx/DiskMELTS/main/Realobs_data/Consub_data/j16120505_v9.0_contsub_RVcorr.csv
from diskmelts import fit_stage, load_fitting_models, load_observed_spectrum
models = load_fitting_models('C2H2')
obs_wav, obs_flux = load_observed_spectrum(
'j16120505_contsub.csv'
)
fit = fit_stage(
obs_wav,
obs_flux,
molecule='C2H2',
wavelength_range=(13.0, 15.0),
pretrained=models,
fit_ranges=(13.5, 14.1),
distance_pc=122.5,
n_samples=1024,
n_refine=4,
n_top=4,
)
print(fit['params']['C2H2'])
You can also read spectra with your own code. DiskMELTS only requires
one-dimensional obs_wav and obs_flux arrays. Replace the sample CSV with
your own file to fit your source; update distance_pc and fit intervals.
For a complete staged fit-and-subtract workflow from a checkout, edit and run:
python examples/dev_v2_realobs.py
The v2 fitting API is load_fitting_models, fit_stage, fit_observation, and
plot_saved_observation. The production checkpoints are packaged under
src/diskmelts/models/ and included in the wheel. Model fitting requires no
Model_grids/ or Pretrain_grid/ directory. The model metadata, including
PCA counts and network layers, are in diskmelts.MODEL_SPECS and checked when
loading. The checkpoint flux convention is 1 au² at 140 pc; distance_pc
sets the source distance and makes the returned emitting area physical.
The fitting notebook requires 13C12CH2 to
be no hotter than C2H2 and gives them the same emitting area. It ties 13CO2
to CO2 in both temperature and area. Set
isotopologue_groups, Tshare (free, equal, or less), and Ashare in a
joint stage to choose those constraints. See the
fitting guide for examples.
For an optional fit directly from slab grids, use fit_grid_stage or
fit_observation_grids and supply grid_root='Model_grids' explicitly. This
separate method does require the full local grids. See the
quick start for both workflows and saved-result
plotting.
Training and validation data
Model_grids/ and Pretrain_grid/ are intentionally ignored by Git because
they contain the full local training data. The generated checkpoint directories
under the top-level Trained_model/ are also optional; the package bundles
only the production checkpoints needed for v2 fitting. To run
examples/dev_v2_pt_validation.py or
notebooks/Example_Training_Validation.ipynb, place the complete model grids
under Model_grids/<molecule>/. The workflows create or reuse the corresponding
pretraining CSV under Pretrain_grid/.
The maintained v2 workflow uses a hybrid design after restricting the expanded
IRIS grids to the intended physical domain. H2O uses five overlapping
wavelength checkpoints covering 4.9–25.0 µm, all sharing T=100–1400 K and
logN=13–19. Primary carbon-bearing and rarer molecules use one checkpoint
each, the same temperature range, and logN=13–19.5.
The new C2HD checkpoint spans 11.5–20.5 µm to include its 19 µm band;
CO17O and CO18O span 13–18 µm. The updated 13C12CH2 checkpoint keeps
11.5–17 µm. To retrain these four grids, run:
DISKMELTS_MOLECULES=13C12CH2,C2HD,CO17O,CO18O python examples/dev_v2_pt_validation.py
Five to ten percent of complete (T, logN) grid spectra are excluded before
PCA or neural-network training. They are used to select the PCA dimension and
to validate spectral reconstruction and full parameter fitting. The
run_H2O, run_Cmol, and run_rarer switches select which groups run.
Forward model convention
flux(T, logN, A, d) = A * (140 pc / d)^2 * peak(T, logN) * shape(T, logN)
Each molecule has two pretrained MLPs:
net_shape:(T, logN)to PCA coefficients of the peak-normalized spectral shapenet_peak:(T, logN)tolog10(peak flux)in Jy
The linear amplitude A is solved analytically with NNLS or bounded least
squares after the nonlinear (T, logN) search.
Contributors
- Chengyan Xie (University of Arizona)
- Dingshan Deng (University of Arizona)
Metadata
Release files for diskmelts 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diskmelts-2.1.1.tar.gz | 9.6 MB | Without provenance | Details for diskmelts-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diskmelts-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for diskmelts-2.1.1-py3-none-any.whl |
Total release size: 19.3 MB
Release files / diskmelts-2.1.1.tar.gz
| Download URL | diskmelts-2.1.1.tar.gz |
|---|---|
| Size | 9.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb44d3530130162360fb39525b4f163c930bc9a6f79eacdbc4246d2b29015988
|
|
BLAKE2b-256 checksum How to use checksums |
1e1e4db131c3b1348580a3f1fa388135eb37f15122802cdc28e6394672b8db73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.12
|
Release files / diskmelts-2.1.1-py3-none-any.whl
| Download URL | diskmelts-2.1.1-py3-none-any.whl |
|---|---|
| Size | 9.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2234f1a09bf7c1e11a13a1d46f1a7fdb1a4f36b3a39b6b76daf807fc2cd792f3
|
|
BLAKE2b-256 checksum How to use checksums |
baafc232e2c1c5eec5e9f71659a1063e2fdc18bb74e989c94d5710a1df2855e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.12
|
Security for diskmelts 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.