{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# SyntaxError\n\nExample script with invalid Python syntax\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "\"\"\"\nPlotting Radial WS with Leading Times\n====================================\nThis script plots the 850 hPa radial wind speed with leading times. The `radialAvg.ncl <https://github.com/E3SM-Project/ACME-ECP/blob/master/components/homme/dcmip_tests/dcmip2016_test2_tropical_cyclone/preqx/radialAvg.ncl>`_ needs to be staged to the same directory as the example ncl script below.\n\n\"\"\"\nloadscript( \"radialAvg.ncl\")\n\nbegin\n\n; Define plot name\npngname=\"ufs_GFSv16beta_radial_ws_time_plot\"\nwks=gsn_open_wks(\"png\", pngname)\n\n; Read GFSv16beta vortext tracker results\ntcfile=\"GFSv16beta/fort.69\"\ndelim=\",\"\ntclines=asciiread(tcfile, -1, \"string\")\nleadtimestr=tointeger(str_get_field(tclines, 6, delim))\ntclatstr=str_get_field(tclines, 7, delim)\ntclonstr=str_get_field(tclines, 8, delim)\ntcRMWstr=str_get_field(tclines, 20, delim)\ntcRMW=tofloat(tcRMWstr)\n\n\ntcdimsize=dimsizes(leadtimestr)-1\ncritstr=str_get_field(tclines, 12, delim)\ncrit=toint(critstr)\ncount=0\nnewtcRMW=new((/29/),float)\ndo i=0,tcdimsize,1\n\n    if(crit(i).eq.34) then\n        newtcRMW(count)=tcRMW(i)\n        count=count+1\n    end if\nend do\n\ndo i=0,tcdimsize,1\n    if(leadtimestr(i).eq.leadtime) then\n        tclat=tofloat(str_get_cols(tclatstr(i), 0, 3))*0.1\n        tclon=tofloat(str_get_cols(tclonstr(i), 0, 4))*0.1\n        print(tclat)\n        print(tclon)\n    end if\nend do\npsminlat= tclat\npsminlon= tclon*(-1)+360\n\n; Use wgrib2 to convert all the GFSPRS* outputs to netcdf format, and read in all the nc files\nncfili=systemfunc(\"ls GFSv16beta/GFSPRS.GrbF*.nc\")\nncfiles=addfiles(ncfili,\"r\")\n\nUGRD850=ncfiles[:]->UGRD_850mb\nVGRD850=ncfiles[:]->VGRD_850mb\nWS850=(wind_speed(UGRD850,VGRD850))*1.944\n\n\n; Make a array for leading time after landfall from f66 to f120\ntime=(/66,72,78,84,90,96,102,108,114,120/)\ndsizes=dimsizes(UGRD850)\n\n;Define a new array for 850 hPa wind speed, /Pressure, latitude, longitude/\nverTMP=new((/dsizes(0),dsizes(1),dsizes(2)/),float)\nverTMP!0 =\"Pressure\"\nverTMP&Pressure=time ;Trick to replace pressure with leading time data\nverTMP&Pressure@units=\"hPa\"\nverTMP!1=\"latitude\"\nverTMP&latitude=UGRD850&latitude\nverTMP!2=\"longitude\"\nverTMP&longitude=UGRD850&longitude\n\nverTMP(0,:,:)=(/WS850(0,:,:)/)\nverTMP(1,:,:)=(/WS850(1,:,:)/)\nverTMP(2,:,:)=(/WS850(2,:,:)/)\nverTMP(3,:,:)=(/WS850(3,:,:)/)\nverTMP(4,:,:)=(/WS850(4,:,:)/)\nverTMP(5,:,:)=(/WS850(5,:,:)/)\nverTMP(6,:,:)=(/WS850(6,:,:)/)\nverTMP(7,:,:)=(/WS850(7,:,:)/)\nverTMP(8,:,:)=(/WS850(8,:,:)/)\nverTMP(9,:,:)=(/WS850(9,:,:)/)\n\n; Using the radialAvg3D function from the radialAvg.ncl\nouterRad=700.\nmergeInnerBins=True\nradiaverWS850=radialAvg3D(verTMP(:,:,:),lat,lon,verTMP&Pressure,psminlat,psminlon,outerRad,mergeInnerBins)\nradiaverWS850f=tofloat(radiaverWS850)\ncopy_VarCoords(radiaverWS850, radiaverWS850f)\n\n\n\n; Plot the contour field of wind speed at 850hPa\nresx=True\nresx@gsnDraw = False\nresx@gsnFrame=False\n resx@cnFillOn             = True            ; turn on color fill\nresx@cnLinesOn            = False        ; turn lines on/off         ; True is default\nresx@cnLineLabelsOn       = False          ; turn line labels on/off   ; True is default\nresx@cnFillPalette=\"WhiteBlueGreenYellowRed\";\"temp_19lev\"\nresx@cnLevelSelectionMode=\"ManualLevels\"\n resx@tmXTOn=False\n resx@tmYROn=False\n resx@lbOrientation=\"Vertical\" \nresx@tiYAxisString =\"Forecast Hour\"\nresx@tiXAxisString=\"Radius (km)\"\nradiaverWS850f@units=\"knots\"\nradiaverWS850f@long_name=\"GFSv16beta 850hPa Wind Speed\"\nresx@cnLevelSelectionMode=\"ManualLevels\"\nresx@cnMinLevelValF= 10\nresx@cnMaxLevelValF= 60\nresx@cnLevelSpacingF= 2\nresx@trYMinF=66\nresx@trYMaxF=96\nresx@tmYLMode=\"Explicit\"\nresx@tmYLValues=(/66,72,78,84,90,96/)\nresx@tmYLLabels=(/66,72,78,84,90,96/)\nplot=gsn_csm_contour(wks, radiaverWS850f(0:5,:), resx)\n\n\n; Overlay the whiteline of radius of the maximum wind (RMW) to the wind speed contour plot\nres=True\nres@gsnDraw = False\nres@gsnFrame=False\nres@xyLineColors        = (/\"white\"/) \nres@xyLineThicknesses   = (/5.0/)\nplotxy=gsn_csm_xy(wks, newtcRMW(10:15), time(0:5),res)\noverlay(plot, plotxy)\ndraw(plot)\nframe(wks)\n\nend"
      ]
    }
  ],
  "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
}