{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Plotting Spatial Map of 2-m Temperature\n\nThis example plots the spatial distribution of 2-m temperature from UFS WM outputs.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import Ngl, Nio\nimport pandas as pd\nimport numpy as np\nimport xarray as xr\nimport netCDF4 as nc\nfrom netCDF4 import Dataset\nimport matplotlib.pyplot as plt\n\n# Read in NetCDF data\nfv3=nc.MFDataset('GFSv16veta/GFSPRS.GrbF96.nc')\ntmp2m=fv3[\"TMP_2maboveground\"][0,:,:]\ntmp2mF=(tmp2m-273.15)*9/5+32\nlat=fv3[\"latitude\"]\nlon=fv3[\"longitude\"]\n\n# Read in NetCDF data\nwks_type = \"png\"\nwks = Ngl.open_wks(wks_type,\"FV3_T2_20200121_1200_GFSv16beta\")\ncnres                 = Ngl.Resources()\n\n# Contour resources\ncnres.cnFillOn        = True\ncnres.cnFillPalette   = \"NCV_bright_white\"\ncnres.cnLinesOn       = False\ncnres.cnLineLabelsOn  = False\ncnres.cnLevelSelectionMode = \"ManualLevels\"\ncnres.cnMinLevelValF = -30\ncnres.cnMaxLevelValF = 100\ncnres.nglMaximize = True\ncnres.tiXAxisString = \"Lon\"\ncnres.tiYAxisString = \"Lat\"\ncnres.lbOrientation   = \"horizontal\"\n\n# Scalar field resources\ncnres.sfXArray        = lon[:]\ncnres.sfYArray        = lat[:]\n\n# Map resources\ncnres.mpFillOn               = False\ncnres.mpGridAndLimbOn = False\ncnres.mpLandFillColor        = \"Transparent\"\ncnres.mpOceanFillColor       = \"Transparent\"\ncnres.mpInlandWaterFillColor = \"Transparent\"\ncnres.mpLimitMode        = \"LatLon\"\n\n# Map region\ncnres.mpMaxLonF = -65\ncnres.mpMaxLatF = 55\ncnres.mpMinLonF = -125\ncnres.mpMinLatF = 20\ncnres.mpDataBaseVersion     = \"MediumRes\"\ncnres.mpOutlineBoundarySets = \"USStates\"\n\n# Plot resources\ncnres0=cnres\ncnres0.tiMainString = \"FV3 GFSv16beta: 2m Temp (F) FV3 ~C~Initilized 12Z 17 Jan 2020 valid 12Z 21 Jan 2020\"#\"{} ({}) at {:.2f} hPa with fast_sat\".format(clwmr.long_name,clwmr.units,vpfull)\ncnres0.tiMainFontHeightF=0.012\ncontour = Ngl.contour_map(wks,tmp2mF[:,:],cnres0)\n\n# Draw the plot\nNgl.draw(contour)\nNgl.end()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. figure:: /images/FV3_T2_20200121_1200_GFSv16beta.png\n :width: 600\n :align: center\n\n"
      ]
    }
  ],
  "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.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}