Skip to content

anibal-art/rubin_lightcurves

Repository files navigation

Rubin Microlensing Light Curves

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} $$.


Table of Contents


Features

  • 🔭 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

Installation

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 pyarrow

Rubin 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().


Configuration

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_type are 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: true to 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 (uppercase Y). The loader maps TRILEGAL umag→u, …, ymag→Y.


Run

python main.py

On first use you’ll be prompted for your Astro Data Lab credentials (the login runs only in the parent process; workers never prompt).


Models

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)
  • 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"
  • Planetary systems (star+planet)

    • Config: "model": "USBL", "system_type": "Planet_system"
    • Includes finite source and parallax
  • Binary star systems (star+star)

    • Config: "model": "USBL", "system_type": "Binary_stars"
    • Includes finite source and parallax

Parallax is included by default for these models.


Light Curve Filtering Flags

During the photometric filtering step, each light curve point is evaluated against two conditions:

  1. Saturation check — the point must not be saturated.
  2. 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.

How It Works

  1. Query TRILEGAL via Astro Data Lab within (ra, dec, radius), limited by Ds_max. Rubin-band mags (u, g, r, i, z, y) are retrieved.
  2. 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} ).
  3. Rubin cadence: rubin_sim.maf supplies visit times and 5σ depths using the latest baseline.
  4. Photometric errors: computed with calc_mag_error_m5 (Ivezić+ 2019 model).
  5. Simulate microlensing using pyLIMA (FSPL/PSPL/USBL + parallax).
  6. Quality cuts: ensure sufficient coverage and variability; events passing cuts are saved to path_save.

Parallel Execution

  • 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 via SLURM_CPUS_PER_TASK).

References


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors