Upload README.md
Browse files
README.md
CHANGED
|
@@ -13,6 +13,27 @@ configs:
|
|
| 13 |
|
| 14 |
The machine learning tier data is provided as a set of normalized tables in Parquet format: **RMDC26_ML_Data_obs.parquet**, **RMDC26_ML_Data_meta.parquet**, and **RMDC26_ML_Data_epoch.parquet**.
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
## Tables
|
| 17 |
|
| 18 |
### 1. Observations Table (`_obs.parquet`)
|
|
@@ -35,20 +56,20 @@ Contains the "ground truth" and physical parameters for each event.
|
|
| 35 |
| :--- | :--- | :--- |
|
| 36 |
| `name` | string | Unique event identifier (e.g., `RMDC26_XXXXXX`). |
|
| 37 |
| `event_id` | int64 | Integer ID matching the observations table. |
|
| 38 |
-
| `sim_label` | string | Simulation category (e.g., `
|
| 39 |
| `SubRun` | float64 | Sub-run identifier. |
|
| 40 |
| `Field` | float64 | Field identifier. |
|
| 41 |
| `EventID` | float64 | Event ID. |
|
| 42 |
| `final_weight` | float64 | Population weight for the event. |
|
| 43 |
-
| `ObsGroup_0_chi2` | float64 |
|
| 44 |
| `t0lens1` | float64 | Time of closest approach for the primary lens. |
|
| 45 |
| `tE_ref` | float64 | Einstein timescale (reference frame). |
|
| 46 |
| `tE_helio` | float64 | Einstein timescale (heliocentric frame). |
|
| 47 |
| `u0lens1` | float64 | Impact parameter. |
|
| 48 |
| `rho` | float64 | Normalized source radius. |
|
| 49 |
| `piE` | float64 | Microlens parallax magnitude. |
|
| 50 |
-
| `piEE` | float64 | Parallax-East term. |
|
| 51 |
-
| `piEN` | float64 | Parallax-North term. |
|
| 52 |
| `piEll` | float64 | Parallax-parallel term. |
|
| 53 |
| `piErp` | float64 | Parallax-perpendicular term. |
|
| 54 |
| `rE` | float64 | Einstein radius. |
|
|
@@ -124,9 +145,9 @@ Contains unique spatio-temporal definitions for every observation epoch.
|
|
| 124 |
|
| 125 |
**Event Complexity:**
|
| 126 |
- There are three simulations included in this dataset:
|
| 127 |
-
- `
|
| 128 |
-
- `
|
| 129 |
-
- `
|
| 130 |
- Note that not all lens and sources are neccesarily involved in the microlensing event. `ObsGroup_0_chi2` > 160 indicates that an anomaly may be present in the light curve.
|
| 131 |
|
| 132 |
**Dataset Structure:**
|
|
@@ -135,3 +156,299 @@ Contains unique spatio-temporal definitions for every observation epoch.
|
|
| 135 |
|
| 136 |
**Disclaimer:** This dataset is intended for testing and development purposes and should be used with the understanding of the biases inherent in the simulation sampling.
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
The machine learning tier data is provided as a set of normalized tables in Parquet format: **RMDC26_ML_Data_obs.parquet**, **RMDC26_ML_Data_meta.parquet**, and **RMDC26_ML_Data_epoch.parquet**.
|
| 15 |
|
| 16 |
+
## Entity-Relationship Diagram
|
| 17 |
+
|
| 18 |
+
```
|
| 19 |
+
┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐
|
| 20 |
+
│ metadata │ │ observations │ │ epochs │
|
| 21 |
+
├───────────────────┤ ├───────────────────┤ ├───────────────────┤
|
| 22 |
+
│ event_id (PK) │◄───────├ event_id (FK) │ ┌──►│ epoch_id (PK) │
|
| 23 |
+
│ name │ │ epoch_id (FK) ────┼────┘ │ bjd │
|
| 24 |
+
│ sim_label │ │ filt │ │ obs_x │
|
| 25 |
+
│ tE_helio │ │ flux_uJy │ │ obs_y │
|
| 26 |
+
│ u0lens1 │ │ flux_err_uJy │ │ obs_z │
|
| 27 |
+
│ …(physical params)│ │ true_flux_uJy │ └───────────────────┘
|
| 28 |
+
└───────────────────┘ │ saturation_flag │
|
| 29 |
+
└───────────────────┘
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
**Relationships:**
|
| 33 |
+
- **observations → metadata**: many-to-one on `event_id` (each event has one metadata record)
|
| 34 |
+
- **observations → epochs**: many-to-one on `epoch_id` (each epoch has many observations)
|
| 35 |
+
- To reconstruct a full lightcurve: join all three tables on `event_id` and `epoch_id`
|
| 36 |
+
|
| 37 |
## Tables
|
| 38 |
|
| 39 |
### 1. Observations Table (`_obs.parquet`)
|
|
|
|
| 56 |
| :--- | :--- | :--- |
|
| 57 |
| `name` | string | Unique event identifier (e.g., `RMDC26_XXXXXX`). |
|
| 58 |
| `event_id` | int64 | Integer ID matching the observations table. |
|
| 59 |
+
| `sim_label` | string | Simulation category (e.g., `RMDC26_1S1L_ML`). |
|
| 60 |
| `SubRun` | float64 | Sub-run identifier. |
|
| 61 |
| `Field` | float64 | Field identifier. |
|
| 62 |
| `EventID` | float64 | Event ID. |
|
| 63 |
| `final_weight` | float64 | Population weight for the event. |
|
| 64 |
+
| `ObsGroup_0_chi2` | float64 | Delta ($\chi^2$) between the best fitting single lens model and the true model. |
|
| 65 |
| `t0lens1` | float64 | Time of closest approach for the primary lens. |
|
| 66 |
| `tE_ref` | float64 | Einstein timescale (reference frame). |
|
| 67 |
| `tE_helio` | float64 | Einstein timescale (heliocentric frame). |
|
| 68 |
| `u0lens1` | float64 | Impact parameter. |
|
| 69 |
| `rho` | float64 | Normalized source radius. |
|
| 70 |
| `piE` | float64 | Microlens parallax magnitude. |
|
| 71 |
+
| `piEE` | float64 | Parallax-East term. In equitorial co-ordinates. |
|
| 72 |
+
| `piEN` | float64 | Parallax-North term. In equitorial co-ordinates.|
|
| 73 |
| `piEll` | float64 | Parallax-parallel term. |
|
| 74 |
| `piErp` | float64 | Parallax-perpendicular term. |
|
| 75 |
| `rE` | float64 | Einstein radius. |
|
|
|
|
| 145 |
|
| 146 |
**Event Complexity:**
|
| 147 |
- There are three simulations included in this dataset:
|
| 148 |
+
- `RMDC26_1S1L_ML`: Single lens and single source events.
|
| 149 |
+
- `RMDC26_1S2L_ML`: One star - one planet lens and single source events.
|
| 150 |
+
- `RMDC26_2S2L_ML`: One star - one planet lens and binary source events.
|
| 151 |
- Note that not all lens and sources are neccesarily involved in the microlensing event. `ObsGroup_0_chi2` > 160 indicates that an anomaly may be present in the light curve.
|
| 152 |
|
| 153 |
**Dataset Structure:**
|
|
|
|
| 156 |
|
| 157 |
**Disclaimer:** This dataset is intended for testing and development purposes and should be used with the understanding of the biases inherent in the simulation sampling.
|
| 158 |
|
| 159 |
+
## Code Examples
|
| 160 |
+
|
| 161 |
+
The dataset is hosted on Hugging Face as `RGES-PIT/MachineLearning` with three configs: `observations`, `metadata`, and `epochs`. Below are examples for loading and working with the data.
|
| 162 |
+
|
| 163 |
+
### Prerequisites (DuckDB method)
|
| 164 |
+
|
| 165 |
+
```bash
|
| 166 |
+
pip install duckdb huggingface_hub
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
Set your Hugging Face token (get one at https://huggingface.co/settings/tokens):
|
| 170 |
+
|
| 171 |
+
```bash
|
| 172 |
+
export HF_TOKEN="hf_your_token_here"
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
### 1. Query with DuckDB (SQL — only downloads what you need)
|
| 176 |
+
|
| 177 |
+
DuckDB has native support for the `hf://` protocol, so you can run full SQL queries directly against your Hugging Face repo without downloading the entire dataset:
|
| 178 |
+
|
| 179 |
+
```python
|
| 180 |
+
import duckdb
|
| 181 |
+
from huggingface_hub import HfFileSystem
|
| 182 |
+
|
| 183 |
+
# Register the Hugging Face filesystem
|
| 184 |
+
duckdb.register_filesystem(HfFileSystem())
|
| 185 |
+
|
| 186 |
+
# Count unique events (not rows — each event has many observations)
|
| 187 |
+
result = duckdb.sql("""
|
| 188 |
+
SELECT COUNT(DISTINCT event_id) AS n_events
|
| 189 |
+
FROM 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_obs.parquet'
|
| 190 |
+
""").fetchone()
|
| 191 |
+
print(f"Unique events: {result[0]:,}")
|
| 192 |
+
|
| 193 |
+
# Aggregate — only downloads the columns you need
|
| 194 |
+
stats = duckdb.sql("""
|
| 195 |
+
SELECT
|
| 196 |
+
COUNT(*) AS n_obs,
|
| 197 |
+
AVG(flux_uJy) AS mean_flux,
|
| 198 |
+
AVG(true_flux_uJy) AS mean_true_flux
|
| 199 |
+
FROM 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_obs.parquet'
|
| 200 |
+
""").fetchone()
|
| 201 |
+
print(f"{stats[0]:,} total observations")
|
| 202 |
+
print(f" Mean measured flux : {stats[1]:.2f} μJy")
|
| 203 |
+
print(f" Mean true flux : {stats[2]:.2f} μJy")
|
| 204 |
+
|
| 205 |
+
# Join observations with metadata using SQL
|
| 206 |
+
joined = duckdb.sql("""
|
| 207 |
+
SELECT
|
| 208 |
+
o.event_id,
|
| 209 |
+
e.bjd,
|
| 210 |
+
o.filt,
|
| 211 |
+
o.flux_uJy,
|
| 212 |
+
m.sim_label,
|
| 213 |
+
m.tE_helio
|
| 214 |
+
FROM 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_obs.parquet' o
|
| 215 |
+
JOIN 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_epoch.parquet' e
|
| 216 |
+
ON o.epoch_id = e.epoch_id
|
| 217 |
+
JOIN 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_meta.parquet' m
|
| 218 |
+
ON o.event_id = m.event_id
|
| 219 |
+
WHERE m.sim_label = 'RMDC26_1S1L_ML'
|
| 220 |
+
AND o.filt = 'F146'
|
| 221 |
+
ORDER BY o.event_id, e.bjd
|
| 222 |
+
""").fetchall()
|
| 223 |
+
print(f"{len(joined)} F146 observations for 1S1L events")
|
| 224 |
+
```
|
| 225 |
+
|
| 226 |
+
**Expected output:**
|
| 227 |
+
```text
|
| 228 |
+
Unique events: 610
|
| 229 |
+
30,187,680 total observations
|
| 230 |
+
Mean measured flux : 50.74 μJy
|
| 231 |
+
Mean true flux : 50.74 μJy
|
| 232 |
+
11,761,464 F146 observations for 1S1L events
|
| 233 |
+
```
|
| 234 |
+
|
| 235 |
+
> **Tip:** If your dataset is private or gated, make sure `HF_TOKEN` is set — `HfFileSystem` will automatically authenticate.
|
| 236 |
+
|
| 237 |
+
### 2. Load all three tables as pandas DataFrames
|
| 238 |
+
|
| 239 |
+
```python
|
| 240 |
+
from datasets import load_dataset
|
| 241 |
+
import os
|
| 242 |
+
|
| 243 |
+
token = os.environ.get("HF_TOKEN")
|
| 244 |
+
assert token, "Set HF_TOKEN environment variable first"
|
| 245 |
+
|
| 246 |
+
dataset_name = "RGES-PIT/MachineLearning"
|
| 247 |
+
|
| 248 |
+
obs = load_dataset(dataset_name, "observations", split="train")
|
| 249 |
+
meta = load_dataset(dataset_name, "metadata", split="train")
|
| 250 |
+
epochs = load_dataset(dataset_name, "epochs", split="train")
|
| 251 |
+
|
| 252 |
+
obs_df = obs.to_pandas()
|
| 253 |
+
meta_df = meta.to_pandas()
|
| 254 |
+
epochs_df = epochs.to_pandas()
|
| 255 |
+
|
| 256 |
+
print(f"Observations : {obs_df.shape[0]:,} rows")
|
| 257 |
+
print(f"Metadata : {meta_df.shape[0]:,} rows")
|
| 258 |
+
print(f"Epochs : {epochs_df.shape[0]:,} rows")
|
| 259 |
+
```
|
| 260 |
+
|
| 261 |
+
**Expected output:**
|
| 262 |
+
```text
|
| 263 |
+
Observations : 30,187,680 rows
|
| 264 |
+
Metadata : 610 rows
|
| 265 |
+
Epochs : 98,973 rows
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
### 3. Query with DuckDB and return a pandas DataFrame
|
| 269 |
+
|
| 270 |
+
You can also fetch results directly as a pandas DataFrame for further analysis:
|
| 271 |
+
|
| 272 |
+
```python
|
| 273 |
+
import duckdb
|
| 274 |
+
from huggingface_hub import HfFileSystem
|
| 275 |
+
|
| 276 |
+
duckdb.register_filesystem(HfFileSystem())
|
| 277 |
+
|
| 278 |
+
df = duckdb.sql("""
|
| 279 |
+
SELECT
|
| 280 |
+
o.event_id,
|
| 281 |
+
e.bjd,
|
| 282 |
+
o.filt,
|
| 283 |
+
o.flux_uJy,
|
| 284 |
+
m.tE_helio,
|
| 285 |
+
m.sim_label
|
| 286 |
+
FROM 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_obs.parquet' o
|
| 287 |
+
JOIN 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_epoch.parquet' e
|
| 288 |
+
ON o.epoch_id = e.epoch_id
|
| 289 |
+
JOIN 'hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_meta.parquet' m
|
| 290 |
+
ON o.event_id = m.event_id
|
| 291 |
+
""").df()
|
| 292 |
+
|
| 293 |
+
print(f"Loaded {len(df):,} rows into pandas")
|
| 294 |
+
print(df.head())
|
| 295 |
+
```
|
| 296 |
+
|
| 297 |
+
**Expected output:**
|
| 298 |
+
```text
|
| 299 |
+
Loaded 30,187,680 rows into pandas
|
| 300 |
+
event_id bjd filt flux_uJy tE_helio sim_label
|
| 301 |
+
3000 2.461448e+06 F087 0.035214 3.553733 RMDC26_1S1L_ML
|
| 302 |
+
3000 2.461448e+06 F087 -0.234762 3.553733 RMDC26_1S1L_ML
|
| 303 |
+
3000 2.461448e+06 F087 0.042257 3.553733 RMDC26_1S1L_ML
|
| 304 |
+
3000 2.461449e+06 F087 -0.157291 3.553733 RMDC26_1S1L_ML
|
| 305 |
+
3000 2.461449e+06 F087 0.110338 3.553733 RMDC26_1S1L_ML
|
| 306 |
+
```
|
| 307 |
+
|
| 308 |
+
### Sample Light Curves
|
| 309 |
+
|
| 310 |
+
Here are normalized light curves for 9 sample events from the dataset (3 from each simulation type: 1S1L, 1S2L, 2S2L), colored by filter band. Each filter's flux is divided by its median value (per event) so all bands appear on the same relative scale — the dashed gray line marks the baseline (ratio = 1). The time axis is zoomed to t₀ ± 5·t_E.
|
| 311 |
+
|
| 312 |
+

|
| 313 |
+
|
| 314 |
+
### Prerequisites
|
| 315 |
+
|
| 316 |
+
```bash
|
| 317 |
+
pip install datasets pandas numpy matplotlib
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
### 4. Reconstruct a single event's lightcurve
|
| 321 |
+
|
| 322 |
+
```python
|
| 323 |
+
# Pick an event_id from the metadata
|
| 324 |
+
event_id = 42 # replace with actual event_id
|
| 325 |
+
|
| 326 |
+
# Merge observations with epochs to get BJD times
|
| 327 |
+
event_obs = obs_df[obs_df["event_id"] == event_id].merge(
|
| 328 |
+
epochs_df[["epoch_id", "bjd"]], on="epoch_id", how="left"
|
| 329 |
+
)
|
| 330 |
+
event_obs = event_obs.sort_values("bjd")
|
| 331 |
+
|
| 332 |
+
# Merge with metadata for simulation label and physical parameters
|
| 333 |
+
event_meta = meta_df[meta_df["event_id"] == event_id].iloc[0]
|
| 334 |
+
|
| 335 |
+
print(f"Event {event_id}: {event_meta['name']} ({event_meta['sim_label']})")
|
| 336 |
+
print(f" {len(event_obs)} observations")
|
| 337 |
+
print(f" Einstein timescale tE_helio = {event_meta['tE_helio']:.2f} days")
|
| 338 |
+
|
| 339 |
+
# Plot the lightcurve
|
| 340 |
+
import matplotlib.pyplot as plt
|
| 341 |
+
|
| 342 |
+
colors = {"F087": "#e69f00", "F146": "#56b4e9", "F213": "#009e73"}
|
| 343 |
+
for filt, grp in event_obs.groupby("filt"):
|
| 344 |
+
plt.plot(grp["bjd"] - grp["bjd"].min(), grp["flux_uJy"], "o", markersize=3,
|
| 345 |
+
color=colors[filt], label=filt)
|
| 346 |
+
|
| 347 |
+
plt.xlabel("Time (days)")
|
| 348 |
+
plt.ylabel("Flux (μJy)")
|
| 349 |
+
plt.legend()
|
| 350 |
+
plt.yscale("log")
|
| 351 |
+
plt.show()
|
| 352 |
+
```
|
| 353 |
+
|
| 354 |
+
**Expected output:**
|
| 355 |
+
```text
|
| 356 |
+
Event 3000: RMDC26_003000 (RMDC26_1S1L_ML)
|
| 357 |
+
49,488 observations
|
| 358 |
+
Einstein timescale tE_helio = 3.55 days
|
| 359 |
+
```
|
| 360 |
+
*(In addition to the console printout, this generates a matplotlib plot window displaying a log-scale flux vs. time lightcurve, with data points colored by filter band.)*
|
| 361 |
+
|
| 362 |
+
### 5. Filter events by simulation type and anomaly presence
|
| 363 |
+
|
| 364 |
+
```python
|
| 365 |
+
# ObsGroup_0_chi2 is the delta-chi2 between the best single-lens fit and the true model.
|
| 366 |
+
# A value <= 160 indicates a clean, non-anomalous single-lens event (good single-lens fit).
|
| 367 |
+
# A value > 160 indicates a significant anomaly, such as a planetary or binary perturbation.
|
| 368 |
+
good_events = meta_df[
|
| 369 |
+
(meta_df["sim_label"] == "RMDC26_1S1L_ML") &
|
| 370 |
+
(meta_df["ObsGroup_0_chi2"] <= 160)
|
| 371 |
+
]
|
| 372 |
+
|
| 373 |
+
print(f"{len(good_events)} single-lens events with χ² ≤ 160")
|
| 374 |
+
|
| 375 |
+
# Get all observations for these events
|
| 376 |
+
good_obs = obs_df[obs_df["event_id"].isin(good_events["event_id"])]
|
| 377 |
+
print(f"{len(good_obs)} corresponding observations")
|
| 378 |
+
```
|
| 379 |
+
|
| 380 |
+
**Expected output:**
|
| 381 |
+
```text
|
| 382 |
+
48 single-lens events with χ² ≤ 160
|
| 383 |
+
2,375,424 corresponding observations
|
| 384 |
+
```
|
| 385 |
+
|
| 386 |
+
### 6. Subsample for faster exploration
|
| 387 |
+
|
| 388 |
+
```python
|
| 389 |
+
# Load only a subset of observations (useful for quick prototyping)
|
| 390 |
+
obs_subset = load_dataset(dataset_name, "observations", split="train[:100000]").to_pandas()
|
| 391 |
+
print(f"Subsampled to {len(obs_subset):,} observations")
|
| 392 |
+
```
|
| 393 |
+
|
| 394 |
+
**Expected output:**
|
| 395 |
+
```text
|
| 396 |
+
Subsampled to 100,000 observations
|
| 397 |
+
```
|
| 398 |
+
|
| 399 |
+
### 7. Access ground-truth parameters for an event
|
| 400 |
+
|
| 401 |
+
```python
|
| 402 |
+
# Get all physical parameters for a single event
|
| 403 |
+
event = meta_df[meta_df["event_id"] == 100].iloc[0]
|
| 404 |
+
|
| 405 |
+
print("Physical parameters:")
|
| 406 |
+
print(f" tE_helio : {event['tE_helio']:.3f} days")
|
| 407 |
+
print(f" u0lens1 : {event['u0lens1']:.3f}")
|
| 408 |
+
print(f" Lens_Mass : {event['Lens_Mass']:.3f} M☉")
|
| 409 |
+
print(f" Lens_Dist : {event['Lens_Dist']:.1f} kpc")
|
| 410 |
+
val = event["Source_Is_Binary"]
|
| 411 |
+
print(f" Source_Is_Binary: {0 if pd.isna(val) else int(val)}")
|
| 412 |
+
print(f" χ² : {event['ObsGroup_0_chi2']:.1f}")
|
| 413 |
+
```
|
| 414 |
+
|
| 415 |
+
**Expected output:**
|
| 416 |
+
```text
|
| 417 |
+
Physical parameters:
|
| 418 |
+
tE_helio : 3.554 days
|
| 419 |
+
u0lens1 : -1.830
|
| 420 |
+
Lens_Mass : 0.004 M☉
|
| 421 |
+
Lens_Dist : 8.3 kpc
|
| 422 |
+
Source_Is_Binary: 0
|
| 423 |
+
χ² : 66.7
|
| 424 |
+
```
|
| 425 |
+
|
| 426 |
+
### 8. In the Browser (SQL Console)
|
| 427 |
+
|
| 428 |
+
For quick exploratory data analysis without writing any code:
|
| 429 |
+
|
| 430 |
+
1. Go to [RGES-PIT/MachineLearning](https://huggingface.co/datasets/RGES-PIT/MachineLearning)
|
| 431 |
+
2. Click the **Dataset Viewer** tab
|
| 432 |
+
3. Click the **SQL Console** button
|
| 433 |
+
|
| 434 |
+
This runs DuckDB WASM entirely in your browser — type SQL directly against the remote Parquet files. Select a config from the dropdown (e.g. `observations`) and query using the config name:
|
| 435 |
+
|
| 436 |
+
```sql
|
| 437 |
+
SELECT
|
| 438 |
+
COUNT(DISTINCT event_id) AS n_events,
|
| 439 |
+
COUNT(*) AS n_observations,
|
| 440 |
+
AVG(flux_uJy) AS avg_flux,
|
| 441 |
+
AVG(true_flux_uJy) AS avg_true_flux
|
| 442 |
+
FROM observations
|
| 443 |
+
```
|
| 444 |
+
|
| 445 |
+
**Expected output table:**
|
| 446 |
+
```text
|
| 447 |
+
┌──────────┬──────────────-┬─────────────┬─────────────────┐
|
| 448 |
+
│ n_events │ n_observations│ avg_flux │ avg_true_flux │
|
| 449 |
+
├──────────┼──────────────-┼─────────────┼─────────────────┤
|
| 450 |
+
│ 610 │ 30,187,680 │ 50.738523 │ 50.738970 │
|
| 451 |
+
└──────────┴──────────────-┴─────────────┴─────────────────┘
|
| 452 |
+
```
|
| 453 |
+
|
| 454 |
+
|