Re: change in array index - no different in graphics result!!!

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Sun Nov 11 2012 - 22:56:12 MST

The plots are the same because while the data is read in "upside-down", the
coordinate array that accompanies that coordinate (latitude here) is also
read in reverse. When NCL then goes to plot, the -90, -89.5,... lat values
all correspond to the same values in var they originally did, just at the
end of the array instead of the beginning. NCL then knows to plot the -89.5
latitude array at 89.5 deg S, regardless of whether it is read in second or
second to last.

If you actually want to plot things upside-down, you would need to reverse
the latitude coordinate. Assuming your coordinate arrays are 1D (they
appear to be), you should be able to use (I haven't tested this):

var&lat = var&lat(::-1)

as this would flip the order of just the latitude array and thus plot the
data "upside-down." Hope that answers your question.

Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
1225 W Dayton St, Madison, WI 53706
Room 1421 Email: ksgriffin2@wisc.edu

On Sun, Nov 11, 2012 at 11:15 PM, marziyeh dadizadeh <marzi_d65@yahoo.com>wrote:

> Dear NCL Users,
>
> I need to plot a contour with lat in reverse. I use to this: var(::-1,:),
> to plot reverse lat and all lon but my plots in both condition, are same! I
> want to show this change in output graphics result but I can not.
>
> var(:,:) and var(::-1,:) are not different in graphics output, why??
>
> can any one help me please?
> Dose any one have any suggestion to solve this problem?
>
> Thanks in advance!
> Marzie
>
>
> -----------------------------------------------------------------------------------
> This is the header of input file:
>
> -----------------------------------------------------------------------------------
>
> path: output.nc
> file global attributes:
> dimensions:
> lat = 181
> lon = 261
> variables:
> float rainfall ( lat, lon )
> units : mm/day
> _FillValue : -100000
>
> float lat ( lat )
> standard_name : latitude
> endValue : 50.125
> startValue : 4.875
> stride : 0.25
> numberOfElements : 181
> units : degrees_N
>
> float lon ( lon )
> standard_name : longitude
> endValue : 85.375
> startValue : 20.125
> stride : 0.25
> numberOfElements : 261
> units : degrees_E
>
>
>
> ----------------------------------------------------------------------------------
> and this is the variable's details :
>
> ----------------------------------------------------------------------------------
>
> Variable: rainfall
> Type: float
> Total Size: 188964 bytes
> 47241 values
> Number of Dimensions: 2
> Dimensions and sizes: [lat | 181] x [lon | 261]
> Coordinates:
> lat: [4.875..50.125]
> lon: [20.125..85.375]
> Number Of Attributes: 2
> units : mm/day
> _FillValue : -100000
>
>
>
> ----------------------------------------------------------------------------
> and this is my script for plotting:
>
> ----------------------------------------------------------------------------
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> begin
>
> wks = gsn_open_wks("x11","out")
> gsn_define_colormap(wks,"WhBlGrYeRe")
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> inf = addfile("output.nc","r")
> var = inf->rainfall(::-1,:) ; here is my question! not
> diffrent between (:,:) and (::-1,:), why????
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> res = True
>
> res@gsnAddCyclic = False
> res@cnFillOn = True
> res@gsnSpreadColors = True
> res@lbOrientation = "Vertical"
> res@gsnMaximize = True
> res@lbLabelAutoStride = True
> res@cnLinesOn = False
>
> res@cnLevelSelectionMode = "ManualLevels"
> res@cnMinLevelValF = 0
> res@cnMaxLevelValF = 50
> res@cnLevelSpacingF = 0.5
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> plot = gsn_csm_contour(wks,var,res)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Nov 11 22:56:42 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 13 2012 - 14:27:24 MST