[ncl-talk] Plotting_ET gridded data

Mary Haley haley at ucar.edu
Mon Aug 8 09:41:33 MDT 2016


I looked at your data more closely, and noticed that your A array is
ordered lon x lat, and not lat x lon.  You need to reorder it before you
can plot it, which is what I guess you were trying to do with this code:

A!0="lat"
A!1="lon"

This doesn't work, because this just renames the dimensions, but it doesn't
actually reorder the array.

To reorder the array, you must do one of the following:

A_tranpose = A(lat|:,lon|:)

or:

A_transpose = transpose(A)

It is not necessary to do all that stuff of renaming dimensions and units.

I have modified your script to use transpose. See the attached script and
image.

For future reference, there's a page that describes plotting data on a map
using NCL, and it mentions what to do when your data is ordered lon x lat.
See example 8 at:

http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex8

It uses the "|" method of reordering, rather than "transpose".

--Mary




On Mon, Aug 8, 2016 at 5:08 PM, Kerandi, Noah Misati (IMK) <
noah.kerandi at kit.edu> wrote:

> Dear Mary,
>
> This is what exactly i got with that code.
>
> But i see the first three figures is as if they do not illustrate any
> data. Since with ncview i see clear patterns.
>
> I am using ncl-6.3.0.
>
> Thank you very much.
>
>
> Noah M. Kerandi
> KIT-Campus Alpin
> IMK-IFU: Atmospheric Environmental Research
> Kreuzeckbahnstr. 19,
> 82467 Garmisch-Partenkirchen
> Germany
> ------------------------------
> *From:* Mary Haley <haley at ucar.edu>
> *Sent:* Monday, August 8, 2016 4:58 PM
> *To:* Kerandi, Noah Misati (IMK)
> *Cc:* ncl-talk
> *Subject:* Re: [ncl-talk] Plotting_ET gridded data
>
> Hi Noah,
>
> I was able to run your script just fine with NCL versions 6.2.0, 6.2.1 and
> 6.3.0, and it produced the attached plot.  I didn't get any errors.
>
> What version of NCL are you running?
>
> ncl -V
>
> Also, are you getting any other kind of errors? The error from
> "NhlRemovePrimitive" is very odd, because I don't see anything in your code
> that is trying to remove any primitives.
>
> --Mary
>
>
> On Sun, Aug 7, 2016 at 4:51 PM, Kerandi, Noah Misati (IMK) <
> noah.kerandi at kit.edu> wrote:
>
>> Hi,
>>
>> I am trying to plot some gridded dataset (attached file_*) and model
>> outputs.
>>
>> The model outputs get plotted. However nothing is plotted for the other
>> three (gridded datasets) files.
>>
>> I had seen the error below in one of my trials.
>>
>>
>> "warning:_NclIRemovePrimitive: First parameter is a missing value,
>> returning missing values"
>>
>>
>> However, subsequently i don't see any error though my data is not plotted.
>>
>> If you have any idea or suggestion please share with me.
>>
>> The basic script is pasted below and also attached.
>>
>> Thank you very much.
>>
>> ###################################################
>>
>>
>>
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> ;
>>
>> begin
>> a= addfile("file_v3.0a.nc","r")
>> b=addfile("file_v3.0b.nc","r")
>> c=addfile("file_v3.0c.nc","r")
>> d=addfile("WRF1.nc","r")
>> e=addfile("HYDRO1.nc","r")
>>
>>
>> A=a->E(0,:,:)
>>
>> A at _FillValue = -999
>>
>> A at long_name=""
>> A!0="lat"
>> A!1="lon"
>> A at units    =""
>>
>> A at _FillValue =A at _FillValue
>> A at _FillValue =-999
>> lat =a->lat
>> lat at long_name = "latitude" ;
>>
>> lon = a->lon
>> lon at long_name = "longitude" ;
>>
>> A&lat at units="degrees_north"
>> A&lon at units="degrees_east"
>>
>>
>>
>>
>> printVarSummary(A)
>>
>>
>>
>> B=b->E(0,:,:)
>>
>> B!0="lat"
>> B!1="lon"
>> B at units    =""
>> B at _FillValue = B at _FillValue
>>
>>
>> B at _FillValue= -999
>>
>> lat =b->lat
>> lat at long_name = "latitude" ;
>> lon = b->lon
>> lon at long_name = "longitude" ;
>>
>> B&lat at units="degrees_north"
>> B&lon at units="degrees_east"
>>
>>
>>
>> B at long_name=""
>> B at units    =""
>>
>>
>>
>> C=c->E(0,:,:)
>> C at _FillValue = -999
>> C!0="lat"
>> C!1="lon"
>> C at units    =""
>> C at _FillValue = C at _FillValue
>>
>> C at _FillValue= -999
>>
>>
>> lat =c->lat
>> lat at long_name = "latitude" ;
>>
>> lon = c->lon
>> lon at long_name = "longitude" ;
>>
>>
>>
>> C&lat at units="degrees_north"
>> C&lon at units="degrees_east"
>> C at long_name=""
>> C at units    =""
>>
>>
>>
>>
>> C at long_name=""
>> C at units    =""
>>
>> D=d->ACLHF(0,:,:)
>> D at long_name=""
>> D at units    =""
>>
>> E=e->ACLHF(0,:,:)
>> E at long_name=""
>> E at units    =""
>>
>>
>>
>> ; We generate plots, but what kind do we prefer?
>>      type = "x11"
>>     ;type = "pdf"
>>   ;type = "png"
>>     ;type = "ps"
>> ; type = "ncgm"
>>   wks = gsn_open_wks(type,"test")
>>  plot = new(5,graphic)
>>
>>
>>
>>
>>
>>
>>
>>
>> ;-- plot resource settings
>>
>>    res                    = True
>>   res at cnFillOn             =  True            ;-- enable color filled
>> contours
>>
>>   res at gsnDraw              =  False           ;-- don't draw the plot -
>> yet
>>   res at gsnFrame             =  False           ;-- don't advance the frame
>>   res at gsnMaximize       = True      ; maximize the plot space on page -
>> this will apply to each individual plot
>>   res at cnLineLabelsOn       =  False           ;-- don't draw labels on
>> contour lines
>>   res at cnInfoLabelOn        =  False           ;-- don't draw labels on
>> contour lines
>>   res at lbLabelBarOn         =  False           ;-- don't draw a labelbar
>> below
>>   res at gsnPaperOrientation  = "landscape"
>>   res at cnLevelSelectionMode = "ManualLevels"   ;-- set manual contour
>> levels, so that all
>>                                               ;-- plots have the same
>> labelbar colors/values
>>   res at cnMinLevelValF       =   20            ;-- contour level minimum
>>   res at cnMaxLevelValF       =   200          ;-- contour level maximum
>>   res at cnLevelSpacingF      =    20            ;-- contour level interval
>>
>>
>>   res                    = True
>>
>>   res at pmTickMarkDisplayMode = "Always"
>>   res at mpLimitMode       =  "LatLon"
>>   res at mpMinLatF         = -3.061569  ;min(lat2d)
>>   res at mpMaxLatF         =  2.22883  ;max(lat2d)
>>   res at mpMinLonF         =  34.56185  ;min(lon2d)
>>   res at mpMaxLonF         =  39.91379 ;max(lon2d)
>>   res at mpCenterLonF      = (res at mpMinLonF + res at mpMaxLonF) / 2.
>>   res at mpGeophysicalLineColor      = "Blue"
>>   res at mpDataBaseVersion           = "MediumRes"
>>   res at mpDataSetName               = "Earth..4"
>>   res at mpPerimLineColor            = "Black"
>>   res at mpUSStateLineColor          = "Black"
>>   res at mpLimbLineColor             = "Black"
>>   res at mpNationalLineColor         = "Black"
>>   res at mpNationalLineThicknessF    = 2.5
>>   res at mpOutlineBoundarySets       = "National"
>>   res at mpFillBoundarySets           ="AllBoundaries"
>>   res at mpOutlineOn                  = True
>>   ;res at lbLabelAutoStride            = True
>>   res at lbOrientation =   "horizontal"          ; vertical label bar
>>
>> ; Set the size of the individual title and axis fonts
>>   res at tiXAxisFontHeightF     = 0.035
>>   res at tiYAxisFontHeightF     = 0.035
>>
>> ;Set to False if plotting regional data or setting sfXArray/sfYArray
>>    res at gsnAddCyclic      = False
>>
>>
>>
>>  ;---Uncomment if you want to change the contour levels
>>
>>        res at cnLinesOn            = False    ; turn of contour lines
>>        res at cnFillMode           = "CellFill"           ; Cell Mode
>>        res at cnFillMode           = "RasterFill"         ; Raster Mode
>>        res at cnLinesOn            =  False       ; Turn off contour lines
>>        res at cnLineLabelsOn       =  False       ; Turn off contour lines
>>        res at cnFillPalette        = "precip_11lev"
>>
>>
>>
>>
>>
>>         res at tmXBLabelFontHeightF = 0.035    ; boost the axis value
>> labels even more
>>         res at tmYLLabelFontHeightF = 0.035
>>
>>         ;res at tmYRLabelFontHeightF = 0.030
>>
>>
>>  res at tiMainString         = "file_v3.0a"    ; main title
>>   res at txFont  = "times-roman"
>>   res at tiMainOffsetYF       = -0.008
>>   res at tiMainFontHeightF  = 0.035
>>  plot(0)=gsn_csm_contour_map_ce(wks,A,res)
>>
>>
>>
>>
>>
>>  res at tiMainString         = "file_v3.0b"    ; main title
>>  res at txFont               = "times-roman"
>>  plot(1)=gsn_csm_contour_map_ce(wks,B,res)
>>
>>
>>
>>  res at tiMainString         = "file_v3.0c"    ; main title
>>  res at txFont               = "times-roman"
>> plot(2)=gsn_csm_contour_map_ce(wks,C,res)
>>
>>
>>
>>
>>  res at tiMainString         = "WRF1"    ; main title
>>   res at txFont              = "times-roman"
>>  plot(3)=gsn_csm_contour_map_ce(wks,D,res)
>>
>>
>>
>>
>>  res at tiMainString         = "Hydro1"    ; main title
>>   res at txFont              = "times-roman"
>>   plot(4)=gsn_csm_contour_map_ce(wks,E,res)
>>
>> ;-- panel resources
>>   resP                     =  True
>>   resP at gsnPanelYWhiteSpacePercent= 5     ; set a bit of extra white
>> space between panels in the x and y directions
>>   resP at gsnPanelXWhiteSpacePercent =5
>>
>>
>>    ;resP at gsnPanelBottom      =  0.1            ;-- panel bottom position
>> (y-value)
>>   ;resP at gsnPanelTop         = 0.40
>>   resP at gsnPanelLabelBar    =  True             ;-- draw a common labelbar
>>   resP at lbTitleOn        =  True
>>   resP at lbLabelAutoStride = True
>>   resP at lbTitlePosition  = "Bottom"
>>   resP at lbTitleString    = "ET (mm/month)"
>>   resP at lbTitleFontHeightF= .020                ; make title smaller
>>   resP at lbTitleDirection = "Across"             ; title direction
>>
>>
>>
>>   resP at lbTitleFontHeightF  = .025
>>   resP at amJust              = "TopLeft"    ;-- text justification
>>   resP at gsnMaximize        = True
>>   resP at gsnPanelBottom     = 0.02
>>
>>    resP at lbLabelFontHeightF = 0.015 ;-- label font height
>>    resP at lbLabelFont = "times-roman" ;-- label font
>>
>>
>>    resP at lbTitleOffsetF        = -0.1              ; move the labelbar
>> title downwards
>>
>>   gsn_panel(wks,plot,(/2,3/),resP)
>>
>>
>> end
>>
>>
>> Noah M. Kerandi
>> KIT-Campus Alpin
>> IMK-IFU: Atmospheric Environmental Research
>> Kreuzeckbahnstr. 19,
>> 82467 Garmisch-Partenkirchen
>> Germany
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160808/e6f2e4bc/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 69094 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160808/e6f2e4bc/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_script_mod.ncl
Type: application/octet-stream
Size: 5679 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160808/e6f2e4bc/attachment.obj 


More information about the ncl-talk mailing list