Re: Masking a map correctly with a black background

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri, 8 May 2009 15:19:15 -0600

On May 8, 2009, at 2:24 PM, Mary Haley wrote:

>
> [Dave B, please see below for a question directed at you.]
>
> On Fri, 8 May 2009, Mark Branson wrote:
>
>>
>> Hi Mary.
>>
>> Many thanks for coming up with this solution, and sorry for
>> causing you such
>> grief with the ice shelves. I may just stick with the original
>> map database
>> because I'm not crazy about all of the small islands showing up as
>> little
>> white dots now, but I may let our end user make the final call on
>> that.
>
> With the default map database, it is possible to mask these small
> islands, but I don't see a way to do this with the Earth..4 database.
>
> Dave, do you know of a way?

I think we are talking about a global map, correct?
It is possible to eliminate many of the islands and much of the
perceived clutter by setting mpMaskAreaSpecifiers and/or
mpMaskOutlineSpecifiers
to the following:

(/"atlantic islands", "pacific islands", "indian ocean islands",
"caribbean islands"/)

This may remove somewhat more than you want, so you can add selected
bigger islands back in by setting mpFillAreaSpecifiers and/or
mpOutlineSpecifiers, using, e.g.:

(/"cuba","jamaica"/)

However this does not address islands that "belong" to continental
areas, such as the islands near Antarctica, Australia or Indonesia.
Unfortunately, there is no way that I know of to specify 'all the
islands around Australia but not the continent itself'. However, if
you have the patience you could create a mask specifier that
individually lists all the additional islands you want to eliminate.

That is something that should be on the to-do list: as you can now
specify "colorado : counties", maybe it would not be too hard to
create an "islands" specifier that would allow for entries like
"australia : islands".
  -dave

>
>> One final question: What font do you have set up on your end?
>> The labels on
>> this latest png file you sent me look a million times better than
>> what I
>> have. I have *Font : helvetica set in my .hluresfile.
>
> That's what I used. However, I also set:
>
> res_at_gsnMaximize = True
>
> inside the code so that the plot was maximized in the PS file. This
> caused the image to be rotated, and was much bigger.
>
> I then used "convert" from ImageMagick:
>
> convert -trim -rotate -90 icearea_m.ps icearea_m.png
>
> The PS file does get rather large when you set gsnMaximize to True.
>
> One thing you can try instead is to increase the density
> when/if you use convert:
>
> convert -trim -denisty 200 icearea1.ps icearea1.png
>
>> Thanks again for all your hard work on this. It is very much
>> appreciated!
>
> You're welcome. I hope you are able to get things sorted out.
>
> --Mary
>
>> Mark
>>
>>>
>>> Mark,
>>>
>>> Horrors on my part. I spent a bit of time convincing myself
>>> yesterday
>>> that the default map database didn't have ice shelves, and now that
>>> I've apparently rebooted my brain, I do see them. Grrrr.
>>>
>>> I'm not sure what I did yesterday, because I know I generated maps
>>> that contained solid gray fill where there should have been ice
>>> shelves.
>>>
>>> Well, mystery aside, these ice shelves that you are seeing in black
>>> (once you swap the foreground/background colors) is due to the fact
>>> that they are considered part of the ocean in the default map
>>> database. There's no way to single them out to color them in white.
>>>
>>> So, we're back to having to use the "Earth..4" database if you
>>> want to
>>> color those ice shelves individually. You need to have V5.1.0 in
>>> order
>>> to get these shelves.
>>>
>>> Please see the attached script (and image), which is taken from your
>>> last script, with your original color map added back in.
>>>
>>> I'm sorry about the go around on this. Now I'll probably spend
>>> another
>>> hour trying to prove I didn't imagine things yesterday. :-)
>>>
>>> --Mary
>>>
>>>
>>> On Thu, 7 May 2009, Mark Branson wrote:
>>>
>>>> Well, I think I understand what's going on in the sample codes
>>>> and pngs
>>>> you sent, but I'm still confused as to how to solve my problem.
>>>> So I've
>>>> trimmed my code down to the bare essentials, and to avoid any
>>>> possible
>>>> confusion that my custom color scheme (with the blues going to
>>>> white)
>>>> might be injecting into the mix I'm just using the "cosam"
>>>> predefined
>>>> color table for now. Then with this code I created three
>>>> different test
>>>> plots:
>>>>
>>>> icearea1.ps - The code as it is displayed below (i.e., gray is
>>>> not being
>>>> added to the end of the color table, and I'm not changing the
>>>> background
>>>> and foreground colors). What I see in my postscript viewer is
>>>> white
>>>> continents with the color fill of the ice area data.
>>>>
>>>> icearea2.ps - uncomment out the line "i = NhlNewColor(wks,
>>>> 0.8,0.8,0.8)".
>>>> Now the continents are gray, but the inland lakes and what I
>>>> call the
>>>> Antarctic ice shelve areas are still white.
>>>>
>>>> icearea3.ps - now also uncomment out the setvalues block to
>>>> change the
>>>> foreground and background colors. This plot looks identical to
>>>> icearea2.ps except that now the inland lakes and ice shelves
>>>> area black.
>>>>
>>>> I hope it's okay to attach postscript files to this message. I
>>>> was going
>>>> to convert them to png with imagemagick and send those but that
>>>> actually
>>>> makes them look slightly different than the ps files on my
>>>> machine (Mac
>>>> Powerpc desktop).
>>>>
>>>> And below is the actual code.
>>>>
>>>> Thanks!
>>>> Mark
>>>>
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>>>
>>>> begin
>>>>
>>>> b = addfile("/Volumes/xraid3/endworld/ice/endworld3.csim.h.
>>>> 0011-07.nc",
>>>> "r")
>>>>
>>>> data = b->aice
>>>> lat2d = b->TLAT
>>>> lon2d = b->TLON
>>>> data_at_lon2d = lon2d
>>>> data_at_lat2d = lat2d
>>>> outfile = "icearea1"
>>>>
>>>> wks = gsn_open_wks("ps",outfile) ; open a postscript file
>>>>
>>>> gsn_define_colormap(wks,"cosam")
>>>> ;i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to
>>>> colormap
>>>>
>>>> res = True
>>>>
>>>> ;setvalues wks
>>>> ; "wkBackgroundColor" : (/0.,0.,0./)
>>>> ; "wkForegroundColor" : (/1.,1.,1./)
>>>> ;end setvalues
>>>>
>>>> res_at_cnFillOn = True ; Fill contours
>>>> res_at_cnLinesOn = False
>>>> res_at_cnLineLabelsOn = False
>>>>
>>>> res_at_gsnAddCyclic = True
>>>> res_at_mpOutlineOn = False
>>>>
>>>> res_at_gsnRightString = "percent"
>>>> res_at_gsnLeftString = "July Year 11"
>>>> res_at_tiMainString = "Sea Ice Area"
>>>>
>>>> res_at_tmXBTickSpacingF = 60. ; every 60 degrees
>>>>
>>>> plot = gsn_csm_contour_map(wks,data(0,:,:),res)
>>>>
>>>> end
>>>>
>>> <icearea_m.png><icearea_m.ncl>
>>
>>
> _______________________________________________
> 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 Fri May 08 2009 - 15:19:15 MDT

This archive was generated by hypermail 2.2.0 : Mon May 11 2009 - 09:43:46 MDT