[pyngl-talk] mapping regional data with mpLimitMode corners
Mary Haley
haley at ucar.edu
Mon Jun 25 12:05:17 MDT 2018
Hi Matt,
Sorry for the delay. I was creating a new NCL example to help explain
things.
Plotting data in its native projection can be tricky, especially if you
have a rotated pole or if you are not sure of the exact parameters for the
map projection.
I think you already know this, but these resources are going to be critical
to getting the map projection correct:
mpres.mpProjection = "Stereographic"
mpres.mpLeftCornerLatF = lat[0,0]
mpres.mpLeftCornerLonF = lon[0,0]
mpres.mpRightCornerLatF = lat[ny-1,nx-1]
mpres.mpRightCornerLonF = lon[ny-1,nx-1]
# mpres.mpCenterRotF = -1
mpres.mpRelativeCenterLon = True
mpres.mpCenterLonF = 358.
mpres.mpRelativeCenterLat = True
mpres.mpCenterLatF = 80.
It's likely going to be the center lat/lon settings that are the issue, and
not the four corners of your data, since the way you are setting the
corners looks correct to me.
Did the data come from a file that had the map projection parameters
defined? If so, could you include the output from an ncdump -h of that file
so I can see if there's anything that might have been left out?
I don't know if you saw these examples, but they might help (even though
they are NCL-based, the same principles apply):
http://www.ncl.ucar.edu/Applications/native.shtml#ex1
http://www.ncl.ucar.edu/Applications/native.shtml#ex6
Example native_6.ncl is the one I just created. This was an example where
we didn't know the correct center longitude, so I had to create a do loop
to try different ones out. I also drew the lat/lon lines associated with
the data (since I had them), so I could see if they were straight or not.
If the lines are straight, then this is a good sign that you have the
correct map projection resources set.
Since you have the lat/lon arrays, you can also add the grid for debugging
purposes. You can use Ngl.add_polyline for this. I've attached an example
of adding lat/lon grid lines using dummy data.
Hope this helps,
--Mary
On Wed, Jun 20, 2018 at 2:14 PM, Fearon, Dr. Matthew, Contractor, Code 7533
via pyngl-talk <pyngl-talk at ucar.edu> wrote:
> Hello,
>
>
>
> I’m using the following Ngl resources to map regional raster data with a
> stereographic projection onto a basemap. Things work fairly well, except I
> am able to see edges of the underlying basemap. Please see figure one
> attached. When I include mpCenterRotF= -1, the basemap edge visibility is
> reduced, but still partially shown along the NW and SE edges. Please see
> figure two. I would like the data overlay to fill the window fully. I’ve
> tried adjusting the lat corners by 0.5 to 1 degree, eg, mpRightCornerLatF =
> lat[ny-1,nx-1]-0.5 and mpLeftCornerLatF = lat[0,0]+0.5, to figure two but
> doing so seems to reveal the underlying basemap more – perhaps because
> rotation of -1 is active after I contract my lat corners. Seems like this
> should be a simple fix, but here I struggle. Perhaps I should be mapping
> regional data differently? Any help or suggestions would be greatly
> appreciated.
>
>
>
> Thank you,
>
> Matt
>
>
>
>
>
> cnres.sfXArray = lon
>
> cnres.sfYArray = lat
>
>
>
> mpres.mpFillOn = True
>
> mpres.mpLandFillColor = "Tan1"
>
> mpres.mpOceanFillColor = "SkyBlue"
>
> mpres.mpInlandWaterFillColor = "SkyBlue"
>
> mpres.mpGeophysicalLineThicknessF= 2.5
>
> mpres.mpLimitMode = "Corners" #"LatLon"
>
>
>
> mpres.mpProjection = "Stereographic"
>
> mpres.mpLeftCornerLatF = lat[0,0]
>
> mpres.mpLeftCornerLonF = lon[0,0]
>
> mpres.mpRightCornerLatF = lat[ny-1,nx-1]
>
> mpres.mpRightCornerLonF = lon[ny-1,nx-1]
>
>
>
> # mpres.mpCenterRotF = -1
>
> mpres.mpRelativeCenterLon = True
>
> mpres.mpCenterLonF = 358.
>
> mpres.mpRelativeCenterLat = True
>
> mpres.mpCenterLatF = 80.
>
> mpres.tfDoNDCOverlay = "DataTransform" #NDCViewport"
>
>
>
> mpres.mpGridLineThicknessF = 0.5
>
> mpres.mpGridLineDashPattern = 2
>
> mpres.mpGridSpacingF = 1
>
>
>
> mpres.mpDataBaseVersion = "MediumRes"
>
> map_plot = Ngl.map(wks,mpres)
>
>
>
> cnres.cnFillOn = True
>
> cnres.cnLinesOn = False
>
> cnres.cnLineLabelsOn = False
>
> cmap = Ngl.read_colormap_file("MPL_PuOr")
>
> cnres.cnFillPalette = cmap[::-1,:]
>
> cnres.cnLevelSelectionMode = "ExplicitLevels"
>
> cnres.cnLevels = [-10,-8,-6,-4,-2,2,4,6,8,10]
>
>
>
> cnres.lbAutoManage = False
>
> cnres.pmLabelBarWidthF = 0.02
>
> cnres.lbLabelFontHeightF = 0.009
>
> contour_plot = Ngl.contour(wks,cvar,cnres)
>
>
>
> Ngl.overlay(map_plot,contour_plot)
>
> _______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20180625/19243d1a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: latlon_grid.py
Type: text/x-python-script
Size: 2811 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20180625/19243d1a/attachment.bin>
More information about the pyngl-talk
mailing list