Tools to simulate Rubin Observatory microlensing light curves.
The code uses rubin_sim for cadence & photometry, TRILEGAL (via Astro Data Lab) for stellar populations, and pyLIMA for microlensing light-curve generation. The focus is on producing realistic light curves, not on population-level inference; e.g., we use uniform mass distributions and associate TRILEGAL source proper motions with foreground lenses along the same line of sight to obtain
$$\mu_{\rm rel} $$ .
- Features
- Installation
- Configuration
- Run
- Models
- How It Works
- Parallel Execution
- Troubleshooting
- References
- License
- Acknowledgements
- 🔭 Rubin cadence from the latest baseline via
rubin_sim.maf - 📈 Photometric errors using the LSST model (Ivezić et al. 2019; DOI: 10.3847/1538-4357/ab042c)
- 🌌 TRILEGAL star selection via Astro Data Lab (account required; P. Dal Tio et al. 2022; DOI: 10.3847/1538-4365/ac7be6)
- ✨ Microlensing models with pyLIMA:
- FSPL (finite-source point lens) — free-floating planets (FFP)
- PSPL (point-source point lens) — stellar lenses (e.g., BH)
- USBL (uniform-source binary lens) — planetary systems (finite-source + parallax)
- 🧭 Parallax included by default
- ⚙️ Parallel runner (process pool) that scales: each child loads the TRILEGAL table once (Parquet), avoiding per-task pickling
Python 3.9+ recommended.
# Create & activate an environment (example with conda)
conda create -n rubin-ml python=3.10
conda activate rubin-ml
# Core deps
pip install pyLIMA astropy numpy pandas matplotlib
pip install rubin-sim
scheduler_download_data
rs_download_data
# Astro Data Lab client (provides the `dl` module)
pip install --ignore-installed --no-cache-dir astro-datalab
# For fast Parquet I/O used by the parallel runner
pip install pyarrowRubin throughputs/baseline
The code expects Rubin throughputs under:
~/rubin_sim_data/throughputs/baseline/total_{u,g,r,i,z,y}.dat
and uses the latest Opsim baseline via rubin_sim.data.get_baseline().
Edit config_file.json:
{
"model": "PSPL",
"system_type": "BH",
"path_save": "/home/USER/light_curve_rubin_test/",
"ra": 266,
"dec": -29.0,
"radius": 0.1,
"N": 50,
"description": "test",
"t0_range": [2460413.013828608, 2463335.01383],
"Ds_max": 8000,
"run_parallel": true,
"N_tr": 8
}model/system_typeare paired (see Models).t0_range(JD) sets the window to draw event peaks (t_0). If "t0_range": false is set, then time t0 is randomly drawn between the 1st and 99th percentiles of the time stamps provided for the OpSim given the line of sight (ra,dec) introduced. Extended by half the Einstein crossing time on either side to allow for values slightly outside the observed data range.radius(deg) is the cone search around(ra, dec)for TRILEGAL sources.Ds_max(pc) filters by distance modulus.run_parallel:trueto use the process pool runner.N_tr: number of worker processes (optional; can also be detected from Slurm).
Note: The simulator expects band keys
u,g,r,i,z,Y(uppercaseY). The loader maps TRILEGALumag→u, …,ymag→Y.
python main.pyOn first use you’ll be prompted for your Astro Data Lab credentials (the login runs only in the parent process; workers never prompt).
we compute the parameters using uniform distributions for the mass of the lens.
-
Free-floating planets (FFP)
- Config:
"model": "FSPL", "system_type": "FFP" -
$M_L = [0.1 M_{\oplus}, 13 M_{jup}]$ (this will be the range for planetary mass in the following binary models) - Finite-source effects included (small Einstein radii)
- Config:
-
Stellar lenses (e.g., BH)
-
$M_L = [1 M_{\odot}, 120 M_{\odot}]$ (this will be the range for stellar mass in the following binary models)- Config:
"model": "PSPL", "system_type": "BH"
- Config:
-
Planetary systems (star+planet)
- Config:
"model": "USBL", "system_type": "Planet_system" - Includes finite source and parallax
- Config:
-
Binary star systems (star+star)
- Config:
"model": "USBL", "system_type": "Binary_stars" - Includes finite source and parallax
- Config:
Parallax is included by default for these models.
During the photometric filtering step, each light curve point is evaluated against two conditions:
- Saturation check — the point must not be saturated.
- Depth check — the point must be brighter than the 5σ limiting magnitude.
The results are stored as boolean flags in the light curve DataFrame:
| Flag | Condition | Description |
|---|---|---|
sat_ok |
mag − err_mag > mag_sat[fil] |
True if the point is not saturated (1σ fainter than the saturation limit). |
depth_ok |
mag + err_mag < m5 |
True if the point is brighter than the 5σ limiting magnitude. |
pass_filter |
sat_ok AND depth_ok |
True only if both conditions are satisfied. Used to select “good” points. |
These flags make it possible to retain all light curve data while tagging points that pass or fail quality checks, which is useful for diagnostics and later selection.
- Query TRILEGAL via Astro Data Lab within
(ra, dec, radius), limited byDs_max. Rubin-band mags (u, g, r, i, z, y) are retrieved. - Build source–lens pairs: associate distant sources with nearer lenses along the line of sight and draw a relative angle to obtain ( \mu_{\rm rel} ).
- Rubin cadence:
rubin_sim.mafsupplies visit times and 5σ depths using the latest baseline. - Photometric errors: computed with
calc_mag_error_m5(Ivezić+ 2019 model). - Simulate microlensing using pyLIMA (FSPL/PSPL/USBL + parallax).
- Quality cuts: ensure sufficient coverage and variability; events passing cuts are saved to
path_save.
- Set true or false in parallel in the configuration file.
- The TRILEGAL DataFrame is written once to Parquet and loaded once per worker.
- Thread oversubscription is avoided by setting
OMP_NUM_THREADS=1,MKL_NUM_THREADS=1, etc., in each child. - Control concurrency with
N_tr(or leave it for Slurm to provide viaSLURM_CPUS_PER_TASK).
- TRILEGAL via Astro Data Lab: Piero Dal Tio et al., ApJS, DOI: 10.3847/1538-4365/ac7be6
- Rubin photometric error model: Ivezić et al. 2019, ApJ, DOI: 10.3847/1538-4357/ab042c
- pyLIMA: microlensing modeling & simulation. E. Bachelet et al 2017 AJ 154 203DOI 10.3847/1538-3881/aa911c (https://pylima.readthedocs.io/en/latest/)