{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example notebook for reading and plotting CM1 netcdf output\n", "\n", "## Imports\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Define where your output file is and read it in\n", "\n", "I've put the output for each run into its own directory, which is a good practice so you don't accidentally overwrite them. Or even better, you can run the model itself from separate directories for each run; just copy or symlink the cm1.exe executable and other needed files into each directory" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "run_name = \"bubble_10km_noshear\"\n", "\n", "data = xr.open_dataset(run_name+\"/cm1out.nc\")\n", "\n", "#data ## this will print the metadata for your file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set up some variables to see what the times and heights are" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'zh' (zh: 40)>\n", "array([ 0.25 , 0.75 , 1.25 , 1.75 , 2.25 , 2.75 ,\n", " 3.25 , 3.75 , 4.25 , 4.75 , 5.25 , 5.75 ,\n", " 6.25 , 6.75 , 7.25 , 7.75 , 8.25 , 8.75 ,\n", " 9.25 , 9.75 , 10.250001, 10.750001, 11.250001, 11.750001,\n", " 12.250001, 12.750001, 13.250001, 13.750001, 14.250001, 14.750001,\n", " 15.250001, 15.750001, 16.25 , 16.75 , 17.25 , 17.75 ,\n", " 18.25 , 18.75 , 19.25 , 19.75 ], dtype=float32)\n", "Coordinates:\n", " * zh (zh) float32 0.25 0.75 1.25 1.75 2.25 ... 18.25 18.75 19.25 19.75\n", "Attributes:\n", " long_name: nominal height of scalar grid points\n", " units: km\n", " axis: Z