ucar.nc2.ft.point.writer
Class CFPointObWriter

java.lang.Object
  extended by ucar.nc2.ft.point.writer.CFPointObWriter

public class CFPointObWriter
extends java.lang.Object

Write point obs data in CF obs format.

Since:
Oct 22, 2008
Author:
caron

Constructor Summary
CFPointObWriter(java.io.DataOutputStream stream, java.util.List<Attribute> globalAtts, java.lang.String altUnits, java.util.List<PointObVar> dataVars, int numrec)
          Constructor
 
Method Summary
 void addPoint(double lat, double lon, double alt, java.util.Date time, double[] vals, java.lang.String[] svals)
          Add one data point to the file
 void finish()
          Call this when all done, output is flushed
static void main(java.lang.String[] args)
           
static void main2(java.lang.String[] args)
           
static boolean rewritePointFeatureDataset(java.lang.String fileIn, java.lang.String fileOut, boolean inMemory)
          Open a ucar.nc2.ft.PointFeatureCollection, write out in CF point format.
static boolean rewritePointObsDataset(java.lang.String fileIn, java.lang.String fileOut, boolean inMemory)
          Open a ucar.nc2.dt.PointObsDataset, write out in CF point format.
static int writePointFeatureCollection(FeatureDatasetPoint pfDataset, java.lang.String fileOut)
          Write a ucar.nc2.ft.PointFeatureCollection in CF point format.
static void writePointObsDataset(PointObsDataset pobsDataset, java.lang.String fileOut)
          write data from a ucar.nc2.dt.PointObsDataset into CF point format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CFPointObWriter

public CFPointObWriter(java.io.DataOutputStream stream,
                       java.util.List<Attribute> globalAtts,
                       java.lang.String altUnits,
                       java.util.List<PointObVar> dataVars,
                       int numrec)
                throws java.io.IOException
Constructor

Parameters:
stream - write to this stream
globalAtts - optional list of global attributes (may be null)
altUnits - optional altitude units (set to null if no altitude variable)
dataVars - the set of data variables: first the double values, then the String values
Throws:
java.io.IOException - if write error
Method Detail

addPoint

public void addPoint(double lat,
                     double lon,
                     double alt,
                     java.util.Date time,
                     double[] vals,
                     java.lang.String[] svals)
              throws java.io.IOException
Add one data point to the file

Parameters:
lat - latitude value in units of degrees_north
lon - longitude value in units of degrees_east
alt - altitude value in units of altUnits (may be NaN)
time - time value as a date
vals - list of data values, matching dataVars in the constructor
svals - list of String values, matching dataVars in the constructor
Throws:
java.io.IOException - if write error

finish

public void finish()
            throws java.io.IOException
Call this when all done, output is flushed

Throws:
java.io.IOException - if write error

rewritePointObsDataset

public static boolean rewritePointObsDataset(java.lang.String fileIn,
                                             java.lang.String fileOut,
                                             boolean inMemory)
                                      throws java.io.IOException
Open a ucar.nc2.dt.PointObsDataset, write out in CF point format.

Parameters:
fileIn - open through TypedDatasetFactory.open(FeatureType.POINT, ..)
fileOut - write to this netcdf-3 file
inMemory - if true, read file into memory for efficiency
Returns:
true on success
Throws:
java.io.IOException - on read/write error

writePointObsDataset

public static void writePointObsDataset(PointObsDataset pobsDataset,
                                        java.lang.String fileOut)
                                 throws java.io.IOException
write data from a ucar.nc2.dt.PointObsDataset into CF point format.

Parameters:
pobsDataset - rewrite data from here
fileOut - write to tehis netcdf-3 file
Throws:
java.io.IOException - on read/write error

rewritePointFeatureDataset

public static boolean rewritePointFeatureDataset(java.lang.String fileIn,
                                                 java.lang.String fileOut,
                                                 boolean inMemory)
                                          throws java.io.IOException
Open a ucar.nc2.ft.PointFeatureCollection, write out in CF point format.

Parameters:
fileIn - open through TypedDatasetFactory.open(FeatureType.POINT, ..)
fileOut - write to this netcdf-3 file
inMemory - if true, read file into memory for efficiency
Returns:
true on success
Throws:
java.io.IOException - on read/write error

writePointFeatureCollection

public static int writePointFeatureCollection(FeatureDatasetPoint pfDataset,
                                              java.lang.String fileOut)
                                       throws java.io.IOException
Write a ucar.nc2.ft.PointFeatureCollection in CF point format.

Parameters:
pfDataset - find the first PointFeatureCollection, and write all data from it
fileOut - write to this netcdf-3 file
Returns:
number of records written
Throws:
java.io.IOException - on read/write error, or if no PointFeatureCollection in pfDataset

main2

public static void main2(java.lang.String[] args)
                  throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException