{ "cells": [ { "cell_type": "markdown", "id": "025d50e4", "metadata": {}, "source": [ "# 2. NetCDF and GRIB Datasets I/O\n", "\n", "## Read a NetCDF File\n", "\n", "The command to open a single netCDF file is simply **`xarray.open_dataset(filename)`**。\n", "\n", "**Example 1:** Read an OLR file into a xarray.Dataset. " ] }, { "cell_type": "code", "execution_count": 1, "id": "87e44596", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 1GB\n", "Dimensions: (time: 8760, lon: 360, bnds: 2, lat: 90)\n", "Coordinates:\n", " * time (time) datetime64[ns] 70kB 1998-01-01 1998-01-02 ... 2021-12-31\n", " * lon (lon) float32 1kB 0.5 1.5 2.5 3.5 4.5 ... 356.5 357.5 358.5 359.5\n", " * lat (lat) float32 360B -44.5 -43.5 -42.5 -41.5 ... 41.5 42.5 43.5 44.5\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " lon_bnds (lon, bnds) float32 3kB ...\n", " lat_bnds (lat, bnds) float32 720B ...\n", " olr (time, lat, lon) float32 1GB ...\n", "Attributes: (12/49)\n", " CDI: Climate Data Interface version 1.9.10 (https:...\n", " Conventions: CF-1.6\n", " source: NOAA Archive of HIRS L1B data from TIROS-N Se...\n", " institution: UMD/ESSIC > Earth System Science Interdiscipl...\n", " history: Fri Jan 14 11:02:54 2022: cdo sellonlatbox,0,...\n", " conventions: CF-1.6\n", " ... ...\n", " Metadata_Link: gov.noaa.ncdc:C00875\n", " product_version: Ver01Rev02\n", " platform: TIROS-N > Television Infrared Observation Sat...\n", " sensor: HIRS-2 > High Resolution Infra-red Sounder/2,...\n", " spatial_resolution: 1.0 by 1.0 degree equal angle\n", " CDO: Climate Data Operators version 1.9.10 (https:...
<xarray.Dataset> Size: 369MB\n", "Dimensions: (time: 8766, bnds: 2, level: 1, lat: 73, lon: 144)\n", "Coordinates:\n", " * time (time) datetime64[ns] 70kB 1998-01-01 1998-01-02 ... 2021-12-31\n", " * lon (lon) float32 576B 0.0 2.5 5.0 7.5 ... 350.0 352.5 355.0 357.5\n", " * lat (lat) float32 292B 90.0 87.5 85.0 82.5 ... -85.0 -87.5 -90.0\n", " * level (level) float32 4B 850.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) datetime64[ns] 140kB dask.array<chunksize=(365, 2), meta=np.ndarray>\n", " uwnd (time, level, lat, lon) float32 369MB dask.array<chunksize=(365, 1, 73, 144), meta=np.ndarray>\n", "Attributes:\n", " CDI: Climate Data Interface version 1.9.10 (https://mpimet.mpg...\n", " Conventions: CF-1.0\n", " source: NCEP/DOE AMIP-II Reanalysis (Reanalysis-2) Model\n", " institution: National Centers for Environmental Prediction\n", " title: Daily NCEP/DOE Reanalysis 2\n", " history: Tue Jan 04 11:04:24 2022: cdo select,level=850 uwnd.1998....\n", " comments: Data is from \\nNCEP/DOE AMIP-II Reanalysis (Reanalysis-2)...\n", " platform: Model\n", " dataset_title: NCEP-DOE AMIP-II Reanalysis\n", " References: https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.rean...\n", " source_url: http://www.cpc.ncep.noaa.gov/products/wesley/reanalysis2/\n", " CDO: Climate Data Operators version 1.9.10 (https://mpimet.mpg...
<xarray.Dataset> Size: 369MB\n", "Dimensions: (time: 8766, bnds: 2, level: 1, lat: 73, lon: 144)\n", "Coordinates:\n", " * time (time) datetime64[ns] 70kB 1998-01-01 1998-01-02 ... 2021-12-31\n", " * lon (lon) float32 576B 0.0 2.5 5.0 7.5 ... 350.0 352.5 355.0 357.5\n", " * lat (lat) float32 292B 90.0 87.5 85.0 82.5 ... -85.0 -87.5 -90.0\n", " * level (level) float32 4B 850.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) datetime64[ns] 140kB dask.array<chunksize=(365, 2), meta=np.ndarray>\n", " uwnd (time, level, lat, lon) float32 369MB dask.array<chunksize=(365, 1, 73, 144), meta=np.ndarray>\n", "Attributes:\n", " CDI: Climate Data Interface version 1.9.10 (https://mpimet.mpg...\n", " Conventions: CF-1.0\n", " source: NCEP/DOE AMIP-II Reanalysis (Reanalysis-2) Model\n", " institution: National Centers for Environmental Prediction\n", " title: Daily NCEP/DOE Reanalysis 2\n", " history: Tue Jan 04 11:04:24 2022: cdo select,level=850 uwnd.1998....\n", " comments: Data is from \\nNCEP/DOE AMIP-II Reanalysis (Reanalysis-2)...\n", " platform: Model\n", " dataset_title: NCEP-DOE AMIP-II Reanalysis\n", " References: https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.rean...\n", " source_url: http://www.cpc.ncep.noaa.gov/products/wesley/reanalysis2/\n", " CDO: Climate Data Operators version 1.9.10 (https://mpimet.mpg...
<xarray.Dataset> Size: 184MB\n", "Dimensions: (time: 4383, bnds: 2, level: 1, lat: 73, lon: 144)\n", "Coordinates:\n", " * time (time) datetime64[ns] 35kB 1998-01-01 1998-01-02 ... 2009-12-31\n", " * lon (lon) float32 576B 0.0 2.5 5.0 7.5 ... 350.0 352.5 355.0 357.5\n", " * lat (lat) float32 292B 90.0 87.5 85.0 82.5 ... -85.0 -87.5 -90.0\n", " * level (level) float32 4B 850.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) datetime64[ns] 70kB dask.array<chunksize=(365, 2), meta=np.ndarray>\n", " uwnd (time, level, lat, lon) float32 184MB dask.array<chunksize=(365, 1, 73, 144), meta=np.ndarray>\n", "Attributes:\n", " CDI: Climate Data Interface version 1.9.10 (https://mpimet.mpg...\n", " Conventions: CF-1.0\n", " source: NCEP/DOE AMIP-II Reanalysis (Reanalysis-2) Model\n", " institution: National Centers for Environmental Prediction\n", " title: Daily NCEP/DOE Reanalysis 2\n", " history: Tue Jan 04 11:04:24 2022: cdo select,level=850 uwnd.1998....\n", " comments: Data is from \\nNCEP/DOE AMIP-II Reanalysis (Reanalysis-2)...\n", " platform: Model\n", " dataset_title: NCEP-DOE AMIP-II Reanalysis\n", " References: https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.rean...\n", " source_url: http://www.cpc.ncep.noaa.gov/products/wesley/reanalysis2/\n", " CDO: Climate Data Operators version 1.9.10 (https://mpimet.mpg...
<xarray.Dataset> Size: 184MB\n", "Dimensions: (time: 4383, bnds: 2, level: 1, lat: 73, lon: 144)\n", "Coordinates:\n", " * time (time) datetime64[ns] 35kB 1998-01-01 1998-01-02 ... 2009-12-31\n", " * lon (lon) float32 576B 0.0 2.5 5.0 7.5 ... 350.0 352.5 355.0 357.5\n", " * lat (lat) float32 292B 90.0 87.5 85.0 82.5 ... -85.0 -87.5 -90.0\n", " * level (level) float32 4B 850.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) datetime64[ns] 70kB 1998-01-01 ... 2010-01-01\n", " uwnd (time, level, lat, lon) float32 184MB -7.99 -7.96 ... -3.74 -3.71\n", "Attributes:\n", " CDI: Climate Data Interface version 1.9.10 (https://mpimet.mpg...\n", " Conventions: CF-1.0\n", " source: NCEP/DOE AMIP-II Reanalysis (Reanalysis-2) Model\n", " institution: National Centers for Environmental Prediction\n", " title: Daily NCEP/DOE Reanalysis 2\n", " history: Tue Jan 04 11:04:24 2022: cdo select,level=850 uwnd.1998....\n", " comments: Data is from \\nNCEP/DOE AMIP-II Reanalysis (Reanalysis-2)...\n", " platform: Model\n", " dataset_title: NCEP-DOE AMIP-II Reanalysis\n", " References: https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.rean...\n", " source_url: http://www.cpc.ncep.noaa.gov/products/wesley/reanalysis2/\n", " CDO: Climate Data Operators version 1.9.10 (https://mpimet.mpg...