[ncl-talk] mpProjection in gsn_csm_contour
David Brown
dbrown at ucar.edu
Mon Mar 23 14:43:57 MDT 2015
Hi Frank,
Sorry for the delay in answering. Only map plots themselves have the
concept of a projection. When you overlay a contour plot on a map plot the
contour data locations are transformed into the current map projection.
That is, as long as the contour data has the appropriate coordinate arrays
attached. If the u1 data has 1d coordinates that are defined in the file
using the usual NetCDF-style conventions, then the coordinates will be
automatically known to the gsn routines and the data will be mapped
correctly into the current map projection.
In this case, a printVarSummary of the u1 variable should show something
like:
Variable: u1
Type: float
Total Size: 32768 bytes
8192 values
Number of Dimensions: 2
Dimensions and sizes: [lat | 64] x [lon | 128]
Coordinates:
lat: [-87.8638..87.8638]
lon: [-180..177.1875]
Number Of Attributes: 5
time : 1
_FillValue : -999
long_name : Zonal Wind
short_name : U
units : m/s
which indicates that there are 1D variables in the file named lat and lon
that have the same dimensions as the two dimensions of the u1 variable.
The names of these don't matter but in order to overlay properly these
variables need a compatible 'units' attribute, usually 'degrees_east' for
longitude and 'degrees_north' for latitude.
If u1 is on some sort of pre-projected grid, then an overlay into a
arbitrary map projection requires that that a set of 2D coordinate
variables that define the individual position of each grid point be passed
along with the contour data. There are two ways to do this:
1) define the special attributes lon2d and lat2d for the u1 variable:
u1 at lat2d = <2d lat coordinates>
u1 at lon2d = <2d lon coordinates>
2) define the resources sfXArray and sfYArray with these same coordinates:
resNatVar at sfXArray = <2d lon coordinates>
resNatVar at sfYArray = <2d lat coordinates>
If these 2D coordinates are not available in the file, then you will need
to use an external program such as PROJ4 to calculate them based on the
projection used for the u1 data.
If this does not answer your questions, then we will need sample data files
plus a complete runnable script in order to help further.
-dave
On Wed, Mar 18, 2015 at 1:08 AM, Kreienkamp Frank <Frank.Kreienkamp at dwd.de>
wrote:
> Hello,
>
>
>
> i want to plot a grid based plot, including an contour overlay. The grid
> based plot is drawn in Stereographic projection using mpProjection =
> "Stereographic" and plot = gsn_csm_map(wks,res). On top of this map I want
> to add a contour-plot showing if changes are significant or not.
>
> Unfortunately both plots do not use the same projection.
>
>
>
> But if I use resNatVar at mpProjection = "Stereographic" I get the
> information: warning:mpProjection is not a valid resource in ..
>
>
>
> I have added the source-code part and an example plot.
>
>
>
> What can I do?
>
>
>
> Thanks in advance
>
> Frank
>
>
>
> ;************************************************
> ; create plot
> wtype = "png"
> wtype at wkWidth = 970 ; Set the pixel
> size of image.
> wtype at wkHeight = 1000 ; Set the pixel
> size of image.
> wks = gsn_open_wks(wtype,"test")
> ;************************************************
> res = True
> res at gsnMaximize = True
> res at gsnDraw = False
> res at gsnFrame = False
> res at mpProjection = "Stereographic"
> res at mpCenterLatF = 50 ; Centered over
> Germany
> res at mpCenterLonF = 10 ; Centered over
> Germany
> res at mpLimitMode = "Corners" ; choose range
> of map
> res at mpLeftCornerLatF = 55.8
> res at mpLeftCornerLonF = 2.6
> res at mpRightCornerLatF = 45.1
> res at mpRightCornerLonF = 19.5
> res at mpGridLatSpacingF = 2
> res at mpGridLonSpacingF = 2
> res at mpOutlineDrawOrder = "PostDraw" ; draw
> continental outline last
> res at mpFillDrawOrder = "PreDraw"
> res at mpDataBaseVersion = "HighRes" ; use finer
> database
> res at mpOutlineBoundarySets = "National"
> res at mpFillOn = False ; turns off
> continent gray
> res at mpLeftAngleF = 7
> res at mpRightAngleF = 8
> res at mpBottomAngleF = 6
> res at mpTopAngleF = 8
> res at mpMinLatF = 10.0
> res at pmTickMarkDisplayMode = "Always" ; Nicer
> tickmark labels
> res at mpGridAndLimbOn = True ; Turn on
> lat/lon grid
> res at mpGridLineDashPattern = 2 ; Dashed lines
> res at tmXTOn = False ; turn
> tickmarks of
> res at tmXBOn = False ; turn
> tickmarks of
> res at tmYLOn = False ; turn
> tickmarks of
> res at tmYROn = False ; turn
> tickmarks of
> res at gsnLeftString = ""
> ;************************************************
> ; Plot will just be created, and not drawn yet.
> plot = gsn_csm_map(wks,res) ; Create plot
> ;************************************************
> ; adding color definition
> cmap =
> RGBtoCmap("/kp/kp06/VisTool/data/konstdat/Farben_rgb_temp.dat")
> gsn_define_colormap(wks,cmap)
> ;************************************************
> ; adding map
> res at cnFillOn = True ; color Fill
> res at cnFillMode = "RasterFill" ; Raster Mode
> res at cnLinesOn = False ; Turn off
> contour lines
> res at cnLevelSelectionMode = "ManualLevels"
> res at cnMinLevelValF = -90.0 ; min contour level
> res at cnMaxLevelValF = 90.0 ; max contour level
> res at cnLevelSpacingF = 20.0 ; contour spacing
> res at cnLabelBarEndStyle = "ExcludeOuterBoxes" ; no
> additional ColorBoxes
> res at gsnAddCyclic = False ; regional
> data: not cyclic
> ;************************************************
> ; Plot will just be created, and not drawn yet.
> plot = gsn_csm_contour_map(wks,u,res)
> ;************************************************
> ; add Info robust signal
> resNatVar = True
> resNatVar at gsnMaximize = True
> resNatVar at gsnDraw = False
> resNatVar at gsnFrame = False
> resNatVar at gsnLeftString = ""
> resNatVar at lbLabelBarOn = False
> resNatVar at cnFillOn = True ; color
> Fill
> resNatVar at cnLinesOn = False ; Turn
> off contour lines
> resNatVar at cnLevelSelectionMode = "AutomaticLevels"
> resNatVar at cnFillMode = "AreaFill" ; Raster
> Mode
> resNatVar at cnFillPattern = 17
> resNatVar at cnFillBackgroundColor = -1
> resNatVar at cnInfoLabelOn = False
> resNatVar at cnLineLabelsOn = False
> resNatVar at cnMonoFillColor = True
> resNatVar at cnConstFEnableFill = True
> resNatVar at cnConstFLabelOn = False
> resNatVar at cnFillColor = "black"
> ;************************************************
> ; Plot will just be created, and not drawn yet.
> plot1 =
> gsn_csm_contour(wks,u1,resNatVar)
> overlay(plot,plot1)
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20150323/3a27ebbf/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 145280 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150323/3a27ebbf/attachment.png
More information about the ncl-talk
mailing list