Input: when component resizes we need a new buffer [CODESPLIT] private void newScreenSize ( Rectangle b ) { boolean sameSize = ( b . width == myBounds . width ) && ( b . height == myBounds . height ) ; if ( debugBounds ) System . out . println ( "NavigatedPanel newScreenSize old= " + myBounds ) ; if ( sameSize && ( b . x == myBounds . x ) && ( b . y == myBounds . y ) ) return ; myBounds . setBounds ( b ) ; if ( sameSize ) return ; if ( debugBounds ) System . out . println ( "  newBounds = " + b ) ; // create new buffer the size of the window //if (bImage != null) //  bImage.dispose(); if ( ( b . width > 0 ) && ( b . height > 0 ) ) { bImage = new BufferedImage ( b . width , b . height , BufferedImage . TYPE_INT_RGB ) ; // why RGB ? } else { // why not device dependent? bImage = null ; } navigate . setScreenSize ( b . width , b . height ) ; }


Input: draw and drawG are like paintImmediately () [CODESPLIT] public void drawG ( ) { Graphics g = getGraphics ( ) ; // bypasses double buffering ? if ( null != g ) { draw ( ( Graphics2D ) g ) ; g . dispose ( ) ; } }


Input:
Set the currently selected Variable . [CODESPLIT] public void setSelected ( VariableIF v ) { if ( v == null ) { return ; } // construct chain of variables
 final List < VariableIF > vchain = new ArrayList <> ( ) ; vchain . add ( v ) ; VariableIF vp = v ; while ( vp . isMemberOfStructure ( ) ) { vp = vp . getParentStructure ( ) ; vchain . add ( 0 , vp ) ; // reverse
 } // construct chain of groups
 final List < Group > gchain = new ArrayList <> ( ) ; Group gp = vp . getParentGroup ( ) ; gchain . add ( gp ) ; while ( gp . getParentGroup ( ) != null ) { gp = gp . getParentGroup ( ) ; gchain . add ( 0 , gp ) ; // reverse
 } final List < Object > pathList = new ArrayList <> ( ) ; // start at root, work down through the nested groups, if any
 GroupNode gnode = ( GroupNode ) model . getRoot ( ) ; pathList . add ( gnode ) ; Group parentGroup = gchain . get ( 0 ) ; // always the root group
 for ( int i = 1 ; i < gchain . size ( ) ; i ++ ) { parentGroup = gchain . get ( i ) ; gnode = gnode . findNestedGroup ( parentGroup ) ; assert gnode != null ; pathList . add ( gnode ) ; } vp = vchain . get ( 0 ) ; VariableNode vnode = gnode . findNestedVariable ( vp ) ; if ( vnode == null ) { return ; } // not found
 pathList . add ( vnode ) ; // now work down through the structure members, if any
 for ( int i = 1 ; i < vchain . size ( ) ; i ++ ) { vp = vchain . get ( i ) ; vnode = vnode . findNestedVariable ( vp ) ; if ( vnode == null ) { return ; } // not found
 pathList . add ( vnode ) ; } // convert to TreePath, and select it
 final Object [ ] paths = pathList . toArray ( ) ; final TreePath treePath = new TreePath ( paths ) ; tree . setSelectionPath ( treePath ) ; tree . scrollPathToVisible ( treePath ) ; }


Input: TODO : add index range checks [CODESPLIT] public Class getElementType ( ) { DataType dt = CDMTypeFcns . daptype2cdmtype ( this . basetype ) ; if ( dt == null ) throw new IllegalArgumentException ( "Unknown datatype: " + this . basetype ) ; return CDMTypeFcns . cdmElementClass ( dt ) ; }


Input: Convert int base to Index based [CODESPLIT] public double getDouble ( int offset ) { DapVariable d4var = ( DapVariable ) getTemplate ( ) ; long [ ] dimsizes = DapUtil . getDimSizes ( d4var . getDimensions ( ) ) ; return getDouble ( DapUtil . offsetToIndex ( offset , dimsizes ) ) ; }


Input: Get the array element at a specific dap4 index as a double [CODESPLIT] protected double getDouble ( dap4 . core . util . Index idx ) { assert data . getScheme ( ) == Scheme . ATOMIC ; try { Object value = data . read ( idx ) ; value = Convert . convert ( DapType . FLOAT64 , this . basetype , value ) ; return ( Double ) java . lang . reflect . Array . get ( value , 0 ) ; } catch ( IOException ioe ) { throw new IndexOutOfBoundsException ( ioe . getMessage ( ) ) ; } }


Input: Get the array element at a specific dap4 index as an Object [CODESPLIT] protected Object getObject ( dap4 . core . util . Index idx ) { assert data . getScheme ( ) == Scheme . ATOMIC ; try { Object value = data . read ( idx ) ; value = java . lang . reflect . Array . get ( value , 0 ) ; return value ; } catch ( IOException ioe ) { throw new IndexOutOfBoundsException ( ioe . getMessage ( ) ) ; } }


Input: Return the string of Sector for the GINI image file [CODESPLIT] String gini_GetSectorID ( int ent_id ) { String name ; switch ( ent_id ) { case 0 : name = "Northern Hemisphere Composite" ; break ; case 1 : name = "East CONUS" ; break ; case 2 : name = "West CONUS" ; break ; case 3 : name = "Alaska Regional" ; break ; case 4 : name = "Alaska National" ; break ; case 5 : name = "Hawaii Regional" ; break ; case 6 : name = "Hawaii National" ; break ; case 7 : name = "Puerto Rico Regional" ; break ; case 8 : name = "Puerto Rico National" ; break ; case 9 : name = "Supernational" ; break ; case 10 : name = "NH Composite - Meteosat/GOES E/ GOES W/GMS" ; break ; case 11 : name = "Central CONUS" ; break ; case 12 : name = "East Floater" ; break ; case 13 : name = "West Floater" ; break ; case 14 : name = "Central Floater" ; break ; case 15 : name = "Polar Floater" ; break ; default : name = "Unknown-ID" ; } return name ; }


Input: Return the channel ID for the GINI image file [CODESPLIT] String gini_GetEntityID ( int ent_id ) { String name ; switch ( ent_id ) { case 2 : name = "Miscellaneous" ; break ; case 3 : name = "JERS" ; break ; case 4 : name = "ERS/QuikSCAT/Scatterometer" ; break ; case 5 : name = "POES/NPOESS" ; break ; case 6 : name = "Composite" ; break ; case 7 : name = "DMSP satellite Image" ; break ; case 8 : name = "GMS satellite Image" ; break ; case 9 : name = "METEOSAT satellite Image" ; break ; case 10 : name = "GOES-7 satellite Image" ; break ; case 11 : name = "GOES-8 satellite Image" ; break ; case 12 : name = "GOES-9 satellite Image" ; break ; case 13 : name = "GOES-10 satellite Image" ; break ; case 14 : name = "GOES-11 satellite Image" ; break ; case 15 : name = "GOES-12 satellite Image" ; break ; case 16 : name = "GOES-13 satellite Image" ; break ; case 17 : name = "GOES-14 satellite Image" ; break ; case 18 : name = "GOES-15 satellite Image" ; break ; case 19 : // GOES-R name = "GOES-16 satellite Image" ; break ; case 99 : // special snowflake GEMPAK Composite Images generated by Unidata name = "RADAR-MOSIAC Composite Image" ; break ; default : name = "Unknown" ; } return name ; }


Input: Return the channel ID for the GINI image file [CODESPLIT] String gini_GetPhysElemID ( int phys_elem , int ent_id ) { String name ; switch ( phys_elem ) { case 1 : name = "VIS" ; break ; case 3 : name = "IR_WV" ; break ; case 2 : case 4 : case 5 : case 6 : case 7 : name = "IR" ; break ; case 13 : name = "LI" ; break ; case 14 : name = "PW" ; break ; case 15 : name = "SFC_T" ; break ; case 16 : name = "LI" ; break ; case 17 : name = "PW" ; break ; case 18 : name = "SFC_T" ; break ; case 19 : name = "CAPE" ; break ; case 20 : name = "T" ; break ; case 21 : name = "WINDEX" ; break ; case 22 : name = "DMPI" ; break ; case 23 : name = "MDPI" ; break ; case 25 : if ( ent_id == 99 ) name = "HHC" ; else name = "Volcano_imagery" ; break ; case 26 : name = "EchoTops" ; break ; case 27 : if ( ent_id == 99 ) name = "Reflectivity" ; else name = "CTP" ; break ; case 28 : if ( ent_id == 99 ) name = "Reflectivity" ; else name = "Cloud_Amount" ; break ; case 29 : name = "VIL" ; break ; case 30 : case 31 : name = "Precipitation" ; break ; case 40 : case 41 : case 42 : case 43 : case 44 : case 45 : case 46 : case 47 : case 48 : case 49 : case 50 : case 51 : case 52 : case 53 : case 54 : case 55 : case 56 : case 57 : case 58 : name = "sounder_imagery" ; break ; case 59 : name = "VIS_sounder" ; break ; default : name = "Unknown" ; } return name ; }


Input: Return the channel ID for the GINI image file [CODESPLIT] String getPhysElemLongName ( int phys_elem , int ent_id ) { switch ( phys_elem ) { case 1 : return "Imager Visible" ; case 2 : return "Imager 3.9 micron IR" ; case 3 : return "Imager 6.7/6.5 micron IR (WV)" ; case 4 : return "Imager 11 micron IR" ; case 5 : return "Imager 12 micron IR" ; case 6 : return "Imager 13 micron IR" ; case 7 : return "Imager 1.3 micron IR" ; case 13 : return "Lifted Index LI" ; case 14 : return "Precipitable Water PW" ; case 15 : return "Surface Skin Temperature" ; case 16 : return "Lifted Index LI" ; case 17 : return "Precipitable Water PW" ; case 18 : return "Surface Skin Temperature" ; case 19 : return "Convective Available Potential Energy" ; case 20 : return "land-sea Temperature" ; case 21 : return "Wind Index" ; case 22 : return "Dry Microburst Potential Index" ; case 23 : return "Microburst Potential Index" ; case 24 : return "Derived Convective Inhibition" ; case 25 : if ( ent_id == 99 ) return "1km National Hybrid Hydrometeor Classification Composite (Unidata)" ; else return "Volcano_imagery" ; case 26 : if ( ent_id == 99 ) return "1 km National Echo Tops Composite (Unidata)" ; else return "4 km National Echo Tops" ; case 27 : if ( ent_id == 99 ) return "1 km National Base Reflectivity Composite (Unidata)" ; else return "Cloud Top Pressure or Height" ; case 28 : if ( ent_id == 99 ) return "1 km National Reflectivity Composite (Unidata)" ; else return "Cloud Amount" ; case 29 : if ( ent_id == 99 ) return "1 km National Vertically Integrated Liquid Water (Unidata)" ; else return "4 km National Vertically Integrated Liquid Water" ; case 30 : if ( ent_id == 99 ) return "1 km National 1-hour Precipitation (Unidata)" ; else return "Surface wind speeds over oceans and Great Lakes" ; case 31 : if ( ent_id == 99 ) return "4 km National Storm Total Precipitation (Unidata)" ; else return "Surface Wetness" ; case 32 : return "Ice concentrations" ; case 33 : return "Ice type" ; case 34 : return "Ice edge" ; case 35 : return "Cloud water content" ; case 36 : return "Surface type" ; case 37 : return "Snow indicator" ; case 38 : return "Snow/water content" ; case 39 : return "Derived volcano imagery" ; case 41 : return "Sounder 14.71 micron imagery" ; case 42 : return "Sounder 14.37 micron imagery" ; case 43 : return "Sounder 14.06 micron imagery" ; case 44 : return "Sounder 13.64 micron imagery" ; case 45 : return "Sounder 13.37 micron imagery" ; case 46 : return "Sounder 12.66 micron imagery" ; case 47 : return "Sounder 12.02 micron imagery" ; case 48 : return "11.03 micron sounder image" ; case 49 : return "Sounder 11.03 micron imagery" ; case 50 : return "7.43 micron sounder image" ; case 51 : return "7.02 micron sounder image" ; case 52 : return "6.51 micron sounder image" ; case 53 : return "Sounder 4.57 micron imagery" ; case 54 : return "Sounder 4.52 micron imagery" ; case 55 : return "4.45 micron sounder image" ; case 56 : return "Sounder 4.13 micron imagery" ; case 57 : return "3.98 micron sounder image" ; case 58 : return "Sounder 3.74 micron imagery" ; case 59 : return "VIS sounder image " ; default : return "unknown physical element " + phys_elem ; } }


Input: Read a scaled 3 - byte integer from file and convert to double [CODESPLIT] private double readScaledInt ( ByteBuffer buf ) { // 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 ; }


Input: Convenience function ; look up Parameter by name ignoring case . [CODESPLIT] public Parameter findParameterIgnoreCase ( String name ) { for ( Parameter a : params ) { if ( name . equalsIgnoreCase ( a . getName ( ) ) ) return a ; } return null ; }


Input: Iterator API Overrides [CODESPLIT] @ Override public boolean hasNext ( ) { 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 ( ) ; }


Input: Compute the total number of elements . [CODESPLIT] @ Override public long totalSize ( ) { long size = 1 ; for ( int i = 0 ; i < this . rank ; i ++ ) { size *= slice ( i ) . getCount ( ) ; } return size ; }


Input:
Parse the ctl file [CODESPLIT] private void parseDDF ( int maxLines ) throws IOException { //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 ) ; } }


Input:
Swap the byte order from the system default [CODESPLIT] private void swapByteOrder ( ) { // 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 ; } }


Input: Get the number of timesteps per file and the starting offset [CODESPLIT] public int [ ] getTimeStepsPerFile ( String filename ) { if ( chsubs != null ) { for ( Chsub ch : chsubs ) { if ( filename . contains ( ch . subString ) ) { return new int [ ] { ch . numTimes , ch . startTimeIndex } ; } } } return new int [ ] { timeStepsPerFile , 0 } ; }


Input: Get the file name for the particular time and ensemble index [CODESPLIT] public String getFileName ( int eIndex , int tIndex ) { 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 ) ; }


Input:
Get the list of filenames [CODESPLIT] private List < String > getFileNames ( ) throws IOException { 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 ; }


Input: Get the path to the Data Descriptor File [CODESPLIT] private String getDDFPath ( ) { 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 ; }


Input: Get the full path for a given filename [CODESPLIT] private String getFullPath ( String filename ) { 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 ; }


Input: Add a Chsub [CODESPLIT] private void addChsub ( Chsub sub ) { if ( chsubs == null ) { chsubs = new ArrayList <> ( ) ; } chsubs . add ( sub ) ; }


Input: //////////////////////////////////////////////////////////////////////////////////////////////// [CODESPLIT] public void writeDataAll ( DataOutputStream stream ) throws IOException { 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 ( ) ; } }


Input: /////////////////////////////////////////// [CODESPLIT] private long writeData ( Variable v , DataOutputStream stream , Array values ) throws java . io . IOException { 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 ) ; }


Input: Calculate the offset in units of timeUnit from the given reference date? [CODESPLIT] public TimeCoordIntvValue convertReferenceDate ( CalendarDate refDate , CalendarPeriod timeUnit ) { 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 ) ; }


Input: / * create new ArrayBoolean with given indexImpl and backing store . Should be private . [CODESPLIT] static ArrayBoolean factory ( Index index , boolean [ ] storage ) { 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 ) ; } }


Input: copy from javaArray to storage using the iterator : used by factory ( Object ) ; [CODESPLIT] protected void copyFrom1DJavaArray ( IndexIterator iter , Object javaArray ) { boolean [ ] ja = ( boolean [ ] ) javaArray ; for ( boolean aJa : ja ) iter . setBooleanNext ( aJa ) ; }


Input:
check if this file is a nids / tdwr file [CODESPLIT] public boolean isValidFile ( ucar . unidata . io . RandomAccessFile raf ) { 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 ; }


Input:
read the header of input file and parsing the WMO part [CODESPLIT] int readWMO ( ucar . unidata . io . RandomAccessFile raf ) throws IOException { 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 ; }


Input: read the compressed data [CODESPLIT] public byte [ ] getUncompData ( int offset , int len ) { if ( len == 0 ) len = uncompdata . length - offset ; byte [ ] data = new byte [ len ] ; System . arraycopy ( uncompdata , offset , data , 0 , len ) ; return data ; }


Input:
read and parse the header of the nids / tdwr file [CODESPLIT] void read ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile ) throws IOException { 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 ( ) ; }


Input:
construct a dataset for special graphic symbol packet with code 12 13 and 14 [CODESPLIT] int pcode_12n13n14 ( int [ ] pos , int [ ] dlen , int hoff , int len , boolean isZ , String structName , int code ) { //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 ; }


Input: construct a dataset for special symbol packet with code 25 [CODESPLIT] int pcode_25 ( int [ ] pos , int hoff , int len , boolean isZ ) { 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 ; }


Input:
check level III file header [CODESPLIT] int checkMsgHeader ( ucar . unidata . io . RandomAccessFile raf ) throws IOException { 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 ) ; }


Input:
construct a dataset for vector arrow data packet with code 5 [CODESPLIT] int pcode_5 ( int [ ] pos , int hoff , int len , boolean isZ ) { 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 ; }


Input:
construct a dataset for text and special symbol packets with code 1 2 and 8 [CODESPLIT] int pcode_128 ( int [ ] pos , int [ ] size , int code , int hoff , int len , String structName , String abbre , boolean isZ ) { //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 ; }


Input: construct a dataset for linked vector packet and unlinked vector packet [CODESPLIT] int pcode_10n9 ( int [ ] pos , int [ ] dlen , int hoff , int len , boolean isZ ) { 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 ; }


Input:
construct a dataset for NIDS digital precipitation array [CODESPLIT] int pcode_DPA ( ByteBuffer bos , int pos , int hoff , int hedsiz , boolean isZ , int slayer , int code ) { 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 ; }


Input:
construct a raster dataset for NIDS raster products ; [CODESPLIT] int pcode_raster ( ByteBuffer bos , short pkcode , int hoff , int hedsiz , boolean isZ , byte [ ] data ) { 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 ; }


Input:
construct a radial dataset for NIDS radial products ; [CODESPLIT] int pcode_radial ( ByteBuffer bos , int hoff , int hedsiz , boolean isZ , byte [ ] data , short [ ] threshold ) throws IOException { 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 ; }


Input: for level3 176 product [CODESPLIT] public List parseComponents ( ByteBuffer datainput ) throws IOException { 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 ; }


Input:
for level3 176 product [CODESPLIT] public ArrayList parseData ( ByteBuffer datainput ) throws IOException { 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 ; }


Input: for level3 176 product [CODESPLIT] public List parseParameters ( ByteBuffer datainput ) throws IOException { 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 ; }


Input: for level3 176 product [CODESPLIT] public HashMap addAttributePairs ( String s ) { 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 ; }


Input: for level3 176 product [CODESPLIT] public static String readInString ( ByteBuffer datainput ) throws IOException { 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 ( ) ; }


Input:
construct a generic radial dataset for dualpol radial products ; [CODESPLIT] int pcode_generic ( ByteBuffer bos , int hoff , int hedsiz , boolean isZ , byte [ ] data , short [ ] threshold ) throws IOException { 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 ; }


Input: get the table to calibrate data value [CODESPLIT] public int [ ] getLevels ( int nlevel , short [ ] th ) { 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 ; }


Input:
get the calibrate data values for TDWR data [CODESPLIT] public int [ ] getTDWRLevels ( int nlevel , short [ ] th ) { 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 ; }


Input:
get the calibrate data values for TDWR data [CODESPLIT] public int [ ] getTDWRLevels1 ( int nlevel , short [ ] th ) { 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 ; }


Input:
get the calibrate data values for dualpol data [CODESPLIT] public int [ ] getDualpolLevels ( short [ ] th ) { 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 ; }


Input:
get the calibrate data values for TDWR data [CODESPLIT] public int [ ] getTDWRLevels2 ( int nlevel , short [ ] th ) { 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 ; }


Input: adding new variable to the netcdf file [CODESPLIT] 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 ) { 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 ) ) ; }


Input: adding new parameter to the netcdf file [CODESPLIT] void addParameter ( String pName , String longName , NetcdfFile nc , ArrayList dims , Attribute att , DataType dtype , String ut , long hoff , long doff , boolean isZ , int y0 ) { 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 ) ) ; }


Input: Misc [CODESPLIT] private int getProductLevel ( int prod_elevation ) { 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 ; }