NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: contouring plus a colored field of same quantity

Hi Stuart,

> Again working through Ugo Taddei's VisAd tutorial, in section 3.5
> (http://www.ssec.wisc.edu/~billh/tutorial/s3/Section3.html)
> 
> I am trying to modify the example program P3_05 to plot contours
> of one color on a color-filled background map of the same quantity.
> 
> The program as given plots contours of temperature, and the contours
> are colored according to the underlying elevation. I want to have one color
> contours of temperature over a background colored by temperature value.
> 
> Commenting out the     "display.addMap( elevMap );"
> I get white contours on a black background, which is fine.
> 
> then using (in place of tempIsoMap),
>     tempMapRGB = new ScalarMap( temperature,  Display.RGB );
>     display.addMap( tempMapRGB );
> 
> I get a colored field, colored according to temperature values. As expected.
> 
> So I think I shall plot white contours over the colored temperature
> field, by using both tempIsoMap and tempMapRGB.  To my surprise
> I get colored contours, and no colored field at all.  Why?
> 
> Why does adding a isocontour map means my surface gets
> destroyed, when I simply wanted to have the isolines on top of the
> surface?

The behavior of the default DataRenderers is to render either
contours or filled colors for a single FlatField (instead of
contours, you could also substitute flow vectors, shapes or
text).

To do what you want with the default DataRenderers is a little
tricky.  You need to make a copy of 'FlatField vals_ff'
temperature values with a new RealType substituted for
temperature in its MathType (which is a FunctionType).
Something like this:

    . . .
    temperature_2 = new RealType("temperature_2");
    func_domain_range_2 = new FunctionType( domain_tuple, temperature_2);
    . . .
    vals_ff = . . .
    float[][] values = vals_ff.getFloats(false); // don't copy
    float[][] values_2 = {values[0]};
    FlatField vals_ff_2 = new FlatField(func_domain_range_2, domain_set);
    vals_ff_2.setSamples(values_2, false); // don't copy
    . . .
    // simple color fill with temperature_2 values
    display.addMap(temperature_2, Display.RGB);
    . . .
    DataReferenceImpl data_ref_2 = new DataReferenceImpl("data_ref_2");
    data_ref_2.setData( vals_ff_2 );
    display.addReference(data_ref_2);
    . . .

Leave all the other logic alone, to get the iso-contours of
temperature values in vals_ff.  I have not tried this code,
but the basic idea should work.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html

  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: