[ncl-talk] landseamask
Mary Haley
haley at ucar.edu
Sun Dec 23 09:47:12 MST 2018
Ehsan,
Please look at the last script I sent you, the one called
WRF_pcp_tv_mod_layers.ncl.
It shows how to create the various plots that you want, in the order that
you want everything drawn. If you want to see the mpGeophysical/National
lines, then instead of adding them to the terrain plot, try adding them to
the code that creates "wrf_map", as this is the last plot that gets drawn
on top of everything else.
--Mary
On Fri, Dec 21, 2018 at 6:38 PM Ehsan Taghizadeh <ehsantaghizadeh at yahoo.com>
wrote:
> Dear Mary,
> I really appreciate for your time and very helpful reply and script.
> You are right whether I want the rain totals over land and water. So your
> attached figure is what I want. However, the problem is that country
> boundaries have been covered by rain! I mean (mpGeophysicalLineColor and
> mpNationalLineColor) which have taken black color, have gone under
> rain contours.
>
> Sincerely
> Ehsan
> On Saturday, December 22, 2018, 3:42:12 AM GMT+3:30, Mary Haley <
> haley at ucar.edu> wrote:
>
>
> Ehsan,
>
> I was concerned that the last script might have slowed down the plotting
> too much, so I created a second version that is faster. It goes back to
> setting tfDoNDCOverlay=True, which makes the plotting faster.
>
> This time, however, instead of using "overlay" to overlay the plots, the
> script simply creates three plots:
>
> 1. Filled terrain plot over a map
> 2. Filled rain total plot
> 3. WRF map with city markers, text, and shapefile outlines added
>
> and then it makes sure these three plots have the same vpXF / vpYF /
> vpWidthF / vpHeightF values and draws them one after. This script takes
> about 4 seconds on my Mac compared to 11 seconds for the other one. The
> advantage of this script is that you don't have to deal with as many
> "DrawOrder" resources, as the draw order is controlled by creating
> individual plots and drawing them in the order you want them to appear.
>
> --Mary
>
>
> On Fri, Dec 21, 2018 at 8:34 AM Mary Haley <haley at ucar.edu> wrote:
>
> Ehsan,
>
> That's what I wasn't sure of, whether you wanted the rain totals over land
> and water.
>
> This involved a minor tweak to a draw order resource. Is the attached what
> you want?
>
> Here are some of the changes I had to make to get this script to work:
>
> - In order to get the markers and shapefile polylines to not be
> covered up, I had to add them to the rain total plot, since this plot is
> the one that gets drawn last.
>
> - Since the rain total plot was a simple contour plot with no concept
> of X and Y coordinate values, you can't add lat/lon markers and shapefile
> polylines to it because it needs lat/lon information to do this. So, I had
> to add sfXArray and sfYArray resources for this plot, and that makes it
> possible to attach lat/lon stuff to it.
>
> - To stay consistent, I also set sfXArray and sfYArray to the terrain
> plot.
>
> - Now that sfX/YArray are being set, you do NOT want to set
> tfDoNDCOverlay for either plot. Also, you must set gsnAddCyclic to False
> for both plots so it doesn't try to add a longitude cyclic point.
>
>
> Unfortunately, when you set sfX/YArray, this means your plot takes a
> longer to draw, because now it is doing a transformation calculation.
>
> See attached.
>
> --Mary
>
>
> On Fri, Dec 21, 2018 at 12:39 AM Ehsan Taghizadeh <
> ehsantaghizadeh at yahoo.com> wrote:
>
> Dear Mary,
> In your attached figure, water in lake cover total rain and this is wrong!
> But poly line of shapefile are seen under rain total and this is OK.
>
> Sincerely
> Ehsan
> On Friday, December 21, 2018, 4:30:42 AM GMT+3:30, Mary Haley <
> haley at ucar.edu> wrote:
>
>
> Thanks for providing the files.
>
> I think I understand the ordering of everything that you want, and it can
> be really frustrating trying to do this with NCL.
>
> The issue is simply that since the lines and markers are being added to
> the terrain map, and then the rain total contours are being drawn on top of
> that, they are going to cover up the lines and markers.
>
> The solution seem to be to add the lines and markers to the rain total
> plot instead, but in order to do this, you have to provide lat/lon
> coordinate information to the rain total map, so that the lines and markers
> are added in the correct locations.
>
> Before I go any further with this, can you tell me if the attached image
> is what you are looking for?
>
> thanks,
>
> --Mary
>
>
> On Thu, Dec 20, 2018 at 4:43 PM Ehsan Taghizadeh <
> ehsantaghizadeh at yahoo.com> wrote:
>
> Dear Mary,
> I'm so sorry that this debugging has been prolonged. I've tried to fix the
> problems by myself, however unfortunately I failed.
> I've put input data files in ftp: (wrfout_d01_2018-12-19.tar.gz,
> shp_stations.tar.gz, shp_ostan.tar.gz), also my color table (tvprecp.rgb).
> I've also attached my script, and two figures which reflect my problem. As
> you can see, national boundaries (black poly lines) and province boundaries
> (red poly lines) are masked in WRF5.png by precipitation contours.
>
> I hope you have time to consider my problem again.
> Sincerely
> Ehsan
> On Friday, December 21, 2018, 2:01:08 AM GMT+3:30, Mary Haley <
> haley at ucar.edu> wrote:
>
>
> I'm not sure I follow all that logic, because I'm losing track of what's
> being drawn when. :-)
>
> But, this might work:
>
> lnres at gsPolyDrawOrder = "PostDraw"
>
> If that doesn't work, then I'll need more clarification on what you mean
> by things being masked or not masked. For example, in the image you
> provided, I can see the red province lines, but I'm not sure where you were
> expecting the markers to show up.
>
> At some point I may need to have your script and data if I'm going to
> continue debugging this.
>
> --Mary
>
>
>
> On Thu, Dec 20, 2018 at 12:36 PM Ehsan Taghizadeh <
> ehsantaghizadeh at yahoo.com> wrote:
>
> Dear Mary
> As you suggested I add following line:
> res_tot at cnLineDrawOrder = "PostDraw"
> and it works well. Now I have contour lines and also raster contours
> become smooth. However I still have problem with outlineboundaries and also
> province shapefiles. I've used below line:
> res_ter at mpOutlineDrawOrder = "PostDraw"
> However as you may guess it doesn't work, because after that I have:
> res_tot at cnFillDrawOrder = "PostDraw"
> Same problem is for province shapefile, as province boundaries are masked
> (red lines). But interesting (may be just for me) markers in other
> shapefile (MASA, OIGG, ...) are not masked!
> So the remained problem is masking of outlineboundaries and province
> boundaries in shapefile (WRF4.png is attached).
>
> I'll be thankful if I could have your help about it.
>
> Sincerely
> Ehsan
> On Thursday, December 20, 2018, 8:29:02 PM GMT+3:30, Mary Haley <
> haley at ucar.edu> wrote:
>
>
> Hi Ehsan,
>
> Good catch on the inland water resource addition!
>
> When you set cnFillDrawOrder to PostDraw, this causes the filled contours
> to be drawn last, and since these are raster contours and hence blocky
> looking, you are seeing the artefacts of the blocks bleeding into the
> contour lines
>
> There is a cnLineDrawOrder resource, so perhaps try setting to to
> "PostDraw" and see if it gets drawn on top of the filled contours. You
> might have to play around with the cnFillDrawOrder too, maybe setting it to
> "Draw" instead of "PostDraw".
>
> If you continue to have problems, let us know. There are other ways to do
> this kind of ordering, but it can get a little more involved.
>
> Good luck,
>
> --Mary
>
>
>
>
> On Thu, Dec 20, 2018 at 6:41 AM Ehsan Taghizadeh <
> ehsantaghizadeh at yahoo.com> wrote:
>
> Dear Mary
> Your answer is exactly what I want. However I still have 2 problems and
> I'll be thankful for any help about them.
> 1. Caspian sea and Black sea didn't fill (WRF1.png in attached)! So I
> added following line:
> res_ter at mpInlandWaterFillColor = "SkyBlue"
> and it seems works (WRF2.png in attached).
> 2. However in both figures I missed last shaded contours (here
> precipitation) on water lands! So I added following line too:
> res_tot at cnFillDrawOrder = "PostDraw" ; Also can try "Predraw"
> Now I missed contour lines for both precipitation and boundaries (WRF3.png
> in attached)! Beside that I've got RasterFill for precipitation. I've
> used
> res_tot at cnFillMode = "RasterFill"
> however it didn't affect for figures (WRF1.png and WRF2.png), but it
> affected WRF3.png!
>
> My plot lines are as below:
> plot_terrain = gsn_csm_contour_map(wks,HGT,res_ter)
> add_outlines_to_map(wks,plot_terrain) ; OK
> add_places_to_map(wks,plot_terrain) ; OK
> plot_raintot = gsn_csm_contour(wks,RainTotal,res_tot)
>
> overlay(plot_terrain, plot_raintot)
> draw(plot_terrain)
> frame(wks)
>
> I hope my email is clear and I ask my problem correctly. Also I attached
> my script, even though it seems sloppy and doesn't have input data!
> Any help will be appreciated.
>
> Sincerely
> Ehsan
> On Wednesday, December 19, 2018, 7:55:28 PM GMT+3:30, Mary Haley <
> haley at ucar.edu> wrote:
>
>
> Ehsan,
>
> Do you mean that you want to fill the ocean in some solid color and hence
> mask any data in that area? If so, you can try:
>
> res at mpFillOn = True
> res at mpOceanFillColor = "SkyBlue" ; use whatever color you want
> res at mpLandFillColor = "Transparent" ; to make sure land doesn't get
> filled
>
> You might also need to set some draw order resources, to make sure the
> filled contours and filled map areas get drawn in the right order:
>
> res at cnFillDrawOrder = "Draw" ; Also can try "predraw"
> res at mpFillDrawOrder = "PostDraw"
>
> You can see some masking examples at:
>
> http://www.ncl.ucar.edu/Applications/mask.shtml
>
> Use your browser search to look for "draworder".
>
> --Mary
>
>
> On Wed, Dec 19, 2018 at 8:13 AM Ehsan Taghizadeh <
> ehsantaghizadeh at yahoo.com> wrote:
>
> Hi,
> May I ask how to fill sea (lake, ...) areas differently from land. I've
> tried using "https://www.ncl.ucar.edu/Applications/grid_fill.shtml" (
> grid_fill_5.ncl) and I've got attached map.
> That part which I used from grid_fill_5.ncl are:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; Read/open NCL'ls crude (1x1) land-sea mask
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> a2 = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")
> lsdata = a2->LSMASK
> lsm = landsea_mask(lsdata, xlat, xlong)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> HGT2 := HGT ; replicate for plot
> HGT2 = where(lsm.eq.0 , HGT2 at _FillValue , HGT2)
> HGT2 = where(lsm.eq.2 , HGT2 at _FillValue , HGT2)
> HGT2 = where(lsm.eq.4 , HGT2 at _FillValue , HGT2)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> where "HGT" is "Terrain Height" of WRF. The issue of the attached file is
> raster filled of sea areas. However is there a better way to fill sea areas?
>
> Sincerely
> Ehsan
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> 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/20181223/5c4bdfd6/attachment.html>
More information about the ncl-talk
mailing list