Re: [netcdf-java] netcdf serialization

I'd also be curious to hear other thoughts here, but here are a few to add to the pot;

1) You've of course already noted that NetcdfFile/NetcdfDataset does not have the Serializable marker interface.

2) For binary representation, you could look at base64 encoded byte arrays (for example, but yuck) as Netcdf API uses files alot (need to check applet restrictions on file use). I also noted this constructor which may be of use for deserialization if you wanted to avoid writing a temporary file to disk (possibly not recommended);

 /**
  * Open an in-memory netcdf file.
  *
  * @param location location of file, used as the name.
  * @param data     in-memory netcdf file
  * @return memory-resident NetcdfFile
  * @throws java.io.IOException if error
  */
public static NetcdfFile openInMemory(String location, byte[] data) throws IOException { ucar.unidata.io.InMemoryRandomAccessFile raf = new ucar.unidata.io.InMemoryRandomAccessFile(location, data);
   return open(raf, location, null, null);
 }

While I'm no expert on any, I believe other options would be the more Java specific remoting APIs - hessian, burlap, flex data services, rmi and again look at using byte array in the message bean.

3) I didn't look into #2 much and instead use ncml extensively within a Mule+JMS data distribution system (sources: files, sinks: rdbms, files, jms queus, monitoring apps). In a sink you can deserialize NcML to memory like this;

       // Read ncml from Mule Message
       String ncml = (String)message.getPayload();
       InputStream ins = new ByteArrayInputStream(ncml.getBytes());
       NetcdfDataset netcdfDataset = NcMLReader.readNcML(ins, null);

from where you can access the netcdfDataset dimensions, attributes and variables. For low data volumes I find this the best approach as it provides not only serialization via String type, but also a data type that can be understood not necessarily using the netcdf api (eg Javascript xslt/XPath).




lele wrote:
Dear netcdf-ers,
I need your help to write a java applet that receives a netcdf file from a servlet. The first problem is that I don't know if netcdf objects are serializable The second problem (I'm a java newcomer) is that I don't know how a servlet serializes a NetcdfFile object to send it to the applet.

Can you help me?

Thank you from italy,
Emanuele Lombardi



_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/



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