# Example 12 -- image of Chlorophyll with SEAWIFS (logarithmic) palette # # Contributed 1998-Feb-28 by D. Kelley <Dan.Kelley@Dal.CA>. `setup seawifs colorscale' { # Formula to convert chlorophyll (C) to 'image' value (V): # V = [2 + log(C)] / 3.699 # (derived by Dan Kelley from a GIF image of SEAWIFS palette # provided by Gadiel Alarcon, 98-Feb-28. In the above # transformation, C values ranging from 0.01 to 50 map, # logarithmically, into the V range 0 to 1. # First, set image range and then read in the colorscale set image range 0 1 open "gawk '{print($1/255,$2/255,$3/255)}' seawifs.palette |" read image colorscale rgb close } # Next, define function to place a label below the palette. # This uses `palette label .value' { draw line from \ {rpn \.word2. log 2 + 3.699 / .px1. .px0. - * .px0. +} .py0. \ to \ {rpn \.word2. log 2 + 3.699 / .px1. .px0. - * .px0. +} {rpn .py0. "M" ascent 0.5 * -} cm draw label "\.word2." centered at \ {rpn \.word2. log 2 + 3.699 / .px1. .px0. - * .px0. +} {rpn .py0. "M" ascent 2. * -} cm } `draw seawifs palette .x_ll_cm. .y_ll_cm. .x_ur_cm. .y_ur.cm.' { set font size 0 set tic size 0 .px0. = \.word3. .py0. = \.word4. .px1. = \.word5. .py1. = \.word6. draw image palette box .px0. .py0. .px1. .py1. set font size 8 palette label ".01" palette label ".02" palette label ".03" palette label ".02" palette label ".03" palette label ".05" palette label ".1" palette label ".2" palette label ".3" palette label ".5" palette label "1" palette label "2" palette label "3" palette label "5" palette label "10" palette label "15" palette label "20" palette label "30" palette label "50" set font size 12 draw label "Chlorophyll a Concentration, mg/m$^3$" centered at \ {rpn .px0. .px1. + 2 /} {rpn .py0. "M" ascent 5 * -} cm } # Set axes set x name "" set y name "" set x margin 2 set y margin 2 set x size 15 set y size 15 set x axis 0 1 set y axis 0 1 setup seawifs colorscale draw seawifs palette 2 20 17 21 set x grid 0 1 /3 set y grid 0 1 /3 # For demonstration purposes, fake an image by reading in a grid # and transforming it according to the chlorophyll-to-image # formula given at the top of this example. read grid data .1 1 10 .2 2 20 .3 3 30 # Transform the grid data according to formula grid data _= 10 grid data += 2 grid data /= 3.699 convert grid to image # Now, draw the image. draw image