Output files

From: Melissa Lazenby <M.Lazenby_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 10 2013 - 07:01:15 MDT

Hi

I am plotting graphics showing lat vs time for precipitation and was wondering how to get the output of the data into a .nc file as I would like to perform a spatial correlation on it using cdo. I assume this should be simple but everything I have found on it has been rather complicated. I have just read in a .nc file and want to output the modified .nc. Is there an easy was to do this?

Many thanks for your help in this matter!

Kind Regards

Melissa

Here is the script

;*********************************************
; lat_time_bw.ncl
;*********************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

begin

 fili = "/mnt/nfs2/geog/ml382/melphd/hov/siczoutputprhov/cmap_pr_safrica_1979-1999_12.nc" ; data

 f = addfile (fili , "r") ; add file
 lat = f->lat ; get lat
 lon = f->lon ; get lon
 time = f->time ; get time
 ;level = f->z ; get level
 precip = f->precip ; get precip
 precip2 = precip(:,:,:)

 printVarSummary(precip2)

 ;lon30E = ind(lon.eq.30.) ; subscript at 30E
 latS = -30.
 latN = 30.
 shov = precip2(time|:,lat|:,lon|:)
 dims = dimsizes(shov) ; shov=3D array=(12,40,37)
 printVarSummary(dims)
 sdemo = dim_avg_Wrap(shov) ;sdemo(time,lat)

 printVarSummary(sdemo)

 ;sdemo!0 = "lat"
 ;sdemo!1 = "time"
 ;sdemo&lat = lat
 ;sdemo&time= time

 sdemo1 = sdemo(lat|:,time|:)
 sdemo1 = smth9 (sdemo1,0.5, 0.25, False) ; 2D smoother
 sdemo1@units<mailto:sdemo1@units> = "mm/month"
 sdemo1@long_name<mailto:sdemo1@long_name> = "pr"
 gtPat = 17 ; stiple
 ltPat = 3 ; hatch
;*************************
; plotting parameters
;*************************
 wks = gsn_open_wks ("eps", "lat_time_bw_CMAP" ) ; open workstation
 gsn_define_colormap(wks,"gsltod") ; choose color map

 res = True ; plot mods desired
 res@cnFillOn<mailto:res@cnFillOn> = True ; color on
 ;res@gsnDraw = False ; don't draw yet
 res@gsnAddCyclic<mailto:res@gsnAddCyclic> = False
 res@lbLabelStride<mailto:res@lbLabelStride> = 4 ; every other label
 res@lbOrientation<mailto:res@lbOrientation> = "Horizontal" ; vertical label bar
 res@pmLabelBarOrthogonalPosF<mailto:res@pmLabelBarOrthogonalPosF> = -0.04 ; move label bar closer to axis
 res@cnLinesOn<mailto:res@cnLinesOn> = False ; turn off contour lines
 res@gsnSpreadColors<mailto:res@gsnSpreadColors> = True ; use full range of color map
 res@gsnFrame<mailto:res@gsnFrame> = True ; don't advance frame yet

 res@tiMainString<mailto:res@tiMainString> = "CMAP" ; title

 res@vpXF<mailto:res@vpXF> = 0.12 ; default is 0.2 change aspect
 res@vpYF<mailto:res@vpYF> = 0.8 ; default is 0.8 ration
 res@vpHeightF<mailto:res@vpHeightF> = 0.4 ; default is 0.6
 res@vpWidthF<mailto:res@vpWidthF> = 0.8 ; default is 0.6

 res@cnLevelSelectionMode<mailto:res@cnLevelSelectionMode> = "ManualLevels" ; manual levels
 res@cnMinLevelValF<mailto:res@cnMinLevelValF> = 0 ; min level
 res@cnMaxLevelValF<mailto:res@cnMaxLevelValF> = 260 ; max level
 res@cnLevelSpacingF<mailto:res@cnLevelSpacingF> = 20 ; contour spacing

 res@tmXBMode<mailto:res@tmXBMode> = "Explicit" ; Define own tick mark labels.
 res@tmXBValues<mailto:res@tmXBValues> = (/ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11. /)
 res@tmXBLabels<mailto:res@tmXBLabels> = (/"DEC","JAN","FEB","MAR" ,"APR","MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV" /)

; reverse the first two colors
  setvalues wks
    "wkColorMap" : "gsltod"
    "wkForegroundColor" : (/0.,0.,0./)
    "wkBackgroundColor" : (/1.,1.,1./)
  end setvalues

 plot = gsn_csm_lat_time(wks, sdemo1({-30:30},:), res )
 ;plot = ShadeLtGtContour(plot, -0.7, ltPat, 0.6, gtPat)
 ;plot = ZeroLineContour (plot)
 ;draw (plot) ; draw the contour object
 frame (wks) ; advance frame

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 10 07:01:32 2013

This archive was generated by hypermail 2.1.8 : Mon Sep 16 2013 - 13:43:52 MDT