How yeh-tc/python_project-thermal_displacement works
Project type and purpose
• This is a scientific data-processing pipeline implemented in Python.
• Its goal is to calculate “thermal displacement by marine heatwaves” using NOAA OISST (sea-surface temperature) data.
File structure
Top-level Python scripts correspond to discrete pipeline stages:
• 00_download_data.py – Ingest raw OISST data from NOAA
• 01_calculate_monthly_average.py – Compute monthly climatology
• apply_oisst_masks.py – Apply spatial masks (land/sea, regions)
• 02_make_mask.py – Create custom masks (e.g., marine heatwave domains)
• 03_calculate_an.py – Calculate anomalies relative to climatology
• 04_defineheatwaves.py – Identify marine heatwave events
• update_monthly.py – Update monthly summaries with new data
• 05_oisst_distance.py – Compute distance metrics from heatwave centroids
• 06_thermal_displacement.py – Derive final thermal displacement statistics
Configuration occurs implicitly via script defaults or command-line arguments; there are no separate config files.
Key insights from the README
• Data source: daily OISST v2.1 from NOAA
• Methodology follows Jacox et al. (2020)
• Pure Python implementation (likely uses xarray, numpy, netCDF4 under the hood)
a. Main components
• External Data Source (NOAA OISST)
• Ingestion Module
• Preprocessing Module
• Analysis Module
• Computation Module
• Data Store (intermediate NetCDF/CSV outputs)
• Final Output / Reporting
b. Relationships & data flow
1. External Data Source → (00_download_data.py) → Raw Data Store
2. Raw Data Store → (01_calculate_monthly_average.py) → Climatology Store
3. Raw Data Store + Climatology Store → (apply_oisst_masks.py & 02_make_mask.py) → Masked Data Store
4. Masked Data Store + Climatology Store → (03_calculate_an.py) → Anomaly Store
5. Anomaly Store → (04_defineheatwaves.py) → Heatwave Event Store
6. Heatwave Event Store → (05_oisst_distance.py) → Distance Metrics Store
7. Distance Metrics Store → (06_thermal_displacement.py) → Final Results
c. Architectural patterns & design principles
• Pipeline pattern: each script is a stage that reads inputs and emits outputs
• Single responsibility per script (modularity)
• Stateless processing: each stage writes to disk and can be re-run independently
• Data provenance: intermediate files document each step
d. Technologies & libraries
• Python 3.x
• xarray / netCDF4 for multi-dimensional data
• numpy / pandas for array and tabular operations
• Possible use of Dask for parallelization (if data volumes demand it)
Final advice
• Every script as its own component to reflect the pipeline’s modularity.
• Intermediate data stores clearly; these are critical for reproducing results.