Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/workflows/trigger-delete-preview.yaml

This file was deleted.

16 changes: 11 additions & 5 deletions _toc.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
format: jb-book
root: README
parts:
- caption: Preámbulo
- caption: "Preámbulo"
chapters:
- file: notebooks/how-to-cite
- caption: Introducción a la programación científica con Python

- caption: "Introducción a la programación científica con Python"
chapters:
- file: notebooks/1.fundamentos/1.1Fundamentos-python
- file: notebooks/1.fundamentos/1.2Numpy-Pandas-Xarray
- file: notebooks/1.fundamentos/1.3PyArt-Xradar-Wradlib
- caption: Acceso a datos hidrometeorológicos
- file: notebooks/1.fundamentos/1.4exploracion_netcdf_grib
title: "1.4 NetCDF y GRIB"

- caption: "Acceso a datos hidrometeorológicos"
chapters:
- file: notebooks/2.acceso-datos/2.1.Estaciones
- file: notebooks/2.acceso-datos/2.2.Radares
- file: notebooks/2.acceso-datos/2.3.GFS
- caption: ENOS

- caption: "ENOS"
chapters:
- file: notebooks/3.ENSO/3.1ENSO
- caption: Cambio Climático

- caption: "Cambio Climático"
chapters:
- file: notebooks/4.cambio-climatico/4.1Global-Mean-SST
60 changes: 60 additions & 0 deletions myst.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 1

project:
title: Ciencia de Datos Hidrometeorológicos con Python
description: Un libro interactivo enfocado en programación científica con Python para datos climáticos.
keywords: [Python, clima, hidrometeorología, ciencia abierta, Pythia, ENSO, cambio climático, Radar]
authors:
- name: Alfonso Ladino-Rincon
orcid: 0000-0001-8081-7827
github: aladinor
- name: Nicole Rivera
orcid: 0000-0001-8318-1983
github: nicolerivera1
- name: Max Grover
orcid: 0000-0002-0370-8974
github: mgrover1
github: https://github.com/ProjectPythia/AtmosCol-2023
toc:
- file: README.md
- file: notebooks/how-to-cite.md
- title: Introducción a la programación científica con Python
children:
- file: notebooks/1.fundamentos/1.0.Introduccion-JupyterLab.ipynb
- file: notebooks/1.fundamentos/1.1.Fundamentos-python.ipynb
- file: notebooks/1.fundamentos/1.2.Introduccion-Numpy.ipynb
- file: notebooks/1.fundamentos/1.3.Introduccion-Pandas.ipynb
- file: notebooks/1.fundamentos/1.4.Introduccion-Xarray.ipynb
- file: notebooks/1.fundamentos/1.5.Introduccion-Radar.ipynb
- file: notebooks/1.fundamentos/1.6.Exploracion_netcdf_grib.ipynb
- title: Acceso a datos hidrometeorológicos
children:
- file: notebooks/2.acceso-datos/2.1.Estaciones.ipynb
- file: notebooks/2.acceso-datos/2.2.Radares.ipynb
# - file: notebooks/2.acceso-datos/2.3.GFS.ipynb
- title: Aplicaciones científicas
children:
- file: notebooks/3.Aplicaciones/3.1.ENSO.ipynb
# - file: notebooks/3.Aplicaciones/3.2.Global-Mean-SST.ipynb
- file: notebooks/3.Aplicaciones/3.3.ERA5.ipynb
- file: notebooks/3.Aplicaciones/3.4.QVPs.ipynb
- file: notebooks/3.Aplicaciones/3.5.QPE.ipynb
jupyter:
binder:
url: https://binder.projectpythia.org/
repo: ProjectPythia/AtmosCol-2023

site:
template: book-theme
options:
toc_title: Contenido
nav:
- title: Página principal
url: https://github.com/ProjectPythia/AtmosCol-2023
actions:
- title: Ejecutar en Binder
url: https://binder.projectpythia.org/v2/gh/ProjectPythia/AtmosCol-2023/main?labpath=notebooks

config:
execute:
execute_notebooks: "off"
272 changes: 272 additions & 0 deletions notebooks/1.fundamentos/1.6.Exploracion-NetCDF-GRIB.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "cd843307",
"metadata": {},
"source": [
"<img src=\"../images/netcdf_portada_1.png\" width=300 alt=\"portada\"></img>"
]
},
{
"cell_type": "markdown",
"id": "cc968afc",
"metadata": {},
"source": [
"# 📘 Exploración de formatos climáticos: NetCDF y GRIB\n",
"**Curso AtmosCol-2023 – Cuadernillo Didáctico**\n",
"\n",
"Este cuaderno está diseñado para introducir los dos formatos de archivo más comunes en el análisis de datos meteorológicos y climáticos: **NetCDF** y **GRIB**. Está pensado para ser completado en aproximadamente 20 minutos y utiliza exclusivamente Python."
]
},
{
"cell_type": "markdown",
"id": "bbb1ffdf",
"metadata": {},
"source": [
"## ✨ Introducción\n",
"Los modelos meteorológicos y los satélites generan enormes volúmenes de datos. Estos se almacenan en formatos especializados que permiten eficiencia y flexibilidad. En este cuaderno aprenderás a reconocer, leer y explorar los formatos **NetCDF** y **GRIB** usando Python. Estos conocimientos son esenciales para cualquier persona que trabaje en ciencia del clima, meteorología operativa o análisis satelital."
]
},
{
"cell_type": "markdown",
"id": "f1b0ad01",
"metadata": {},
"source": [
"## ⚙️ Prerrequisitos\n",
"Este cuaderno requiere conocimientos básicos de Python y las siguientes librerías:\n",
"\n",
"```python\n",
"import xarray as xr\n",
"import matplotlib.pyplot as plt\n",
"# Para archivos GRIB\n",
"# pip install cfgrib\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "27eabe4f",
"metadata": {},
"source": [
"## 📦 Formato NetCDF\n",
"**NetCDF (Network Common Data Form)** es un formato de archivo binario auto-descriptivo ampliamente utilizado en las ciencias atmosféricas.\n",
"\n",
"### 📊 Estructura\n",
"<img src=\"../images/Netcdf_1.png\" width=300 alt=\"NetCDF-estructura\"></img>"
]
},
{
"cell_type": "markdown",
"id": "5a45291b",
"metadata": {},
"source": [
"### 🔍 Características principales\n",
"- Almacena datos multidimensionales (tiempo, latitud, longitud, nivel)\n",
"- Permite metadatos descriptivos\n",
"- Soporta estructuras jerárquicas (NetCDF-4)"
]
},
{
"cell_type": "markdown",
"id": "a191c26c",
"metadata": {},
"source": [
"### ✅ Ventajas\n",
"- Fácil de explorar con `xarray`\n",
"- Compatible con muchas herramientas científicas\n",
"- Ideal para almacenamiento a largo plazo"
]
},
{
"cell_type": "markdown",
"id": "de2fa285",
"metadata": {},
"source": [
"### ⚠️ Desventajas\n",
"- Tamaño de archivo mayor comparado con GRIB\n",
"- Puede ser más lento para acceso puntual"
]
},
{
"cell_type": "markdown",
"id": "5666e3b2",
"metadata": {},
"source": [
"### 🔄 Versiones\n",
"- **Classic**: estructura simple y universal\n",
"- **NetCDF-4**: permite compresión y grupos jerárquicos"
]
},
{
"cell_type": "markdown",
"id": "c99d5d4a",
"metadata": {},
"source": [
"### 🛠️ Tips ETL en Python\n",
"- Usa `ds.sel()` y `ds.isel()` para filtrar por dimensión\n",
"- Verifica unidades (`ds.attrs`, `ds.variable.attrs`)\n",
"- Asegura el formato de fechas (`time` en UTC)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c39de887",
"metadata": {},
"outputs": [],
"source": [
"# Lectura básica NetCDF\n",
"ds = xr.open_dataset('datos/ejemplo.nc')\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a50e5eab",
"metadata": {},
"outputs": [],
"source": [
"# Visualización de una variable\n",
"ds['nombre_variable'].isel(time=0).plot()"
]
},
{
"cell_type": "markdown",
"id": "bd664646",
"metadata": {},
"source": [
"## 📦 Formato GRIB\n",
"**GRIB (GRIdded Binary)** es un formato binario eficiente utilizado principalmente para pronósticos numéricos del tiempo.\n",
"\n",
"### 📊 Estructura\n",
"<img src=\"../images/grib_1.png\" width=300 alt=\"GRIB-estructura\"></img>"
]
},
{
"cell_type": "markdown",
"id": "68bd067a",
"metadata": {},
"source": [
"### 🔍 Características principales\n",
"- Datos almacenados como registros binarios con encabezados\n",
"- Alta eficiencia en tamaño y lectura\n",
"- Muy usado por servicios meteorológicos operativos"
]
},
{
"cell_type": "markdown",
"id": "451a6056",
"metadata": {},
"source": [
"### ✅ Ventajas\n",
"- Tamaño de archivo reducido\n",
"- Acceso puntual eficiente\n",
"- Ideal para distribución de pronósticos"
]
},
{
"cell_type": "markdown",
"id": "e220679f",
"metadata": {},
"source": [
"### ⚠️ Desventajas\n",
"- Menos intuitivo que NetCDF\n",
"- Requiere herramientas específicas como `cfgrib`"
]
},
{
"cell_type": "markdown",
"id": "12cb0595",
"metadata": {},
"source": [
"### 🔄 Versiones\n",
"- **GRIB1**: formato más simple y aún en uso\n",
"- **GRIB2**: admite más metadatos y compresión"
]
},
{
"cell_type": "markdown",
"id": "1d1ad588",
"metadata": {},
"source": [
"### 🛠️ Tips ETL en Python\n",
"- Usa `engine='cfgrib'` con `xarray`\n",
"- Explora claves con `filter_by_keys` si hay múltiples campos\n",
"- Presta atención al paso temporal (`step`), tipo de nivel y superficie"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "182d6873",
"metadata": {},
"outputs": [],
"source": [
"# Lectura básica GRIB\n",
"ds_grib = xr.open_dataset('datos/ejemplo.grib', engine='cfgrib')\n",
"ds_grib"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1e9b166b",
"metadata": {},
"outputs": [],
"source": [
"# Visualización de una variable\n",
"ds_grib['nombre_variable'].isel(time=0).plot()"
]
},
{
"cell_type": "markdown",
"id": "a7ecf997",
"metadata": {},
"source": [
"## 📊 Comparación general\n",
"| Aspecto | NetCDF | GRIB |\n",
"|----------------|-----------------------------|----------------------------|\n",
"| Compresión | Opcional (NetCDF-4) | Alta (GRIB2) |\n",
"| Facilidad de uso | Más intuitivo | Más eficiente |\n",
"| Finalidad | Archivos científicos | Distribución operativa |\n",
"| Estructura | Auto-descriptiva | Encabezados + binario |"
]
},
{
"cell_type": "markdown",
"id": "d3180fa4",
"metadata": {},
"source": [
"## ✅ Conclusiones\n",
"Ambos formatos son esenciales en meteorología. NetCDF es más flexible para análisis y documentación, mientras que GRIB es óptimo para pronósticos y distribución de modelos. Manejar ambos con Python permite construir flujos ETL robustos para proyectos climáticos, energéticos y operativos."
]
},
{
"cell_type": "markdown",
"id": "7b6fe8a4",
"metadata": {},
"source": [
"## 📚 Recursos y Bibliografía\n",
"- Earth Lab. (s.f.). *Introduction to Climate Data in NetCDF Format*. University of Colorado Boulder. https://www.earthdatascience.org/courses/use-data-open-source-python/hierarchical-data-formats-hdf/intro-to-climate-data/\n",
"- ECMWF. (2014). *GRIB – NetCDF: Setting the Scene*. https://www.ecmwf.int/sites/default/files/elibrary/2014/13706-grib-netcdf-setting-scene.pdf\n",
"- UCAR Unidata. (s.f.). *NetCDF Documentation*. https://www.unidata.ucar.edu/software/netcdf/docs/\n",
"- ECMWF. (s.f.). *GRIB API & ecCodes*. https://confluence.ecmwf.int/display/ECC"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.12.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added notebooks/images/Netcdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notebooks/images/Netcdf_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notebooks/images/grib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notebooks/images/grib_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notebooks/images/netcdf_portada.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notebooks/images/netcdf_portada_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.