Re: starlink uncompress

Steve i really apologize for taking so long to get back to you.

Writing data is still a bit of work. The user manual has a couple of examples. You will have to decide how you want the file to be laid out, what metadata etc, then extract the data arrays from WritableRaster and your other objects and write them. Sorry I dont have more complete examples

You can also read Nexrad in raw format and then write to a netcdf file. see the main program of ucar.nc2.FileWriter:

public static void main( String arg[]) throws java.net.MalformedURLException, IOException { String datasetIn = (arg.length > 0) ? arg[0] : "C:/data/image/gini/n0r_20041013_1852"; String filenameOut = (arg.length > 1) ? arg[1] : "C:/data/image/gini/n0r_20041013_1852.nc";

NetcdfFile ncfileIn = ucar.nc2.dataset.NetcdfDataset.openFile(datasetIn, null); NetcdfFile ncfileOut = ucar.nc2.FileWriter.writeToFile( ncfileIn, filenameOut);
   ncfileOut.close();
   System.out.println("NetcdfFile = "+ncfileOut);
 }




Steve Ansari wrote:

Hello John,

I've attached a zip file with the code I use from Starlink. Basically they have created a convenience class (Compression.java) that will take care of bzip2, gzip and unix .Z. I've included 2 folders: "classes" has the bzip2 binary needed for the bzip2 compression. This is from the apache bzip jar file which can be used instead. "src" has the Starlink source code for their convenience class and the Unix decompress class (UncompressInputStream.java) which is apparently from the HTTPClient library.

Here is some example usage:

           // Open streams
InputStream zin = Compression.decompressStatic(new FileInputStream(new File("something.Z"))); OutputStream out = new FileOutputStream(new File("somthing.out")); // Transfer bytes from the compressed file to the output file
           byte[] buf = new byte[1024];
           int len;
           while ((len = zin.read(buf)) > 0) {
              out.write(buf, 0, len);
           }

           // Close the file and stream
           zin.close();
           out.close();


It should automatically determine the compression type from the header part of the file. Let me know if you have any problems with it.


I have a NetCDF question for you. I'm getting into exporting NEXRAD to NetCDF within the NCDC NEXRAD Data Exporter and I was wondering if you could guide me a little. I am moderately familiar with the NetCDF but I have not done anything with the API. I have the version 2.2.06 jar. Basically, I'm looking for a few simple lines of code to write a NetCDF file if I have the following information:

A java.awt.image.WritableRaster object with 2-D lon/lat gridded data.
Image bounds defined by a java.awt.geom.Rectangle2D.Double object.
A defined datum (WGS84 or NAD83).
Other defined information (product, time, etc..)


Thanks!
Steve










John Caron wrote:

Hi Steve:

im looking for a uncompress library in java, and while looking at your Java Nexrad Viewer web page , i noticed

Starlink <http://star-www.rl.ac.uk/> - Unix .Z Decompression

but i dont see exactly where the uncompress library is. can you give me a more specific pointer?

thanks!







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