[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use netcdf data and draw with visad problem..
- Subject: Re: use netcdf data and draw with visad problem..
- Date: Mon, 27 Feb 2006 15:14:47 -0700
Yes, I agree, use the IDV:
http://www.unidata.ucar.edu/software/idv/
Roland Schweitzer wrote:
> Hello,
>
> I can't offer you any advice about how to get your code working, but I
> can offer you a suggestion. You might want to take a look at the
> Integrated Data Viewer from Unidata. It's a high-level framework (based
> partly on visad) for looking at geo-science data. First of all you might
> find that it creates the plots you need with no coding on your part. If
> you find that you need to write code to achieve your goals, you can take
> advantage of the IDV source code and existing classes for some good
> examples.
>
> Roland
>
> 劉育帆 wrote:
>
>>Dear All:
>>I have a netcdf file which have head file like this, and
>>I want to get the data (rhum[0][1][][]) to draw with visad ...
>>I don't know how to assign the section netcdf data to draw with visad.
>>Is there any function I can use or any example which about get nectdf
>>file,
>>parse it and draw with visad..thanks a lot(special get section data)
>>
>>netcdf rh {
>>dimensions:
>>time = 10 ;
>>level = 8 ;
>>lat = 73 ;
>>lon = 144 ;
>>variables:
>>short rhum(time, level, lat, lon) ;//rhum[time][level][lat][lon]
>>.....
>>.....
>>rhum:add_offset = 302.65f ;
>>rhum:scale_factor = 0.01f ;
>>.....
>>.....
>>}
>>
>>
>>
>>[code]
>>import visad.data.netcdf.*;
>>
>>Field imagesNC = null;
>>DisplayImpl display = new DisplayImplJ3D("image display");
>>
>>try
>>{
>>imagesNC = (Field) plain.open("C:/tempNcfile/rh.nc");
>>}
>>catch (IOException exc)
>>{
>>System.out.println(exc);
>>System.exit(0);
>>}
>>
>>final Field image_sequence = imagesNC;
>>FunctionType image_sequence_type = (FunctionType)
>>image_sequence.getType();
>>FunctionType image_type = (FunctionType) image_sequence_type.getRange();
>>RealTupleType domain_type = image_type.getDomain();
>>
>>// map image coordinates to display coordinates
>>display.addMap(new ScalarMap((RealType) domain_type.getComponent(0),
>>Display.XAxis));
>>display.addMap(new ScalarMap((RealType) domain_type.getComponent(1),
>>Display.YAxis));
>>display.addMap(new ScalarMap((RealType) domain_type.getComponent(2),
>>Display.ZAxis));
>>
>>// map netcdf variable(varname) values to RGB
>>RealTupleType range_type = (RealTupleType)image_type.getFlatRange();
>>for(int nIdex = 0 ; nIdex < range_type.getNumberOfRealComponents() ;
>>nIdex++)
>>{
>>String netcdf_varname = range_type.getComponent(nIdex).prettyString();
>>if(netcdf_varname.equals(varname))
>>{
>>display.addMap(new ScalarMap((RealType)
>>range_type.getComponent(nIdex), Display.RGB));
>>break;
>>}
>>}
>>
>>// link the Display to image_ref
>>// display will update whenever image changes
>>final DataReference image_ref = new DataReferenceImpl("image");
>>
>>image_ref.setData(image_sequence);
>>display.addReference(image_ref);
>>[/code]
>>
>>Can I use "import visad.data.netcdf.*;" functions in these package, or
>>rewrite parse function in netcdf class package?
>>
>>Please Help me, thank you~~ :)
>>
>>p.s I have other question with this..Any boby knows what's wrong ?
>>why I run examples.VerySimple class which input val(x, y) netcdf file
>>will be ok, but
>>I run same function which input rhum(time, level, lat, lon) will get
>>these exception..
>>
>>visad.BadMappingException: DisplayImpl.addMap: DisplayZAxis illegal
>>for this DisplayRenderer
>>at visad.DisplayImpl.addMap(DisplayImpl.java:1884)
>>at visad.DisplayImpl.addMap(DisplayImpl.java:1846)
>>at visad.util.DataUtility.makeSimpleDisplay(DataUtility.java:329)
>>at examples.VerySimple.main(VerySimple.java:45)
>>
>>Thanks a lot :)
>
>