ucar.nc2.iosp.nids
Class Nidsiosp

java.lang.Object
  extended by ucar.nc2.iosp.AbstractIOServiceProvider
      extended by ucar.nc2.iosp.nids.Nidsiosp
All Implemented Interfaces:
IOServiceProvider

public class Nidsiosp
extends AbstractIOServiceProvider

IOServiceProvider implementation abstract base class to read/write "version 3" netcdf files. AKA "file format version 1" files.

see concrete class


Field Summary
protected  boolean debug
           
protected  boolean debugSize
           
protected  boolean debugSPIO
           
protected  java.util.HashMap dimHash
           
protected  int fileUsed
           
protected  boolean fill
           
protected  ucar.nc2.iosp.nids.Nidsheader headerParser
           
protected  boolean readonly
           
protected  int recStart
           
protected  boolean showHeaderBytes
           
 
Constructor Summary
Nidsiosp()
           
 
Method Summary
 void close()
          Close the file.
 short convertunsignedByte2Short(byte b)
           
 void flush()
           
 boolean isValidFile(RandomAccessFile raf)
          Check if this is a valid file for this IOServiceProvider.
static void main(java.lang.String[] args)
           
 void open(RandomAccessFile raf, NetcdfFile file, CancelTask cancelTask)
          Open existing file, and populate ncfile with it.
 ArrayStructure readCircleStructData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 byte[] readCompData(long hoff, long doff)
          Read compressed data
 byte[] readCompData1(byte[] uncomp, long hoff, long doff)
           
 Array readData(Variable v2, Section section)
          Read data from a top level Variable and return a memory resident Array.
 java.lang.Object readDistance(ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
           
 ArrayStructure readGraphicSymbolData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 ArrayStructure readLinkedVectorData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 Array readNestedCircleStructData(java.lang.String name, java.lang.String memberName, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 Array readNestedData(Variable v2, Section section)
           
 Array readNestedDataUnlinkVector(java.lang.String name, java.lang.String memberName, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 Array readNestedGraphicSymbolData(java.lang.String name, StructureMembers.Member m, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 Array readNestedLinkedVectorData(java.lang.String name, java.lang.String memberName, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 Array readNestedTextStringData(java.lang.String name, java.lang.String memberName, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 Array readNestedVectorArrowData(java.lang.String name, java.lang.String memberName, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 Array readNestedWindBarbData(java.lang.String name, java.lang.String memberName, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List section)
          Read nested data
 java.lang.Object readOneArrayData(java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.lang.String vName)
           
 java.lang.Object readOneArrayData1(java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 byte[] readOneBeamData(byte[] ddata, int rLen, int xt, int off)
           
 byte[] readOneRowData(byte[] ddata, int rLen, int xt)
          Read data from encoded values and run len into regular data array
 byte[] readOneRowData1(byte[] ddata, int rLen, int xt)
          Read data from encoded values and run len into regular data array
 java.lang.Object readOneScanData(java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.lang.String vName)
          Read data
 java.lang.Object readRadialDataAzi(java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
           
 java.lang.Object readRadialDataEle(java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
           
 java.lang.Object readRadialDataGate(ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
           
 java.lang.Object readRadialDataLatLonAlt(double t, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
           
 java.lang.Object readTabAlphaNumData(java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 ArrayStructure readTextStringData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 byte[] readUCompData(long hoff, long doff)
          Read uncompressed data
 ArrayStructure readUnlinkedVectorData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 ArrayStructure readVectorArrowData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
          Read data
 ArrayStructure readWindBarbData(java.lang.String name, java.nio.ByteBuffer bos, ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo, java.util.List sList)
          Read data
 
Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
createValidNetcdfObjectName, getDetailInfo, getStructureIterator, readSection, readToByteChannel, sendIospMessage, sync, syncExtend, toStringDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readonly

protected boolean readonly

headerParser

protected ucar.nc2.iosp.nids.Nidsheader headerParser

fileUsed

protected int fileUsed

recStart

protected int recStart

debug

protected boolean debug

debugSize

protected boolean debugSize

debugSPIO

protected boolean debugSPIO

showHeaderBytes

protected boolean showHeaderBytes

fill

protected boolean fill

dimHash

protected java.util.HashMap dimHash
Constructor Detail

Nidsiosp

public Nidsiosp()
Method Detail

readNestedData

public Array readNestedData(Variable v2,
                            Section section)
                     throws java.io.IOException,
                            InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

isValidFile

public boolean isValidFile(RandomAccessFile raf)
Description copied from interface: IOServiceProvider
Check if this is a valid file for this IOServiceProvider. You must make this method thread safe, ie dont keep any state.

Parameters:
raf - RandomAccessFile
Returns:
true if valid.

open

public void open(RandomAccessFile raf,
                 NetcdfFile file,
                 CancelTask cancelTask)
          throws java.io.IOException
Description copied from interface: IOServiceProvider
Open existing file, and populate ncfile with it. This method is only called by the NetcdfFile constructor on itself. The provided NetcdfFile object will be empty except for the location String and the IOServiceProvider associated with this NetcdfFile object.

Parameters:
raf - the file to work on, it has already passed the isValidFile() test.
file - add objects to this empty NetcdfFile
cancelTask - used to monitor user cancellation; may be null.
Throws:
java.io.IOException - if read error

readData

public Array readData(Variable v2,
                      Section section)
               throws java.io.IOException,
                      InvalidRangeException
Description copied from interface: IOServiceProvider
Read data from a top level Variable and return a memory resident Array. This Array has the same element type as the Variable, and the requested shape.

Parameters:
v2 - a top-level Variable
section - the section of data to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed. IOSP may not modify.
Returns:
the requested data in a memory-resident Array
Throws:
java.io.IOException - if read error
InvalidRangeException - if invalid section
See Also:
Range

readNestedGraphicSymbolData

public Array readNestedGraphicSymbolData(java.lang.String name,
                                         StructureMembers.Member m,
                                         java.nio.ByteBuffer bos,
                                         ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                         java.util.List section)
                                  throws java.io.IOException,
                                         InvalidRangeException
Read nested data

Parameters:
name - Variable name,
m - Structure mumber name,
bos - data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readGraphicSymbolData

public ArrayStructure readGraphicSymbolData(java.lang.String name,
                                            java.nio.ByteBuffer bos,
                                            ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                     throws java.io.IOException,
                                            InvalidRangeException
Read data

Parameters:
name - Variable name
bos - data buffer,
vinfo - variable info,
Returns:
the arraystructure of graphic symbol data
Throws:
java.io.IOException
InvalidRangeException

readNestedLinkedVectorData

public Array readNestedLinkedVectorData(java.lang.String name,
                                        java.lang.String memberName,
                                        java.nio.ByteBuffer bos,
                                        ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                        java.util.List section)
                                 throws java.io.IOException,
                                        InvalidRangeException
Read nested data

Parameters:
name - Variable name,
memberName - mumber name,
bos - data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readLinkedVectorData

public ArrayStructure readLinkedVectorData(java.lang.String name,
                                           java.nio.ByteBuffer bos,
                                           ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                    throws java.io.IOException,
                                           InvalidRangeException
Read data

Parameters:
name - Variable name,
bos - data buffer,
vinfo - variable info,
Returns:
the arraystructure of linked vector data
Throws:
java.io.IOException
InvalidRangeException

readNestedCircleStructData

public Array readNestedCircleStructData(java.lang.String name,
                                        java.lang.String memberName,
                                        java.nio.ByteBuffer bos,
                                        ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                        java.util.List section)
                                 throws java.io.IOException,
                                        InvalidRangeException
Read nested data

Parameters:
name - Variable name,
memberName - Structure mumber name,
bos - Data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readCircleStructData

public ArrayStructure readCircleStructData(java.lang.String name,
                                           java.nio.ByteBuffer bos,
                                           ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                    throws java.io.IOException,
                                           InvalidRangeException
Read data

Parameters:
name - Variable name,
bos - Data buffer,
vinfo - variable info,
Returns:
the arraystructure of circle struct data
Throws:
java.io.IOException
InvalidRangeException

readTabAlphaNumData

public java.lang.Object readTabAlphaNumData(java.nio.ByteBuffer bos,
                                            ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                     throws java.io.IOException,
                                            InvalidRangeException
Read data

Parameters:
bos - Data buffer,
vinfo - variable info,
Returns:
the array of tab data
Throws:
java.io.IOException
InvalidRangeException

readOneScanData

public java.lang.Object readOneScanData(java.nio.ByteBuffer bos,
                                        ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                        java.lang.String vName)
                                 throws java.io.IOException,
                                        InvalidRangeException
Read data

Parameters:
bos - Data buffer
vinfo - variable info
Returns:
the data object of scan data
Throws:
java.io.IOException
InvalidRangeException

readOneBeamData

public byte[] readOneBeamData(byte[] ddata,
                              int rLen,
                              int xt,
                              int off)
                       throws java.io.IOException,
                              InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readNestedWindBarbData

public Array readNestedWindBarbData(java.lang.String name,
                                    java.lang.String memberName,
                                    java.nio.ByteBuffer bos,
                                    ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                    java.util.List section)
                             throws java.io.IOException,
                                    InvalidRangeException
Read nested data

Parameters:
name - Variable name,
memberName - Structure mumber name,
bos - Data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readWindBarbData

public ArrayStructure readWindBarbData(java.lang.String name,
                                       java.nio.ByteBuffer bos,
                                       ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                       java.util.List sList)
                                throws java.io.IOException,
                                       InvalidRangeException
Read data

Parameters:
name - Variable name,
bos - Data buffer,
vinfo - variable info,
Returns:
the arraystructure of wind barb data
Throws:
java.io.IOException
InvalidRangeException

readNestedVectorArrowData

public Array readNestedVectorArrowData(java.lang.String name,
                                       java.lang.String memberName,
                                       java.nio.ByteBuffer bos,
                                       ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                       java.util.List section)
                                throws java.io.IOException,
                                       InvalidRangeException
Read nested data

Parameters:
name - Variable name,
memberName - Structure mumber name,
bos - Data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readVectorArrowData

public ArrayStructure readVectorArrowData(java.lang.String name,
                                          java.nio.ByteBuffer bos,
                                          ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                   throws java.io.IOException,
                                          InvalidRangeException
Read data

Parameters:
name - Variable name,
bos - Data buffer,
vinfo - variable info,
Returns:
the arraystructure of vector arrow data
Throws:
java.io.IOException
InvalidRangeException

readNestedTextStringData

public Array readNestedTextStringData(java.lang.String name,
                                      java.lang.String memberName,
                                      java.nio.ByteBuffer bos,
                                      ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                      java.util.List section)
                               throws java.io.IOException,
                                      InvalidRangeException
Read nested data

Parameters:
name - Variable name,
memberName - Structure mumber name,
bos - Data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readTextStringData

public ArrayStructure readTextStringData(java.lang.String name,
                                         java.nio.ByteBuffer bos,
                                         ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                  throws java.io.IOException,
                                         InvalidRangeException
Read data

Parameters:
name - Variable name,
bos - Data buffer,
vinfo - variable info
Returns:
the arraystructure of text string data
Throws:
java.io.IOException
InvalidRangeException

readNestedDataUnlinkVector

public Array readNestedDataUnlinkVector(java.lang.String name,
                                        java.lang.String memberName,
                                        java.nio.ByteBuffer bos,
                                        ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                        java.util.List section)
                                 throws java.io.IOException,
                                        InvalidRangeException
Read nested data

Parameters:
name - Variable name,
memberName - Structure mumber name,
bos - Data buffer,
vinfo - variable info,
section - variable section
Returns:
the array of member variable data
Throws:
java.io.IOException
InvalidRangeException

readUnlinkedVectorData

public ArrayStructure readUnlinkedVectorData(java.lang.String name,
                                             java.nio.ByteBuffer bos,
                                             ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                      throws java.io.IOException,
                                             InvalidRangeException
Read data

Parameters:
name - Variable name,
bos - Data buffer,
vinfo - variable info,
Returns:
the arraystructure of unlinked vector data
Throws:
java.io.IOException
InvalidRangeException

readOneArrayData

public java.lang.Object readOneArrayData(java.nio.ByteBuffer bos,
                                         ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo,
                                         java.lang.String vName)
                                  throws java.io.IOException,
                                         InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readOneArrayData1

public java.lang.Object readOneArrayData1(java.nio.ByteBuffer bos,
                                          ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                   throws java.io.IOException,
                                          InvalidRangeException
Read data

Parameters:
bos - is data buffer
vinfo - is variable info
Returns:
the data object
Throws:
java.io.IOException
InvalidRangeException

readOneRowData1

public byte[] readOneRowData1(byte[] ddata,
                              int rLen,
                              int xt)
                       throws java.io.IOException,
                              InvalidRangeException
Read data from encoded values and run len into regular data array

Parameters:
ddata - is encoded data values
Returns:
the data array of row data
Throws:
java.io.IOException
InvalidRangeException

readOneRowData

public byte[] readOneRowData(byte[] ddata,
                             int rLen,
                             int xt)
                      throws java.io.IOException,
                             InvalidRangeException
Read data from encoded values and run len into regular data array

Parameters:
ddata - is encoded data values
Returns:
the data array of row data
Throws:
java.io.IOException
InvalidRangeException

readRadialDataEle

public java.lang.Object readRadialDataEle(java.nio.ByteBuffer bos,
                                          ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                   throws java.io.IOException,
                                          InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readRadialDataLatLonAlt

public java.lang.Object readRadialDataLatLonAlt(double t,
                                                ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                         throws java.io.IOException,
                                                InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readRadialDataAzi

public java.lang.Object readRadialDataAzi(java.nio.ByteBuffer bos,
                                          ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                   throws java.io.IOException,
                                          InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readDistance

public java.lang.Object readDistance(ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                              throws java.io.IOException,
                                     InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readRadialDataGate

public java.lang.Object readRadialDataGate(ucar.nc2.iosp.nids.Nidsheader.Vinfo vinfo)
                                    throws java.io.IOException,
                                           InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readCompData1

public byte[] readCompData1(byte[] uncomp,
                            long hoff,
                            long doff)
                     throws java.io.IOException
Throws:
java.io.IOException

readCompData

public byte[] readCompData(long hoff,
                           long doff)
                    throws java.io.IOException
Read compressed data

Parameters:
hoff - header offset
doff - data offset
Returns:
the array of data
Throws:
java.io.IOException

readUCompData

public byte[] readUCompData(long hoff,
                            long doff)
                     throws java.io.IOException
Read uncompressed data

Parameters:
hoff - header offset
doff - data offset
Returns:
the array of data
Throws:
java.io.IOException

convertunsignedByte2Short

public short convertunsignedByte2Short(byte b)

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from interface: IOServiceProvider
Close the file. It is the IOServiceProvider's job to close the file (even though it didnt open it), and to free any other resources it has used.

Throws:
java.io.IOException - if read error

main

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