Package root: /home/mariodamore/Documents/work/MESSENGER/MASCS_gn_dlr_processed/healpyxel
Test data: /home/mariodamore/Documents/work/MESSENGER/MASCS_gn_dlr_processed/healpyxel/test_data
Available test files:
Batches: 10 files
Samples: 3 files
Validation: 2 files
Migration Steps
1. Create Core Utilities (00_core.ipynb)
Extract common functions used across multiple modules: - HEALPix validation - Statistics functions (MAD, robust_std) - File I/O utilities - Logging setup
2. Convert Scripts to Notebooks
For each script (healpix_*.py), create corresponding notebook:
Read the script to understand structure
Create notebook with appropriate number
Add markdown cells explaining functionality
Split code into cells by logical sections
Add #| export directive to cells that should be in the module
Add tests as assert statements in separate cells
Add examples showing how to use the functions
3. nbdev Directives
Key directives to use in cells:
#| default_exp module_name # Define which module this nb creates#| export # Export this cell to the module#| hide # Hide this cell from docs#| echo: false # Don't show code in docs
import pandas as pdfrom pathlib import Path# Load small sample for quick testingsample_file = test_data_dir /'samples'/'sample_5k.parquet'if sample_file.exists(): df = pd.read_parquet(sample_file)print(f"Loaded {len(df):,} observations")print(f"Columns: {len(df.columns)}")print(f"\nSpectral columns:") spectral_cols = [col for col in df.columns if col.startswith('r') and col[1:4].isdigit()]print(f" {spectral_cols}")else:print(f"⚠️ Test file not found: {sample_file}")
Let’s create the core utilities notebook (00_core.ipynb) first:
# This will be done manually in Jupyter# See the notebook 00_core.ipynb for the templateprint("✓ Ready to create notebooks!")print("\nNext: Open Jupyter and create 00_core.ipynb")
✓ Ready to create notebooks!
Next: Open Jupyter and create 00_core.ipynb
Installation for Development
Make sure you have the package installed in editable mode:
cd healpyxelpip install -e".[dev,tdigest,duckdb]"nbdev_install_hooks