Re: Masking a map correctly with a black background

From: Mark Branson <mark_at_nyahnyahspammersnyahnyah>
Date: Thu, 7 May 2009 15:43:31 -0600

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: - 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. - 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. - now also uncomment out the setvalues block to change the
foreground and background colors. This plot looks identical to 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.



load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"


   b = addfile("/Volumes/xraid3/endworld/ice/endworld3.csim.h.", "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

   ;i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to

   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)


> Yes, that does, thanks.
> The default behavior of the gsn_csm_xxxx_map scripts is that land is
> colored in gray, and oceans and water areas in the background color
> (white in the first case).
> So, you originally saw gray land and white water areas. The ice
> shelves themselves should be filled in gray, too, as they are just
> considered part of land in the default map being drawn.
> I'm not sure how you managed to see white ice shelves, unless
> you are setting some map resources in a separate resource file.
> When you switched the background/foreground colors, you still
> got gray land (and hence gray ice shelves), but black water/ocean,
> since black is now the background color.
> The best way to get ice shelves is to use the "Earth..4"
> map database. Please see the attached scripts and resultant
> *png files, which will show you the default map that you're
> getting, and how to get a map with white ice shelves and
> inland water.
> --Mary

Received on Thu May 07 2009 - 15:43:31 MDT

This archive was generated by hypermail 2.2.0 : Fri May 08 2009 - 10:05:07 MDT