Self-Consistent Fitting of Filament Profiles: Code and Data
Abstract
Self-Consistent Fitting of Filament Profiles: Code and Data This repository provides the Python implementation of the finite‑cylinder filament profile model described in Men’shchikov & Zhang (2026). The code performs self‑consistent fitting of observed surface density profiles using a geometric truncation method — it explicitly accounts for the finite outer boundary of filaments — and derives the corresponding volume density parameters, linear densities, and quality metrics. The method is general and can be applied to any filament observations; the included example data from the Taurus molecular cloud serve as a default test case. ● Companion Papers • Men’shchikov, A. & Zhang, G.-Y. (2026). Deriving volume density profiles of filaments from observed surface densities. Astronomy & Astrophysics, doi:10.48550/arXiv.2604.12570 • Zhang, G.-Y., Men’shchikov, A. & Li, J.-Z. (2026). Scale-dependent surface and volume density properties of filaments in molecular clouds. Astronomy & Astrophysics, in press, doi:10.48550/arXiv.2604.11485 • The results underpin the submission to the Astrophysical Journal Letters: Zhang, Men’shchikov & Li, “A Salpeter‑like filament linear density function across nearby molecular clouds”. ● Repository Contents initial_profile_selector_ValleyPeakDetector.py → Step 1: detect truncation points analytic_profile_fitter.py → Step 2: geometric fit of surface density profiles scale0216/ → Example data (Taurus, 216" scale) +profiless0216as10pixelsobs/ → Original filament profiles +profiless0216as10pixels/ → Background‑subtracted filament profiles plot/ → Pre‑run outputs (see below) ● Requirements • Python 3 (3.8–3.11) with numpy, scipy, matplotlib, pandas • Ghostscript (gs) for PDF merging Install dependencies: pip install numpy scipy matplotlib pandas ● Usage Step 1: python3 initial_profile_selector_ValleyPeakDetector.py Step 2: python3 analytic_profile_fitter.py --truncation-level 0.15 --no-log-space `--truncation-level 0.15`: trim profiles below 15 % of the crest value. `--no-log-space`: fit in linear space. The code is fully configurable through command‑line arguments; run `python3 analytic_profile_fitter.py --help` for a complete list of options. The code is general; edit REGION, distance, and skeleton_ids at the top of each script to use your own data. ● Pre‑run Outputs (in scale0216/plot/ and parent directory) The repository already contains the complete results of both processing steps for the Taurus example. From Step 1 (initial profile selection): initial_Taurus_scale0216_goods.pdf → merged PDF of all segments with good left or right profiles merged PDF of all segments with good left or right profiles (selection based purely on measured profile features; no model fitting is used in this step) scale0216/plot/initial_Taurus_scale0216_bad_profiles.pdf → merged PDF of rejected profiles scale0216/plot/truncation_pointsscale0216.txt → detected truncation points From Step 2 (geometric fitting): initial_Geometric_fit_results_scale0216.txt → all fits final_Geometric_fit_results_scale0216.txt → only good-quality fits initial_Taurus_Analytical_Geometric_Truncation_merged_scale0216.pdf → fitted profiles of all segments final_Taurus_Analytical_Geometric_Truncation_merged_scale0216.pdf → fitted profiles of good segments only Diagnostic plots: fitting_quality_plots/ → R² vs noise, matrix condition, number of points, etc. gamma_diagonal_plots/ → γ diagonal element vs γ value, γ relative error gamma_parameter_plots/ → γ vs physical parameters (R, H, h, ϵ, contrast, …) Detailed logs: log_files/ → timestamped log files with full parameter trace and fitting diagnostics ● Citation Please cite the two companion papers listed above if you use this code or derived data. ● License MIT License – free for academic and commercial use with proper attribution.
Publication details
- Journal / source
- Zenodo (CERN European Organization for Nuclear Research)
- Publication date
- 19 May 2026