Arindam's answer prompted me to look at the question again.
[1] attached is a variation of the earlier response.
This assumes that you the contour levels and rgb triblets in a txt
file.
So if you have little text files whch are read by ferret, they could
be used directly.
[2] The answer to the 2nd question:
shade/lev=(-10250,-250,250)(-250,250,25)(250,8250,250) topo
That is, from -10250 to -250, use 250 increments, from -250 to 250,
increment by 25, and then from 250 to 8250, go back to 250.
Yes, but it is not so nice
res_at_cnLevels = array_append_record ( \
array_append_record (ispan(-10250,-250,250), ispan(-250,250,25),
0), ispan(250,8250,250), 0)
print(res_at_cnLevels
http://www.ncl.ucar.edu/Document/Functions/Contributed/array_append_record.shtml
Note the "See Also" section for some other, generically similar functions.
Arindam Chakraborty wrote:
> hi Gary,
> you can do this in NCL. You can define your own colormap using
> gsn_define_colormap() function:
>
> cmap = (/(/1,1,1/) \
> , (/0,0,0/) \
> , (/0.8,0.2,0.2/) \ ; 2 (r,g,b)
> , (/0.6,0.2,0.4/) \ ; 3
> , (/0.4,0.4,0.1/) \ ; 4
> , (/0.4,0.6,0.2/) \ ; 5
> , (/0.2,0.8,0.2/) \ ; 6
> , (/0.2,0.9,0.5/) \ ; 7
> , (/0.0,1.0,0.0/) \ ; 8
> /)
> gsn_define_colormap(wks,cmap)
>
> See NCL documention for further details on this. Also, you can assign
> a specific color for a specific contour level using resources cnLevels
> and cnFillColors. See the attached file for a simple example.
> For the irregular contouring levels in your example, use ispan()
> thrice to make three separate arrays, and then join them to make a
> single array and use that in cnLevels.
>
> hope this helps,
>
> arindam
>
>
> Gary Strand wrote:
>>
>> I'm attempting to replicate a Ferret code that I have in NCL, and one
>> of the things Ferret allows you to do is associate specific colors
>> with specific contour levels. One does this by giving the contour
>> level and color triplet in the colormap file used, e.g.:
>>
>> RGB_Mapping By_Value
>> ! Val R G B
>> -6000. 0. 0. 20. ! blue-black
>> -4000. 10. 18. 90.
>> -2000. 20. 35. 100. ! blue
>> -300. 40. 70. 100.
>> -100. 50. 100. 100.
>> -50. 40. 80. 70.
>> -0.1 90. 100. 100. ! light green-blue
>> 0. 0. 40. 00. ! dark green
>> 100. 0. 70. 30. ! light green
>> 300. 90. 100. 0. ! light yellow
>> 1200. 60. 30. 0. ! rust
>> 4000. 90. 90. 100. ! ice blue
>> 5000. 100. 100. 100. ! white
>>
>> Is there a way to do something like this in NCL?
>>
>> Also, can I specify contour levels in "chunks" without having to
>> specify all of them explicitly? Ferret allows you to this via the
>> "LEV" command:
>>
>> shade/lev=(-10250,-250,250)(-250,250,25)(250,8250,250) topo
>>
>> That is, from -10250 to -250, use 250 increments, from -250 to 250,
>> increment by 25, and then from 250 to 8250, go back to 250.
>>
>> Thanks!
>>
>> Gary Strand
>> strandwg_at_ucar.edu <mailto:strandwg_at_ucar.edu>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> --
> ----------------------------
> ARINDAM CHAKRABORTY
> Department of Meteorology
> Florida State University
> Tallahassee, FL-32306, USA
> Tel: 850-644-3524 (O)
> 850-524-0717 (C)
> Fax: 850-644-9642
> ____________________________
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- ====================================================== Dennis J. Shea tel: 303-497-1361 | P.O. Box 3000 fax: 303-497-1333 | Climate Analysis Section | Climate & Global Dynamics Div. | National Center for Atmospheric Research | Boulder, CO 80307 | USA email: shea 'at' ucar.edu | ======================================================
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/contributed.ncl"
function mimicFerret(res[1] , levRGB[*][*]:numeric)
begin
dims = dimsizes(levRGB)
res_at_cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels
res_at_cnLevels = levRGB(:,0)
LEV = levRGB(:,0)
nLEV = dimsizes(LEV)
scale = 1/100. ; convert ferret RGB to NCL RGB
RGB = new( (/nLEV+2, 3/), "float")
RGB(0 ,:) = (/1,1,1/)
RGB(1 ,:) = (/0,0,0/)
RGB(2:,:) = (levRGB(:,1:)*scale)
return(RGB)
end
z = generate_2d_array(20,20, -6230, 5100 ,0,(/30,50/))
; ferret RGB range from 0=>100, NCL 0->1
diri = "./"
fili = "ferretLevColor.txt"
ferret = readAsciiTable(diri+fili, 4, "float", 2); number of contours
res = True
res_at_cnFillOn = True
res_at_lbLabelAutoStride = True ; automatically choose best stride
rgb = mimicFerret(res, ferret)
wks = gsn_open_wks("x11","gary")
gsn_define_colormap(wks,rgb)
gsn_draw_colormap(wks) ; draw isolated color map for test
plot = gsn_csm_contour(wks, z, res)
res_at_cnLabelBarEndStyle = "ExcludeOuterBoxes" ; change end style
res_at_gsnCenterString = res_at_cnLabelBarEndStyle
plot = gsn_csm_contour(wks, z, res)
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 31 2008 - 14:52:36 MDT
This archive was generated by hypermail 2.2.0 : Fri Aug 01 2008 - 09:46:25 MDT