Environment Setup and Project Folder Structure¶
This lesson is the prerequisite step for all sessions in Module 1 — Observational climate pipeline.
You will install VS Code, create and activate a Python virtual environment, install all required packages, and build the canonical folder structure used throughout the workshop.
Overview¶
flowchart LR
A[Install VS Code] --> B[Create virtual environment]
B --> C[Activate environment]
C --> D[Install core packages]
D --> E[Create folder structure]
E --> F[Ready for Session 1.1 →] 1. Install VS Code¶
Visual Studio Code is the recommended IDE for this workshop.
Steps¶
- Go to https://code.visualstudio.com/download and download the Windows installer (
.exe). - Run the installer and accept the defaults.
- Launch VS Code and install the following extensions from the Extensions panel (
Ctrl+Shift+X):
| Extension | Publisher | Purpose |
|---|---|---|
| Python | Microsoft | Python language support, IntelliSense, linting |
| Jupyter | Microsoft | Run .ipynb notebooks inside VS Code |
| GitLens | GitKraken | Enhanced Git history and blame views |
Tip: Press
Ctrl+Shift+P→ "Python: Select Interpreter" to point VS Code to the virtual environment you create below.
2. Create the Virtual Environment¶
Open a terminal in the repository root (the folder containing mkdocs.yml).
This creates .venv/ in the repository root — that folder is already listed in .gitignore.
3. Activate the Virtual Environment¶
Your prompt should now show (.venv) to confirm the environment is active.
All subsequent pip install commands install only into this isolated environment.
4. Install Core Packages¶
With the environment active, install the full set of packages used across the workshop:
pip install --upgrade pip
pip install numpy pandas matplotlib cftime cf_xarray openpyxl shapely scipy requests cartopy geopandas rioxarray rasterio regionmask salem netCDF4 xarray cdsapi
Xarray note: If Xarray is not installed.
Windows note:
cartopyandrasteriosometimes need pre-built wheels.
Ifpip install cartopyfails, try:
Package roles¶
| Package | Role |
|---|---|
| numpy | Array operations, numerical base |
| pandas | Tabular data, date-range helpers |
| matplotlib | Plotting engine for all diagnostics |
| cftime | Non-standard calendar support (360-day, etc.) |
| cf_xarray | CF-convention accessors on xarray datasets |
| openpyxl | Read/write Excel files |
| shapely | Geometric operations on vector features |
| scipy | Statistics, interpolation |
| requests | Streaming HTTP downloads (CHIRPS, etc.) |
| cartopy | Map projections and coastlines |
| geopandas | GeoDataFrame for shapefiles and vector data |
| rioxarray | Raster I/O extension on top of xarray |
| rasterio | GeoTIFF and raster file I/O |
| regionmask | Country and ocean region masks on grids |
| salem | Geospatial utilities, reprojection |
| netCDF4 | NetCDF engine used by xarray |
| xarray | Labelled N-D arrays; core dataset interface |
Verify the installation¶
import numpy, pandas, matplotlib, xarray, cartopy, geopandas, rasterio
print("All core packages imported successfully ✓")
Run this in a terminal (python -c "...") or in the companion notebook.
5. Create the Project Folder Structure¶
The pipeline expects the following layout under the repository root.
Run the block below once to create every required folder:
from pathlib import Path
folders = [
# Raw observations (one sub-directory per source)
"data/raw/chirps",
# Preprocessed, QC-passed data
"data/processed/chirps",
# Static ancillary files — Ethiopia grid, land mask, shapefiles
"data/ancillary/grid_mask",
# QC diagnostic plots and reports
"reports/qc_chirps",
# Processing logs (download logs, run logs)
"reports/logs",
]
for f in folders:
Path(f).mkdir(parents=True, exist_ok=True)
print(f"Created {f}/")
print("\nFolder structure ready ✓")
Expected layout¶
vectri-seasonal/ ← repository root
│
├── data/
│ ├── raw/
│ │ └── chirps/ ← yearly CHIRPS NetCDF files (downloaded)
│ ├── processed/
│ │ └── chirps/ ← QC-passed, clipped, merged files
│ └── ancillary/
│ └── grid_mask/ ← Ethiopia land mask, target-grid definition
│
├── reports/
│ ├── qc_chirps/ ← QC diagnostic plots (PNG / HTML)
│ └── logs/ ← download & processing logs (TXT / JSON)
│
├── docs/
├── notebooks/
└── ...
Convention: Never write processed outputs back into
raw/.
This keeps raw data pristine and makes the pipeline fully reproducible.
Notebook walk-through¶
Open the companion notebook for an interactive, cell-by-cell version of steps 2–5:
00_environment_setup_folder_structure.ipynb
Next steps¶
Once your environment is active and the folder structure is in place, continue with: