Update README.md
Browse files
README.md
CHANGED
|
@@ -12,7 +12,7 @@ pipeline_tag: image-classification
|
|
| 12 |
This model predicts on 15 minutes spectrograms if they contain a burst or not, see paper:
|
| 13 |
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
```bash
|
| 18 |
pip install torch torchvision huggingface_hub ecallisto_ng
|
|
@@ -39,11 +39,11 @@ from huggingface_hub import hf_hub_download
|
|
| 39 |
from ecallisto_ng.data_download.downloader import get_ecallisto_data
|
| 40 |
from ecallisto_ng.data_processing.utils import subtract_constant_background
|
| 41 |
from ecallisto_ng.plotting.plotting import plot_spectrogram
|
|
|
|
| 42 |
import torch.nn as nn
|
| 43 |
from torchvision import models
|
| 44 |
import os
|
| 45 |
|
| 46 |
-
|
| 47 |
# ============================================================================
|
| 48 |
# Model Definition
|
| 49 |
# ============================================================================
|
|
@@ -312,8 +312,6 @@ def main():
|
|
| 312 |
instrument = "Australia-ASSA_01"
|
| 313 |
|
| 314 |
print(f"Example prediction on instrument: {instrument}")
|
| 315 |
-
duration_minutes = (end_time - start_time).total_seconds() / 60
|
| 316 |
-
print(f"Time window: {start_time} to {end_time} ({duration_minutes:.0f} minutes)\n")
|
| 317 |
|
| 318 |
# Load model (downloaded and cached automatically)
|
| 319 |
model = load_flaresense_model(device=device)
|
|
@@ -322,11 +320,9 @@ def main():
|
|
| 322 |
print(f"Fetching data from e-Callisto...")
|
| 323 |
df_dict = get_ecallisto_data(start_time, end_time, instrument)
|
| 324 |
|
| 325 |
-
if instrument not in df_dict:
|
| 326 |
-
print(f"Error: No data found for instrument {instrument}")
|
| 327 |
-
return
|
| 328 |
|
| 329 |
df_spectrogram = df_dict[instrument]
|
|
|
|
| 330 |
print(f"Data shape: {df_spectrogram.shape} (time x frequency)")
|
| 331 |
print(f"Time range: {df_spectrogram.index[0]} to {df_spectrogram.index[-1]}")
|
| 332 |
print(f"Frequency range: {df_spectrogram.columns[0]:.2f} - {df_spectrogram.columns[-1]:.2f} MHz\n")
|
|
@@ -347,21 +343,12 @@ def main():
|
|
| 347 |
|
| 348 |
# Plot and save the spectrogram
|
| 349 |
print("\nGenerating spectrogram plot...")
|
| 350 |
-
df_processed = subtract_constant_background(
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
# Create output filename
|
| 354 |
-
burst_label = "burst" if burst_detected else "no_burst"
|
| 355 |
-
date_str = start_time.strftime("%Y-%m-%d_%H-%M-%S")
|
| 356 |
-
output_filename = f"{instrument}_{date_str}_{burst_label}.png"
|
| 357 |
-
output_path = os.path.join("ecallisto_ng", output_filename)
|
| 358 |
-
|
| 359 |
-
# Create directory if it doesn't exist
|
| 360 |
-
os.makedirs("ecallisto_ng", exist_ok=True)
|
| 361 |
|
| 362 |
-
#
|
| 363 |
-
fig
|
| 364 |
-
|
| 365 |
|
| 366 |
|
| 367 |
if __name__ == "__main__":
|
|
|
|
| 12 |
This model predicts on 15 minutes spectrograms if they contain a burst or not, see paper:
|
| 13 |
|
| 14 |
|
| 15 |
+
# Usage
|
| 16 |
|
| 17 |
```bash
|
| 18 |
pip install torch torchvision huggingface_hub ecallisto_ng
|
|
|
|
| 39 |
from ecallisto_ng.data_download.downloader import get_ecallisto_data
|
| 40 |
from ecallisto_ng.data_processing.utils import subtract_constant_background
|
| 41 |
from ecallisto_ng.plotting.plotting import plot_spectrogram
|
| 42 |
+
from plotly.io import show
|
| 43 |
import torch.nn as nn
|
| 44 |
from torchvision import models
|
| 45 |
import os
|
| 46 |
|
|
|
|
| 47 |
# ============================================================================
|
| 48 |
# Model Definition
|
| 49 |
# ============================================================================
|
|
|
|
| 312 |
instrument = "Australia-ASSA_01"
|
| 313 |
|
| 314 |
print(f"Example prediction on instrument: {instrument}")
|
|
|
|
|
|
|
| 315 |
|
| 316 |
# Load model (downloaded and cached automatically)
|
| 317 |
model = load_flaresense_model(device=device)
|
|
|
|
| 320 |
print(f"Fetching data from e-Callisto...")
|
| 321 |
df_dict = get_ecallisto_data(start_time, end_time, instrument)
|
| 322 |
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
df_spectrogram = df_dict[instrument]
|
| 325 |
+
|
| 326 |
print(f"Data shape: {df_spectrogram.shape} (time x frequency)")
|
| 327 |
print(f"Time range: {df_spectrogram.index[0]} to {df_spectrogram.index[-1]}")
|
| 328 |
print(f"Frequency range: {df_spectrogram.columns[0]:.2f} - {df_spectrogram.columns[-1]:.2f} MHz\n")
|
|
|
|
| 343 |
|
| 344 |
# Plot and save the spectrogram
|
| 345 |
print("\nGenerating spectrogram plot...")
|
| 346 |
+
df_processed = subtract_constant_background(df_dict[instrument])
|
| 347 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
|
| 349 |
+
# Show the plot
|
| 350 |
+
fig = plot_spectrogram(df_processed)
|
| 351 |
+
show(fig)
|
| 352 |
|
| 353 |
|
| 354 |
if __name__ == "__main__":
|