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: Wed, 03 Jul 2013 10:09:23 -0500
Hi Jose...

Thanks for the background information.

Have you considered writing your formula using Jython (Python)?  It is
very well integrated into the IDV and there are many, many functions
available that would allow you to, for example, obtain the latitude
and longitude of the grid points, and get an array of the data where
you could apply the algorithm and fill up a 3D array with values,
which you would then have to use to create a new FlatField.

Even if you code this in Java, I would still recommend that you
consider using the IDV to read the data and then call your method
to do the computations and create the new data field for display.

The "netCDF file adapter" in the VisAD library uses a very old version of
the netCDF library and may not understand the structure of the data in
your file.  We do not have the resources to re-write that code.

Good luck.

tom

On Tue, Jul 2, 2013 at 3:27 PM, Jose Carro <joandca@xxxxxxxxx> wrote:
> Hi Tom
>
> Thanks for your quick response.
> I already tested my nc file in IDV and I was able to draw beautiful
> contours.
>
> The problem is that for my region (South America), specifically coast of
> Uruguay and Argentine, we have sea surface temperature data but missing
> measures for different depths.
>
> I am working with a local professor who developed a formula function, where
> he can get the approximate temperature for different depths based on SST
> isotherms.
>
> I am trying to develop a Java application using Visad libraries. This
> program should read the 2D Netcdf. Calculate the contours for different
> temperatures and depending on the lat.lon of each point I would apply a
> specific formula. That’s why I need the contours coordinates (each point
> lat,lon) for each coordinate in order to apply different formulas for
> different points depending between what contours they are. (I understand
> that class Conrourd2D can provide x,y for each points of the contours)
>
> With a new 3d array I plan to create a 3D Netcdf in order to be imported to
> IDV.
>
> I hope it clarifies my requirements.
>
> I will investigate the information you provided me.
>
> Thanks
>
> Jose
>
>
>
> 2013/7/2 Tom Whittaker <whittaker@xxxxxxxx>
>>
>> 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
>
>



--
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



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