Re: Tell me more

Silvere-

I have been at http://www.ssec.wisc.edu/~billh/globe.gif and found exactly
what I am looking for. From the refering page from Visad "See the
visad/examples/SatDisplay.java program for an example of how to use this
capability." I haven't had the time yet, I admit.

What I would like to do is a "best resolution" real time global cloud cover
with Java3D. I can't use the Global Montage
http://www.ssec.wisc.edu/data/comp/latest_moll.gif since the projection
system seems difficult to use in Java3D and resolution as well as
continental contour don't fit my needs. But it appears you are using the
kind of data I am looking for.

The globe.gif image is from an application I wrote a long time
ago so I guess I'm best qualified to answer.

The latest_moll.gif image is generated from a satellite composite
in McIDAS AREA file format with a Mollweide projection that has
been displayed in McIDAS. The globe.gif image is a display in VisAD
of an AREA file similar to the one in latest_moll.gif.  VisAD supports
most of the McIDAS navigation modules, so if your data were stored
in a McIDAS AREA file, you could use SatDisplay to map it to a globe.

If all you have is a GIF or JPEG, mapping to a sphere is going to
be a little difficult.  If your image is rectillinear and you
know the upper left corner of the image, you could use something
like the attached program to do this. This image will add a
CoordinateSystem to the domain of the image that will transform
image coordinates to lat/lon.  You can test this program by compiling
it and running:

java -Xmx128m WorldImageAdapter
ftp://ftp.unidata.ucar.edu/pub/dmurray/bigmap_541x271.jpg

(you'll need visad.jar and . in your classpath to compile and run)

The image is a global topography image that covers -180 to 180 lon
and 90 to -90 lat.  You could adjust the code accordingly if your
domain is smaller.

Any non-rectillinear image would require a different CoordinateSystem.

Good luck.

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************

import java.awt.event.*;
import javax.swing.*;
import visad.*;
import visad.bom.*;
import visad.data.gif.*;
import visad.data.jai.*;
import visad.data.tiff.*;
import visad.data.DefaultFamily;
import visad.data.mcidas.BaseMapAdapter;
import visad.data.netcdf.Plain;
import visad.georef.*;
import visad.java2d.*;
import visad.java3d.*;
import visad.jmet.GRIBCoordinateSystem;

public class WorldImageAdapter {

    FlatField newField = null;

    public WorldImageAdapter(String source) 
      throws Exception {

       DefaultFamily df = new DefaultFamily("images", true);
       FlatField image = (FlatField) df.open(source);
       FunctionType fType = (FunctionType) image.getType();
       Linear2DSet domainSet = (Linear2DSet) image.getDomainSet();
       int neles =  domainSet.getLengths()[0];
       int nlines = domainSet.getLengths()[1];
       double nlat = 180./(nlines-1);
       double nlon = 360./(neles-1);
       MapProjection mp = 
           new GRIBCoordinateSystem(0, 
                                    neles,
                                    nlines,
                                    -90.0,
                                    -180.0,
                                    90.0,
                                    180.0,
                                    nlon,
                                    nlat);
       RealTupleType domainType = fType.getDomain();
       RealTupleType rangeType = fType.getFlatRange();
       RealTupleType newDomainType = 
           new RealTupleType((RealType)domainType.getComponent(0),
                             (RealType)domainType.getComponent(1), mp, null);
       Linear2DSet newDomain = 
           new Linear2DSet(newDomainType, 0, neles-1, neles,
                                          nlines - 1, 0.0, nlines);
       FunctionType newFieldType = 
           new FunctionType(newDomainType, rangeType);
       newField = new FlatField(newFieldType, newDomain);
       newField.setSamples(image.getFloats(false), false);
    }

    public FlatField getData() {
        return newField;
    }

    public static void main(String[] args) 
      throws Exception {

        if (args.length == 0) {
            System.out.println("Must supply a filename");
            System.exit(1);
        }
        WorldImageAdapter wia = new WorldImageAdapter(args[0]);
        final FlatField data = wia.getData();
        RealTupleType rangeType = 
           ((FunctionType)data.getType()).getFlatRange();
        DisplayImpl display = 
        /*
            new DisplayImplJ2D("display");
            new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D());
        */
            new DisplayImplJ3D("display");
        /*
        GraphicsModeControl gmc = display.getGraphicsModeControl();
        gmc.setTextureEnable(false);
        */
        //display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
        //display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
        display.addMap(new ScalarMap(RealType.Latitude, Display.Latitude));
        display.addMap(new ScalarMap(RealType.Longitude, Display.Longitude));
        display.addMap(
            new ScalarMap((RealType)rangeType.getComponent(0), Display.Red));
        display.addMap(
            new ScalarMap((RealType)rangeType.getComponent(1), Display.Green));
        display.addMap(
            new ScalarMap((RealType)rangeType.getComponent(2), Display.Blue));
        display.getGraphicsModeControl().setScaleEnable(true);
        DataReference ref = new DataReferenceImpl("ref");
        ref.setData(data);
        display.addReference(ref);
        /*
        try {
            BaseMapAdapter bma = new BaseMapAdapter("OUTLSUPW");
            DataReference mapRef = new DataReferenceImpl("map");
            mapRef.setData(bma.getData());
            display.addReference(mapRef);
        } catch (Exception e) { 
            System.out.println("Map OUTLSUPW not available");
        }
        */
        JFrame frame = new JFrame("adapter test");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.getContentPane().add(display.getComponent());
        JButton save = new JButton("Save");
        save.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                  new Plain().save("world.nc", data, true);
                } catch (Exception exp) {
                  System.out.println("couldn't save image");
                }
            }
        });
        frame.getContentPane().add("South", save);
        frame.pack();
        frame.show();
    }
}
  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: