Datasets:

Modalities:
Tabular
Text
DOI:
License:
dylannpaterson commited on
Commit
3fb9e62
·
verified ·
1 Parent(s): 45f0ff6

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +96 -222
  2. lightcurves_sample.png +3 -0
README.md CHANGED
@@ -11,6 +11,8 @@ configs:
11
 
12
  # Machine Learning Tier
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
@@ -50,7 +52,7 @@ Contains the primary time-series data for all events.
50
  | `saturation_flag` | float64 | Saturation flag: 0 = unsaturated, 1 = saturated. |
51
 
52
  ### 2. Metadata Table (`_meta.parquet`)
53
- Contains the "ground truth" and physical parameters for each event.
54
 
55
  | Column Name | Data Type | Description |
56
  | :--- | :--- | :--- |
@@ -61,15 +63,16 @@ Contains the "ground truth" and physical parameters for each event.
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. |
@@ -129,7 +132,7 @@ Contains the "ground truth" and physical parameters for each event.
129
  | `extinction_F213` | float64 | Extinction in F213. |
130
 
131
  ### 3. Epochs Table (`_epoch.parquet`)
132
- Contains unique spatio-temporal definitions for every observation epoch.
133
 
134
  | Column Name | Data Type | Description |
135
  | :--- | :--- | :--- |
@@ -141,14 +144,23 @@ Contains unique spatio-temporal definitions for every observation epoch.
141
 
142
  ## Simulation Details & Disclaimer
143
 
144
- **Simulation Engine:** All events have been generated using **GULLS**. More information is available at [gulls-microlensing.github.io](https://gulls-microlensing.github.io/).
 
 
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:**
154
  - The dataset is split into **observations**, **metadata**, and **epochs**.
@@ -156,85 +168,31 @@ Contains unique spatio-temporal definitions for every observation epoch.
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
@@ -245,110 +203,59 @@ 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
- ![Sample Light Curves](lightcurves_sample.png)
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:**
@@ -357,98 +264,65 @@ 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
 
 
11
 
12
  # Machine Learning Tier
13
 
14
+ This dataset is a collection of synthetic microlensing light curves designed to accurately represent the yields of microlensing events from the lifetime of the Nancy Grace Roman Space Telescope Galactic Bulge Time Domain Survey. It is intended for the training and benchmarking of machine learning models for microlensing event classification, parameter estimation, and anomaly detection.
15
+
16
  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**.
17
 
18
  ## Entity-Relationship Diagram
 
52
  | `saturation_flag` | float64 | Saturation flag: 0 = unsaturated, 1 = saturated. |
53
 
54
  ### 2. Metadata Table (`_meta.parquet`)
55
+ Contains the simulated physical parameters and lensing variables for each event.
56
 
57
  | Column Name | Data Type | Description |
58
  | :--- | :--- | :--- |
 
63
  | `Field` | float64 | Field identifier. |
64
  | `EventID` | float64 | Event ID. |
65
  | `final_weight` | float64 | Population weight for the event. |
66
+ | `ObsGroup_0_chi2` | float64 | For binary events, the $\Delta\chi^2$ between the best-fitting single-lens (PSPL) model and the true simulated model ($\chi^2_{\text{PSPL\_fit}} - \chi^2_{\text{true}}$). For single-source single-lens events, this instead stores the $\Delta\chi^2$ of the true simulated model vs a flat baseline fit ($\chi^2_{\text{flat}} - \chi^2_{\text{true}}$). |
67
+ | `is_out_of_season` | boolean | Flag indicating whether the event peak ($t_0$) falls in a seasonal gap (when Roman cannot observe the bulge). |
68
  | `t0lens1` | float64 | Time of closest approach for the primary lens. |
69
  | `tE_ref` | float64 | Einstein timescale (reference frame). |
70
  | `tE_helio` | float64 | Einstein timescale (heliocentric frame). |
71
  | `u0lens1` | float64 | Impact parameter. |
72
  | `rho` | float64 | Normalized source radius. |
73
  | `piE` | float64 | Microlens parallax magnitude. |
74
+ | `piEE` | float64 | Parallax-East term. In equatorial coordinates. |
75
+ | `piEN` | float64 | Parallax-North term. In equatorial coordinates. |
76
  | `piEll` | float64 | Parallax-parallel term. |
77
  | `piErp` | float64 | Parallax-perpendicular term. |
78
  | `rE` | float64 | Einstein radius. |
 
132
  | `extinction_F213` | float64 | Extinction in F213. |
133
 
134
  ### 3. Epochs Table (`_epoch.parquet`)
135
+ Maps each unique observation time (BJD) and corresponding telescope coordinates (X, Y, Z relative to the Solar System Barycenter) to a unique epoch ID.
136
 
137
  | Column Name | Data Type | Description |
138
  | :--- | :--- | :--- |
 
144
 
145
  ## Simulation Details & Disclaimer
146
 
147
+ **Simulation Engine:** All events have been generated using the **GULLS** simulator. More information is available at [gulls-microlensing.github.io](https://gulls-microlensing.github.io/).
148
+
149
+ **Stellar Populations:** The input stellar population catalogs used for the source and lens stars were generated using **synthpop** ([github.com/synthpop-galaxy/synthpop](https://github.com/synthpop-galaxy/synthpop)).
150
 
151
  **Event Complexity:**
152
  - There are three simulations included in this dataset:
153
  - `RMDC26_1S1L_ML`: Single lens and single source events.
154
  - `RMDC26_1S2L_ML`: One star - one planet lens and single source events.
155
+ - `RMDC26_2S2L_ML`: One star - one planet lens and potentially binary source events.
156
+ - Note that not all lenses and sources are necessarily involved in the microlensing event. `ObsGroup_0_chi2` > 160 for events from the binary lens simulations indicates that an anomaly may be present in the light curve. The anomalies may be planetary perturbations and caustic crossings, finite source effects, or parallax effects.
157
+
158
+ **Representativeness & Weighting:**
159
+ - This data set only includes potentially detectable microlensing events where the chi-squared difference between the best fit flat model and the true model is greater than 60, i.e. $$\chi^2_{\text{flat}} - \chi^2_{\text{true}} > 60$$.
160
+ - The full set of events is **not directly representative** of the raw astrophysical population due to detection significance cuts and GULLS coordinate transformations (e.g. in `croin` caustic-relative coordinates, the host star $t_0$ and $u_0$ are often transformed far outside of normal ranges or observing seasons, even though the planetary anomaly itself is actively observed in-season).
161
+ - To make the dataset more representative of the true underlying Galactic population, you can apply the population weights stored in the **`final_weight`** column directly during training and analysis, or use them to draw a resampled, less biased dataset.
162
+ - The **`is_out_of_season`** flag indicates whether the closest approach time of the primary lens (`t0lens1`) falls in a seasonal gap when the Galactic Bulge is unobservable. While the lightcurves of these events still show signature features of the microlensing event, their peak stellar magnification is not covered by observations. As a result, these events might be difficult for machine learning models to classify correctly, and you may want to filter them out depending on your specific modeling goals.
163
+
164
 
165
  **Dataset Structure:**
166
  - The dataset is split into **observations**, **metadata**, and **epochs**.
 
168
 
169
  **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.
170
 
171
+ ## Sample Light Curves
172
+
173
+ 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_0 \pm 5 \cdot t_E$.
174
+
175
+ ![Sample Light Curves](lightcurves_sample.png)
176
+
177
  ## Code Examples
178
 
179
  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.
180
 
181
+ ### Prerequisites
182
+
183
+ To load the metadata and epochs tables directly from Hugging Face, install the `datasets` and `pandas` libraries:
184
 
185
  ```bash
186
+ pip install datasets pandas pyarrow duckdb huggingface_hub
187
  ```
188
 
189
+ Set your Hugging Face access token:
190
 
191
  ```bash
192
  export HF_TOKEN="hf_your_token_here"
193
  ```
194
 
195
+ ### 1. Load the metadata and epochs tables
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  ```python
198
  from datasets import load_dataset
 
203
 
204
  dataset_name = "RGES-PIT/MachineLearning"
205
 
206
+ # Load metadata and epochs tables (which fit easily in RAM)
207
+ meta_df = load_dataset(dataset_name, "metadata", split="train", token=token).to_pandas()
208
+ epochs_df = load_dataset(dataset_name, "epochs", split="train", token=token).to_pandas()
 
 
 
 
209
 
 
210
  print(f"Metadata : {meta_df.shape[0]:,} rows")
211
  print(f"Epochs : {epochs_df.shape[0]:,} rows")
212
  ```
213
 
214
  **Expected output:**
215
  ```text
216
+ Metadata : 341,740 rows
217
+ Epochs : 98,974 rows
 
218
  ```
219
 
220
+ ### 2. Reconstruct a single event's lightcurve
221
 
222
+ Because the observations table is extremely large (~160 GB in total), loading it in full is not recommended for local machines. Instead, we use DuckDB's remote `hf://` protocol to fetch observations for a single event without downloading the entire table:
223
 
224
  ```python
225
  import duckdb
226
  from huggingface_hub import HfFileSystem
227
+ import os
228
+
229
+ token = os.environ.get("HF_TOKEN")
230
+ con = duckdb.connect()
231
+ con.register_filesystem(HfFileSystem(token=token))
232
 
233
+ obs_p = "hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_obs.parquet"
234
+ meta_p = "hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_meta.parquet"
235
+ epoch_p = "hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_epoch.parquet"
236
 
237
+ event_id = 3000
238
+
239
+ # Reconstruct a single event's lightcurve
240
+ event_obs = con.execute(f"""
241
  SELECT
242
  o.event_id,
243
+ m.name,
244
  e.bjd,
245
  o.filt,
246
  o.flux_uJy,
247
  m.tE_helio,
248
  m.sim_label
249
+ FROM '{obs_p}' o
250
+ JOIN '{epoch_p}' e ON o.epoch_id = e.epoch_id
251
+ JOIN '{meta_p}' m ON o.event_id = m.event_id
252
+ WHERE o.event_id = {event_id}
253
+ ORDER BY e.bjd
254
  """).df()
255
 
256
+ print(f"Event {event_id}: {event_obs['name'].iloc[0]} ({event_obs['sim_label'].iloc[0]})")
257
+ print(f" {len(event_obs):,} observations")
258
+ print(f" Einstein timescale tE_helio = {abs(event_obs['tE_helio'].iloc[0]):.2f} days")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  ```
260
 
261
  **Expected output:**
 
264
  49,488 observations
265
  Einstein timescale tE_helio = 3.55 days
266
  ```
 
267
 
268
+ ### 3. Filter events by metadata constraints
269
+
270
+ You can perform filtering on the metadata table first, and then fetch observations for matched events. To run this efficiently over the network without full-table scans, query observations only for the target event IDs:
271
 
272
  ```python
273
+ from datasets import load_dataset
274
+ import os
275
+ import duckdb
276
+ from huggingface_hub import HfFileSystem
277
+
278
+ token = os.environ.get("HF_TOKEN")
279
+ meta_df = load_dataset("RGES-PIT/MachineLearning", "metadata", split="train", token=token).to_pandas()
280
+
281
+ # Select low-significance single-lens events (chi2 <= 160)
282
  good_events = meta_df[
283
  (meta_df["sim_label"] == "RMDC26_1S1L_ML") &
284
  (meta_df["ObsGroup_0_chi2"] <= 160)
285
  ]
286
 
287
+ print(f"{len(good_events)} events matched filters")
 
 
 
 
 
 
 
 
 
 
 
288
 
289
+ # Query observations count for matched events via DuckDB filter pushdown
290
+ con = duckdb.connect()
291
+ con.register_filesystem(HfFileSystem(token=token))
292
+ obs_p = "hf://datasets/RGES-PIT/MachineLearning/RMDC26_ML_Data_obs.parquet"
293
 
294
+ event_ids_str = ", ".join(map(str, good_events["event_id"].tolist()))
295
+ good_obs_count = con.execute(f"SELECT COUNT(*) FROM '{obs_p}' WHERE event_id IN ({event_ids_str})").fetchone()[0]
296
+ print(f"{good_obs_count:,} corresponding observations")
 
297
  ```
298
 
299
  **Expected output:**
300
  ```text
301
+ 58307 events matched filters
302
+ 2,885,496,816 corresponding observations
303
  ```
304
 
305
+ ### 4. Sum final_weight per simulation
306
+
307
+ To verify the population representation or check the total astrophysical weights of each simulation, you can sum the `final_weight` column grouped by simulation label:
308
 
309
  ```python
310
+ # Sum weights and count events per simulation
311
+ weights_summary = meta_df.groupby("sim_label").agg(
312
+ total_weight=("final_weight", "sum"),
313
+ event_count=("final_weight", "count")
314
+ ).reset_index()
315
+
316
+ print(weights_summary.to_string(index=False))
 
 
 
 
317
  ```
318
 
319
  **Expected output:**
320
  ```text
321
+ sim_label total_weight event_count
322
+ RMDC26_1S1L_ML 59492.119963 294728
323
+ RMDC26_1S2L_ML 1490.050405 29656
324
+ RMDC26_2S2L_ML 789.135800 17356
 
 
 
325
  ```
326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
 
328
 
lightcurves_sample.png ADDED

Git LFS Details

  • SHA256: f1d60c54e4a7892b88dc6f3171fd006824d528bd0b70085293d63a91b2341003
  • Pointer size: 131 Bytes
  • Size of remote file: 528 kB