{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from netCDF4 import Dataset\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from matplotlib.cm import get_cmap\n", "import cartopy.crs as crs\n", "from cartopy.feature import NaturalEarthFeature\n", "\n", "from wrf import (to_np, getvar, smooth2d, get_cartopy, cartopy_xlim,\n", " cartopy_ylim, latlon_coords)\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#Converts WRF variables from netcdf to npy object. Gets rid of grid location since\n", "#this would complicated the code significantly" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#WRF path\n", "wrf_path = \"/uufs/chpc.utah.edu/common/home/lin-group10/dvm/WRF_files/COVID_SLC/2020/\"\n", "wrf_file = \"wrfout_d03_2020-04-01_00:00:00\"\n", "\n", "#WRF file\n", "ncfile = Dataset(wrf_path+wrf_file)\n", "\n", "#Grab height and temperature data\n", "T2K = getvar(ncfile, \"T2\")\n", "HGT = getvar(ncfile, \"ter\")\n", "\n", "#Convert temperature from K to C\n", "temp = T2K - 273.15" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#Convert temp to numpy array\n", "temp = np.array(temp)\n", "HGT = np.array(HGT)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#Save array as npy object\n", "np.save('wrf_temp_Utah.npy',temp)\n", "np.save('wrf_hght_Utah.npy',HGT)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 4 }