Re: Masking a map correctly with a black background

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

Hi Mary.

I should have explained my problem better. In the original script
with a white background, I get the continents masked in gray with no
outlines, and all of the inland lakes as well as the ice shelves are
white, and that's exactly what I want and everything looks great. But
when I switch to a black background, the continents are still gray but
now have black borders, and the inland lakes as well as the ice
shelves are now black as well. I'd rather keep those all white as
they were originally.

Does that make more sense?

Thanks!
Mark

>
> Mark,
>
> I'm not exactly sure what you mean by black ice shelf areas, because
> in the script you have below, I wouldn't expect you to see any ice
> shelves; they are not included in the default map database.
>
> See the attached script. I've taken your script, removed the
> data stuff, and set some resources to get blue-filled ice shelves.
>
> Is this what you're looking for?
>
> --Mary
>
>
> On Wed, 6 May 2009, Mark Branson wrote:
>
>>
>> I'm making cylindrical equidistant maps of sea ice area from some
>> CCSM
>> ice history files. It all works great until I try to switch the
>> foreground and background colors such that I have white text on a
>> black background (request by the end user). However, this messes up
>> the default masking colors such that I get black ice shelf areas down
>> off Antarctica. I can see from the examples in "Masking" section on
>> the web site that there are rather detailed ways of masking/filling
>> certain subareas, but so far what I've tried has not worked.
>>
>> Any suggestions would be greatly appreciated!
>>
>> Thanks,
>> Mark
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> begin
>>
>> ;------------------------------------------------------------------------------------;
>> ; add files
>>
>> ;fList = systemfunc("ls /Volumes/xraid3/endworld/ice/endworld*.nc")
>> fList = systemfunc("ls /Volumes/xraid3/endworld/ice/endworld3.csim.h.
>> 0011-07.nc")
>> nFiles = dimsizes(fList)
>>
>> month = (/
>> "Jan
>> ","Feb
>> ","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" /)
>> imo = 6
>> iyr = 1
>> do iFile = 0, nFiles-1
>> b = addfile(fList(iFile), "r")
>>
>> data = b->aice
>> lat2d = b->TLAT
>> lon2d = b->TLON
>> data_at_lon2d = lon2d
>> data_at_lat2d = lat2d
>>
>> ;----------------------------------------------------------------------------------------;
>> ;create plot
>> ;***************************************************************************************
>> ;***************************************************************************************
>> outfile = "icearea" + sprinti("%0.3i",iFile)
>>
>> wks = gsn_open_wks("ps",outfile) ; open a postscript file
>>
>> color_map = (/(/1.00,1.00,1.00/),(/0.00,0.00,0.00/), \
>> (/0.1411765,0.,0.8470588/), (/
>> 0.09411765,0.1098039,0.9686275/), \
>> (/0.1568628,0.3411765,1./), (/
>> 0.2392157,0.5294118,1./), \
>> (/0.3372549,0.6901961,1./),(/
>> 0.4588235,0.827451,1.00/), \
>> (/0.6,0.9176471,1./), (/0.7372549,0.9764706,1.0/), \
>> (/0.9176471,1.0,1.0/),(/1.00,1.00,1.00/)/)
>>
>> gsn_define_colormap(wks,color_map)
>> i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to
>> colormap
>> ;***************************************************************************************
>> ;***************************************************************************************
>> ; resources for all plots
>> res = True
>> res_at_gsnDraw = False ; Do not draw plot
>> res_at_gsnFrame = False ; Do not advance
>> frame
>>
>> setvalues wks
>> "wkBackgroundColor" : (/0.,0.,0./)
>> "wkForegroundColor" : (/1.,1.,1./)
>> end setvalues
>>
>> ;*** from mask_4.ncl example, try to explicit set the fill areas we
>> want
>> ;fill_specs = (/"ice_shelf","land"/)
>> ;res_at_mpFillBoundarySets = "NoBoundaries"
>> ;res_at_mpFillAreaSpecifiers = fill_specs
>> ;res_at_mpSpecifiedFillColors = (/12,12/)
>>
>> res_at_cnFillOn = True ; Fill contours
>> res_at_cnLinesOn = False
>> res_at_cnLineLabelsOn = False
>>
>> ; select which colors out of the colormap to use. These are the
>> colors
>> of
>> ; the contours only. They do not effect the missing value,
>> continental
>> fill
>> ; color etc. The -1 is no color or "transparent"
>> res_at_cnFillColors = (/2,3,4,5,6,7,8,9,10,11,12/)
>> res_at_cnFillDrawOrder = "PreDraw" ; make sure fill map
>> on top
>>
>> res_at_cnLevelSelectionMode = "ExplicitLevels" ; set manual contour
>> levels
>> res_at_cnLevels = (/0.2, 20., 30., 40., 50., 60., 70.,
>> 80., 90./)
>>
>> res_at_gsnAddCyclic = True
>> res_at_mpOutlineOn = False
>> res_at_gsnRightString = "percent"
>> res_at_gsnLeftString = month(imo) + " Year " + iyr
>> res_at_tiMainString = "Sea Ice Area"
>>
>> res_at_tmXBTickSpacingF = 60. ; every 60 degrees
>>
>> ;***************************************************************************************
>>
>> plot = gsn_csm_contour_map(wks,data(0,:,:),res)
>> draw(plot)
>> frame(wks)
>> delete(wks)
>> delete(b)
>>
>> if (imo .eq. 11) then
>> imo = 0
>> iyr = iyr+1
>> else
>> imo = imo+1
>> end if
>> end do
>>
>> end
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> <iceshelf.ncl>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 07 2009 - 09:15:49 MDT

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