Re: [visad] Convert Netcdf content to visad object in order generate contours coordinates

  • To: Jose Carro <joandca@xxxxxxxxx>
  • Subject: Re: [visad] Convert Netcdf content to visad object in order generate contours coordinates
  • From: Tom Whittaker <whittaker@xxxxxxxx>
  • Date: Tue, 02 Jul 2013 13:14:04 -0500
Hello Jose...

Unless you need to write Java code, you might consider using a
higher-level application like McIDAS-V (which is based on the
IDV...which, in turn, uses the VisAD library for it's data model and
display).  If your file is truly CF-compliant, then either of these
applications would be able to display contour lines.  Both
applications are freely available -- for McIDAS-V, go to:
<http://www.ssec.wisc.edu/mcidas/software/v/download.html>.  The IDV
homepage is: <http://www.unidata.ucar.edu/software/idv/>.

If you must write your own code, you can look in the examples in the
VisAD library in the various "File Adapters", or in some of the
"field" methods defined in the JPythonMethods which create FlatFields,
for examples.  In addition, the VisAD Develooper's Guide and the Data
Tutorial will be helpful.

tom


On Tue, Jul 2, 2013 at 10:49 AM, Jose Carro <joandca@xxxxxxxxx> wrote:
> Dear visad group
> I am totally new in visad library and netcdf manipulation.
> The file I am trying to manipulate has this features:
>
> Netcdfile follows the convention CF-1.0
> type: Time -> ((Longitude, Latitude, zlev) -> (sst, anom, err, ice)
> It is 2D because zlev is 0.
>
> I wrote a small java program where I can read a Netcdf file and list  values
> following some examples from netcdf library,
> My question is how can I transform this array into a format that visad can
> understand. As instance FieldImpl.
> My goal is to get isotherms (contours) lat,lon using some visad contour
> class.
> Thanks in advance
> Jose
> code:
>
> dataFile=NetcdfFile.open("d:/mymodel.nc");
> Variable tempVar = dataFile.findVariable("sst");
> if (tempVar == null) {
> System.out.println("Cant find Variable sst");
> return;
> }else{
> // read variable
> int [] shape = tempVar.getShape();
>   int recLen = shape[0]; // number of times
>   int[] origin = new int[4];
>    shape[0] = 1; // only one rec per read
>
>    // loop over the rec dimension
>    for (int rec = 0; rec < recLen; rec++) {
>     origin[0] = rec;  // read this index
>     // Get the lat/lon data from the file.
>     ArrayShort.D2 tempArray = null;
>     try {
> tempArray = (ArrayShort.D2) (tempVar.read(origin, shape).reduce());
> } catch (InvalidRangeException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
>
>     // now checking the value
>     for (int lvl = 0; lvl < NLVL; lvl++)
>     for (int lat = 0; lat < NLAT; lat++)
>     for (int lon = 0; lon < NLON; lon++) {
>     // System.out.println(tempArray.get(1,1, lat, lon));
>     System.out.println("Longitude:" + lon);
>     System.out.println("Latitude:" + lat);
>     System.out.println("Temp:" + Float.toString(tempArray.get(lat, lon)));
>     }
>    }
>
>
>
>
>
>
>
> _______________________________________________
> visad mailing list
> visad@xxxxxxxxxxxxxxxx
> For list information, to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/



-- 
Tom Whittaker
University of Wisconsin-Madison
Space Science & Engineering Center (SSEC)
Cooperative Institute for Meteorological Satellite Studies (CIMSS)
1225 W. Dayton Street
Madison, WI  53706  USA
ph: +1 608 262 2759