[Thread Prev][Thread Next][Index]
Re: [ferret_users] Customized palette
Hi William,
Thanks! The method works but my demand is a little more precise
controlling of the colors. We want 0 to be white because we don't want
to see it in the figure (only extrema are concerned). And also I prefer
some colors a little more complicated, e.g. blue_darkred.
So, I have written a fortran program to easily achieve that. You can
compile it in the ppl directory and add it to your path. In ferret, just
simply run this:
sp Ma_pal palname lo1 hi1 lo2 hi2
where palname is an already existing palette that have the colors you
want to use, lo1 and hi2 are the min and max value of the data, hi1
(neg) and lo2 (pos) are the boundaries of white regions about 0.
The generated spk file will insert a white color between 0-50% and
50%-100% of the original spk file. This program is specifically designed
for blue_darkred or darkred_blue, but can be used to other spectrum
after slight modification. Note that, by_value put the color beyond the
set value in the color bar, and this program fixes the slight shift.
The program and a sample spk file are attached.
Cheers,
Tony
On Thu, 2010-10-21 at 15:43 -0700, William S. Kessler wrote:
> By the way, I consider it better to have the central shade be light
> gray, rather than white (e.g. my script sets this color to (90,90,90).
> That allows you to distinguish zero values from missing data (for
> example land points in an ocean field).
>
> BK
>
> On Oct 21, 2010, at 3:06 PM, William S. Kessler wrote:
>
> > You can write the palette from within Ferret. This is probably not
> > the most elegant solution, but it works:
> >
> > 1) make a one-line file in your Ferret path consisting of the line
> > (I call it "palette_header"):
> >
> > RGB_Mapping By_Value
> >
> > 2) make a script in your Ferret path with the following lines (I
> > call it "make_centered_palette.jnl"):
> >
> > sp \rm centered_palette.spk
> > sp cat palette_header > centered_palette.spk
> > list/nohead/append/file=centered_palette.spk/format=(4f8.0)
> > `vname[i=@min,j=@min,k=@min,l=@min]-1`,`0`,`0`,`80`
> > list/nohead/append/file=centered_palette.spk/format=(4f8.0)
> > `0`,`90`,`90`,`90`
> > list/nohead/append/file=centered_palette.spk/format=(4f8.0)
> > `vname[i=@max,j=@max,k=@max,l=@max]+1`,`80`,`0`,`0`
> >
> > 3) in your Ferret session (or another script), suppose you want to
> > shade the variable "rose" (e.g. from etopo20, as I tested):
> >
> > set dat etopo20
> > let vname=rose
> > go make_centered_palette.jnl
> > pal centered_palette
> > shade rose
> >
> > I suppose this will fail if there is no zero in the data being
> > shaded ....
> >
> > Billy K
> >
> > On Oct 21, 2010, at 1:36 PM, Jian Ma wrote:
> >
> >> Hi Andy,
> >>
> >> Thanks! But that (percentage method) only works when you use
> >> lev=(-a,a,b). If 0 is not in the middle of your value range, it
> >> does not
> >> work to show 0 as white.
> >>
> >> Tony
> >>
> >> On Thu, 2010-10-21 at 08:59 -0600, Andy Jacobson wrote:
> >>> Hi Tony,
> >>>
> >>> Did you try light_centered.spk or white_centered.spk? If you
> >>> don't like those, my memory is that you can define a palette with
> >>> just three colors (white and the two endpoints), and ferret will
> >>> interpolate.
> >>>
> >>> -Andy
> >>>
> >>>
> >>> On Wed 20 Oct 2010, at 19:31 , Jian Ma wrote:
> >>>
> >>>> Hi All,
> >>>>
> >>>> There are 3 methods in Ferret to define new pal files. However, I
> >>>> found
> >>>> no way to define one like this:
> >>>>
> >>>> White near 0, dark red on maximum, and blue on minimum.
> >>>>
> >>>> I know I can use blue_darkred to achieve this when I have proper
> >>>> level
> >>>> values or change the percentage values in the pal file, but is
> >>>> there any
> >>>> method to make a universal pal file to self adjust correctly
> >>>> about 0?
> >>>>
> >>>> The last method is to write a fortran program to generate files,
> >>>> given
> >>>> particular level values.
> >>>>
> >>>> Many thanks,
> >>>> Tony
> >>>>
> >>>>
> >>>
> >>
> >
>
program ma
integer n,n0,n1
real p1(100),p2(100),r(100),g(100),b(100)
real hi1,lo1,hi2,lo2,in
character*20 pal_nm,lev
CALL GETARG(1,pal_nm)
CALL GETARG(2,lev)
READ(lev,*) lo1
CALL GETARG(3,lev)
READ(lev,*) hi1
CALL GETARG(4,lev)
READ(lev,*) lo2
CALL GETARG(5,lev)
READ(lev,*) hi2
open(100,file="/usr/local/ferret/ppl/"//trim(pal_nm)//".spk")
read(100,*)
read(100,*)
do n=1,100
read(100,*,end=1000)p1(n),r(n),g(n),b(n)
enddo
1000 close(100)
n0=n-1
do n=1,n0-1
if(p1(n)<(p1(1)+p1(n0))/2..and.p1(n+1)>(p1(1)+p1(n0))/2.)n1=n
enddo
in=(hi1-lo1)/n1
do n=1,n1
p2(n)=lo1+(n-1)*in
enddo
in=(hi2-lo2)/(n0-n1)
do n=n1+1,n0
p2(n)=lo2+(n-n1-1)*in
enddo
open(200,file="/usr/local/ferret/ppl/"//"Ma_"//trim(pal_nm)//".spk")
write(200,*)"RGB_Mapping By_Value"
do n=1,n1
write(200,*)p2(n),r(n),g(n),b(n)
enddo
write(200,*)hi1,100,100,100
write(200,*)0,100,100,100
do n=n1+1,n0
write(200,*)p2(n),r(n),g(n),b(n)
enddo
close(200)
stop
end
RGB_Mapping By_Value
-0.5000000 14.20000 0.000000 85.00000
-0.4500000 9.700000 11.20000 97.00000
-0.4000000 16.00000 34.20000 100.0000
-0.3500000 24.00000 53.10000 100.0000
-0.3000000 34.00000 69.20000 100.0000
-0.2500000 46.00000 82.90000 100.0000
-0.2000000 60.00000 92.00000 100.0000
-0.1500000 74.00000 97.80000 100.0000
-0.1000000 92.00000 100.0000 100.0000
-5.0000001E-02 100 100 100
0 100 100 100
5.0000001E-02 100.0000 100.0000 92.00000
0.1888889 100.0000 94.80000 74.00000
0.3277778 100.0000 84.00000 60.00000
0.4666667 100.0000 67.60000 46.00000
0.6055556 100.0000 47.20000 34.00000
0.7444445 100.0000 24.00000 24.00000
0.8833334 97.00000 15.50000 21.00000
1.022222 85.00000 8.500000 18.70000
1.161111 65.00000 0.000000 13.00000
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Privacy Policy | Disclaimer | Accessibility Statement