signature:
public class Giniheader { /** * Read a scaled , 3 - byte integer from file and convert to double */
private double readScaledInt ( ByteBuffer buf ) { } }

implementation:
// Get the first two bytes
short s1 = buf . getShort ( ) ; // And the last one as unsigned
short s2 = DataType . unsignedByteToShort ( buf . get ( ) ) ; // Get the sign bit , converting from 0 or 2 to + / - 1.
int posneg = 1 - ( ( s1 & 0x8000 ) >> 14 ) ; // Combine the first two bytes ( without sign bit ) with the last byte .
// Multiply by proper factor for + / -
int nn = ( ( ( s1 & 0x7FFF ) << 8 ) | s2 ) * posneg ; return ( double ) nn / 10000.0 ;


signature:
public class CoordinateTransform { /** * Convenience function ; look up Parameter by name , ignoring case .
 * @ param name the name of the attribute
 * @ return the Attribute , or null if not found */
public Parameter findParameterIgnoreCase ( String name ) { } }

implementation: for ( Parameter a : params ) { if ( name . equalsIgnoreCase ( a . getName ( ) ) ) return a ; } return null ;


signature:
public class MultiOdometer { /** * Iterator API Overrides */
@ Override public boolean hasNext ( ) { } }

implementation:
if ( this . current >= odomset . size ( ) ) return false ; Odometer ocurrent = odomset . get ( this . current ) ; if ( ocurrent . hasNext ( ) ) return true ; // Try to move to next odometer
this . current ++ ; return hasNext ( ) ;


signature:
public class MultiOdometer { /** * Compute the total number of elements . */
@ Override public long totalSize ( ) { } }

implementation: long size = 1 ; for ( int i = 0 ; i < this . rank ; i ++ ) { size *= slice ( i ) . getCount ( ) ; } return size ;


signature:
public class GradsDataDescriptorFile { /** * Parse the ctl file
 * @ throws IOException problem reading the file */
private void parseDDF ( int maxLines ) throws IOException { } }

implementation:
// long start2 = System . currentTimeMillis ( ) ;
variableList = new ArrayList < > ( ) ; dimList = new ArrayList < > ( ) ; attrList = new ArrayList < > ( ) ; // LOOK not using raf - opened file again
int count = 0 ; try ( BufferedReader r = new BufferedReader ( new InputStreamReader ( new FileInputStream ( ddFile ) , CDM . utf8Charset ) ) ) { boolean inVarSection = false ; boolean inEnsSection = false ; String line ; String original ; GradsDimension curDim = null ; while ( ( original = r . readLine ( ) ) != null ) { count ++ ; if ( count > maxLines ) { error = true ; return ; } original = original . trim ( ) ; if ( original . isEmpty ( ) ) { continue ; } line = original . toLowerCase ( ) ; if ( line . startsWith ( "@ " ) ) { attrList . add ( GradsAttribute . parseAttribute ( original ) ) ; continue ; } // ignore attribute metadata and comments
if ( line . startsWith ( "*" ) ) { continue ; } if ( inEnsSection ) { if ( line . startsWith ( ENDEDEF . toLowerCase ( ) ) ) { inEnsSection = false ; continue ; // done skipping ensemble definitions
} // parse the ensemble info
} if ( inVarSection ) { if ( line . startsWith ( ENDVARS . toLowerCase ( ) ) ) { inVarSection = false ; continue ; // done parsing variables
} GradsVariable var = new GradsVariable ( original ) ; int numLevels = var . getNumLevels ( ) ; if ( numLevels == 0 ) { numLevels = 1 ; } gridsPerTimeStep += numLevels ; // parse a variable
variableList . add ( var ) ; } else { // not in var section or edef section , look for general metadata
StringTokenizer st = new StringTokenizer ( original ) ; String label = st . nextToken ( ) ; // TODO : Handle other options
if ( label . equalsIgnoreCase ( OPTIONS ) ) { curDim = null ; while ( st . hasMoreTokens ( ) ) { String token = st . nextToken ( ) ; if ( token . equalsIgnoreCase ( BIG_ENDIAN ) ) { bigEndian = true ; } else if ( token . equalsIgnoreCase ( LITTLE_ENDIAN ) ) { bigEndian = false ; } else if ( token . equalsIgnoreCase ( BYTESWAPPED ) ) { swapByteOrder ( ) ; } else if ( token . equalsIgnoreCase ( YREV ) ) { yReversed = true ; } else if ( token . equalsIgnoreCase ( TEMPLATE ) ) { isTemplate = true ; } else if ( token . equalsIgnoreCase ( SEQUENTIAL ) ) { isSequential = true ; } } } else if ( label . equalsIgnoreCase ( CHSUB ) ) { int start = Integer . parseInt ( st . nextToken ( ) ) ; int end = Integer . parseInt ( st . nextToken ( ) ) ; String sub = st . nextToken ( ) ; addChsub ( new Chsub ( start , end , sub ) ) ; } else if ( label . equalsIgnoreCase ( DSET ) ) { curDim = null ; dataFile = st . nextToken ( ) ; } else if ( label . equalsIgnoreCase ( UNDEF ) ) { curDim = null ; missingData = Double . parseDouble ( st . nextToken ( ) ) ; } else if ( label . equalsIgnoreCase ( XYHEADER ) ) { curDim = null ; xyHeaderBytes = Integer . parseInt ( st . nextToken ( ) ) ; } else if ( label . equalsIgnoreCase ( FILEHEADER ) ) { curDim = null ; fileHeaderBytes = Integer . parseInt ( st . nextToken ( ) ) ; } else if ( label . equalsIgnoreCase ( XDEF ) ) { int xSize = Integer . valueOf ( st . nextToken ( ) ) ; String xMapping = st . nextToken ( ) ; xDim = new GradsDimension ( label , xSize , xMapping ) ; curDim = xDim ; dimList . add ( xDim ) ; } else if ( label . equalsIgnoreCase ( YDEF ) ) { int ySize = Integer . valueOf ( st . nextToken ( ) ) ; String yMapping = st . nextToken ( ) ; yDim = new GradsDimension ( label , ySize , yMapping ) ; curDim = yDim ; dimList . add ( yDim ) ; } else if ( label . equalsIgnoreCase ( ZDEF ) ) { int zSize = Integer . valueOf ( st . nextToken ( ) ) ; String zMapping = st . nextToken ( ) ; zDim = new GradsDimension ( label , zSize , zMapping ) ; curDim = zDim ; dimList . add ( zDim ) ; } else if ( label . equalsIgnoreCase ( TDEF ) ) { int tSize = Integer . valueOf ( st . nextToken ( ) ) ; // we can read the following directly
// since tdef never uses " levels "
String tMapping = st . nextToken ( ) ; tDim = new GradsTimeDimension ( label , tSize , tMapping ) ; curDim = tDim ; dimList . add ( tDim ) ; } else if ( label . equalsIgnoreCase ( EDEF ) ) { int eSize = Integer . valueOf ( st . nextToken ( ) ) ; // Check if EDEF entry is the short or extended version
if ( st . nextToken ( ) . equalsIgnoreCase ( GradsEnsembleDimension . NAMES ) ) { inEnsSection = false ; String eMapping = GradsEnsembleDimension . NAMES ; eDim = new GradsEnsembleDimension ( label , eSize , eMapping ) ; curDim = eDim ; dimList . add ( curDim ) ; } else { // TODO : handle list of ensembles
curDim = null ; inEnsSection = true ; } } else if ( label . equalsIgnoreCase ( PDEF ) ) { curDim = null ; hasProjection = true ; } else if ( label . equalsIgnoreCase ( VARS ) ) { curDim = null ; inVarSection = true ; } else if ( label . equalsIgnoreCase ( DTYPE ) ) { curDim = null ; dataType = st . nextToken ( ) ; } else if ( label . equalsIgnoreCase ( TITLE ) ) { curDim = null ; title = original . substring ( original . indexOf ( " " ) ) . trim ( ) ; } else if ( curDim != null ) { curDim . addLevel ( label ) ; } // get the rest of the tokens
if ( curDim != null ) { while ( st . hasMoreTokens ( ) ) { curDim . addLevel ( st . nextToken ( ) ) ; } } } } // end parsing loop
// System . out . println ( " Time to parse file = "
// + ( System . currentTimeMillis ( ) - start2 ) ) ;
// update the units for the zDimension if they are specified as
// an attribute
if ( zDim != null ) { for ( GradsAttribute attr : attrList ) { if ( attr . getVariable ( ) . equalsIgnoreCase ( ZDEF ) && attr . getType ( ) . equalsIgnoreCase ( GradsAttribute . STRING ) && attr . getName ( ) . equalsIgnoreCase ( "units" ) ) { zDim . setUnit ( attr . getValue ( ) ) ; break ; } } } } catch ( IOException ioe ) { log . error ( "Error parsing metadata for " + ddFile ) ; throw new IOException ( "error parsing metadata for " + ddFile ) ; }


signature:
public class GradsDataDescriptorFile { /** * Swap the byte order from the system default */
private void swapByteOrder ( ) { } }

implementation:
// NB : we are setting bigEndian to be opposite the system arch
String arch = System . getProperty ( "os.arch" ) ; if ( arch . equals ( "x86" ) || // Windows , Linux
arch . equals ( "arm" ) || // Window CE
arch . equals ( "x86_64" ) || // Windows64 , Mac OS - X
arch . equals ( "amd64" ) || // Linux64?
arch . equals ( "alpha" ) ) { // Utrix , VAX , DECOS
bigEndian = true ; } else { bigEndian = false ; }


signature:
public class GradsDataDescriptorFile { /** * Get the number of timesteps per file and the starting offset
 * @ param filename the filename to check
 * @ return the starting index and number of times in that file */
public int [ ] getTimeStepsPerFile ( String filename ) { } }

implementation: if ( chsubs != null ) { for ( Chsub ch : chsubs ) { if ( filename . contains ( ch . subString ) ) { return new int [ ] { ch . numTimes , ch . startTimeIndex } ; } } } return new int [ ] { timeStepsPerFile , 0 } ;


signature:
public class GradsDataDescriptorFile { /** * Get the file name for the particular time and ensemble index
 * @ param eIndex ensemble index
 * @ param tIndex time index
 * @ return the appropriate filename */
public String getFileName ( int eIndex , int tIndex ) { } }

implementation: String dataFilePath = dataFile ; if ( ( getTemplateType ( ) == ENS_TEMPLATE ) || ( getTemplateType ( ) == ENS_TIME_TEMPLATE ) ) { dataFilePath = getEnsembleDimension ( ) . replaceFileTemplate ( dataFilePath , eIndex ) ; } dataFilePath = getTimeDimension ( ) . replaceFileTemplate ( dataFilePath , tIndex ) ; if ( ( chsubs != null ) && ( dataFilePath . contains ( CHSUB_TEMPLATE_ID ) ) ) { for ( Chsub ch : chsubs ) { if ( ( tIndex >= ch . startTimeIndex ) && ( tIndex <= ch . endTimeIndex ) ) { dataFilePath = dataFilePath . replace ( CHSUB_TEMPLATE_ID , ch . subString ) ; break ; } } } return getFullPath ( dataFilePath ) ;


signature:
public class GradsDataDescriptorFile { /** * Get the list of filenames
 * @ return the filenames
 * @ throws IOException file does not exist . */
private List < String > getFileNames ( ) throws IOException { } }

implementation:
if ( fileNames == null ) { fileNames = new ArrayList < > ( ) ; timeStepsPerFile = tDim . getSize ( ) ; if ( ! isTemplate ( ) ) { // single file
fileNames . add ( getFullPath ( getDataFile ( ) ) ) ; } else { // figure out template type
long start = System . currentTimeMillis ( ) ; List < String > fileSet = new ArrayList < > ( ) ; String template = getDataFile ( ) ; if ( GradsTimeDimension . hasTimeTemplate ( template ) ) { if ( template . contains ( GradsEnsembleDimension . ENS_TEMPLATE_ID ) ) { templateType = ENS_TIME_TEMPLATE ; } else { templateType = TIME_TEMPLATE ; } } else { // not time - either ens or chsub
if ( template . contains ( GradsEnsembleDimension . ENS_TEMPLATE_ID ) ) { templateType = ENS_TEMPLATE ; } else { templateType = TIME_TEMPLATE ; } } if ( templateType == ENS_TEMPLATE ) { for ( int e = 0 ; e < eDim . getSize ( ) ; e ++ ) { fileSet . add ( getFullPath ( eDim . replaceFileTemplate ( template , e ) ) ) ; } } else if ( ( templateType == TIME_TEMPLATE ) || ( templateType == ENS_TIME_TEMPLATE ) ) { int numens = ( templateType == TIME_TEMPLATE ) ? 1 : eDim . getSize ( ) ; for ( int t = 0 ; t < tDim . getSize ( ) ; t ++ ) { for ( int e = 0 ; e < numens ; e ++ ) { String file = getFileName ( e , t ) ; if ( ! fileSet . contains ( file ) ) { fileSet . add ( file ) ; } } } // this ' ll be a bogus number if chsub was used
timeStepsPerFile = tDim . getSize ( ) / ( fileSet . size ( ) / numens ) ; } // System . out . println ( " Time to generate file list = "
// + ( System . currentTimeMillis ( ) - start ) ) ;
fileNames . addAll ( fileSet ) ; } // long start2 = System . currentTimeMillis ( ) ;
// now make sure they exist
for ( String file : fileNames ) { File f = new File ( file ) ; if ( ! f . exists ( ) ) { log . error ( "File: " + f + " does not exist" ) ; throw new IOException ( "File: " + f + " does not exist" ) ; } } // System . out . println ( " Time to check file list = "
// + ( System . currentTimeMillis ( ) - start2 ) ) ;
} return fileNames ;


signature:
public class GradsDataDescriptorFile { /** * Get the path to the Data Descriptor File
 * @ return the path to the Data Descriptor File */
private String getDDFPath ( ) { } }

implementation: if ( pathToDDF == null ) { int lastSlash = ddFile . lastIndexOf ( "/" ) ; if ( lastSlash < 0 ) { lastSlash = ddFile . lastIndexOf ( File . separator ) ; } pathToDDF = ( lastSlash < 0 ) ? "" : ddFile . substring ( 0 , lastSlash + 1 ) ; } return pathToDDF ;


signature:
public class GradsDataDescriptorFile { /** * Get the full path for a given filename
 * @ param filename the raw filename
 * @ return the full filename */
private String getFullPath ( String filename ) { } }

implementation: String file ; String ddfPath = getDDFPath ( ) ; if ( filename . startsWith ( "^" ) ) { file = filename . replace ( "^" , "" ) ; file = ddfPath + file ; } else { File f = new File ( filename ) ; if ( ! f . isAbsolute ( ) ) { file = ddfPath + filename ; } else { file = filename ; } } return file ;


signature:
public class GradsDataDescriptorFile { /** * Add a Chsub
 * @ param sub the chsub */
private void addChsub ( Chsub sub ) { } }

implementation: if ( chsubs == null ) { chsubs = new ArrayList < > ( ) ; } chsubs . add ( sub ) ;


signature: public class N3outputStreamWriter { public void writeDataAll ( DataOutputStream stream ) throws IOException { } }

implementation:
for ( Vinfo vinfo : vinfoList ) { if ( ! vinfo . isRecord ) { Variable v = vinfo . v ; assert filePos == vinfo . offset ; if ( debugPos ) System . out . println ( " writing at " + filePos + " should be " + vinfo . offset + " " + v . getFullName ( ) ) ; int nbytes = writeDataFast ( v , stream , v . read ( ) ) ; filePos += nbytes ; filePos += pad ( stream , nbytes , ( byte ) 0 ) ; } } // see if it has a record dimension we can use
// see if it has a record dimension we can use
boolean useRecordDimension = ncfile . hasUnlimitedDimension ( ) ; if ( useRecordDimension ) { ncfile . sendIospMessage ( NetcdfFile . IOSP_MESSAGE_ADD_RECORD_STRUCTURE ) ; } // write record data
if ( useRecordDimension ) { boolean first = true ; int nrec = 0 ; Structure recordVar = ( Structure ) ncfile . findVariable ( "record" ) ; try ( StructureDataIterator ii = recordVar . getStructureIterator ( ) ) { while ( ii . hasNext ( ) ) { StructureData sdata = ii . next ( ) ; int count = 0 ; for ( Vinfo vinfo : vinfoList ) { if ( vinfo . isRecord ) { Variable v = vinfo . v ; int nbytes = writeDataFast ( v , stream , sdata . getArray ( v . getShortName ( ) ) ) ; count += nbytes ; count += pad ( stream , nbytes , ( byte ) 0 ) ; if ( first && debugWriteData ) System . out . println ( v . getShortName ( ) + " wrote " + count + " bytes" ) ; } } if ( first && debugWriteData ) { System . out . println ( "wrote " + count + " bytes" ) ; first = false ; } nrec ++ ; } } if ( debugWriteData ) System . out . println ( "wrote " + nrec + " records" ) ; stream . flush ( ) ; // remove the record structure this is rather fishy , perhaps better to leave it
ncfile . sendIospMessage ( NetcdfFile . IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE ) ; ncfile . finish ( ) ; }


signature: public class N3outputStreamWriter { private long writeData ( Variable v , DataOutputStream stream , Array values ) throws java . io . IOException { } }

implementation: DataType dataType = v . getDataType ( ) ; IndexIterator ii = values . getIndexIterator ( ) ; if ( dataType == DataType . BYTE ) { while ( ii . hasNext ( ) ) stream . write ( ii . getByteNext ( ) ) ; return values . getSize ( ) ; } else if ( dataType == DataType . CHAR ) { while ( ii . hasNext ( ) ) stream . write ( ii . getByteNext ( ) ) ; return values . getSize ( ) ; } else if ( dataType == DataType . SHORT ) { while ( ii . hasNext ( ) ) stream . writeShort ( ii . getShortNext ( ) ) ; return 2 * values . getSize ( ) ; } else if ( dataType == DataType . INT ) { while ( ii . hasNext ( ) ) stream . writeInt ( ii . getIntNext ( ) ) ; return 4 * values . getSize ( ) ; } else if ( dataType == DataType . FLOAT ) { while ( ii . hasNext ( ) ) stream . writeFloat ( ii . getFloatNext ( ) ) ; return 4 * values . getSize ( ) ; } else if ( dataType == DataType . DOUBLE ) { while ( ii . hasNext ( ) ) stream . writeDouble ( ii . getDoubleNext ( ) ) ; return 8 * values . getSize ( ) ; } throw new IllegalStateException ( "dataType= " + dataType ) ;


signature:
public class TimeCoordIntvDateValue { /** * Calculate the offset in units of timeUnit from the given reference date ? */
public TimeCoordIntvValue convertReferenceDate ( CalendarDate refDate , CalendarPeriod timeUnit ) { } }

implementation:
if ( timeUnit == null ) { throw new IllegalArgumentException ( "null time unit" ) ; } int startOffset = timeUnit . getOffset ( refDate , start ) ; // LOOK wrong - not dealing with value ? ?
int endOffset = timeUnit . getOffset ( refDate , end ) ; return new TimeCoordIntvValue ( startOffset , endOffset ) ;


signature:
public class ArrayBoolean { /** * / * create new ArrayBoolean with given indexImpl and backing store .
 * Should be private .
 * @ param index use this Index
 * @ param stor . use this storage . if null , allocate .
 * @ return . new ArrayDouble . D < rank > or ArrayDouble object . */
static ArrayBoolean factory ( Index index , boolean [ ] storage ) { } }

implementation: if ( index instanceof Index0D ) { return new ArrayBoolean . D0 ( index , storage ) ; } else if ( index instanceof Index1D ) { return new ArrayBoolean . D1 ( index , storage ) ; } else if ( index instanceof Index2D ) { return new ArrayBoolean . D2 ( index , storage ) ; } else if ( index instanceof Index3D ) { return new ArrayBoolean . D3 ( index , storage ) ; } else if ( index instanceof Index4D ) { return new ArrayBoolean . D4 ( index , storage ) ; } else if ( index instanceof Index5D ) { return new ArrayBoolean . D5 ( index , storage ) ; } else if ( index instanceof Index6D ) { return new ArrayBoolean . D6 ( index , storage ) ; } else if ( index instanceof Index7D ) { return new ArrayBoolean . D7 ( index , storage ) ; } else { return new ArrayBoolean ( index , storage ) ; }


signature:
public class ArrayBoolean { /** * copy from javaArray to storage using the iterator : used by factory ( Object ) ; */
protected void copyFrom1DJavaArray ( IndexIterator iter , Object javaArray ) { } }

implementation: boolean [ ] ja = ( boolean [ ] ) javaArray ; for ( boolean aJa : ja ) iter . setBooleanNext ( aJa ) ;


signature:
public class Nidsheader { /** * check if this file is a nids / tdwr file
 * @ param raf input file
 * @ return true if valid */
public boolean isValidFile ( ucar . unidata . io . RandomAccessFile raf ) { } }

implementation:
try { long t = raf . length ( ) ; if ( t == 0 ) { throw new IOException ( "zero length file " ) ; } } catch ( IOException e ) { return ( false ) ; } try { int p = this . readWMO ( raf ) ; if ( p == 0 ) return false ; // not unidata radar mosiac gini file
} catch ( IOException e ) { return ( false ) ; } return true ;


signature:
public class Nidsheader { /** * read the header of input file and parsing the WMO part
 * @ param raf input file
 * @ return 1 if checking passing
 * @ throws IOException */
int readWMO ( ucar . unidata . io . RandomAccessFile raf ) throws IOException { } }

implementation:
int pos = 0 ; // long actualSize = 0;
raf . seek ( pos ) ; int readLen = 35 ; // Read in the contents of the NEXRAD Level III product head
byte [ ] b = new byte [ readLen ] ; int rc = raf . read ( b ) ; if ( rc != readLen ) { // out . println ( " error reading nids product header " ) ;
return 0 ; } // new check
int iarr2_1 = bytesToInt ( b [ 0 ] , b [ 1 ] , false ) ; int iarr2_16 = bytesToInt ( b [ 30 ] , b [ 31 ] , false ) ; int iarr2_10 = bytesToInt ( b [ 18 ] , b [ 19 ] , false ) ; int iarr2_7 = bytesToInt ( b [ 12 ] , b [ 13 ] , false ) ; if ( ( iarr2_1 == iarr2_16 ) && ( ( iarr2_1 >= 16 ) && ( iarr2_1 <= 299 ) ) && ( iarr2_10 == - 1 ) && ( iarr2_7 < 10000 ) ) { noHeader = true ; return 1 ; } // Get product message header into a string for processing
String pib = new String ( b , CDM . utf8Charset ) ; if ( pib . indexOf ( "SDUS" ) != - 1 ) { noHeader = false ; return 1 ; } else if ( raf . getLocation ( ) . indexOf ( ".nids" ) != - 1 ) { noHeader = true ; return 1 ; // } else if ( checkMsgHeader ( raf ) = = 1 ) {
// noHeader = true ;
// return 1;
} else return 0 ;


signature:
public class Nidsheader { /** * read the compressed data
 * @ param offset offset of the compressed data
 * @ param len length of data to compress
 * @ return uncompressed byte array */
public byte [ ] getUncompData ( int offset , int len ) { } }

implementation: if ( len == 0 ) len = uncompdata . length - offset ; byte [ ] data = new byte [ len ] ; System . arraycopy ( uncompdata , offset , data , 0 , len ) ; return data ;


signature:
public class Nidsheader { /** * read and parse the header of the nids / tdwr file
 * @ param raf input file
 * @ param ncfile output file
 * @ throws IOException */
void read ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile ) throws IOException { } }

implementation:
int hedsiz ; /* NEXRAD header size */
int rc ; /* function return status */
int hoff = 0 ; int type ; int zlibed ; boolean isZ = false ; int encrypt ; long actualSize ; int readLen ; readWMO ( raf ) ; this . ncfile = ncfile ; actualSize = raf . length ( ) ; int pos = 0 ; raf . seek ( pos ) ; // Read in the whole contents of the NEXRAD Level III product since
// some product require to go through the whole file to build the struct of file .
readLen = ( int ) actualSize ; byte [ ] b = new byte [ readLen ] ; rc = raf . read ( b ) ; if ( rc != readLen ) { log . warn ( " error reading nids product header " + raf . getLocation ( ) ) ; } if ( ! noHeader ) { // Get product message header into a string for processing
String pib = new String ( b , 0 , 100 , CDM . utf8Charset ) ; type = 0 ; pos = pib . indexOf ( "\r\r\n" ) ; while ( pos != - 1 ) { hoff = pos + 3 ; type ++ ; pos = pib . indexOf ( "\r\r\n" , pos + 1 ) ; } raf . seek ( hoff ) ; // Test the next two bytes to see if the image portion looks like
// it is zlib - compressed .
byte [ ] b2 = new byte [ 2 ] ; // byte [ ] b4 = new byte [ 4 ] ;
System . arraycopy ( b , hoff , b2 , 0 , 2 ) ; zlibed = isZlibHed ( b2 ) ; if ( zlibed == 0 ) { encrypt = IsEncrypt ( b2 ) ; if ( encrypt == 1 ) { log . error ( "error reading encryted product " + raf . getLocation ( ) ) ; throw new IOException ( "unable to handle the product with encrypt code " + encrypt ) ; } } // process product description for station ID
byte [ ] b3 = new byte [ 3 ] ; switch ( type ) { case 0 : log . warn ( "ReadNexrInfo:: Unable to seek to ID " + raf . getLocation ( ) ) ; break ; case 1 : case 2 : case 3 : case 4 : System . arraycopy ( b , hoff - 6 , b3 , 0 , 3 ) ; stationId = new String ( b3 , CDM . utf8Charset ) ; try { NexradStationDB . init ( ) ; // make sure database is initialized
NexradStationDB . Station station = NexradStationDB . get ( "K" + stationId ) ; if ( station != null ) { stationName = station . name ; } } catch ( IOException ioe ) { log . error ( "NexradStationDB.init " + raf . getLocation ( ) , ioe ) ; } break ; default : break ; } if ( zlibed == 1 ) { isZ = true ; uncompdata = GetZlibedNexr ( b , readLen , hoff ) ; // uncompdata = Nidsiosp . readCompData ( hoff , 160 ) ;
if ( uncompdata == null ) { log . warn ( "ReadNexrInfo: error uncompressing image " + raf . getLocation ( ) ) ; uncompdata = new byte [ b . length - hoff ] ; System . arraycopy ( b , hoff , uncompdata , 0 , b . length - hoff ) ; } } else { uncompdata = new byte [ b . length - hoff ] ; System . arraycopy ( b , hoff , uncompdata , 0 , b . length - hoff ) ; } } else { uncompdata = new byte [ b . length ] ; System . arraycopy ( b , 0 , uncompdata , 0 , b . length ) ; // stationId = " YYY " ;
} byte [ ] b2 = new byte [ 2 ] ; ByteBuffer bos = ByteBuffer . wrap ( uncompdata ) ; rc = read_msghead ( bos , 0 ) ; hedsiz = 18 ; Pinfo pinfo = read_proddesc ( bos , hedsiz ) ; hedsiz += 102 ; // Set product - dependent information
int prod_type = code_typelookup ( pinfo . pcode ) ; setProductInfo ( prod_type , pinfo ) ; // int windb = 0;
int pcode1Number = 0 ; int pcode2Number = 0 ; int pcode8Number = 0 ; int pcode4Number = 0 ; int pcode5Number = 0 ; int pcode10Number = 0 ; int pcode6Number = 0 ; int pcode25Number = 0 ; int pcode12Number = 0 ; int pcode13Number = 0 ; int pcode14Number = 0 ; int pcode15Number = 0 ; int pcode16Number = 0 ; int pcode19Number = 0 ; int pcode20Number = 0 ; int pkcode1Doff [ ] = null ; int pkcode2Doff [ ] = null ; int pkcode8Doff [ ] = null ; int pkcode1Size [ ] = null ; int pkcode2Size [ ] = null ; int pkcode8Size [ ] = null ; int pkcode4Doff [ ] = null ; int pkcode5Doff [ ] = null ; int pkcode10Doff [ ] = null ; int pkcode10Dlen [ ] = null ; int pkcode6Doff [ ] = null ; int pkcode6Dlen [ ] = null ; int pkcode25Doff [ ] = null ; int pkcode12Doff [ ] = null ; int pkcode13Doff [ ] = null ; int pkcode14Doff [ ] = null ; int pkcode12Dlen [ ] = null ; int pkcode13Dlen [ ] = null ; int pkcode14Dlen [ ] = null ; int pkcode15Dlen [ ] = null ; int pkcode15Doff [ ] = null ; int pkcode16Dlen [ ] = null ; int pkcode16Doff [ ] = null ; int pkcode19Dlen [ ] = null ; int pkcode19Doff [ ] = null ; int pkcode20Dlen [ ] = null ; int pkcode20Doff [ ] = null ; // Get product symbology header ( needed to get image shape )
ifloop : if ( pinfo . offsetToSymbologyBlock != 0 ) { // Symbology header
if ( pinfo . p8 == 1 ) { // TDWR data and the symbology is compressed
int size = shortsToInt ( pinfo . p9 , pinfo . p10 , false ) ; uncompdata = uncompressed ( bos , hedsiz , size ) ; bos = ByteBuffer . wrap ( uncompdata ) ; } Sinfo sinfo = read_dividlen ( bos , hedsiz ) ; if ( rc == 0 || pinfo . divider != - 1 ) { log . warn ( "error in product symbology header " + raf . getLocation ( ) ) ; } if ( sinfo . id != 1 ) { if ( pinfo . pcode == 82 ) { read_SATab ( bos , hedsiz ) ; } break ifloop ; } hedsiz += 10 ; // Symbology layer
int klayer = pinfo . offsetToSymbologyBlock * 2 + 10 ; for ( int i = 0 ; i < sinfo . nlayers ; i ++ ) { hedsiz = klayer ; bos . position ( hedsiz ) ; short Divlen_divider = bos . getShort ( ) ; hedsiz += 2 ; int Divlen_length = bos . getInt ( ) ; hedsiz += 4 ; if ( Divlen_divider != - 1 ) { log . warn ( "error reading length divider " + raf . getLocation ( ) ) ; } int icount = 0 ; int plen ; while ( icount < Divlen_length ) { int boff = klayer + icount + 6 ; bos . position ( boff ) ; bos . get ( b2 ) ; int pkcode = getUInt ( b2 , 2 ) ; hedsiz += 2 ; boff += 2 ; switch ( pkcode ) { case 18 : // DPA
case 17 : // ( pkcode = = 0x11 ) Digital Precipitation Array
hedsiz += 8 ; plen = pcode_DPA ( bos , boff , hoff , hedsiz , isZ , i , pkcode ) ; break ; case 10 : // ( pkcode = = 0xA )
if ( pkcode10Doff == null ) { pkcode10Doff = new int [ 250 ] ; pkcode10Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; // for unlinked Vector Packet the length of data block
pkcode10Doff [ pcode10Number ] = boff + 2 ; pkcode10Dlen [ pcode10Number ] = ( plen - 2 ) / 8 ; pcode10Number ++ ; // pcode _ 10n7 ( bos , boff , hoff , isZ , pkcode ) ;
break ; case 1 : if ( pkcode1Doff == null ) { pkcode1Doff = new int [ 250 ] ; pkcode1Size = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode1Doff [ pcode1Number ] = boff + 2 ; pkcode1Size [ pcode1Number ] = plen - 4 ; pcode1Number ++ ; break ; case 2 : if ( pkcode2Doff == null ) { pkcode2Doff = new int [ 250 ] ; pkcode2Size = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode2Doff [ pcode2Number ] = boff + 2 ; pkcode2Size [ pcode2Number ] = plen - 4 ; pcode2Number ++ ; break ; case 8 : // text string
if ( pkcode8Doff == null ) { pkcode8Doff = new int [ 550 ] ; pkcode8Size = new int [ 550 ] ; } plen = bos . getShort ( ) ; pkcode8Doff [ pcode8Number ] = boff + 2 ; pkcode8Size [ pcode8Number ] = plen - 6 ; pcode8Number ++ ; break ; case 3 : case 11 : case 25 : if ( pkcode25Doff == null ) { pkcode25Doff = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode25Doff [ pcode25Number ] = boff + 2 ; pcode25Number ++ ; break ; case 12 : if ( pkcode12Doff == null ) { pkcode12Doff = new int [ 250 ] ; pkcode12Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode12Doff [ pcode12Number ] = boff + 2 ; pkcode12Dlen [ pcode12Number ] = plen / 4 ; pcode12Number ++ ; break ; case 13 : if ( pkcode13Doff == null ) { pkcode13Doff = new int [ 250 ] ; pkcode13Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode13Doff [ pcode13Number ] = boff + 2 ; pkcode13Dlen [ pcode13Number ] = plen / 4 ; pcode13Number ++ ; break ; case 14 : if ( pkcode14Doff == null ) { pkcode14Doff = new int [ 250 ] ; pkcode14Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode14Doff [ pcode14Number ] = boff + 2 ; pkcode14Dlen [ pcode14Number ] = plen / 4 ; pcode14Number ++ ; break ; case 15 : if ( pkcode15Doff == null ) { pkcode15Doff = new int [ 250 ] ; pkcode15Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode15Doff [ pcode15Number ] = boff + 2 ; pkcode15Dlen [ pcode15Number ] = plen / 6 ; pcode15Number ++ ; break ; case 166 : if ( pkcode16Doff == null ) { pkcode16Doff = new int [ 250 ] ; pkcode16Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode16Doff [ pcode16Number ] = boff + 2 ; pkcode16Dlen [ pcode16Number ] = plen / 4 ; pcode16Number ++ ; break ; case 19 : if ( pkcode19Doff == null ) { pkcode19Doff = new int [ 250 ] ; pkcode19Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode19Doff [ pcode19Number ] = boff + 2 ; pkcode19Dlen [ pcode19Number ] = plen / 10 ; pcode19Number ++ ; break ; case 20 : if ( pkcode20Doff == null ) { pkcode20Doff = new int [ 250 ] ; pkcode20Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; pkcode20Doff [ pcode20Number ] = boff + 2 ; pkcode20Dlen [ pcode20Number ] = plen / 8 ; pcode20Number ++ ; break ; case 4 : // wind barb
if ( pkcode4Doff == null ) { pkcode4Doff = new int [ 1000 ] ; } plen = bos . getShort ( ) ; pkcode4Doff [ pcode4Number ] = boff + 2 ; pcode4Number ++ ; break ; case 5 : // Vector Arrow Data
if ( pkcode5Doff == null ) { pkcode5Doff = new int [ 1000 ] ; } plen = bos . getShort ( ) ; pkcode5Doff [ pcode5Number ] = boff + 2 ; pcode5Number ++ ; break ; case 43 : plen = bos . getShort ( ) ; break ; case 23 : case 24 : plen = bos . getShort ( ) ; int poff = 2 ; while ( poff < plen ) { int pcode = bos . getShort ( ) ; int len = bos . getShort ( ) ; switch ( pcode ) { case 2 : if ( pkcode2Doff == null ) { pkcode2Doff = new int [ 250 ] ; pkcode2Size = new int [ 250 ] ; } pkcode2Doff [ pcode2Number ] = boff + poff + 4 ; pkcode2Size [ pcode2Number ] = len - 4 ; pcode2Number ++ ; break ; case 6 : if ( pkcode6Doff == null ) { pkcode6Doff = new int [ 250 ] ; pkcode6Dlen = new int [ 250 ] ; } pkcode6Doff [ pcode6Number ] = boff + poff + 4 ; pkcode6Dlen [ pcode6Number ] = ( len - 6 ) / 4 ; pcode6Number ++ ; break ; case 25 : if ( pkcode25Doff == null ) { pkcode25Doff = new int [ 250 ] ; } pkcode25Doff [ pcode25Number ] = boff + poff + 4 ; pcode25Number ++ ; break ; default : log . error ( "error reading pcode= " + pcode + " " + raf . getLocation ( ) ) ; throw new IOException ( "error reading pcode, " + "unable to handle the packet with code " + pcode ) ; } poff = poff + len + 4 ; // Need to advance the file ' s position
bos . position ( bos . position ( ) + len ) ; } break ; case 0x0802 : log . warn ( "Encountered unhandled packet code 0x0802 (contour color) -- reading past." ) ; Divlen_divider = bos . getShort ( ) ; // Color marker
if ( Divlen_divider != 0x0002 ) { log . warn ( "Missing color marker!" ) ; } plen = 2 ; break ; case 0x0E03 : log . warn ( "Encountered unhandled packet code 0x0E03 (linked contours) -- reading past." ) ; Divlen_divider = bos . getShort ( ) ; // Start marker
if ( Divlen_divider != 0x8000 ) { log . warn ( "Missing start marker!" ) ; } // Read past start x , y for now
bos . getShort ( ) ; bos . getShort ( ) ; plen = 6 + bos . getShort ( ) ; break ; default : if ( pkcode == 0xAF1F || pkcode == 16 ) { /* radial image */
hedsiz += pcode_radial ( bos , hoff , hedsiz , isZ , uncompdata , pinfo . threshold ) ; // myInfo = new Vinfo ( cname , numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ ) ;
plen = Divlen_length ; break ; } else if ( pkcode == 28 ) { /* radial image */
hedsiz += pcode_generic ( bos , hoff , hedsiz , isZ , uncompdata , pinfo . threshold ) ; // myInfo = new Vinfo ( cname , numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ ) ;
plen = Divlen_length ; break ; } else if ( pkcode == 0xBA0F || pkcode == 0xBA07 ) { /* raster image */
hedsiz += pcode_raster ( bos , ( short ) pkcode , hoff , hedsiz , isZ , uncompdata ) ; // myInfo = new Vinfo ( cname , numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ ) ;
plen = Divlen_length ; break ; } else { log . error ( "error reading pkcode equals " + pkcode + " " + raf . getLocation ( ) ) ; throw new IOException ( "error reading pkcode, unable to handle the product with code " + pkcode ) ; } // size and beginning data position in file
} // end of switch
icount = icount + plen + 4 ; } klayer = klayer + Divlen_length + 6 ; } // int curDoff = hedsiz ;
if ( pkcode8Doff != null ) { pcode_128 ( pkcode8Doff , pkcode8Size , 8 , hoff , pcode8Number , "textStruct_code8" , "" , isZ ) ; } if ( pkcode1Doff != null ) { pcode_128 ( pkcode1Doff , pkcode1Size , 1 , hoff , pcode1Number , "textStruct_code1" , "" , isZ ) ; } if ( pkcode2Doff != null ) { pcode_128 ( pkcode2Doff , pkcode2Size , 2 , hoff , pcode2Number , "textStruct_code2" , "" , isZ ) ; } if ( pkcode10Doff != null ) { pcode_10n9 ( pkcode10Doff , pkcode10Dlen , hoff , pcode10Number , isZ ) ; } if ( pkcode4Doff != null ) { pcode_4 ( pkcode4Doff , hoff , pcode4Number , isZ ) ; } if ( pkcode5Doff != null ) { pcode_5 ( pkcode5Doff , hoff , pcode5Number , isZ ) ; } if ( pkcode6Doff != null ) { pcode_6n7 ( pkcode6Doff , pkcode6Dlen , hoff , pcode6Number , isZ , "linkedVector" , 6 ) ; } if ( pkcode25Doff != null ) { pcode_25 ( pkcode25Doff , hoff , pcode25Number , isZ ) ; } if ( pkcode12Doff != null ) { pcode_12n13n14 ( pkcode12Doff , pkcode12Dlen , hoff , pcode12Number , isZ , "TVS" , 12 ) ; } if ( pkcode13Doff != null ) { pcode_12n13n14 ( pkcode13Doff , pkcode13Dlen , hoff , pcode13Number , isZ , "hailPositive" , 13 ) ; } if ( pkcode14Doff != null ) { pcode_12n13n14 ( pkcode14Doff , pkcode14Dlen , hoff , pcode14Number , isZ , "hailProbable" , 14 ) ; } if ( pkcode19Doff != null ) { pcode_12n13n14 ( pkcode19Doff , pkcode19Dlen , hoff , pcode19Number , isZ , "hailIndex" , 19 ) ; } if ( pkcode20Doff != null ) { pcode_12n13n14 ( pkcode20Doff , pkcode20Dlen , hoff , pcode20Number , isZ , "mesocyclone" , 20 ) ; } } else { log . debug ( "GetNexrDirs:: no product symbology block found (no image data) " + raf . getLocation ( ) ) ; } if ( pinfo . offsetToTabularBlock != 0 ) { int tlayer = pinfo . offsetToTabularBlock * 2 ; bos . position ( tlayer ) ; if ( bos . hasRemaining ( ) ) { short tab_divider = bos . getShort ( ) ; if ( tab_divider != - 1 ) { log . error ( "Block divider not found " + raf . getLocation ( ) ) ; throw new IOException ( "error reading graphic alphanumeric block" ) ; } short tab_bid = bos . getShort ( ) ; int tblen = bos . getInt ( ) ; bos . position ( tlayer + 116 ) ; int inc = bos . getInt ( ) ; bos . position ( tlayer + 128 ) ; // skip the second header and prod description
tab_divider = bos . getShort ( ) ; if ( tab_divider != - 1 ) { log . error ( "tab divider not found " + raf . getLocation ( ) ) ; throw new IOException ( "error reading graphic alphanumeric block" ) ; } int npage = bos . getShort ( ) ; int ppos = bos . position ( ) ; ArrayList dims = new ArrayList ( ) ; Dimension tbDim = new Dimension ( "pageNumber" , npage ) ; ncfile . addDimension ( null , tbDim ) ; dims . add ( tbDim ) ; Variable ppage = new Variable ( ncfile , null , null , "TabMessagePage" ) ; ppage . setDimensions ( dims ) ; ppage . setDataType ( DataType . STRING ) ; ppage . addAttribute ( new Attribute ( CDM . LONG_NAME , "Graphic Product Message" ) ) ; ncfile . addVariable ( null , ppage ) ; ppage . setSPobject ( new Vinfo ( npage , 0 , tblen , 0 , hoff , ppos , isR , isZ , null , null , tab_bid , 0 ) ) ; } } if ( pinfo . offsetToGraphicBlock != 0 ) { int gpkcode1Doff [ ] = null ; int gpkcode2Doff [ ] = null ; int gpkcode10Doff [ ] = null ; int gpkcode10Dlen [ ] = null ; int gpkcode8Doff [ ] = null ; int gpkcode1Size [ ] = null ; int gpkcode2Size [ ] = null ; int gpkcode8Size [ ] = null ; int gpcode1Number = 0 ; int gpcode10Number = 0 ; int gpcode8Number = 0 ; int gpcode2Number = 0 ; int tlayer = pinfo . offsetToGraphicBlock * 2 ; bos . position ( tlayer ) ; short graphic_divider = bos . getShort ( ) ; short graphic_bid = bos . getShort ( ) ; if ( graphic_divider != - 1 || graphic_bid != 2 ) { log . error ( "error reading graphic alphanumeric block " + raf . getLocation ( ) ) ; throw new IOException ( "error reading graphic alphanumeric block" ) ; } int blen = bos . getInt ( ) ; int clen = 0 ; int npage = bos . getShort ( ) ; int lpage ; int ipage = 0 ; int plen ; while ( ( clen < blen ) && ( ipage < npage ) ) { // bos . position ( ppos ) ;
int ppos = bos . position ( ) ; ipage = bos . getShort ( ) ; lpage = bos . getShort ( ) ; int icnt = 0 ; ppos = ppos + 4 ; while ( icnt < lpage ) { bos . position ( ppos + icnt ) ; int pkcode = bos . getShort ( ) ; if ( pkcode == 8 ) { if ( gpkcode8Doff == null ) { gpkcode8Doff = new int [ 550 ] ; gpkcode8Size = new int [ 550 ] ; } plen = bos . getShort ( ) ; gpkcode8Doff [ gpcode8Number ] = ppos + 4 + icnt ; gpkcode8Size [ gpcode8Number ] = plen - 6 ; icnt += plen + 4 ; gpcode8Number ++ ; } else if ( pkcode == 1 ) { if ( gpkcode1Doff == null ) { gpkcode1Doff = new int [ 550 ] ; gpkcode1Size = new int [ 550 ] ; } plen = bos . getShort ( ) ; gpkcode1Doff [ gpcode1Number ] = ppos + 4 + icnt ; gpkcode1Size [ gpcode1Number ] = plen - 4 ; icnt += plen + 4 ; gpcode1Number ++ ; } else if ( pkcode == 10 ) { if ( gpkcode10Doff == null ) { gpkcode10Doff = new int [ 250 ] ; gpkcode10Dlen = new int [ 250 ] ; } plen = bos . getShort ( ) ; // for unlinked Vector Packet the length of data block
gpkcode10Doff [ gpcode10Number ] = ppos + 4 + icnt ; gpkcode10Dlen [ gpcode10Number ] = ( plen - 2 ) / 8 ; icnt += plen + 4 ; gpcode10Number ++ ; } else { plen = bos . getShort ( ) ; icnt += plen + 4 ; } // else {
// out . println ( " error reading pkcode equals " + pkcode ) ;
// throw new IOException ( " error reading pkcode in graphic alpha num block " + pkcode ) ;
} ppos = ppos + lpage + 4 ; clen = clen + lpage + 4 ; } if ( gpkcode8Doff != null ) { pcode_128 ( gpkcode8Doff , gpkcode8Size , 8 , hoff , gpcode8Number , "textStruct_code8g" , "g" , isZ ) ; } if ( gpkcode2Doff != null ) { pcode_128 ( gpkcode2Doff , gpkcode2Size , 2 , hoff , gpcode8Number , "textStruct_code2g" , "g" , isZ ) ; } if ( gpkcode1Doff != null ) { pcode_128 ( gpkcode1Doff , gpkcode1Size , 1 , hoff , gpcode1Number , "textStruct_code1g" , "g" , isZ ) ; } if ( gpkcode10Doff != null ) { pcode_10n9 ( gpkcode10Doff , gpkcode10Dlen , hoff , gpcode10Number , isZ ) ; } /* int ppos = bos . position ( ) ;
 ArrayList dims = new ArrayList ( ) ;
 Dimension tbDim = new Dimension ( " pageNumber " , npage , true ) ;
 ncfile . addDimension ( null , tbDim ) ;
 dims . add ( tbDim ) ;
 Variable ppage = new Variable ( ncfile , null , null , " GraphicMessagePage " ) ;
 ppage . setDimensions ( dims ) ;
 ppage . setDataType ( DataType . STRING ) ;
 ppage . addAttribute ( new Attribute ( CDM . LONG _ NAME , " Graphic Product Message " ) ) ;
 ncfile . addVariable ( null , ppage ) ;
 ppage . setSPobject ( new Vinfo ( npage , 0 , tblen , 0 , hoff , ppos , isR , isZ , null , null , graphic _ bid ) ) ; */
} // finish
ncfile . finish ( ) ;


signature:
public class Nidsheader { /** * construct a dataset for special graphic symbol packet with code 12 , 13 , and 14
 * @ param pos , dlen , hoff , len , isZ , structName , code
 * @ return 1 if successful */
int pcode_12n13n14 ( int [ ] pos , int [ ] dlen , int hoff , int len , boolean isZ , String structName , int code ) { } }

implementation:
// int vlen = len ;
int vlen = 0 ; for ( int i = 0 ; i < len ; i ++ ) { vlen = vlen + dlen [ i ] ; } ArrayList dims = new ArrayList ( ) ; Dimension sDim = new Dimension ( "graphicSymbolSize" , vlen ) ; ncfile . addDimension ( null , sDim ) ; dims . add ( sDim ) ; Structure dist = new Structure ( ncfile , null , null , structName ) ; dist . setDimensions ( dims ) ; ncfile . addVariable ( null , dist ) ; dist . addAttribute ( new Attribute ( CDM . LONG_NAME , "special graphic symbol for code " + code ) ) ; Variable i0 = new Variable ( ncfile , null , dist , "x_start" ) ; i0 . setDimensions ( ( String ) null ) ; i0 . setDataType ( DataType . FLOAT ) ; i0 . addAttribute ( new Attribute ( CDM . UNITS , "KM" ) ) ; dist . addMemberVariable ( i0 ) ; Variable j0 = new Variable ( ncfile , null , dist , "y_start" ) ; j0 . setDimensions ( ( String ) null ) ; j0 . setDataType ( DataType . FLOAT ) ; j0 . addAttribute ( new Attribute ( CDM . UNITS , "KM" ) ) ; dist . addMemberVariable ( j0 ) ; int [ ] pos1 = new int [ len ] ; int [ ] dlen1 = new int [ len ] ; System . arraycopy ( dlen , 0 , dlen1 , 0 , len ) ; System . arraycopy ( pos , 0 , pos1 , 0 , len ) ; dist . setSPobject ( new Vinfo ( 0 , 0 , 0 , 0 , hoff , 0 , isR , isZ , pos1 , dlen1 , code , 0 ) ) ; return 1 ;


signature:
public class Nidsheader { /** * construct a dataset for special symbol packet with code 25
 * @ param pos , size , code , hoff , len , structName , isZ
 * @ return 1 if successful */
int pcode_25 ( int [ ] pos , int hoff , int len , boolean isZ ) { } }

implementation: ArrayList dims = new ArrayList ( ) ; Dimension sDim = new Dimension ( "circleSize" , len ) ; ncfile . addDimension ( null , sDim ) ; dims . add ( sDim ) ; Structure dist = new Structure ( ncfile , null , null , "circleStruct" ) ; dist . setDimensions ( dims ) ; ncfile . addVariable ( null , dist ) ; dist . addAttribute ( new Attribute ( CDM . LONG_NAME , "Circle Packet" ) ) ; Variable ii0 = new Variable ( ncfile , null , dist , "x_center" ) ; ii0 . setDimensions ( ( String ) null ) ; ii0 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( ii0 ) ; Variable ii1 = new Variable ( ncfile , null , dist , "y_center" ) ; ii1 . setDimensions ( ( String ) null ) ; ii1 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( ii1 ) ; Variable jj0 = new Variable ( ncfile , null , dist , "radius" ) ; jj0 . setDimensions ( ( String ) null ) ; jj0 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( jj0 ) ; int [ ] pos1 = new int [ len ] ; System . arraycopy ( pos , 0 , pos1 , 0 , len ) ; dist . setSPobject ( new Vinfo ( 0 , 0 , 0 , 0 , hoff , 0 , isR , isZ , pos1 , null , 25 , 0 ) ) ; return 1 ;


signature:
public class Nidsheader { /** * check level III file header
 * @ param raf input file
 * @ return 1 if success , and 0 if fail
 * @ throws IOException */
int checkMsgHeader ( ucar . unidata . io . RandomAccessFile raf ) throws IOException { } }

implementation:
int rc ; long actualSize ; int readLen ; actualSize = raf . length ( ) ; int pos = 0 ; raf . seek ( pos ) ; // Read in the whole contents of the NEXRAD Level III product since
// some product require to go through the whole file to build the struct of file .
readLen = ( int ) actualSize ; byte [ ] b = new byte [ readLen ] ; rc = raf . read ( b ) ; if ( rc != readLen ) { log . warn ( " error reading nids product header " + raf . getLocation ( ) ) ; } ByteBuffer bos = ByteBuffer . wrap ( b ) ; return read_msghead ( bos , 0 ) ;


signature:
public class Nidsheader { /** * construct a dataset for vector arrow data packet with code 5
 * @ param pos , size , code , hoff , len , isZ
 * @ return 1 if successful */
int pcode_5 ( int [ ] pos , int hoff , int len , boolean isZ ) { } }

implementation:
ArrayList dims = new ArrayList ( ) ; // int vlen = len ;
Dimension sDim = new Dimension ( "windBarbSize" , len ) ; ncfile . addDimension ( null , sDim ) ; dims . add ( sDim ) ; Structure dist = new Structure ( ncfile , null , null , "vectorArrow" ) ; dist . setDimensions ( dims ) ; ncfile . addVariable ( null , dist ) ; dist . addAttribute ( new Attribute ( CDM . LONG_NAME , "Vector Arrow Data" ) ) ; Variable i0 = new Variable ( ncfile , null , dist , "x_start" ) ; i0 . setDimensions ( ( String ) null ) ; i0 . setDataType ( DataType . SHORT ) ; i0 . addAttribute ( new Attribute ( CDM . UNITS , "KM" ) ) ; dist . addMemberVariable ( i0 ) ; Variable j0 = new Variable ( ncfile , null , dist , "y_start" ) ; j0 . setDimensions ( ( String ) null ) ; j0 . setDataType ( DataType . SHORT ) ; j0 . addAttribute ( new Attribute ( CDM . UNITS , "KM" ) ) ; dist . addMemberVariable ( j0 ) ; Variable direct = new Variable ( ncfile , null , dist , "direction" ) ; direct . setDimensions ( ( String ) null ) ; direct . setDataType ( DataType . SHORT ) ; direct . addAttribute ( new Attribute ( CDM . UNITS , "degree" ) ) ; dist . addMemberVariable ( direct ) ; Variable speed = new Variable ( ncfile , null , dist , "arrowLength" ) ; speed . setDimensions ( ( String ) null ) ; speed . setDataType ( DataType . SHORT ) ; speed . addAttribute ( new Attribute ( CDM . UNITS , "pixels" ) ) ; dist . addMemberVariable ( speed ) ; Variable speed1 = new Variable ( ncfile , null , dist , "arrowHeadLength" ) ; speed1 . setDimensions ( ( String ) null ) ; speed1 . setDataType ( DataType . SHORT ) ; speed1 . addAttribute ( new Attribute ( CDM . UNITS , "pixels" ) ) ; dist . addMemberVariable ( speed1 ) ; int [ ] pos1 = new int [ len ] ; System . arraycopy ( pos , 0 , pos1 , 0 , len ) ; dist . setSPobject ( new Vinfo ( 0 , 0 , 0 , 0 , hoff , 0 , isR , isZ , pos1 , null , 4 , 0 ) ) ; return 1 ;


signature:
public class Nidsheader { /** * construct a dataset for text and special symbol packets with code 1 , 2 , and 8
 * @ param pos , size , code , hoff , len , structName , isZ
 * @ return 1 if successful */
int pcode_128 ( int [ ] pos , int [ ] size , int code , int hoff , int len , String structName , String abbre , boolean isZ ) { } }

implementation:
// int vlen = len ;
ArrayList dims = new ArrayList ( ) ; Dimension sDim = new Dimension ( "textStringSize" + abbre + code , len ) ; ncfile . addDimension ( null , sDim ) ; dims . add ( sDim ) ; Structure dist = new Structure ( ncfile , null , null , structName + abbre ) ; dist . setDimensions ( dims ) ; ncfile . addVariable ( null , dist ) ; dist . addAttribute ( new Attribute ( CDM . LONG_NAME , "text and special symbol for code " + code ) ) ; if ( code == 8 ) { Variable strVal = new Variable ( ncfile , null , dist , "strValue" ) ; strVal . setDimensions ( ( String ) null ) ; strVal . setDataType ( DataType . SHORT ) ; strVal . addAttribute ( new Attribute ( CDM . UNITS , "" ) ) ; dist . addMemberVariable ( strVal ) ; } Variable i0 = new Variable ( ncfile , null , dist , "x_start" ) ; i0 . setDimensions ( ( String ) null ) ; i0 . setDataType ( DataType . SHORT ) ; i0 . addAttribute ( new Attribute ( CDM . UNITS , "KM" ) ) ; dist . addMemberVariable ( i0 ) ; Variable j0 = new Variable ( ncfile , null , dist , "y_start" ) ; j0 . setDimensions ( ( String ) null ) ; j0 . setDataType ( DataType . SHORT ) ; j0 . addAttribute ( new Attribute ( CDM . UNITS , "KM" ) ) ; dist . addMemberVariable ( j0 ) ; Variable tstr = new Variable ( ncfile , null , dist , "textString" ) ; tstr . setDimensions ( ( String ) null ) ; tstr . setDataType ( DataType . STRING ) ; tstr . addAttribute ( new Attribute ( CDM . UNITS , "" ) ) ; dist . addMemberVariable ( tstr ) ; int [ ] pos1 = new int [ len ] ; System . arraycopy ( pos , 0 , pos1 , 0 , len ) ; dist . setSPobject ( new Vinfo ( 0 , 0 , 0 , 0 , hoff , 0 , isR , isZ , pos1 , size , code , 0 ) ) ; return 1 ;


signature:
public class Nidsheader { /** * construct a dataset for linked vector packet , and unlinked vector packet
 * @ param pos , dlen , hoff , len , isZ
 * @ return 1 if successful */
int pcode_10n9 ( int [ ] pos , int [ ] dlen , int hoff , int len , boolean isZ ) { } }

implementation: ArrayList dims = new ArrayList ( ) ; Variable v ; int vlen = 0 ; for ( int i = 0 ; i < len ; i ++ ) { vlen = vlen + dlen [ i ] ; } Dimension sDim = new Dimension ( "unlinkedVectorSize" , vlen ) ; ncfile . addDimension ( null , sDim ) ; dims . add ( sDim ) ; Structure dist = new Structure ( ncfile , null , null , "unlinkedVectorStruct" ) ; dist . setDimensions ( dims ) ; ncfile . addVariable ( null , dist ) ; dist . addAttribute ( new Attribute ( CDM . LONG_NAME , "Unlinked Vector Packet" ) ) ; v = new Variable ( ncfile , null , null , "iValue" ) ; v . setDataType ( DataType . SHORT ) ; v . setDimensions ( ( String ) null ) ; dist . addMemberVariable ( v ) ; Variable ii0 = new Variable ( ncfile , null , dist , "x_start" ) ; ii0 . setDimensions ( ( String ) null ) ; ii0 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( ii0 ) ; Variable ii1 = new Variable ( ncfile , null , dist , "y_start" ) ; ii1 . setDimensions ( ( String ) null ) ; ii1 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( ii1 ) ; Variable jj0 = new Variable ( ncfile , null , dist , "x_end" ) ; jj0 . setDimensions ( ( String ) null ) ; jj0 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( jj0 ) ; Variable jj1 = new Variable ( ncfile , null , dist , "y_end" ) ; jj1 . setDimensions ( ( String ) null ) ; jj1 . setDataType ( DataType . SHORT ) ; dist . addMemberVariable ( jj1 ) ; int [ ] pos1 = new int [ len ] ; int [ ] dlen1 = new int [ len ] ; System . arraycopy ( pos , 0 , pos1 , 0 , len ) ; System . arraycopy ( dlen , 0 , dlen1 , 0 , len ) ; dist . setSPobject ( new Vinfo ( 0 , 0 , 0 , 0 , hoff , 0 , isR , isZ , pos1 , dlen1 , 10 , 0 ) ) ; return 1 ;


signature:
public class Nidsheader { /** * construct a dataset for NIDS digital precipitation array
 * @ param bos , pos , hoff , hedsiz , isZ , slayer , code
 * @ return soff - - not used */
int pcode_DPA ( ByteBuffer bos , int pos , int hoff , int hedsiz , boolean isZ , int slayer , int code ) { } }

implementation:
byte [ ] b2 = new byte [ 2 ] ; int soff ; ArrayList dims = new ArrayList ( ) ; bos . position ( pos ) ; bos . get ( b2 , 0 , 2 ) ; // reserved
bos . get ( b2 , 0 , 2 ) ; // reserved
bos . get ( b2 , 0 , 2 ) ; short numBox = ( short ) getInt ( b2 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; short numRow = ( short ) getInt ( b2 , 2 ) ; soff = 8 ; numY0 = 0 ; numX0 = 0 ; numX = numBox ; numY = numRow ; if ( slayer == 0 ) { Dimension jDim = new Dimension ( "y" , numY ) ; Dimension iDim = new Dimension ( "x" , numX ) ; ncfile . addDimension ( null , iDim ) ; ncfile . addDimension ( null , jDim ) ; dims . add ( jDim ) ; dims . add ( iDim ) ; Variable v = new Variable ( ncfile , null , null , cname + "_" + slayer ) ; v . setDataType ( DataType . SHORT ) ; v . setDimensions ( dims ) ; ncfile . addVariable ( null , v ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , ctitle + " at Symbology Layer " + slayer ) ) ; v . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , null , code , 0 ) ) ; v . addAttribute ( new Attribute ( CDM . UNITS , cunit ) ) ; v . addAttribute ( new Attribute ( CDM . MISSING_VALUE , 255 ) ) ; } // else if ( slayer = = 1 ) {
// ncfile . addDimension ( null , iDim ) ;
// ncfile . addDimension ( null , jDim ) ;
for ( int row = 0 ; row < numRow ; row ++ ) { int runLen = bos . getShort ( ) ; byte [ ] rdata = new byte [ runLen ] ; bos . get ( rdata , 0 , runLen ) ; if ( runLen < 2 ) { return soff ; } else { soff += runLen + 2 ; } } // end of for loop
if ( slayer == 0 ) { double ddx = code_reslookup ( pcode ) ; ncfile . addAttribute ( null , new Attribute ( "cdm_data_type" , FeatureType . GRID . toString ( ) ) ) ; // create coordinate variables
Variable xaxis = new Variable ( ncfile , null , null , "x" ) ; xaxis . setDataType ( DataType . DOUBLE ) ; xaxis . setDimensions ( "x" ) ; xaxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "projection x coordinate" ) ) ; xaxis . addAttribute ( new Attribute ( CDM . UNITS , "km" ) ) ; xaxis . addAttribute ( new Attribute ( _Coordinate . AxisType , "GeoX" ) ) ; double [ ] data1 = new double [ numX ] ; for ( int i = 0 ; i < numX ; i ++ ) data1 [ i ] = numX0 + i * ddx ; Array dataA = Array . factory ( DataType . DOUBLE , new int [ ] { numX } , data1 ) ; xaxis . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , xaxis ) ; Variable yaxis = new Variable ( ncfile , null , null , "y" ) ; yaxis . setDataType ( DataType . DOUBLE ) ; yaxis . setDimensions ( "y" ) ; yaxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "projection y coordinate" ) ) ; yaxis . addAttribute ( new Attribute ( CDM . UNITS , "km" ) ) ; yaxis . addAttribute ( new Attribute ( _Coordinate . AxisType , "GeoY" ) ) ; data1 = new double [ numY ] ; for ( int i = 0 ; i < numY ; i ++ ) data1 [ i ] = numY0 + i * ddx ; dataA = Array . factory ( DataType . DOUBLE , new int [ ] { numY } , data1 ) ; yaxis . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , yaxis ) ; ProjectionImpl projection = new FlatEarth ( lat_min , lon_max ) ; // ProjectionImpl projection = new LambertConformal ( latitude , longitude , latitude , latitude ) ;
// coordinate transform variable
Variable ct = new Variable ( ncfile , null , null , projection . getClassName ( ) ) ; ct . setDataType ( DataType . CHAR ) ; ct . setDimensions ( "" ) ; List params = projection . getProjectionParameters ( ) ; for ( int i = 0 ; i < params . size ( ) ; i ++ ) { Parameter p = ( Parameter ) params . get ( i ) ; ct . addAttribute ( new Attribute ( p ) ) ; } ct . addAttribute ( new Attribute ( _Coordinate . TransformType , "Projection" ) ) ; ct . addAttribute ( new Attribute ( _Coordinate . Axes , "x y" ) ) ; // fake data
dataA = Array . factory ( DataType . CHAR , new int [ ] { } ) ; dataA . setChar ( dataA . getIndex ( ) , ' ' ) ; ct . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , ct ) ; } return soff ;


signature:
public class Nidsheader { /** * construct a raster dataset for NIDS raster products ;
 * @ param bos , pkcode , hoff , hedsiz , isZ , data
 * @ return soff - - not used */
int pcode_raster ( ByteBuffer bos , short pkcode , int hoff , int hedsiz , boolean isZ , byte [ ] data ) { } }

implementation:
byte [ ] b2 = new byte [ 2 ] ; int soff ; ArrayList dims = new ArrayList ( ) ; int iscale = 1 ; /* data scale */
int ival ; ival = convertShort2unsignedInt ( threshold [ 0 ] ) ; if ( ( ival & ( 1 << 13 ) ) != 0 ) iscale = 20 ; if ( ( ival & ( 1 << 12 ) ) != 0 ) iscale = 10 ; short [ ] rasp_code = new short [ 3 ] ; rasp_code [ 0 ] = pkcode ; bos . get ( b2 , 0 , 2 ) ; rasp_code [ 1 ] = ( short ) getInt ( b2 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; rasp_code [ 2 ] = ( short ) getInt ( b2 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; // short rasp _ i = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; // short rasp _ j = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; short rasp_xscale = ( short ) getInt ( b2 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; // short rasp _ xscalefract = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; // short rasp _ yscale = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; // short rasp _ yscalefract = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; short num_rows = ( short ) getInt ( b2 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; // short packing = ( short ) getInt ( b2 , 2 ) ;
soff = 20 ; hedsiz = hedsiz + soff ; int nlevel = code_levelslookup ( pcode ) ; double ddx = code_reslookup ( pcode ) ; int [ ] levels = getLevels ( nlevel , threshold ) ; // prod _ info _ size = ( int ) ( num _ rows * scale ) ;
// out . println ( " resp scale " + ( int ) rasp _ xscale + " and " + ( int ) rasp _ xscalefract + " and " + ( int ) rasp _ yscale + " and " + ( int ) rasp _ yscalefract ) ;
numY0 = 0 ; // rasp _ j ;
numX0 = 0 ; // rasp _ i ;
numX = num_rows ; numY = num_rows ; Dimension jDim = new Dimension ( "y" , numY , true , false , false ) ; Dimension iDim = new Dimension ( "x" , numX , true , false , false ) ; dims . add ( jDim ) ; dims . add ( iDim ) ; ncfile . addDimension ( null , iDim ) ; ncfile . addDimension ( null , jDim ) ; // ncfile . addAttribute ( null , new Attribute ( " cdm _ data _ type " , thredds . catalog . DataType . GRID . toString ( ) ) ) ;
if ( cname . startsWith ( "Precip" ) ) { ncfile . addAttribute ( null , new Attribute ( "isRadial" , new Integer ( 3 ) ) ) ; ddx = ddx * rasp_xscale ; } ncfile . addAttribute ( null , new Attribute ( "cdm_data_type" , FeatureType . GRID . toString ( ) ) ) ; // Variable dist = new Variable ( ncfile , null , null , " distance " ) ;
// dist . setDataType ( DataType . INT ) ;
// dist . setDimensions ( dims ) ;
// ncfile . addVariable ( null , dist ) ;
// dist . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , null , pkcode , 0 ) ) ;
String coordinates = "x y time latitude longitude altitude" ; Variable v = new Variable ( ncfile , null , null , cname + "_RAW" ) ; v . setDataType ( DataType . BYTE ) ; v . setDimensions ( dims ) ; ncfile . addVariable ( null , v ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , ctitle ) ) ; v . addAttribute ( new Attribute ( CDM . UNITS , cunit ) ) ; v . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , null , pkcode , 0 ) ) ; v . addAttribute ( new Attribute ( _Coordinate . Axes , coordinates ) ) ; if ( cname . startsWith ( "VertLiquid" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "EchoTop" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "BaseReflectivityComp" ) || cname . startsWith ( "LayerCompReflect" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "Precip" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } // create coordinate variables
Variable xaxis = new Variable ( ncfile , null , null , "x" ) ; xaxis . setDataType ( DataType . DOUBLE ) ; xaxis . setDimensions ( "x" ) ; xaxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "projection x coordinate" ) ) ; xaxis . addAttribute ( new Attribute ( CDM . UNITS , "km" ) ) ; xaxis . addAttribute ( new Attribute ( _Coordinate . AxisType , "GeoX" ) ) ; double [ ] data1 = new double [ numX ] ; for ( int i = 0 ; i < numX ; i ++ ) data1 [ i ] = numX0 + i * ddx ; Array dataA = Array . factory ( DataType . DOUBLE , new int [ ] { numX } , data1 ) ; xaxis . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , xaxis ) ; Variable yaxis = new Variable ( ncfile , null , null , "y" ) ; yaxis . setDataType ( DataType . DOUBLE ) ; yaxis . setDimensions ( "y" ) ; yaxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "projection y coordinate" ) ) ; yaxis . addAttribute ( new Attribute ( CDM . UNITS , "km" ) ) ; yaxis . addAttribute ( new Attribute ( _Coordinate . AxisType , "GeoY" ) ) ; data1 = new double [ numY ] ; for ( int i = 0 ; i < numY ; i ++ ) data1 [ i ] = numY0 + i * ddx ; dataA = Array . factory ( DataType . DOUBLE , new int [ ] { numY } , data1 ) ; yaxis . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , yaxis ) ; ProjectionImpl projection = new FlatEarth ( lat_min , lon_max ) ; // ProjectionImpl projection = new LambertConformal ( latitude , longitude , latitude , latitude ) ;
// coordinate transform variable
Variable ct = new Variable ( ncfile , null , null , projection . getClassName ( ) ) ; ct . setDataType ( DataType . CHAR ) ; ct . setDimensions ( "" ) ; List params = projection . getProjectionParameters ( ) ; for ( int i = 0 ; i < params . size ( ) ; i ++ ) { Parameter p = ( Parameter ) params . get ( i ) ; ct . addAttribute ( new Attribute ( p ) ) ; } ct . addAttribute ( new Attribute ( _Coordinate . TransformType , "Projection" ) ) ; ct . addAttribute ( new Attribute ( _Coordinate . Axes , "x y" ) ) ; // fake data
dataA = Array . factory ( DataType . CHAR , new int [ ] { } ) ; dataA . setChar ( dataA . getIndex ( ) , ' ' ) ; ct . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , ct ) ; return soff ;


signature:
public class Nidsheader { /** * construct a radial dataset for NIDS radial products ;
 * @ param bos , hoff , hedsiz , isZ , data , threshold
 * @ return soff - - not used */
int pcode_radial ( ByteBuffer bos , int hoff , int hedsiz , boolean isZ , byte [ ] data , short [ ] threshold ) throws IOException { } }

implementation:
byte [ ] b2 = new byte [ 2 ] ; int soff ; ArrayList dims = new ArrayList ( ) ; int iscale = 1 ; /* data scale */
int ival ; ival = convertShort2unsignedInt ( threshold [ 0 ] ) ; if ( ( ival & ( 1 << 13 ) ) != 0 ) iscale = 20 ; if ( ( ival & ( 1 << 12 ) ) != 0 ) iscale = 10 ; bos . get ( b2 , 0 , 2 ) ; short first_bin = ( short ) getInt ( b2 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; short num_bin = ( short ) ( getUInt ( b2 , 2 ) ) ; if ( this . pcode == 94 || this . pcode == 99 ) num_bin = addBinSize ( num_bin ) ; bos . get ( b2 , 0 , 2 ) ; // short radp _ i = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; // short radp _ j = ( short ) getInt ( b2 , 2 ) ;
bos . get ( b2 , 0 , 2 ) ; short radp_scale = ( short ) getInt ( b2 , 2 ) ; if ( this . pcode == 134 || this . pcode == 135 ) radp_scale = ( short ) ( radp_scale * 1000 ) ; bos . get ( b2 , 0 , 2 ) ; short num_radials = ( short ) getInt ( b2 , 2 ) ; soff = 12 ; hedsiz = hedsiz + soff ; numY0 = 0 ; numY = num_radials ; numX0 = first_bin ; numX = num_bin ; int nlevel = code_levelslookup ( pcode ) ; int [ ] levels ; // prod _ info _ size = 2 * ( int ) ( num _ bin * scale + 0.5 ) ;
// dimensions : radial , bin
ncfile . addAttribute ( null , new Attribute ( "cdm_data_type" , FeatureType . RADIAL . toString ( ) ) ) ; Dimension radialDim = new Dimension ( "azimuth" , num_radials ) ; ncfile . addDimension ( null , radialDim ) ; Dimension binDim = new Dimension ( "gate" , num_bin ) ; ncfile . addDimension ( null , binDim ) ; dims . add ( radialDim ) ; dims . add ( binDim ) ; ArrayList dims1 = new ArrayList ( ) ; ArrayList dims2 = new ArrayList ( ) ; dims1 . add ( radialDim ) ; dims2 . add ( binDim ) ; // Variable aziVar = new Variable ( ncfile , null , null , " azimuth " ) ;
// aziVar . setDataType ( DataType . FLOAT ) ;
// aziVar . setDimensions ( dims1 ) ;
// ncfile . addVariable ( null , aziVar ) ;
// aziVar . addAttribute ( new Attribute ( CDM . LONG _ NAME , " azimuth angle in degrees : 0 = true north , 90 = east " ) ) ;
// aziVar . addAttribute ( new Attribute ( CDM . UNITS , " degrees " ) ) ;
// aziVar . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , null , 0 ) ) ;
// dims1 = new ArrayList ( ) ;
// dims1 . add ( binDim ) ;
// Variable gateV = new Variable ( ncfile , null , null , " gate1 " ) ;
// gateV . setDataType ( DataType . FLOAT ) ;
// gateV . setDimensions ( dims2 ) ;
// ncfile . addVariable ( null , gateV ) ;
// gateV . addAttribute ( new Attribute ( CDM . LONG _ NAME , " radial distance to start of gate " ) ) ;
// gateV . addAttribute ( new Attribute ( CDM . UNITS , " m " ) ) ;
// gateV . setSPobject ( new Vinfo ( numX , numX0 , numY , radp _ scale , hoff , hedsiz , isR , isZ , null , null , 0 , 0 ) ) ;
isR = true ; // add elevation coordinate variable
String vName = "elevation" ; String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular" ; Attribute att = new Attribute ( _Coordinate . AxisType , AxisType . RadialElevation . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , p3 ) ; // add azimuth coordinate variable
vName = "azimuth" ; lName = "azimuth angle in degrees: 0 = true north, 90 = east" ; att = new Attribute ( _Coordinate . AxisType , AxisType . RadialAzimuth . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , 0 ) ; // add gate coordinate variable
vName = "gate" ; lName = "Radial distance to the start of gate" ; att = new Attribute ( _Coordinate . AxisType , AxisType . RadialDistance . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims2 , att , DataType . FLOAT , "meters" , hoff , hedsiz , isZ , radp_scale ) ; // add radial coordinate variable
vName = "latitude" ; lName = "Latitude of the instrument" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Lat . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , 0 ) ; vName = "longitude" ; lName = "Longitude of the instrument" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Lon . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , 0 ) ; vName = "altitude" ; lName = "Altitude in meters (asl) of the instrument" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Height . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "meters" , hoff , hedsiz , isZ , 0 ) ; vName = "rays_time" ; lName = "rays time" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Time . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . DOUBLE , "milliseconds since 1970-01-01 00:00 UTC" , hoff , hedsiz , isZ , 0 ) ; // add RAW , BRIT variables for all radial variable
if ( pcode == 182 || pcode == 99 ) { levels = getTDWRLevels ( nlevel , threshold ) ; iscale = 10 ; } else if ( pcode == 186 || pcode == 94 ) { threshold [ 0 ] = - 320 ; threshold [ 1 ] = 5 ; threshold [ 2 ] = 254 ; levels = getTDWRLevels ( nlevel , threshold ) ; iscale = 10 ; } else if ( pcode == 32 ) { levels = getTDWRLevels1 ( nlevel , threshold ) ; iscale = 10 ; } else if ( pcode == 138 ) { levels = getTDWRLevels1 ( nlevel , threshold ) ; iscale = 100 ; } else if ( pcode == 134 || pcode == 135 ) { levels = getTDWRLevels2 ( nlevel , threshold ) ; iscale = 1 ; } else if ( pcode == 159 || pcode == 161 || pcode == 163 || pcode == 170 || pcode == 172 || pcode == 173 || pcode == 174 || pcode == 175 || pcode == 165 || pcode == 177 ) { levels = getDualpolLevels ( threshold ) ; iscale = 100 ; } else { levels = getLevels ( nlevel , threshold ) ; } Variable v = new Variable ( ncfile , null , null , cname + "_RAW" ) ; v . setDataType ( DataType . UBYTE ) ; v . setDimensions ( dims ) ; ncfile . addVariable ( null , v ) ; v . addAttribute ( new Attribute ( CDM . UNITS , cunit ) ) ; String coordinates = "elevation azimuth gate rays_time latitude longitude altitude" ; v . addAttribute ( new Attribute ( _Coordinate . Axes , coordinates ) ) ; // v . addAttribute ( new Attribute ( CDM . UNSIGNED , " true " ) ) ;
v . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , levels , 0 , nlevel ) ) ; // addVariable ( cname + " _ Brightness " , ctitle + " Brightness " , ncfile , dims , coordinates , DataType . FLOAT ,
// cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ;
if ( cname . startsWith ( "CorrelationCoefficient" ) || cname . startsWith ( "HydrometeorClassification" ) || cname . startsWith ( "DifferentialReflectivity" ) || cname . startsWith ( "DifferentialPhase" ) || cname . startsWith ( "HypridHydrometeorClassification" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "OneHourAccumulation" ) || cname . startsWith ( "DigitalAccumulationArray" ) || cname . startsWith ( "StormTotalAccumulation" ) || cname . startsWith ( "DigitalStormTotalAccumulation" ) || cname . startsWith ( "Accumulation3Hour" ) || cname . startsWith ( "Accumulation24Hour" ) || cname . startsWith ( "Digital1HourDifferenceAccumulation" ) || cname . startsWith ( "DigitalInstantaneousPrecipitationRate" ) || cname . startsWith ( "DigitalInstantaneousPrecipitationRate" ) || cname . startsWith ( "DigitalTotalDifferenceAccumulation" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "BaseReflectivity" ) || cname . endsWith ( "Reflectivity" ) || cname . startsWith ( "SpectrumWidth" ) ) { // addVariable ( cname + " _ VIP " , ctitle + " VIP Level " , ncfile , dims , coordinates , DataType . FLOAT ,
// cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ;
addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "RadialVelocity" ) || cname . startsWith ( "StormMeanVelocity" ) || cname . startsWith ( "BaseVelocity" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } else if ( cname . startsWith ( "Precip" ) || cname . endsWith ( "Precip" ) || cname . startsWith ( "EnhancedEchoTop" ) || cname . startsWith ( "DigitalIntegLiquid" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } return soff ;


signature:
public class Nidsheader { /** * for level3 176 product
 * @ param datainput
 * @ return arraylist */
public List parseComponents ( ByteBuffer datainput ) throws IOException { } }

implementation: ArrayList arraylist = null ; int i = datainput . getInt ( ) ; if ( i != 0 ) i = datainput . getInt ( ) ; for ( int j = 0 ; j < i ; j ++ ) { datainput . getInt ( ) ; int type = datainput . getInt ( ) ; arraylist = parseData ( datainput ) ; } return arraylist ;


signature:
public class Nidsheader { /** * for level3 176 product
 * @ param datainput
 * @ return arraylist */
public ArrayList parseData ( ByteBuffer datainput ) throws IOException { } }

implementation:
ArrayList arraylist = new ArrayList ( ) ; int numRadials ; int numBins ; int dataOffset ; readInString ( datainput ) ; // desc
datainput . getFloat ( ) ; // numBins
float rangeToFirstBin = datainput . getFloat ( ) ; datainput . getInt ( ) ; // numOfParms
datainput . getInt ( ) ; numRadials = datainput . getInt ( ) ; dataOffset = datainput . position ( ) ; // getting numbin by checking the first radial , but the data offset should be before this read
datainput . getFloat ( ) ; datainput . getFloat ( ) ; datainput . getFloat ( ) ; numBins = datainput . getInt ( ) ; arraylist . add ( numBins ) ; arraylist . add ( numRadials ) ; arraylist . add ( rangeToFirstBin ) ; arraylist . add ( dataOffset ) ; // data = null ;
/* for ( int k = 0 ; k < numRadials ; k + + )
 angleData [ k ] = datainput . getFloat ( ) ;
 datainput . getFloat ( ) ;
 datainput . getFloat ( ) ;
 numBins = datainput . getInt ( ) ;
 readInString ( datainput ) ;
 if ( data = = null )
 data = new short [ numRadials * numBins ] ;
 numBins = datainputstream . readInt ( ) ;
 for ( int l = 0 ; l < numBins ; l + + )
 data [ k * numBins + l ] = ( short ) datainputstream . getInt ( ) ; */
return arraylist ;


signature:
public class Nidsheader { /** * for level3 176 product
 * @ param datainput
 * @ return arraylist */
public List parseParameters ( ByteBuffer datainput ) throws IOException { } }

implementation: ArrayList arraylist = new ArrayList ( ) ; int i = datainput . getInt ( ) ; if ( i > 0 ) i = datainput . getInt ( ) ; for ( int j = 0 ; j < i ; j ++ ) { arraylist . add ( readInString ( datainput ) ) ; HashMap hm = addAttributePairs ( readInString ( datainput ) ) ; arraylist . add ( hm ) ; } return arraylist ;


signature:
public class Nidsheader { /** * for level3 176 product
 * @ param s
 * @ return attributes */
public HashMap addAttributePairs ( String s ) { } }

implementation: java . util . regex . Pattern PARAM_PATTERN = java . util . regex . Pattern . compile ( "([\\w*\\s*?]*)\\=([(\\<|\\{|\\[|\\()?\\w*\\s*?\\.?\\,?\\-?\\/?\\%?(\\>|\\}|\\]|\\))?]*)" ) ; HashMap attributes = new HashMap ( ) ; for ( java . util . regex . Matcher matcher = PARAM_PATTERN . matcher ( s ) ; matcher . find ( ) ; attributes . put ( matcher . group ( 1 ) . trim ( ) , matcher . group ( 2 ) . trim ( ) ) ) ; return attributes ;


signature:
public class Nidsheader { /** * for level3 176 product
 * @ param datainput
 * @ return string */
public static String readInString ( ByteBuffer datainput ) throws IOException { } }

implementation: StringBuffer stringbuffer = new StringBuffer ( ) ; int i = datainput . getInt ( ) ; for ( int j = 0 ; j < i ; j ++ ) { char c = ( char ) ( datainput . get ( ) & 0xff ) ; stringbuffer . append ( c ) ; } int k = i % 4 ; if ( k != 0 ) k = 4 - k ; for ( int l = 0 ; l < k ; l ++ ) datainput . get ( ) ; return stringbuffer . toString ( ) ;


signature:
public class Nidsheader { /** * construct a generic radial dataset for dualpol radial products ;
 * @ param bos , hoff , hedsiz , isZ , data , threshold
 * @ return soff - - not used */
int pcode_generic ( ByteBuffer bos , int hoff , int hedsiz , boolean isZ , byte [ ] data , short [ ] threshold ) throws IOException { } }

implementation:
byte [ ] b2 = new byte [ 2 ] ; int soff = 0 ; ArrayList dims = new ArrayList ( ) ; int iscale = 1 ; /* data scale */
bos . get ( b2 , 0 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; bos . get ( b2 , 0 , 2 ) ; readInString ( bos ) ; // vname
readInString ( bos ) ; // vdesp
bos . getInt ( ) ; // code
bos . getInt ( ) ; // type
bos . getInt ( ) ; // time
readInString ( bos ) ; // rnameStr
bos . getFloat ( ) ; // lat
bos . getFloat ( ) ; // lon
bos . getFloat ( ) ; // height
bos . getInt ( ) ; // vscanStartTime
bos . getInt ( ) ; // eleScanStartTime
float eleAngle = bos . getFloat ( ) ; p3 = ( short ) eleAngle ; bos . getInt ( ) ; // volScanNum
bos . getInt ( ) ; // opMode
bos . getInt ( ) ; // volPattern
bos . getInt ( ) ; // eleNum
bos . getDouble ( ) ; // skip 8 bytes
parseParameters ( bos ) ; // aa - do nothing
List cc = parseComponents ( bos ) ; // assuming only radial component
if ( cc == null ) { throw new IOException ( "Error reading components for radial data" ) ; } int num_radials = ( Integer ) cc . get ( 1 ) ; int num_bin = ( Integer ) cc . get ( 0 ) ; float rangeToFirstBin = ( Float ) cc . get ( 2 ) ; int dataOffset = ( Integer ) cc . get ( 3 ) ; numY0 = 0 ; numY = num_radials ; numX0 = ( int ) rangeToFirstBin ; // first _ bin ;
numX = num_bin ; int nlevel = code_levelslookup ( pcode ) ; int [ ] levels ; short radp_scale = 1000 ; hedsiz = dataOffset ; // prod _ info _ size = 2 * ( int ) ( num _ bin * scale + 0.5 ) ;
// dimensions : radial , bin
ncfile . addAttribute ( null , new Attribute ( "cdm_data_type" , FeatureType . RADIAL . toString ( ) ) ) ; Dimension radialDim = new Dimension ( "azimuth" , num_radials ) ; ncfile . addDimension ( null , radialDim ) ; Dimension binDim = new Dimension ( "gate" , num_bin ) ; ncfile . addDimension ( null , binDim ) ; dims . add ( radialDim ) ; dims . add ( binDim ) ; ArrayList dims1 = new ArrayList ( ) ; ArrayList dims2 = new ArrayList ( ) ; dims1 . add ( radialDim ) ; dims2 . add ( binDim ) ; isR = true ; // add elevation coordinate variable
String vName = "elevation" ; String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular" ; Attribute att = new Attribute ( _Coordinate . AxisType , AxisType . RadialElevation . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , p3 ) ; // add azimuth coordinate variable
vName = "azimuth" ; lName = "azimuth angle in degrees: 0 = true north, 90 = east" ; att = new Attribute ( _Coordinate . AxisType , AxisType . RadialAzimuth . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , 0 ) ; // add gate coordinate variable
vName = "gate" ; lName = "Radial distance to the start of gate" ; att = new Attribute ( _Coordinate . AxisType , AxisType . RadialDistance . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims2 , att , DataType . FLOAT , "meters" , hoff , hedsiz , isZ , radp_scale ) ; // add radial coordinate variable
vName = "latitude" ; lName = "Latitude of the instrument" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Lat . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , 0 ) ; vName = "longitude" ; lName = "Longitude of the instrument" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Lon . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "degrees" , hoff , hedsiz , isZ , 0 ) ; vName = "altitude" ; lName = "Altitude in meters (asl) of the instrument" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Height . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . FLOAT , "meters" , hoff , hedsiz , isZ , 0 ) ; vName = "rays_time" ; lName = "rays time" ; att = new Attribute ( _Coordinate . AxisType , AxisType . Time . toString ( ) ) ; addParameter ( vName , lName , ncfile , dims1 , att , DataType . DOUBLE , "milliseconds since 1970-01-01 00:00 UTC" , hoff , hedsiz , isZ , 0 ) ; if ( pcode == 176 ) { levels = getDualpolLevels ( threshold ) ; iscale = 1 ; } else { levels = getLevels ( nlevel , threshold ) ; } Variable v = new Variable ( ncfile , null , null , cname + "_RAW" ) ; v . setDataType ( DataType . USHORT ) ; v . setDimensions ( dims ) ; ncfile . addVariable ( null , v ) ; v . addAttribute ( new Attribute ( CDM . UNITS , cunit ) ) ; String coordinates = "elevation azimuth gate rays_time latitude longitude altitude" ; v . addAttribute ( new Attribute ( _Coordinate . Axes , coordinates ) ) ; // v . addAttribute ( new Attribute ( CDM . UNSIGNED , " true " ) ) ;
v . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , levels , 0 , nlevel ) ) ; if ( cname . startsWith ( "DigitalInstantaneousPrecipitationRate" ) ) { addVariable ( cname , ctitle , ncfile , dims , coordinates , DataType . FLOAT , cunit , hoff , hedsiz , isZ , nlevel , levels , iscale ) ; } return soff ;


signature:
public class Nidsheader { /** * get the table to calibrate data value
 * @ param nlevel number of level
 * @ param th thredshold value
 * @ return */
public int [ ] getLevels ( int nlevel , short [ ] th ) { } }

implementation:
int [ ] levels = new int [ nlevel ] ; int ival ; int isign ; for ( int i = 0 ; i < nlevel ; i ++ ) { /* calibrated data values */
ival = convertShort2unsignedInt ( th [ i ] ) ; if ( ( ival & 0x00008000 ) == 0 ) { isign = - 1 ; if ( ( ival & 0x00000100 ) == 0 ) isign = 1 ; levels [ i ] = isign * ( ival & 0x000000FF ) ; } else { levels [ i ] = - 9999 + ( ival & 0x000000FF ) ; } } return levels ;


signature:
public class Nidsheader { /** * get the calibrate data values for TDWR data
 * @ param nlevel
 * @ param th
 * @ return */
public int [ ] getTDWRLevels ( int nlevel , short [ ] th ) { } }

implementation:
int [ ] levels = new int [ nlevel ] ; // th [ 2 ] + 2 ] ;
int inc = th [ 1 ] ; levels [ 0 ] = - 9866 ; levels [ 1 ] = - 9866 ; for ( int i = 2 ; i < nlevel ; i ++ ) { /* calibrated data values */
levels [ i ] = th [ 0 ] + ( i - 2 ) * inc ; } return levels ;


signature:
public class Nidsheader { /** * get the calibrate data values for TDWR data
 * @ param nlevel
 * @ param th
 * @ return */
public int [ ] getTDWRLevels1 ( int nlevel , short [ ] th ) { } }

implementation:
int [ ] levels = new int [ nlevel ] ; // th [ 2 ] ] ;
int inc = th [ 1 ] ; for ( int i = 0 ; i < nlevel ; i ++ ) { /* calibrated data values */
levels [ i ] = th [ 0 ] + ( i ) * inc ; } return levels ;


signature:
public class Nidsheader { /** * get the calibrate data values for dualpol data
 * @ param th
 * @ return */
public int [ ] getDualpolLevels ( short [ ] th ) { } }

implementation:
int inc = th . length ; int [ ] levels = new int [ inc ] ; // th [ 2 ] ] ;
for ( int i = 0 ; i < inc ; i ++ ) { /* calibrated data values */
levels [ i ] = th [ i ] ; } return levels ;


signature:
public class Nidsheader { /** * get the calibrate data values for TDWR data
 * @ param nlevel
 * @ param th
 * @ return */
public int [ ] getTDWRLevels2 ( int nlevel , short [ ] th ) { } }


signature:
public class Nidsheader { /** * adding new variable to the netcdf file
 * @ param pName variable name
 * @ param longName variable long name
 * @ param nc netcdf file
 * @ param dims variable dimensions
 * @ param coordinates variable coordinate
 * @ param dtype variable type
 * @ param ut unit string
 * @ param hoff header offset
 * @ param hedsiz header size
 * @ param isZ is compressed file
 * @ param nlevel calibrated level number
 * @ param levels calibrate levels
 * @ param iscale is scale variable */
void addVariable ( String pName , String longName , NetcdfFile nc , ArrayList dims , String coordinates , DataType dtype , String ut , long hoff , long hedsiz , boolean isZ , int nlevel , int [ ] levels , int iscale ) { } }

implementation: Variable v = new Variable ( nc , null , null , pName ) ; v . setDataType ( dtype ) ; v . setDimensions ( dims ) ; ncfile . addVariable ( null , v ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , longName ) ) ; v . addAttribute ( new Attribute ( CDM . UNITS , ut ) ) ; v . addAttribute ( new Attribute ( _Coordinate . Axes , coordinates ) ) ; v . setSPobject ( new Vinfo ( numX , numX0 , numY , numY0 , hoff , hedsiz , isR , isZ , null , levels , iscale , nlevel ) ) ;


signature:
public class Nidsheader { /** * adding new parameter to the netcdf file
 * @ param pName variable name
 * @ param longName variable long name
 * @ param nc netcdf file
 * @ param dims variable dimensions
 * @ param att attribute
 * @ param dtype data type
 * @ param ut unit string
 * @ param hoff header offset
 * @ param doff data offset
 * @ param isZ is compressed file
 * @ param y0 reserved */
void addParameter ( String pName , String longName , NetcdfFile nc , ArrayList dims , Attribute att , DataType dtype , String ut , long hoff , long doff , boolean isZ , int y0 ) { } }

implementation: String vName = pName ; Variable vVar = new Variable ( nc , null , null , vName ) ; vVar . setDataType ( dtype ) ; if ( dims != null ) vVar . setDimensions ( dims ) ; else vVar . setDimensions ( "" ) ; if ( att != null ) vVar . addAttribute ( att ) ; vVar . addAttribute ( new Attribute ( CDM . UNITS , ut ) ) ; vVar . addAttribute ( new Attribute ( CDM . LONG_NAME , longName ) ) ; nc . addVariable ( null , vVar ) ; vVar . setSPobject ( new Vinfo ( numX , numX0 , numY , y0 , hoff , doff , isR , isZ , null , null , 0 , 0 ) ) ;


signature:
public class Nidsheader { /** * Misc
 * @ param prod _ elevation
 * @ return */
private int getProductLevel ( int prod_elevation ) { } }

implementation: int level = 0 ; if ( prod_elevation == 5 ) level = 0 ; else if ( prod_elevation == 9 ) level = 1 ; else if ( prod_elevation == 13 || prod_elevation == 15 ) level = 2 ; else if ( prod_elevation == 18 ) level = 3 ; else if ( prod_elevation == 24 ) level = 4 ; else if ( prod_elevation == 31 ) level = 6 ; return level ;