{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Using NetCDF4 Compression with CDMS \n", "\n", "\n", "CDMS2 writes out data using the [NetCDF library](https://www.unidata.ucar.edu/software/netcdf/)\n", "\n", "NetCDF4 allows for file compression, a good blog about NetCDF4 and compression can be found [here](http://www.unidata.ucar.edu/blogs/developer/entry/netcdf_compression)\n", "\n", "From this blog:\n", "\n", "*\"The netCDF-4 libraries inherit the capability for data compression from the HDF5 storage layer underneath the netCDF-4 interface. Linking a program that uses netCDF to a netCDF-4 library allows the program to read compressed data without changing a single line of the program source code.\"*\n", "\n", "and\n", "\n", "*\"Also, we're only dealing with lossless compression\"*\n", "\n", "This Notebook shows how to control NetCDF4 compression (shuffling/deflating) capabilities via cdms2.\n", "\n", "The CDAT software was developed by LLNL. This tutorial was written by Charles Doutriaux. This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.\n", "\n", "[Download the Jupyter Notebook](NetCDF4_Compression.ipynb)" ] }, { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "
Deflate Level | NC3 | NC4 Classic no shuffle | NC4 Classic shuffled | NC4 no shuffle | NC4 shuffled | {:.2f}/{:d} | \".format(t,s)\n", "\n", "def nc4s():\n", " out = \"\"\n", " for classic in [1,0]:\n", " cdms2.setNetcdfClassicFlag(classic)\n", " for shuffle in [0,1]:\n", " cdms2.setNetcdfShuffleFlag(shuffle)\n", " out+=addCell()\n", " out+=\"\"\n", " return out\n", "\n", "# NetCDF3\n", "html+=\"
---|---|---|---|---|---|
0 | \"\n", "cdms2.useNetcdf3()\n", "cdms2.setNetcdf4Flag(0)\n", "html+=addCell()\n", "cdms2.setNetcdf4Flag(1)\n", "html+=nc4s()\n", "cdms2.setNetcdfDeflateFlag(1)\n", "for i in range(1,10):\n", " cdms2.setNetcdfDeflateLevelFlag(i)\n", " html += \"|||||
{0} | N/A | \".format(i)\n", " html += nc4s()\n", "html+=\"