{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Plotting Time Series of Vortex Center Max. WS\n\nThis example plots time series of the maximum wind speed at the vortex center estimated from tc-tracker, as well as BestTrack data.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from matplotlib import pyplot as plt\nimport numpy as np\nimport matplotlib\n\n\n# Read GFSv15p2 vortext tracker results\ncsv_file = \"GFSv15p2/fort.69\"\ntc = np.recfromcsv(csv_file, unpack=True, names=['stormid', 'count', 'initdate', 'constant', 'atcf', 'leadtime', 'lat','lon','ws','mslp','placehoder', 'thresh', 'neq', 'blank1', 'blank2', 'blank3','blank4','blank5','blank6','blank7'], dtype=None)\n\n# Read GFSv16beta vortext tracker results\ncsv_file2 = \"GFSv16beta/fort.69\"\ntc2 = np.recfromcsv(csv_file2, unpack=True, names=['stormid', 'count', 'initdate', 'constant', 'atcf', 'leadtime', 'lat','lon','ws','mslp','placehoder', 'thresh', 'neq', 'blank1', 'blank2', 'blank3','blank4','blank5','blank6','blank7'], dtype=None)\n\n# Read BestTrack data\nbal_file =\"/home/Xia.Sun/PySripts/TC_tracker/bal022019_post.dat\"\nbal = np.recfromcsv(bal_file,unpack=True,delimiter=\",\",usecols=[0,2,6,7,8,9,10,11],names=['stormid','time','lat','lon','ws','mslp','intens','thresh'],dtype=None)\n\n# Read in wind speed from BestTrack Data\nbalws=[]\nfor k in range(len(bal.lat)):\n    if bal.thresh[k] == 34 or bal.thresh[k] == 0:\n        balwsd=float(bal.ws[k])\n        balws.append(balwsd)\n\n# Read in wind speed from GFSv15p2\nencoding='utf-8'\ntcws=[]\nfor j in range(len(tc.ws)):\n    tcstormid=str(tc.stormid[j],encoding)\n    if tcstormid=='AL' and tc.count[j]== 2 and tc.thresh[j]==34 and tc.leadtime[j]<=9000:\n        tcwsd=float(tc.ws[j])\n        tcws.append(tcwsd) \n\n# Read in wind speed from GFSv16beta\ntc2ws=[]\nfor j in range(len(tc2.ws)-1):\n    tc2stormid=str(tc2.stormid[j],encoding)\n    if tc2stormid=='AL' and tc2.count[j]==2 and tc2.thresh[j]==34 and tc2.leadtime[j]<=9000:\n        tc2wsd=float(tc2.ws[j])\n        tc2ws.append(tc2wsd)\n\n# Make x axis\nt=np.arange(0,16,1)\n\n# Make the plot\nplt.figure(figsize=(8,6)) \nplt.plot(t,tcws,'.-r',label=\"GFSv15p2\")\nplt.plot(t,tc2ws,'.-b',label=\"GFSv16beta\")\nplt.plot(t,balws,'.-k',label=\"BestTrack\")\nplt.legend(loc=\"upper left\")\nmy_xticks=['11/00z','','11/12z','','12/00z','','12/12z','','13/00z','','13/12z','','14/00z','','14/12z','']\nplt.xlabel('Date/Time (UTC)')\nplt.ylabel('Maximum surface wind (kt)')\nfrequency=2\nplt.xticks(t,my_xticks)\nplt.show()\nplt.savefig('tracker_ws_Barry_ufsv1.png')"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. figure:: /auto_examples/images/thumb/sphx_glr_tracker_ws_Barry_thumb.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
}