<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 PyEarthScience
Step1:  Add cyclic data. Set minimum and maximum contour values although the interval.
Step2:  Open a workstation, here x11 window.
Step3:  Set resources.
Step4:  Draw the plot.
Step5:  Show the plot in this notebook.
<ASSISTANT_TASK:>
Python Code:
import Ngl,Nio
#-- define variables
fname  = "/Users/k204045/NCL/general/data/new_data/rectilinear_grid_2D.nc" #-- data file name
#-- open file and read variables
f      =  Nio.open_file(fname,"r")             #-- open data file
temp   =  f.variables["tsurf"][0,::-1,:]       #-- first time step, reverse latitude
lat    =  f.variables["lat"][::-1]             #-- reverse latitudes
lon    =  f.variables["lon"][:]                #-- all longitudes
Explanation: PyEarthScience:  Python examples for Earth Scientists
contour plots
Using PyNGL
Contour plot with
- filled contour areas
- without contour line labels
- labelbar
- title
End of explanation
tempac =  Ngl.add_cyclic(temp[:,:])
minval =  250.                                 #-- minimum contour level
maxval =  315                                  #-- maximum contour level
inc    =    5.                                 #-- contour level spacing
ncn    = (maxval-minval)/inc + 1               #-- number of contour levels.
Explanation: Add cyclic data. Set minimum and maximum contour values although the interval.
End of explanation
wkres                  =  Ngl.Resources()      #-- generate an res object for workstation
wkres.wkColorMap       = "rainbow"             #-- choose colormap
wks_type               = "png"                 #-- graphics output type
wks                    =  Ngl.open_wks(wks_type,"plot_contour_PyNGL",wkres)  #-- open workstation
Explanation: Open a workstation, here x11 window.
End of explanation
res                    =  Ngl.Resources()      #-- generate an resource object for plot
if hasattr(f.variables["tsurf"],"long_name"):
   res.tiMainString = f.variables["tsurf"].long_name  #-- set main title
res.vpXF                  =  0.1               #-- start x-position of viewport
res.vpYF                  =  0.9               #-- start y-position of viewport
res.vpWidthF              =  0.7               #-- width of viewport
res.vpHeightF             =  0.7               #-- height of viewport
res.cnFillOn              =  True              #-- turn on contour fill.
res.cnLinesOn             =  False             #-- turn off contour lines
res.cnLineLabelsOn        =  False             #-- turn off line labels.
res.cnInfoLabelOn         =  False             #-- turn off info label.
res.cnLevelSelectionMode  = "ManualLevels"     #-- select manual level selection mode
res.cnMinLevelValF        =  minval            #-- minimum contour value
res.cnMaxLevelValF        =  maxval            #-- maximum contour value
res.cnLevelSpacingF       =  inc               #-- contour increment
res.mpGridSpacingF        =  30.                #-- map grid spacing
res.sfXCStartV            =  float(min(lon))   #-- x-axis location of 1st element lon
res.sfXCEndV              =  float(max(lon))   #-- x-axis location of last element lon
res.sfYCStartV            =  float(min(lat))   #-- y-axis location of 1st element lat
res.sfYCEndV              =  float(max(lat))   #-- y-axis location of last element lat
res.pmLabelBarDisplayMode = "Always"           #-- turn on the label bar.
res.lbOrientation         = "Horizontal"       #-- labelbar orientation
Explanation: Set resources.
End of explanation
map = Ngl.contour_map(wks,tempac,res)          #-- draw contours over a map.
#-- end
Ngl.delete_wks(wks)                            #-- this need to be done to close the graphics output file
Ngl.end()
Explanation: Draw the plot.
End of explanation
from IPython.display import Image
Image(filename='plot_contour_PyNGL.png') 
Explanation: Show the plot in this notebook.
End of explanation
<END_TASK>