signature:
public class AggregationExisting { /** * has the name getCacheName ( ) */
private String getCacheName ( ) { } }

implementation: String cacheName = ncDataset . getLocation ( ) ; if ( cacheName == null ) cacheName = ncDataset . getCacheName ( ) ; return cacheName ;


signature:
public class Grib1ParamTables { /** * Make a key from ( center , subcenter , version ) that provides correct sort order . */
static int makeKey ( int center , int subcenter , int version ) { } }

implementation: if ( center < 0 ) center = 255 ; if ( subcenter < 0 ) subcenter = 255 ; if ( version < 0 ) version = 255 ; return center * 1000 * 1000 + subcenter * 1000 + version ;


signature:
public class Grib1ParamTables { /** * Get a Grib1ParamTables object , optionally specifying a parameter table or lookup table specific to this dataset .
 * @ param paramTablePath path to a parameter table , in format Grib1ParamTable can read .
 * @ param lookupTablePath path to a lookup table , in format Lookup . readLookupTable ( ) can read .
 * @ return Grib1Tables
 * @ throws IOException on read error */
public static Grib1ParamTables factory ( String paramTablePath , String lookupTablePath ) throws IOException { } }

implementation: if ( paramTablePath == null && lookupTablePath == null ) return new Grib1ParamTables ( ) ; Lookup lookup = null ; Grib1ParamTableReader override = null ; Grib1ParamTableReader table ; if ( paramTablePath != null ) { table = localTableHash . get ( paramTablePath ) ; if ( table == null ) { table = new Grib1ParamTableReader ( paramTablePath ) ; localTableHash . put ( paramTablePath , table ) ; override = table ; } } if ( lookupTablePath != null ) { lookup = new Lookup ( ) ; if ( ! lookup . readLookupTable ( lookupTablePath ) ) throw new FileNotFoundException ( "cant read lookup table=" + lookupTablePath ) ; } return new Grib1ParamTables ( lookup , override ) ;


signature:
public class Grib1ParamTables { /** * Get a Grib1Tables object , optionally specifiying a parameter table in XML specific to this dataset .
 * @ param paramTableElem parameter table in XML
 * @ return Grib1Tables */
public static Grib1ParamTables factory ( org . jdom2 . Element paramTableElem ) { } }

implementation: if ( paramTableElem == null ) return new Grib1ParamTables ( ) ; return new Grib1ParamTables ( null , new Grib1ParamTableReader ( paramTableElem ) ) ;


signature:
public class Grib1ParamTables { /** * Debugging only */
public Grib1ParamTableReader getParameterTable ( int center , int subcenter , int tableVersion ) { } }

implementation:
Grib1ParamTableReader result = null ; if ( lookup != null ) result = lookup . getParameterTable ( center , subcenter , tableVersion ) ; if ( result == null ) result = standardLookup . getParameterTable ( center , subcenter , tableVersion ) ; // standard tables
return result ;


signature:
public class Grib1ParamTables { /** * Add all tables in list to standard tables
 * @ param lookupFilename filename containing list of tables
 * @ return true if read ok , false if file not found
 * @ throws IOException if file found but read error */
public static boolean addParameterTableLookup ( String lookupFilename ) throws IOException { } }

implementation: Lookup lookup = new Lookup ( ) ; if ( ! lookup . readLookupTable ( lookupFilename ) ) return false ; synchronized ( lock ) { standardLookup . tables . addAll ( standardTablesStart , lookup . tables ) ; standardTablesStart += lookup . tables . size ( ) ; } return true ;


signature:
public class Grib1ParamTables { /** * Add table to standard tables for a specific center , subcenter and version .
 * @ param center center id
 * @ param subcenter subcenter id , or - 1 for all
 * @ param tableVersion table verssion , or - 1 for all
 * @ param tableFilename file to read parameter table from */
public static void addParameterTable ( int center , int subcenter , int tableVersion , String tableFilename ) { } }

implementation: Grib1ParamTableReader table = new Grib1ParamTableReader ( center , subcenter , tableVersion , tableFilename ) ; synchronized ( lock ) { standardLookup . tables . add ( standardTablesStart , table ) ; standardTablesStart ++ ; }


signature:
public class LogarithmicUnit { /** * Multiply this unit by another unit .
 * @ param that
 * The unit to multiply this unit by . Must be dimensionless .
 * @ return The product of this unit and < code > that < / code > .
 * @ throws MultiplyException
 * Can ' t multiply these units together . */
@ Override protected Unit myMultiplyBy ( final Unit that ) throws MultiplyException { } }

implementation: if ( ! that . isDimensionless ( ) ) { throw new MultiplyException ( that ) ; } return that instanceof ScaledUnit ? new ScaledUnit ( ( ( ScaledUnit ) that ) . getScale ( ) , this ) : this ;


signature:
public class LogarithmicUnit { /** * Divide this unit by another unit .
 * @ param that
 * The unit to divide this unit by .
 * @ return The quotient of this unit and < code > that < / code > .
 * @ throws DivideException
 * Can ' t divide these units . */
@ Override protected Unit myDivideBy ( final Unit that ) throws DivideException { } }

implementation: if ( ! that . isDimensionless ( ) ) { throw new DivideException ( that ) ; } return that instanceof ScaledUnit ? new ScaledUnit ( 1.0 / ( ( ScaledUnit ) that ) . getScale ( ) , this ) : this ;


signature:
public class LogarithmicUnit { /** * Raise this unit to a power .
 * @ param power
 * The power to raise this unit by . The only meaningful values
 * are 0 and 1.
 * @ return The result of raising this unit by the power < code > power < / code > .
 * @ throws RaiseException
 * Can ' t raise this unit to { @ code power } , which is neither 0
 * nor 1. */
@ Override protected Unit myRaiseTo ( final int power ) throws RaiseException { } }

implementation: if ( power == 0 ) { return DerivedUnitImpl . DIMENSIONLESS ; } if ( power == 1 ) { return this ; } throw new RaiseException ( this ) ;


signature:
public class LogarithmicUnit { /** * Converts values in this unit to the equivalent values in the convertible
 * derived unit .
 * @ param input
 * The values in this unit .
 * @ param output
 * The equivalent values in the convertible derived unit . May be
 * the same array as < code > input < / code > .
 * @ return < code > output < / code > .
 * @ throws ConversionException
 * Can ' t convert between units . */
public float [ ] toDerivedUnit ( final float [ ] input , final float [ ] output ) throws ConversionException { } }

implementation: for ( int i = input . length ; -- i >= 0 ; ) { output [ i ] = ( float ) ( Math . exp ( input [ i ] * lnBase ) ) ; } return reference . toDerivedUnit ( output , output ) ;


signature:
public class LogarithmicUnit { /** * Converts values in the convertible derived unit to the equivalent values
 * in this unit .
 * @ param input
 * The values in the convertible derived unit .
 * @ param output
 * The equivalent values in this unit . May be the same array as
 * < code > input < / code > .
 * @ return < code > output < / code > .
 * @ throws ConversionException
 * Can ' t convert between units . */
public float [ ] fromDerivedUnit ( final float [ ] input , final float [ ] output ) throws ConversionException { } }

implementation: reference . fromDerivedUnit ( input , output ) ; for ( int i = input . length ; -- i >= 0 ; ) { output [ i ] = ( float ) ( Math . log ( output [ i ] ) / lnBase ) ; } return output ;


signature:
public class Vis5DIosp { /** * Is this a valid file ?
 * @ param raf RandomAccessFile to check
 * @ return true if a valid McIDAS AREA file
 * @ throws IOException problem reading file */
public boolean isValidFile ( RandomAccessFile raf ) throws IOException { } }

implementation:
// quick test
raf . order ( RandomAccessFile . BIG_ENDIAN ) ; raf . seek ( 0 ) ; String got = raf . readString ( V5D . length ( ) ) ; if ( got . equals ( V5D ) ) { return true ; } else { // more rigorous test
V5DStruct vv ; try { vv = V5DStruct . v5dOpenFile ( raf ) ; } catch ( BadFormException bfe ) { vv = null ; } return vv != null ; }


signature:
public class Vis5DIosp { /** * Open the service provider for reading .
 * @ param raf file to read from
 * @ param ncfile netCDF file we are writing to ( memory )
 * @ param cancelTask task for cancelling
 * @ throws IOException problem reading file */
public void open ( RandomAccessFile raf , NetcdfFile ncfile , CancelTask cancelTask ) throws IOException { } }

implementation: super . open ( raf , ncfile , cancelTask ) ; if ( unitTable == null ) { initUnitTable ( ) ; } if ( v5dstruct == null ) { makeFile ( raf , ncfile , cancelTask ) ; }


signature:
public class Vis5DIosp { /** * Make the netcdf file
 * @ param raf the RandomAccessFile
 * @ param ncfile the netCDF file handle
 * @ param cancelTask the cancel task
 * @ throws IOException problem reading the file */
private void makeFile ( RandomAccessFile raf , NetcdfFile ncfile , CancelTask cancelTask ) throws IOException { } }

implementation:
ncfile . empty ( ) ; int [ ] sizes = new int [ 5 ] ; int [ ] map_proj = new int [ 1 ] ; String [ ] varnames = new String [ MAXVARS ] ; String [ ] varunits = new String [ MAXVARS ] ; int [ ] n_levels = new int [ MAXVARS ] ; int [ ] vert_sys = new int [ 1 ] ; float [ ] vertargs = new float [ MAXVERTARGS ] ; double [ ] times = new double [ MAXTIMES ] ; float [ ] projargs = new float [ MAXPROJARGS ] ; try { v5dstruct = V5DStruct . v5d_open ( raf , sizes , n_levels , varnames , varunits , map_proj , projargs , vert_sys , vertargs , times ) ; } catch ( BadFormException bfe ) { throw new IOException ( "Vis5DIosp.makeFile: bad file " + bfe . getMessage ( ) ) ; } if ( sizes [ 0 ] < 1 ) { throw new IOException ( "Vis5DIosp.makeFile: bad file" ) ; } int nr = sizes [ 0 ] ; int nc = sizes [ 1 ] ; int nl = sizes [ 2 ] ; int ntimes = sizes [ 3 ] ; int nvars = sizes [ 4 ] ; // System . out . println ( " nr : " + nr ) ;
// System . out . println ( " nc : " + nc ) ;
// System . out . println ( " nl : " + nl ) ;
// System . out . println ( " ntimes : " + ntimes ) ;
// System . out . println ( " nvars : " + nvars ) ;
Dimension time = new Dimension ( TIME , ntimes , true ) ; Dimension row = new Dimension ( ROW , nr , true ) ; Dimension col = new Dimension ( COLUMN , nc , true ) ; ncfile . addDimension ( null , time ) ; ncfile . addDimension ( null , row ) ; ncfile . addDimension ( null , col ) ; // time
Variable timeVar = new Variable ( ncfile , null , null , TIME ) ; timeVar . setDataType ( DataType . DOUBLE ) ; timeVar . setDimensions ( TIME ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "seconds since 1900-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( "long_name" , TIME ) ) ; timeVar . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Time . toString ( ) ) ) ; Array varArray = new ArrayDouble . D1 ( ntimes ) ; for ( int i = 0 ; i < ntimes ; i ++ ) { ( ( ArrayDouble . D1 ) varArray ) . set ( i , times [ i ] ) ; } timeVar . setCachedData ( varArray , false ) ; ncfile . addVariable ( null , timeVar ) ; // rows and columns
Variable rowVar = new Variable ( ncfile , null , null , ROW ) ; rowVar . setDataType ( DataType . INT ) ; rowVar . setDimensions ( ROW ) ; varArray = new ArrayInt . D1 ( nr , false ) ; for ( int i = 0 ; i < nr ; i ++ ) { ( ( ArrayInt . D1 ) varArray ) . set ( i , i ) ; } rowVar . setCachedData ( varArray , false ) ; ncfile . addVariable ( null , rowVar ) ; Variable colVar = new Variable ( ncfile , null , null , COLUMN ) ; colVar . setDataType ( DataType . INT ) ; colVar . setDimensions ( COLUMN ) ; varArray = new ArrayInt . D1 ( nc , false ) ; for ( int i = 0 ; i < nc ; i ++ ) { ( ( ArrayInt . D1 ) varArray ) . set ( i , i ) ; } colVar . setCachedData ( varArray , false ) ; ncfile . addVariable ( null , colVar ) ; // sanity check on levels
Hashtable < Integer , Object > var_table = new Hashtable < > ( ) ; boolean have3D = false ; for ( int i = 0 ; i < nvars ; i ++ ) { int nlevs = n_levels [ i ] ; if ( ! have3D && ( nlevs > 1 ) ) { have3D = true ; } var_table . put ( nlevs , new Object ( ) ) ; } int n_var_groups = var_table . size ( ) ; if ( n_var_groups > 2 ) { throw new IOException ( "Vis5DIosp.makeFile: more than two variable groups by n_levels" ) ; } else if ( n_var_groups == 0 ) { throw new IOException ( "Vis5DIosp.makeFile: number of variable groups == 0" ) ; } Variable vert = null ; if ( have3D ) { Dimension lev = new Dimension ( LEVEL , nl , true ) ; ncfile . addDimension ( null , lev ) ; vert = makeVerticalVariable ( vert_sys [ 0 ] , nl , vertargs ) ; if ( vert != null ) { ncfile . addVariable ( null , vert ) ; } } varTable = new Hashtable < > ( ) ; String dim3D = TIME + " " + LEVEL + " " + COLUMN + " " + ROW ; String dim2D = TIME + " " + COLUMN + " " + ROW ; // String coords3D = TIME + " " + vert . getName ( ) + " " + LAT + " " + LON ;
String coords3D = "unknown" ; if ( vert != null ) { coords3D = TIME + " Height " + LAT + " " + LON ; } String coords2D = TIME + " " + LAT + " " + LON ; for ( int i = 0 ; i < nvars ; i ++ ) { Variable v = new Variable ( ncfile , null , null , varnames [ i ] ) ; if ( n_levels [ i ] > 1 ) { v . setDimensions ( dim3D ) ; v . addAttribute ( new Attribute ( CF . COORDINATES , coords3D ) ) ; } else { v . setDimensions ( dim2D ) ; v . addAttribute ( new Attribute ( CF . COORDINATES , coords2D ) ) ; } v . setDataType ( DataType . FLOAT ) ; String units = varunits [ i ] . trim ( ) ; if ( units . equals ( "" ) ) { // see if its in the unitTable
String key = varnames [ i ] . trim ( ) . toLowerCase ( ) ; units = unitTable . get ( key ) ; } if ( units != null ) { v . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; } // TODO : do two vars with the same name have different values ?
// check agaist duplicat variable names
if ( varTable . get ( v ) == null ) { varTable . put ( v , i ) ; ncfile . addVariable ( null , v ) ; } } double [ ] [ ] proj_args = Set . floatToDouble ( new float [ ] [ ] { projargs } ) ; addLatLonVariables ( map_proj [ 0 ] , proj_args [ 0 ] , nr , nc ) ; // Vis5DGridDefRecord gridDef = new Vis5DGridDefRecord ( map _ proj [ 0 ] , proj _ args [ 0 ] , nr , nc ) ;
ncfile . addAttribute ( null , new Attribute ( "Conventions" , "CF-1.0" ) ) ; ncfile . finish ( ) ;


signature:
public class Vis5DIosp { /** * Read the data for the variable
 * @ param v2 Variable to read
 * @ param section section infomation
 * @ return Array of data
 * @ throws IOException problem reading from file
 * @ throws InvalidRangeException invalid Range */
public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation:
// long startTime = System . currentTimeMillis ( ) ;
Integer varIdx = varTable . get ( v2 ) ; if ( varIdx == null ) { throw new IOException ( "unable to find variable index" ) ; } int count = 0 ; int [ ] shape = v2 . getShape ( ) ; boolean haveZ = shape . length == 4 ; int nt = shape [ count ++ ] ; int nz = haveZ ? shape [ count ++ ] : 1 ; int ny = shape [ count ++ ] ; int nx = shape [ count ] ; count = 0 ; Range timeRange = section . getRange ( count ++ ) ; Range zRange = haveZ ? section . getRange ( count ++ ) : null ; Range yRange = section . getRange ( count ++ ) ; Range xRange = section . getRange ( count ) ; int grid_size = nx * ny * nz ; Array dataArray = Array . factory ( DataType . FLOAT , section . getShape ( ) ) ; IndexIterator ii = dataArray . getIndexIterator ( ) ; // loop over time
for ( int timeIdx : timeRange ) { float [ ] data = new float [ grid_size ] ; float [ ] ranges = new float [ 2 ] ; try { v5dstruct . v5d_read ( timeIdx , varIdx , ranges , data ) ; } catch ( BadFormException bfe ) { throw new IOException ( "Vis5DIosp.readData: " + bfe . getMessage ( ) ) ; } if ( ( ranges [ 0 ] >= 0.99E30 ) && ( ranges [ 1 ] <= - 0.99E30 ) ) { // range _ sets [ j ] = new Linear1DSet ( 0.0 , 1.0 , 255 ) ;
} else if ( ranges [ 0 ] > ranges [ 1 ] ) { throw new IOException ( "Vis5DIosp.readData: bad read " + v2 . getFullName ( ) ) ; } // invert the rows
float [ ] tmp_data = new float [ grid_size ] ; if ( zRange == null ) { int cnt = 0 ; for ( int mm = 0 ; mm < ny ; mm ++ ) { int start = ( mm + 1 ) * nx - 1 ; for ( int nn = 0 ; nn < nx ; nn ++ ) { tmp_data [ cnt ++ ] = data [ start -- ] ; } } } else { int cnt = 0 ; for ( int ll = 0 ; ll < nz ; ll ++ ) { for ( int mm = 0 ; mm < ny ; mm ++ ) { int start = ( ( mm + 1 ) * nx - 1 ) + nx * ny * ll ; for ( int nn = 0 ; nn < nx ; nn ++ ) { tmp_data [ cnt ++ ] = data [ start -- ] ; } } } } data = tmp_data ; // copy the data into the array
for ( float aData : data ) { ii . setFloatNext ( aData ) ; } } // long end = System . currentTimeMillis ( ) - startTime ;
return dataArray ;


signature:
public class Vis5DIosp { /** * Initialize the unit table . This is used if there are no
 * units in the file . */
private static void initUnitTable ( ) { } }

implementation:
unitTable = new Hashtable < > ( ) ; // temperatures
unitTable . put ( "t" , "K" ) ; unitTable . put ( "td" , "K" ) ; unitTable . put ( "thte" , "K" ) ; // winds
unitTable . put ( "u" , "m/s" ) ; unitTable . put ( "v" , "m/s" ) ; unitTable . put ( "w" , "m/s" ) ; // pressure
unitTable . put ( "p" , "hPa" ) ; unitTable . put ( "mmsl" , "hPa" ) ; // moisture
unitTable . put ( "rh" , "%" ) ; // misc
unitTable . put ( "rhfz" , "%" ) ; unitTable . put ( "zagl" , "m" ) ;


signature:
public class Vis5DIosp { /** * Create a vertical dimension variable based on the info . Based on
 * visad . data . vis5d . Vis5DVerticalSystem .
 * @ param vert _ sys the vertical system id
 * @ param n _ levels the number of levels
 * @ param vert _ args the vertical system arguments
 * @ return the vertical dimesion variable
 * @ throws IOException problem reading the file or creating the data */
private Variable makeVerticalVariable ( int vert_sys , int n_levels , float [ ] vert_args ) throws IOException { } }

implementation:
String vert_unit = null ; String vert_type ; ArrayFloat . D1 data = new ArrayFloat . D1 ( n_levels ) ; AxisType axisType = null ; switch ( vert_sys ) { case ( 0 ) : vert_unit = null ; vert_type = "height" ; break ; case ( 1 ) : case ( 2 ) : vert_unit = "km" ; vert_type = "altitude" ; axisType = AxisType . Height ; break ; case ( 3 ) : vert_unit = "mbar" ; vert_type = "pressure" ; axisType = AxisType . Pressure ; break ; default : throw new IOException ( "vert_sys unknown" ) ; } Variable vertVar = new Variable ( ncfile , null , null , vert_type ) ; vertVar . setDimensions ( LEVEL ) ; vertVar . setDataType ( DataType . FLOAT ) ; if ( vert_unit != null ) { vertVar . addAttribute ( new Attribute ( CDM . UNITS , vert_unit ) ) ; } if ( axisType != null ) { vertVar . addAttribute ( new Attribute ( _Coordinate . AxisType , axisType . toString ( ) ) ) ; } switch ( vert_sys ) { case ( 0 ) : case ( 1 ) : for ( int i = 0 ; i < n_levels ; i ++ ) { data . set ( i , vert_args [ 0 ] + vert_args [ 1 ] * i ) ; } break ; case ( 2 ) : // Altitude in km - non - linear
for ( int i = 0 ; i < n_levels ; i ++ ) { data . set ( i , vert_args [ i ] ) ; } break ; case ( 3 ) : // heights of pressure surfaces in km - non - linear
try { Vis5DVerticalSystem . Vis5DVerticalCoordinateSystem vert_cs = new Vis5DVerticalSystem . Vis5DVerticalCoordinateSystem ( ) ; float [ ] [ ] pressures = new float [ 1 ] [ n_levels ] ; System . arraycopy ( vert_args , 0 , pressures [ 0 ] , 0 , n_levels ) ; for ( int i = 0 ; i < n_levels ; i ++ ) { pressures [ 0 ] [ i ] *= 1000 ; // km - > m
} pressures = vert_cs . fromReference ( pressures ) ; // convert to pressures
for ( int i = 0 ; i < n_levels ; i ++ ) { data . set ( i , pressures [ 0 ] [ i ] ) ; } } catch ( VisADException ve ) { throw new IOException ( "unable to make vertical system" ) ; } break ; } vertVar . setCachedData ( data , false ) ; return vertVar ;


signature:
public class Vis5DIosp { /** * Add lat / lon variables to the file
 * @ param map _ proj the map projection identifier
 * @ param proj _ args the projection args
 * @ param nr number of rows
 * @ param nc number of columns
 * @ throws IOException Problem making the projection */
private void addLatLonVariables ( int map_proj , double [ ] proj_args , int nr , int nc ) throws IOException { } }

implementation:
// Vis5DGridDefRecord . printProjArgs ( map _ proj , proj _ args ) ;
Vis5DGridDefRecord vgd = new Vis5DGridDefRecord ( map_proj , proj_args , nr , nc ) ; GridHorizCoordSys ghc = new GridHorizCoordSys ( vgd , new Vis5DLookup ( ) , null ) ; Vis5DCoordinateSystem coord_sys ; try { coord_sys = new Vis5DCoordinateSystem ( map_proj , proj_args , nr , nc ) ; Variable lat = new Variable ( ncfile , null , null , LAT ) ; lat . setDimensions ( COLUMN + " " + ROW ) ; lat . setDataType ( DataType . DOUBLE ) ; lat . addAttribute ( new Attribute ( "long_name" , "latitude" ) ) ; lat . addAttribute ( new Attribute ( CDM . UNITS , CDM . LAT_UNITS ) ) ; lat . addAttribute ( new Attribute ( CF . STANDARD_NAME , "latitude" ) ) ; lat . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lat . toString ( ) ) ) ; ncfile . addVariable ( null , lat ) ; Variable lon = new Variable ( ncfile , null , null , LON ) ; lon . setDimensions ( COLUMN + " " + ROW ) ; lon . setDataType ( DataType . DOUBLE ) ; lon . addAttribute ( new Attribute ( CDM . UNITS , CDM . LON_UNITS ) ) ; lon . addAttribute ( new Attribute ( "long_name" , "longitude" ) ) ; lon . addAttribute ( new Attribute ( CF . STANDARD_NAME , "longitude" ) ) ; lon . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lon . toString ( ) ) ) ; ncfile . addVariable ( null , lon ) ; int [ ] shape = new int [ ] { nc , nr } ; Array latArray = Array . factory ( DataType . DOUBLE , shape ) ; Array lonArray = Array . factory ( DataType . DOUBLE , shape ) ; double [ ] [ ] rowcol = new double [ 2 ] [ nr * nc ] ; for ( int x = 0 ; x < nc ; x ++ ) { for ( int y = 0 ; y < nr ; y ++ ) { int index = x * nr + y ; rowcol [ 0 ] [ index ] = y ; rowcol [ 1 ] [ index ] = x ; } } double [ ] [ ] latlon = coord_sys . toReference ( rowcol ) ; Index latIndex = latArray . getIndex ( ) ; Index lonIndex = lonArray . getIndex ( ) ; /* for ( int y = 0 ; y < nr ; y + + ) {
 for ( int x = 0 ; x < nc ; x + + ) {
 int index = y * nc + x ; */
for ( int x = 0 ; x < nc ; x ++ ) { for ( int y = 0 ; y < nr ; y ++ ) { int index = x * nr + y ; /* latArray . setDouble ( latIndex . set ( x , y ) , latlon [ 0 ] [ index ] ) ;
 lonArray . setDouble ( lonIndex . set ( x , y ) , latlon [ 1 ] [ index ] ) ; */
latArray . setDouble ( index , latlon [ 0 ] [ index ] ) ; lonArray . setDouble ( index , latlon [ 1 ] [ index ] ) ; } } lat . setCachedData ( latArray , false ) ; lon . setCachedData ( lonArray , false ) ; } catch ( VisADException ve ) { throw new IOException ( "Vis5DIosp.addLatLon: " + ve . getMessage ( ) ) ; }


signature:
public class DoradeDescriptor { /** * Read and set the descriptor name , size , and endianness , and return the
 * entire contents of the descriptor ( including the name and size ) as a
 * byte array . The file position will be left at the beginning of the next
 * descriptor ( or at the end of file ) .
 * @ param file the DORADE sweepfile , positioned at the beginning of a
 * descriptor
 * @ param littleEndianData set to true iff the file contains little - endian
 * data
 * @ param expectedName the expected name for the descriptor being read
 * @ throws DescriptorException for file read errors , descriptor name
 * mismatch , etc . */
protected byte [ ] readDescriptor ( RandomAccessFile file , boolean littleEndianData , String expectedName ) throws DescriptorException { } }

implementation:
this . file = file ; this . littleEndianData = littleEndianData ; this . expectedName = expectedName ; verbose = getDefaultVerboseState ( expectedName ) ; byte [ ] data ; try { // find the next descriptor with our expected name
findNext ( file ) ; // keep track of the start of this descriptor
long startpos = file . getFilePointer ( ) ; // get the name and descriptor size
byte [ ] header = new byte [ 8 ] ; file . readFully ( header ) ; descName = new String ( header , 0 , 4 , CDM . utf8Charset ) ; int size = grabInt ( header , 4 ) ; // now back up to the start of the descriptor and read the entire
// thing into a byte array
file . seek ( startpos ) ; data = new byte [ size ] ; file . readFully ( data ) ; } catch ( java . io . IOException ex ) { throw new DescriptorException ( ex ) ; } // now check the name we got against the expected name
if ( ! descName . equals ( expectedName ) ) throw new DescriptorException ( "Got descriptor name '" + descName + "' when expecting name '" + expectedName + "'" ) ; return data ;


signature:
public class DoradeDescriptor { /** * Skip the current DORADE descriptor in the file , leaving the file position
 * at the beginning of the next descriptor ( or at the end of file ) .
 * @ param file the DORADE sweepfile , positioned at the beginning of a
 * descriptor
 * @ throws java . io . IOException */
protected static void skipDescriptor ( RandomAccessFile file , boolean littleEndianData ) throws DescriptorException , java . io . IOException { } }

implementation:
try { file . readFully ( new byte [ 4 ] ) ; // skip name
byte [ ] lenBytes = new byte [ 4 ] ; file . readFully ( lenBytes ) ; int descLen = grabInt ( lenBytes , 0 , littleEndianData ) ; file . readFully ( new byte [ descLen - 8 ] ) ; } catch ( java . io . EOFException eofex ) { return ; // just leave the file at EOF
} catch ( Exception ex ) { throw new DescriptorException ( ex ) ; }


signature:
public class DoradeDescriptor { /** * Return the name of the DORADE descriptor at the current location
 * in the file . The current location will not be changed .
 * @ param file the DORADE sweep file , positioned at the beginning of a
 * descriptor
 * @ return the name of the DORADE descriptor starting at the current
 * file position , or null if no descriptor name is available
 * @ throws DescriptorException */
protected static String peekName ( RandomAccessFile file ) throws DescriptorException { } }

implementation:
try { long filepos = file . getFilePointer ( ) ; byte [ ] nameBytes = new byte [ 4 ] ; if ( file . read ( nameBytes ) == - 1 ) return null ; // EOF
file . seek ( filepos ) ; return new String ( nameBytes , CDM . utf8Charset ) ; } catch ( IOException ex ) { throw new DescriptorException ( ex ) ; }


signature:
public class DoradeDescriptor { /** * Determine if the given DORADE sweepfile contains little - endian data
 * ( in violation of the DORADE definition . . . ) .
 * @ param file the DORADE sweepfile ,
 * @ return < code > true < / code > iff the file contains little - endian data
 * @ throws DescriptorException */
public static boolean sweepfileIsLittleEndian ( RandomAccessFile file ) throws DescriptorException { } }

implementation:
int descLen ; try { file . seek ( 0 ) ; // skip the 4 - byte descriptor name
byte [ ] bytes = new byte [ 4 ] ; file . readFully ( bytes ) ; // get the descriptor length
descLen = file . readInt ( ) ; file . seek ( 0 ) ; } catch ( Exception ex ) { throw new DescriptorException ( ex ) ; } return ( descLen < 0 || descLen > 0xffffff ) ;


signature:
public class DoradeDescriptor { /** * Unpack a two - byte integer from the given byte array .
 * @ param bytes byte array to be read
 * @ param offset number of bytes to skip in the byte array before reading
 * @ return the unpacked short value */
protected short grabShort ( byte [ ] bytes , int offset ) { } }

implementation:
int ndx0 = offset + ( littleEndianData ? 1 : 0 ) ; int ndx1 = offset + ( littleEndianData ? 0 : 1 ) ; // careful that we only allow sign extension on the highest order byte
return ( short ) ( bytes [ ndx0 ] << 8 | ( bytes [ ndx1 ] & 0xff ) ) ;


signature:
public class DoradeDescriptor { /** * Unpack a four - byte integer from the given byte array .
 * @ param bytes byte array to be read
 * @ param offset number of bytes to skip in the byte array before reading
 * @ param littleEndianData true iff the byte array contains little - endian
 * data
 * @ return the unpacked integer value */
protected static int grabInt ( byte [ ] bytes , int offset , boolean littleEndianData ) { } }

implementation:
int ndx0 = offset + ( littleEndianData ? 3 : 0 ) ; int ndx1 = offset + ( littleEndianData ? 2 : 1 ) ; int ndx2 = offset + ( littleEndianData ? 1 : 2 ) ; int ndx3 = offset + ( littleEndianData ? 0 : 3 ) ; // careful that we only allow sign extension on the highest order byte
return ( bytes [ ndx0 ] << 24 | ( bytes [ ndx1 ] & 0xff ) << 16 | ( bytes [ ndx2 ] & 0xff ) << 8 | ( bytes [ ndx3 ] & 0xff ) ) ;


signature:
public class DoradeDescriptor { /** * Unpack a four - byte IEEE float from the given byte array .
 * @ param bytes byte array to be read
 * @ param offset number of bytes to skip in the byte array before reading
 * @ return the unpacked float value */
protected float grabFloat ( byte [ ] bytes , int offset ) throws DescriptorException { } }

implementation: try { byte [ ] src ; if ( littleEndianData ) { src = new byte [ 4 ] ; src [ 0 ] = bytes [ offset + 3 ] ; src [ 1 ] = bytes [ offset + 2 ] ; src [ 2 ] = bytes [ offset + 1 ] ; src [ 3 ] = bytes [ offset ] ; offset = 0 ; } else { src = bytes ; } DataInputStream stream = new DataInputStream ( new ByteArrayInputStream ( src , offset , 4 ) ) ; return stream . readFloat ( ) ; } catch ( Exception ex ) { throw new DescriptorException ( ex ) ; }


signature:
public class DoradeDescriptor { /** * Unpack an eight - byte IEEE float from the given byte array .
 * @ param bytes byte array to be read
 * @ param offset number of bytes to skip in the byte array before reading
 * @ return the unpacked double value */
protected double grabDouble ( byte [ ] bytes , int offset ) throws DescriptorException { } }

implementation: try { byte [ ] src ; if ( littleEndianData ) { src = new byte [ 8 ] ; src [ 0 ] = bytes [ offset + 7 ] ; src [ 1 ] = bytes [ offset + 6 ] ; src [ 2 ] = bytes [ offset + 5 ] ; src [ 3 ] = bytes [ offset + 4 ] ; src [ 4 ] = bytes [ offset + 3 ] ; src [ 5 ] = bytes [ offset + 2 ] ; src [ 6 ] = bytes [ offset + 1 ] ; src [ 7 ] = bytes [ offset ] ; offset = 0 ; } else { src = bytes ; } DataInputStream stream = new DataInputStream ( new ByteArrayInputStream ( src , offset , 8 ) ) ; return stream . readDouble ( ) ; } catch ( Exception ex ) { throw new DescriptorException ( ex ) ; }


signature:
public class DoradeDescriptor { /** * Get the default verbose state for new < code > DoradeDescriptor < / code > - s
 * of the given name .
 * @ param descriptorName the descriptor name for which the new default
 * verbose state will apply */
public static boolean getDefaultVerboseState ( String descriptorName ) { } }

implementation: Boolean classVerboseState = classVerboseStates . get ( descriptorName . toUpperCase ( ) ) ; if ( classVerboseState != null ) return classVerboseState ; else return defaultVerboseState ;


signature:
public class StandardUnitDB { /** * Gets an instance of this database .
 * @ return An instance of this database .
 * @ throws UnitDBException The instance couldn ' t be created . */
public static synchronized StandardUnitDB instance ( ) throws UnitDBException { } }

implementation: if ( instance == null ) { try { instance = new StandardUnitDB ( ) ; } catch ( Exception e ) { throw new UnitDBException ( "Couldn't create standard unit-database" , e ) ; } } return instance ;


signature:
public class StandardUnitDB { /** * Adds a derived unit to the database .
 * @ param name The name of the unit .
 * @ param definition The definition for the unit .
 * @ throws UnitExistsException Attempt to redefine an existing unit .
 * @ throws NameException Bad unit name .
 * @ throws UnitParseException A string specification couldn ' t be parsed .
 * @ throws SpecificationException Bad string specification .
 * @ throws UnitDBException Problem with the unit database .
 * @ throws PrefixDBException Problem with the prefix database .
 * @ throws NameException Bad unit name .
 * @ throws OperationException Improper unit operation .
 * @ throws UnitSystemException Problem with UnitSystem . */
private void au ( final String name , final String definition ) throws UnitExistsException , NoSuchUnitException , UnitParseException , SpecificationException , UnitDBException , PrefixDBException , OperationException , NameException , UnitSystemException { } }

implementation: au ( name , definition , null ) ;


signature:
public class StandardUnitDB { /** * Adds a derived unit to the database .
 * @ param name The name of the unit .
 * @ param definition The definition for the unit .
 * @ param symbol The symbol for the unit .
 * @ param plural The plural form of the name of the unit .
 * @ throws UnitExistsException Attempt to redefine an existing unit .
 * @ throws NameException Bad unit name .
 * @ throws UnitParseException A string specification couldn ' t be parsed .
 * @ throws SpecificationException Bad string specification .
 * @ throws UnitDBException Problem with the unit database .
 * @ throws PrefixDBException Problem with the prefix database .
 * @ throws NameException Bad unit name .
 * @ throws OperationException Improper unit operation .
 * @ throws UnitSystemException Problem with UnitSystem . */
private void au ( final String name , final String definition , final String symbol , final String plural ) throws UnitExistsException , NoSuchUnitException , UnitParseException , SpecificationException , UnitDBException , PrefixDBException , OperationException , NameException , UnitSystemException { } }

implementation: final Unit unit = format . parse ( definition , this ) ; if ( unit == null ) { throw new NoSuchUnitException ( definition ) ; } addUnit ( unit . clone ( UnitName . newUnitName ( name , plural , symbol ) ) ) ;


signature:
public class StandardUnitDB { /** * Adds an alias for a unit to the database .
 * @ param alias The alias for the unit .
 * @ param name The name of the unit .
 * @ throws UnitExistsException Attempt to redefine an existing unit .
 * @ throws NameException Bad unit name .
 * @ throws UnitParseException A string specification couldn ' t be parsed .
 * @ throws SpecificationException Bad string specification .
 * @ throws UnitDBException Problem with the unit database .
 * @ throws PrefixDBException Problem with the prefix database .
 * @ throws NameException Bad unit name .
 * @ throws OperationException Improper unit operation .
 * @ throws UnitSystemException Problem with UnitSystem . */
private void aa ( final String alias , final String name ) throws UnitExistsException , NoSuchUnitException , UnitParseException , SpecificationException , UnitDBException , PrefixDBException , OperationException , NameException , UnitSystemException { } }

implementation: aa ( alias , name , null ) ;


signature:
public class StandardUnitDB { /** * Adds a symbol for a unit to the database .
 * @ param symbol The symbol for the unit .
 * @ param name The name of the unit .
 * @ throws UnitExistsException Attempt to redefine an existing unit .
 * @ throws NameException Bad unit name .
 * @ throws UnitParseException A string specification couldn ' t be parsed .
 * @ throws SpecificationException Bad string specification .
 * @ throws UnitDBException Problem with the unit database .
 * @ throws PrefixDBException Problem with the prefix database .
 * @ throws NameException Bad unit name .
 * @ throws OperationException Improper unit operation .
 * @ throws UnitSystemException Problem with UnitSystem . */
private void as ( final String symbol , final String name ) throws UnitExistsException , NoSuchUnitException , UnitParseException , SpecificationException , UnitDBException , PrefixDBException , OperationException , NameException , UnitSystemException { } }

implementation: addSymbol ( symbol , name ) ;


signature:
public class StandardUnitDB { /** * Tests this class . */
public static void main ( final String [ ] args ) throws Exception { } }

implementation: final UnitDB db = StandardUnitDB . instance ( ) ; System . out . println ( "db.get(\"meter\")=" + db . get ( "meter" ) ) ; System . out . println ( "db.get(\"meters\")=" + db . get ( "meters" ) ) ; System . out . println ( "db.get(\"metre\")=" + db . get ( "metre" ) ) ; System . out . println ( "db.get(\"metres\")=" + db . get ( "metres" ) ) ; System . out . println ( "db.get(\"m\")=" + db . get ( "m" ) ) ; System . out . println ( "db.get(\"newton\")=" + db . get ( "newton" ) ) ; System . out . println ( "db.get(\"Cel\")=" + db . get ( "Cel" ) ) ; System . out . println ( "db.get(\"Roentgen\")=" + db . get ( "Roentgen" ) ) ; System . out . println ( "db.get(\"rad\")=" + db . get ( "rad" ) ) ; System . out . println ( "db.get(\"rd\")=" + db . get ( "rd" ) ) ; System . out . println ( "db.get(\"perches\")=" + db . get ( "perches" ) ) ; System . out . println ( "db.get(\"jiffies\")=" + db . get ( "jiffies" ) ) ; System . out . println ( "db.get(\"foo\")=" + db . get ( "foo" ) ) ;


signature:
public class URLnaming { /** * / try to figure out if we need to add file : to the location when writing */
static public String canonicalizeWrite ( String location ) { } }

implementation:
try { URI refURI = URI . create ( location ) ; if ( refURI . isAbsolute ( ) ) return location ; } catch ( Exception e ) { // return " file : " + location ;
} return "file:" + location ;


signature:
public class URLnaming { /** * This augments URI . resolve ( ) , by also dealing with file : URIs .
 * If baseURi is not a file : scheme , then URI . resolve is called .
 * Otherwise the last " / " is found in the base , and the ref is appended to it .
 * < p > For file : baseURLS : only reletive URLS not starting with / are supported . This is
 * apparently different from the behavior of URI . resolve ( ) , so may be trouble ,
 * but it allows NcML absolute location to be specified without the file : prefix .
 * Example : < pre >
 * base : file : / / my / guide / collections / designfaq . ncml
 * ref : sub / my . nc
 * resolved : file : / / my / guide / collections / sub / my . nc
 * < / pre >
 * @ param baseUri base URI as a Strng
 * @ param relativeUri reletive URI , as a String
 * @ return the resolved URI as a String */
public static String resolve ( String baseUri , String relativeUri ) { } }

implementation:
if ( ( baseUri == null ) || ( relativeUri == null ) ) return relativeUri ; if ( relativeUri . startsWith ( "file:" ) ) return relativeUri ; // deal with a base file URL
if ( baseUri . startsWith ( "file:" ) ) { // the case where the reletiveURL is absolute .
// unfortunately , we may get an Exception
try { URI uriRelative = URI . create ( relativeUri ) ; if ( uriRelative . isAbsolute ( ) ) return relativeUri ; } catch ( Exception e ) { // empty
} if ( ( relativeUri . length ( ) > 0 ) && ( relativeUri . charAt ( 0 ) == '#' ) ) return baseUri + relativeUri ; if ( ( relativeUri . length ( ) > 0 ) && ( relativeUri . charAt ( 0 ) == '/' ) ) return relativeUri ; baseUri = StringUtil2 . substitute ( baseUri , "\\" , "/" ) ; // assumes forward slash
int pos = baseUri . lastIndexOf ( '/' ) ; if ( pos > 0 ) { String baseDir = baseUri . substring ( 0 , pos + 1 ) ; if ( relativeUri . equals ( "." ) ) { return baseDir ; } else { return baseDir + relativeUri ; } } } // non - file URLs
// relativeUri = canonicalizeRead ( relativeUri ) ;
try { URI relativeURI = URI . create ( relativeUri ) ; if ( relativeURI . isAbsolute ( ) ) return relativeUri ; // otherwise let the URI class resolve it
URI baseURI = URI . create ( baseUri ) ; URI resolvedURI = baseURI . resolve ( relativeURI ) ; return resolvedURI . toASCIIString ( ) ; } catch ( IllegalArgumentException e ) { return relativeUri ; }


signature:
public class ConverterImpl { /** * Factory method for creating a unit converter .
 * @ param fromUnitThe unit from which to convert .
 * @ param toUnit The unit to which to convert .
 * @ throws ConversionException The units are not convertible . */
public static Converter create ( Unit fromUnit , Unit toUnit ) throws ConversionException { } }

implementation: return fromUnit . getConverterTo ( toUnit ) ;


signature:
public class WriterCFPointCollection { /** * writing data */
public void writeRecord ( PointFeature sobs , StructureData sdata ) throws IOException { } }

implementation: writeRecord ( sobs . getObservationTime ( ) , sobs . getObservationTimeAsCalendarDate ( ) , sobs . getLocation ( ) , sdata ) ;


signature:
public class StructureTable { /** * Add listener : ListSelectionEvent sent when a new row is selected
 * @ param l the listener */
public void addListSelectionListener ( ListSelectionListener l ) { } }

implementation: listeners . add ( javax . swing . event . ListSelectionListener . class , l ) ;


signature:
public class StructureTable { /** * Remove listener
 * @ param l the listener */
public void removeListSelectionListener ( ListSelectionListener l ) { } }

implementation: listeners . remove ( javax . swing . event . ListSelectionListener . class , l ) ;


signature:
public class StructureTable { /** * Set the data as a collection of StructureData .
 * @ param structureData List of type StructureData
 * @ throws IOException on io error */
public void setStructureData ( List < StructureData > structureData ) throws IOException { } }

implementation: dataModel = new StructureDataModel ( structureData ) ; initTable ( dataModel ) ;


signature:
public class StructureTable { /** * Set the data as a collection of PointFeature .
 * @ param obsData List of type PointFeature
 * @ throws IOException on io error */
public void setPointFeatureData ( List < PointFeature > obsData ) throws IOException { } }

implementation: dataModel = new PointFeatureDataModel ( obsData ) ; initTable ( dataModel ) ;


signature:
public class GisFeatureRenderer { /** * Draws all the features that are within the graphics clip rectangle ,
 * using the previously set displayProjection .
 * @ param g the Graphics2D context on which to draw
 * @ param pixelAT transforms " Normalized Device " to Device coordinates */
public void draw ( java . awt . Graphics2D g , AffineTransform pixelAT ) { } }

implementation: g . setColor ( color ) ; g . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_OFF ) ; g . setStroke ( new java . awt . BasicStroke ( 0.0f ) ) ; Rectangle2D clipRect = ( Rectangle2D ) g . getClip ( ) ; Iterator siter = getShapes ( g , pixelAT ) ; while ( siter . hasNext ( ) ) { Shape s = ( Shape ) siter . next ( ) ; Rectangle2D shapeBounds = s . getBounds2D ( ) ; if ( shapeBounds . intersects ( clipRect ) ) g . draw ( s ) ; }


signature:
public class GisFeatureRenderer { /** * get the set of shapes to draw , convert projections if need be */
protected Iterator getShapes ( java . awt . Graphics2D g , AffineTransform normal2device ) { } }

implementation:
if ( shapeList != null ) return shapeList . iterator ( ) ; if ( Debug . isSet ( "projection/LatLonShift" ) ) System . out . println ( "projection/LatLonShift GisFeatureRenderer.getShapes called" ) ; ProjectionImpl dataProject = getDataProjection ( ) ; // a list of GisFeatureAdapter - s
List featList = getFeatures ( ) ; shapeList = new ArrayList ( featList . size ( ) ) ; Iterator iter = featList . iterator ( ) ; while ( iter . hasNext ( ) ) { AbstractGisFeature feature = ( AbstractGisFeature ) iter . next ( ) ; Shape shape ; if ( dataProject == null ) shape = feature . getShape ( ) ; else if ( dataProject . isLatLon ( ) ) { // always got to run it through if its lat / lon
shape = feature . getProjectedShape ( displayProject ) ; // System . out . println ( " getShapes dataProject . isLatLon ( ) " + displayProject ) ;
} else if ( dataProject == displayProject ) { shape = feature . getShape ( ) ; // System . out . println ( " getShapes dataProject = = displayProject " ) ;
} else { shape = feature . getProjectedShape ( dataProject , displayProject ) ; // System . out . println ( " getShapes dataProject ! = displayProject " ) ;
} shapeList . add ( shape ) ; } return shapeList . iterator ( ) ;


signature:
public class NcDocumentMetadataType { /** * wml2 : Collection / wml2 : metadata / wml2 : DocumentMetadata */
public static DocumentMetadataType initDocumentMetadata ( DocumentMetadataType documentMetadata ) { } }

implementation:
// @ gml : id
String id = MarshallingUtil . createIdForType ( DocumentMetadataType . class ) ; documentMetadata . setId ( id ) ; // wml2 : generationDate
DateTime generationDate = MarshallingUtil . fixedGenerationDate ; if ( generationDate == null ) { generationDate = new DateTime ( ) ; // Initialized to " now " .
} documentMetadata . setGenerationDate ( generationDate . toGregorianCalendar ( ) ) ; return documentMetadata ;


signature:
public class GribIosp { /** * time ( nruns , ntimes ) - > time ( ntimes ) with dependent reftime ( ntime ) coordinate */
private void makeUniqueTimeCoordinate2D ( NetcdfFile ncfile , Group g , CoordinateTime2D time2D ) { } }

implementation:
CoordinateRuntime runtime = time2D . getRuntimeCoordinate ( ) ; int countU = 0 ; for ( int run = 0 ; run < time2D . getNruns ( ) ; run ++ ) { CoordinateTimeAbstract timeCoord = time2D . getTimeCoordinate ( run ) ; countU += timeCoord . getSize ( ) ; } int ntimes = countU ; String tcName = time2D . getName ( ) ; ncfile . addDimension ( g , new Dimension ( tcName , ntimes ) ) ; Variable v = ncfile . addVariable ( g , new Variable ( ncfile , g , null , tcName , DataType . DOUBLE , tcName ) ) ; String units = runtime . getUnit ( ) ; // + " since " + runtime . getFirstDate ( ) ;
v . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; v . addAttribute ( new Attribute ( CF . STANDARD_NAME , CF . TIME ) ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , Grib . GRIB_VALID_TIME ) ) ; v . addAttribute ( new Attribute ( CF . CALENDAR , Calendar . proleptic_gregorian . toString ( ) ) ) ; // the data is not generated until asked for to save space
if ( ! time2D . isTimeInterval ( ) ) { v . setSPobject ( new Time2Dinfo ( Time2DinfoType . offU , time2D , null ) ) ; } else { v . setSPobject ( new Time2Dinfo ( Time2DinfoType . intvU , time2D , null ) ) ; // bounds for intervals
String bounds_name = tcName + "_bounds" ; Variable bounds = ncfile . addVariable ( g , new Variable ( ncfile , g , null , bounds_name , DataType . DOUBLE , tcName + " 2" ) ) ; v . addAttribute ( new Attribute ( CF . BOUNDS , bounds_name ) ) ; bounds . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; bounds . addAttribute ( new Attribute ( CDM . LONG_NAME , "bounds for " + tcName ) ) ; bounds . setSPobject ( new Time2Dinfo ( Time2DinfoType . boundsU , time2D , null ) ) ; } if ( runtime . getNCoords ( ) != 1 ) { // for this case we have to generate a separate reftime , because have to use the same dimension
String refName = "ref" + tcName ; if ( g . findVariable ( refName ) == null ) { Variable vref = ncfile . addVariable ( g , new Variable ( ncfile , g , null , refName , DataType . DOUBLE , tcName ) ) ; vref . addAttribute ( new Attribute ( CF . STANDARD_NAME , CF . TIME_REFERENCE ) ) ; vref . addAttribute ( new Attribute ( CDM . LONG_NAME , Grib . GRIB_RUNTIME ) ) ; vref . addAttribute ( new Attribute ( CF . CALENDAR , Calendar . proleptic_gregorian . toString ( ) ) ) ; vref . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; vref . setSPobject ( new Time2Dinfo ( Time2DinfoType . isUniqueRuntime , time2D , null ) ) ; } }


signature:
public class GribIosp { /** * / * non unique time case
 * 3 ) time ( nruns , ntimes ) with reftime ( nruns ) */
private void makeTimeCoordinate2D ( NetcdfFile ncfile , Group g , CoordinateTime2D time2D , GribCollectionImmutable . Type gctype ) { } }

implementation:
CoordinateRuntime runtime = time2D . getRuntimeCoordinate ( ) ; int ntimes = time2D . getNtimes ( ) ; String tcName = time2D . getName ( ) ; String dims = runtime . getName ( ) + " " + tcName ; int dimLength = ntimes ; ncfile . addDimension ( g , new Dimension ( tcName , dimLength ) ) ; Variable v = ncfile . addVariable ( g , new Variable ( ncfile , g , null , tcName , DataType . DOUBLE , dims ) ) ; String units = runtime . getUnit ( ) ; // + " since " + runtime . getFirstDate ( ) ;
v . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; v . addAttribute ( new Attribute ( CF . STANDARD_NAME , CF . TIME ) ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , Grib . GRIB_VALID_TIME ) ) ; v . addAttribute ( new Attribute ( CF . CALENDAR , Calendar . proleptic_gregorian . toString ( ) ) ) ; // the data is not generated until asked for to save space
if ( ! time2D . isTimeInterval ( ) ) { v . setSPobject ( new Time2Dinfo ( Time2DinfoType . off , time2D , null ) ) ; } else { v . setSPobject ( new Time2Dinfo ( Time2DinfoType . intv , time2D , null ) ) ; // bounds for intervals
String bounds_name = tcName + "_bounds" ; Variable bounds = ncfile . addVariable ( g , new Variable ( ncfile , g , null , bounds_name , DataType . DOUBLE , dims + " 2" ) ) ; v . addAttribute ( new Attribute ( CF . BOUNDS , bounds_name ) ) ; bounds . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; bounds . addAttribute ( new Attribute ( CDM . LONG_NAME , "bounds for " + tcName ) ) ; bounds . setSPobject ( new Time2Dinfo ( Time2DinfoType . bounds , time2D , null ) ) ; }


signature:
public class GribIosp { /** * only for the 2d times */
private Array makeLazyTime1Darray ( Variable v2 , Time2Dinfo info ) { } }

implementation:
int length = info . time1D . getSize ( ) ; double [ ] data = new double [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { data [ i ] = Double . NaN ; } // coordinate values
switch ( info . which ) { case reftime : CoordinateRuntime rtc = ( CoordinateRuntime ) info . time1D ; int count = 0 ; for ( double val : rtc . getOffsetsInTimeUnits ( ) ) { data [ count ++ ] = val ; } return Array . factory ( DataType . DOUBLE , v2 . getShape ( ) , data ) ; case timeAuxRef : CoordinateTimeAbstract time = ( CoordinateTimeAbstract ) info . time1D ; count = 0 ; List < Double > masterOffsets = gribCollection . getMasterRuntime ( ) . getOffsetsInTimeUnits ( ) ; for ( int masterIdx : time . getTime2runtime ( ) ) { data [ count ++ ] = masterOffsets . get ( masterIdx - 1 ) ; } return Array . factory ( DataType . DOUBLE , v2 . getShape ( ) , data ) ; default : throw new IllegalStateException ( "makeLazyTime1Darray must be reftime or timeAuxRef" ) ; }


signature:
public class GribIosp { /** * only for the 2d times */
private Array makeLazyTime2Darray ( Variable coord , Time2Dinfo info ) { } }

implementation:
CoordinateTime2D time2D = info . time2D ; CalendarPeriod timeUnit = time2D . getTimeUnit ( ) ; int nruns = time2D . getNruns ( ) ; int ntimes = time2D . getNtimes ( ) ; int length = ( int ) coord . getSize ( ) ; if ( info . which == Time2DinfoType . bounds ) { length *= 2 ; } double [ ] data = new double [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { data [ i ] = Double . NaN ; } int count ; // coordinate values
switch ( info . which ) { case off : for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTime coordTime = ( CoordinateTime ) time2D . getTimeCoordinate ( runIdx ) ; int timeIdx = 0 ; for ( int val : coordTime . getOffsetSorted ( ) ) { data [ runIdx * ntimes + timeIdx ] = timeUnit . getValue ( ) * val + time2D . getOffset ( runIdx ) ; timeIdx ++ ; } } break ; case offU : count = 0 ; for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTime coordTime = ( CoordinateTime ) time2D . getTimeCoordinate ( runIdx ) ; for ( int val : coordTime . getOffsetSorted ( ) ) { data [ count ++ ] = timeUnit . getValue ( ) * val + time2D . getOffset ( runIdx ) ; } } break ; case intv : for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; int timeIdx = 0 ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ runIdx * ntimes + timeIdx ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; // use upper bounds for coord value
timeIdx ++ ; } } break ; case intvU : count = 0 ; for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ count ++ ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; // use upper bounds for coord value
} } break ; case is1Dtime : CoordinateRuntime runtime = time2D . getRuntimeCoordinate ( ) ; count = 0 ; for ( double val : runtime . getOffsetsInTimeUnits ( ) ) { // convert to udunits
data [ count ++ ] = val ; } break ; case isUniqueRuntime : // the aux runtime coordinate
CoordinateRuntime runtimeU = time2D . getRuntimeCoordinate ( ) ; List < Double > runOffsets = runtimeU . getOffsetsInTimeUnits ( ) ; count = 0 ; for ( int run = 0 ; run < time2D . getNruns ( ) ; run ++ ) { CoordinateTimeAbstract timeCoord = time2D . getTimeCoordinate ( run ) ; for ( int time = 0 ; time < timeCoord . getNCoords ( ) ; time ++ ) { data [ count ++ ] = runOffsets . get ( run ) ; } } break ; case bounds : for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; int timeIdx = 0 ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ runIdx * ntimes * 2 + timeIdx ] = timeUnit . getValue ( ) * tinv . getBounds1 ( ) + time2D . getOffset ( runIdx ) ; data [ runIdx * ntimes * 2 + timeIdx + 1 ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; timeIdx += 2 ; } } break ; case boundsU : count = 0 ; for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ count ++ ] = timeUnit . getValue ( ) * tinv . getBounds1 ( ) + time2D . getOffset ( runIdx ) ; data [ count ++ ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; } } break ; default : throw new IllegalStateException ( ) ; } return Array . factory ( DataType . DOUBLE , coord . getShape ( ) , data ) ;


signature: public class GribIosp { @ Override public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation:
long start = System . currentTimeMillis ( ) ; // see if its time2D - then generate data on the fly
if ( v2 . getSPobject ( ) instanceof Time2Dinfo ) { Time2Dinfo info = ( Time2Dinfo ) v2 . getSPobject ( ) ; Array data = makeLazyCoordinateData ( v2 , info ) ; Section sectionFilled = Section . fill ( section , v2 . getShape ( ) ) ; return data . sectionNoReduce ( sectionFilled . getRanges ( ) ) ; } try { Array result ; GribCollectionImmutable . VariableIndex vindex = ( GribCollectionImmutable . VariableIndex ) v2 . getSPobject ( ) ; GribDataReader dataReader = GribDataReader . factory ( gribCollection , vindex ) ; SectionIterable sectionIter = new SectionIterable ( section , v2 . getShape ( ) ) ; result = dataReader . readData ( sectionIter ) ; long took = System . currentTimeMillis ( ) - start ; return result ; } catch ( IOException ioe ) { logger . error ( "Failed to readData " , ioe ) ; throw ioe ; }


signature:
public class BufrSplitter { /** * LOOK - needs to be a directory , or maybe an MFILE collection */
public void execute ( String filename ) throws IOException { } }

implementation: File input = new File ( filename ) ; out . format ( "BufrSplitter on %s length=%d%n" , input . getPath ( ) , input . length ( ) ) ; try ( InputStream is = new FileInputStream ( input ) ) { processStream ( is ) ; }


signature:
public class BufrSplitter { /** * process all the bytes in the stream */
public void processStream ( InputStream is ) throws IOException { } }

implementation: int pos = - 1 ; Buffer b = null ; while ( true ) { b = ( pos < 0 ) ? readBuffer ( is ) : readBuffer ( is , b , pos ) ; pos = processBuffer ( b , is ) ; if ( b . done ) break ; }


signature:
public class BufrSplitter { /** * read into dest byte array , until buffer is full or end of stream */
private boolean readBuffer ( InputStream is , byte [ ] dest , int start , int want ) throws IOException { } }

implementation: int done = 0 ; while ( done < want ) { int got = is . read ( dest , start + done , want - done ) ; if ( got < 0 ) return false ; done += got ; } if ( showRead ) System . out . println ( "Read buffer at " + bytesRead + " len=" + done ) ; bytesRead += done ; return true ;


signature:
public class BufrSplitter { /** * read into new Buffer , until buffer is full or end of stream */
private Buffer readBuffer ( InputStream is ) throws IOException { } }

implementation: Buffer b = new Buffer ( ) ; int want = BUFFSIZE ; while ( b . have < want ) { int got = is . read ( b . buff , b . have , want - b . have ) ; if ( got < 0 ) { b . done = true ; break ; } b . have += got ; } if ( showRead ) System . out . println ( "Read buffer at " + bytesRead + " len=" + b . have ) ; bytesRead += b . have ; return b ;


signature:
public class BufrSplitter { /** * read into new Buffer , until buffer is full or end of stream */
private Buffer readBuffer ( InputStream is , Buffer prev , int pos ) throws IOException { } }

implementation:
Buffer b = new Buffer ( ) ; // copy remains of last buffer here
int remain = prev . have - pos ; // if ( remain > BUFFSIZE / 2)
// out . format ( " remain = " + remain + " bytesRead = " + bytesRead ) ;
System . arraycopy ( prev . buff , pos , b . buff , 0 , remain ) ; b . have = remain ; int want = BUFFSIZE ; while ( b . have < want ) { int got = is . read ( b . buff , b . have , want - b . have ) ; if ( got < 0 ) { b . done = true ; break ; } b . have += got ; } if ( showRead ) System . out . println ( "Read buffer at " + bytesRead + " len=" + b . have ) ; bytesRead += b . have ; return b ;


signature:
public class HeaderInputStream { /** * Get more bytes into buffer . Stop when endSequence is found . */
private void getMoreBytes ( ) throws IOException { } }

implementation:
currentOffset = 0 ; // reset current array offset to 0
int bytesRead = 0 ; // bytes read so far
int lookingFor = 0 ; // character in endSequence to look for
for ( ; bytesRead < lineBuf . length ; bytesRead ++ ) { int c = in . read ( ) ; if ( c == - 1 ) break ; // break on EOL and return what we have so far
lineBuf [ bytesRead ] = ( byte ) c ; if ( lineBuf [ bytesRead ] == endSequence [ lookingFor ] ) { lookingFor ++ ; if ( lookingFor == endSequence . length ) { endFound = true ; break ; } } else if ( lineBuf [ bytesRead ] == endSequence [ 0 ] ) { // CHANGED JC
lookingFor = 1 ; } else { lookingFor = 0 ; } } bytesRemaining = bytesRead ; // number of bytes we ' ve read


signature:
public class HeaderInputStream { /** * Reads up to len bytes of data from this input stream into an array of
 * bytes . This method blocks until some input is available . */
public int read ( byte b [ ] , int off , int len ) throws IOException { } }

implementation:
if ( len <= 0 ) { return 0 ; } int c = read ( ) ; if ( c == - 1 ) return - 1 ; b [ off ] = ( byte ) c ; // We ' ve read one byte successfully , let ' s try for more
int i = 1 ; try { for ( ; i < len ; i ++ ) { c = read ( ) ; if ( c == - 1 ) { break ; } b [ off + i ] = ( byte ) c ; } } catch ( IOException e ) { } return i ;


signature:
public class HeaderInputStream { /** * Skips over and discards n bytes of data from the input stream . */
public long skip ( long n ) { } }

implementation: if ( bytesRemaining >= n ) { bytesRemaining -= n ; return n ; } else { int oldBytesRemaining = bytesRemaining ; bytesRemaining = 0 ; return oldBytesRemaining ; }


signature:
public class Doradeiosp { /** * reading */
public void open ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { } }

implementation: super . open ( raf , ncfile , cancelTask ) ; mySweep = new DoradeSweep ( raf . getRandomAccessFile ( ) ) ; headerParser = new Doradeheader ( ) ; headerParser . read ( mySweep , ncfile , null ) ; ncfile . finish ( ) ;


signature:
public class QuantityDimension { /** * Tests this class . */
public static void main ( String [ ] args ) throws Exception { } }

implementation: System . out . println ( "new QuantityDimension() = \"" + new QuantityDimension ( ) + '"' ) ; QuantityDimension timeDimension = new QuantityDimension ( BaseQuantity . TIME ) ; System . out . println ( "timeDimension = \"" + timeDimension + '"' ) ; QuantityDimension lengthDimension = new QuantityDimension ( BaseQuantity . LENGTH ) ; System . out . println ( "lengthDimension = \"" + lengthDimension + '"' ) ; System . out . println ( "lengthDimension.isReciprocalOf(timeDimension) = \"" + lengthDimension . isReciprocalOf ( timeDimension ) + '"' ) ; QuantityDimension hertzDimension = timeDimension . raiseTo ( - 1 ) ; System . out . println ( "hertzDimension = \"" + hertzDimension + '"' ) ; System . out . println ( "hertzDimension.isReciprocalOf(timeDimension) = \"" + hertzDimension . isReciprocalOf ( timeDimension ) + '"' ) ; System . out . println ( "lengthDimension.divideBy(timeDimension) = \"" + lengthDimension . divideBy ( timeDimension ) + '"' ) ; System . out . println ( "lengthDimension.divideBy(timeDimension).raiseTo(2) = \"" + lengthDimension . divideBy ( timeDimension ) . raiseTo ( 2 ) + '"' ) ;


signature:
public class HybridHeight { /** * Get the 3D vertical coordinate array for this time step .
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ return vertical coordinate array
 * @ throws IOException problem reading data
 * @ throws InvalidRangeException not a valid time range */
public ArrayDouble . D3 getCoordinateArray ( int timeIndex ) throws IOException , InvalidRangeException { } }

implementation: Array orogArray = readArray ( orogVar , timeIndex ) ; if ( null == aArray ) { aArray = aVar . read ( ) ; bArray = bVar . read ( ) ; } int nz = ( int ) aArray . getSize ( ) ; Index aIndex = aArray . getIndex ( ) ; Index bIndex = bArray . getIndex ( ) ; int [ ] shape2D = orogArray . getShape ( ) ; int ny = shape2D [ 0 ] ; int nx = shape2D [ 1 ] ; Index orogIndex = orogArray . getIndex ( ) ; ArrayDouble . D3 height = new ArrayDouble . D3 ( nz , ny , nx ) ; for ( int z = 0 ; z < nz ; z ++ ) { double az = aArray . getDouble ( aIndex . set ( z ) ) ; double bz = bArray . getDouble ( bIndex . set ( z ) ) ; for ( int y = 0 ; y < ny ; y ++ ) { for ( int x = 0 ; x < nx ; x ++ ) { double orog = orogArray . getDouble ( orogIndex . set ( y , x ) ) ; height . set ( z , y , x , az + bz * orog ) ; } } } return height ;


signature:
public class HybridHeight { /** * Get the 1D vertical coordinate array for this time step and point
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ param xIndex the x index
 * @ param yIndex the y index
 * @ return vertical coordinate array
 * @ throws java . io . IOException problem reading data
 * @ throws ucar . ma2 . InvalidRangeException _ more _ */
public D1 getCoordinateArray1D ( int timeIndex , int xIndex , int yIndex ) throws IOException , InvalidRangeException { } }

implementation: Array orogArray = readArray ( orogVar , timeIndex ) ; if ( null == aArray ) { aArray = aVar . read ( ) ; bArray = bVar . read ( ) ; } int nz = ( int ) aArray . getSize ( ) ; Index aIndex = aArray . getIndex ( ) ; Index bIndex = bArray . getIndex ( ) ; Index orogIndex = orogArray . getIndex ( ) ; ArrayDouble . D1 height = new ArrayDouble . D1 ( nz ) ; for ( int z = 0 ; z < nz ; z ++ ) { double az = aArray . getDouble ( aIndex . set ( z ) ) ; double bz = bArray . getDouble ( bIndex . set ( z ) ) ; double orog = orogArray . getDouble ( orogIndex . set ( yIndex , xIndex ) ) ; height . set ( z , az + bz * orog ) ; } return height ;


signature:
public class GridVertCoord { /** * Match levels
 * @ param records records to match
 * @ return true if they have the same levels */
boolean matchLevels ( List < GridRecord > records ) { } }

implementation:
// first create a new list
List < LevelCoord > levelList = new ArrayList < LevelCoord > ( records . size ( ) ) ; for ( GridRecord record : records ) { LevelCoord lc = new LevelCoord ( record . getLevel1 ( ) , record . getLevel2 ( ) ) ; if ( ! levelList . contains ( lc ) ) { levelList . add ( lc ) ; } } Collections . sort ( levelList ) ; if ( positive . equals ( "down" ) ) { Collections . reverse ( levelList ) ; } // gotta equal existing list
return levelList . equals ( levels ) ;


signature:
public class GridVertCoord { /** * Add this coord as a dimension to the netCDF file
 * @ param ncfile file to add to
 * @ param g group in the file */
void addDimensionsToNetcdfFile ( NetcdfFile ncfile , Group g ) { } }

implementation: if ( ! isVertDimensionUsed ( ) ) return ; int nlevs = levels . size ( ) ; if ( coordValues != null ) nlevs = coordValues . length ; ncfile . addDimension ( g , new Dimension ( getVariableName ( ) , nlevs , true ) ) ;


signature:
public class GridVertCoord { /** * Add this coord as a variable in the netCDF file
 * @ param ncfile netCDF file to add to
 * @ param g group in file */
void addToNetcdfFile ( NetcdfFile ncfile , Group g ) { } }

implementation:
if ( ! isVertDimensionUsed ( ) ) { typicalRecord = null ; // allow gc
return ; } if ( g == null ) { g = ncfile . getRootGroup ( ) ; } // coordinate axis
Variable v = new Variable ( ncfile , g , null , getVariableName ( ) ) ; v . setDataType ( DataType . DOUBLE ) ; String desc = getLevelDesc ( ) ; v . addAttribute ( new Attribute ( "long_name" , desc ) ) ; v . addAttribute ( new Attribute ( "units" , lookup . getLevelUnit ( typicalRecord ) ) ) ; // positive attribute needed for CF - 1 Height and Pressure
if ( positive != null ) { v . addAttribute ( new Attribute ( "positive" , positive ) ) ; } if ( units != null ) { AxisType axisType ; if ( SimpleUnit . isCompatible ( "millibar" , units ) ) { axisType = AxisType . Pressure ; } else if ( SimpleUnit . isCompatible ( "m" , units ) ) { axisType = AxisType . Height ; } else { axisType = AxisType . GeoZ ; } addExtraAttributes ( v ) ; v . addAttribute ( new Attribute ( _Coordinate . AxisType , axisType . toString ( ) ) ) ; } if ( coordValues == null ) { coordValues = new double [ levels . size ( ) ] ; for ( int i = 0 ; i < levels . size ( ) ; i ++ ) { LevelCoord lc = ( LevelCoord ) levels . get ( i ) ; coordValues [ i ] = lc . mid ; } } Array dataArray = Array . factory ( DataType . DOUBLE , new int [ ] { coordValues . length } , coordValues ) ; v . setDimensions ( getVariableName ( ) ) ; v . setCachedData ( dataArray , true ) ; ncfile . addVariable ( g , v ) ; if ( usesBounds ) { Dimension bd = ucar . nc2 . dataset . DatasetConstructor . getBoundsDimension ( ncfile ) ; String bname = getVariableName ( ) + "_bounds" ; v . addAttribute ( new Attribute ( "bounds" , bname ) ) ; v . addAttribute ( new Attribute ( _Coordinate . ZisLayer , "true" ) ) ; Variable b = new Variable ( ncfile , g , null , bname ) ; b . setDataType ( DataType . DOUBLE ) ; b . setDimensions ( getVariableName ( ) + " " + bd . getShortName ( ) ) ; b . addAttribute ( new Attribute ( "long_name" , "bounds for " + v . getFullName ( ) ) ) ; b . addAttribute ( new Attribute ( "units" , lookup . getLevelUnit ( typicalRecord ) ) ) ; Array boundsArray = Array . factory ( DataType . DOUBLE , new int [ ] { coordValues . length , 2 } ) ; ucar . ma2 . Index ima = boundsArray . getIndex ( ) ; for ( int i = 0 ; i < coordValues . length ; i ++ ) { LevelCoord lc = ( LevelCoord ) levels . get ( i ) ; boundsArray . setDouble ( ima . set ( i , 0 ) , lc . value1 ) ; boundsArray . setDouble ( ima . set ( i , 1 ) , lc . value2 ) ; } b . setCachedData ( boundsArray , true ) ; ncfile . addVariable ( g , b ) ; } if ( factors != null ) { // check if already created
if ( g == null ) { g = ncfile . getRootGroup ( ) ; } if ( g . findVariable ( "hybrida" ) != null ) return ; v . addAttribute ( new Attribute ( "standard_name" , "atmosphere_hybrid_sigma_pressure_coordinate" ) ) ; v . addAttribute ( new Attribute ( "formula_terms" , "ap: hybrida b: hybridb ps: Pressure" ) ) ; // create hybrid factor variables
// add hybrida variable
Variable ha = new Variable ( ncfile , g , null , "hybrida" ) ; ha . setDataType ( DataType . DOUBLE ) ; ha . addAttribute ( new Attribute ( "long_name" , "level_a_factor" ) ) ; ha . addAttribute ( new Attribute ( "units" , "" ) ) ; ha . setDimensions ( getVariableName ( ) ) ; // add data
int middle = factors . length / 2 ; double [ ] adata ; double [ ] bdata ; if ( levels . size ( ) < middle ) { // only partial data wanted
adata = new double [ levels . size ( ) ] ; bdata = new double [ levels . size ( ) ] ; } else { adata = new double [ middle ] ; bdata = new double [ middle ] ; } for ( int i = 0 ; i < middle && i < levels . size ( ) ; i ++ ) adata [ i ] = factors [ i ] ; Array haArray = Array . factory ( DataType . DOUBLE , new int [ ] { adata . length } , adata ) ; ha . setCachedData ( haArray , true ) ; ncfile . addVariable ( g , ha ) ; // add hybridb variable
Variable hb = new Variable ( ncfile , g , null , "hybridb" ) ; hb . setDataType ( DataType . DOUBLE ) ; hb . addAttribute ( new Attribute ( "long_name" , "level_b_factor" ) ) ; hb . addAttribute ( new Attribute ( "units" , "" ) ) ; hb . setDimensions ( getVariableName ( ) ) ; // add data
for ( int i = 0 ; i < middle && i < levels . size ( ) ; i ++ ) bdata [ i ] = factors [ i + middle ] ; Array hbArray = Array . factory ( DataType . DOUBLE , new int [ ] { bdata . length } , bdata ) ; hb . setCachedData ( hbArray , true ) ; ncfile . addVariable ( g , hb ) ; /* / / TODO : delete next time modifying code
 double [ ] adata = new double [ middle ] ;
 for ( int i = 0 ; i < middle ; i + + )
 adata [ i ] = factors [ i ] ;
 Array haArray = Array . factory ( DataType . DOUBLE , new int [ ] { adata . length } , adata ) ;
 ha . setCachedData ( haArray , true ) ;
 ncfile . addVariable ( g , ha ) ;
 / / add hybridb variable
 Variable hb = new Variable ( ncfile , g , null , " hybridb " ) ;
 hb . setDataType ( DataType . DOUBLE ) ;
 hb . addAttribute ( new Attribute ( " long _ name " , " level _ b _ factor " ) ) ;
 / / hb . addAttribute ( new Attribute ( " standard _ name " , " atmosphere _ hybrid _ sigma _ pressure _ coordinate " ) ) ;
 hb . addAttribute ( new Attribute ( " units " , " " ) ) ;
 hb . setDimensions ( getVariableName ( ) ) ;
 / / add data
 double [ ] bdata = new double [ middle ] ;
 for ( int i = 0 ; i < middle ; i + + )
 bdata [ i ] = factors [ i + middle ] ;
 Array hbArray = Array . factory ( DataType . DOUBLE , new int [ ] { bdata . length } , bdata ) ;
 hb . setCachedData ( hbArray , true ) ;
 ncfile . addVariable ( g , hb ) ; */
} // allow gc
// typicalRecord = null ;


signature:
public class GridVertCoord { /** * Get the coordinate index for the record
 * @ param record record in question
 * @ return index or - 1 if not found */
private int coordIndex ( GridRecord record ) { } }

implementation: double val = record . getLevel1 ( ) ; double val2 = record . getLevel2 ( ) ; if ( usesBounds && ( val > val2 ) ) { val = record . getLevel2 ( ) ; val2 = record . getLevel1 ( ) ; } for ( int i = 0 ; i < levels . size ( ) ; i ++ ) { LevelCoord lc = ( LevelCoord ) levels . get ( i ) ; if ( usesBounds ) { if ( ucar . nc2 . util . Misc . nearlyEquals ( lc . value1 , val ) && ucar . nc2 . util . Misc . nearlyEquals ( lc . value2 , val2 ) ) { return i ; } } else { if ( ucar . nc2 . util . Misc . nearlyEquals ( lc . value1 , val ) ) { return i ; } } } return - 1 ;


signature:
public class NOWRadiosp { /** * checking the file
 * @ param raf
 * @ return the valid of file checking */
public boolean isValidFile ( ucar . unidata . io . RandomAccessFile raf ) { } }

implementation: NOWRadheader localHeader = new NOWRadheader ( ) ; return ( localHeader . isValidFile ( raf ) ) ;


signature:
public class NOWRadiosp { /** * Open the file and read the header part
 * @ param raf
 * @ param file
 * @ param cancelTask
 * @ throws java . io . IOException */
public void open ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile file , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { } }

implementation:
super . open ( raf , ncfile , cancelTask ) ; headerParser = new NOWRadheader ( ) ; try { headerParser . read ( this . raf , ncfile ) ; } catch ( Exception e ) { } // myInfo = headerParser . getVarInfo ( ) ;
pcode = 0 ; ncfile . finish ( ) ;


signature:
public class NOWRadiosp { /** * Read the data for each variable passed in
 * @ param v2
 * @ param section
 * @ return output data
 * @ throws IOException
 * @ throws ucar . ma2 . InvalidRangeException */
public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation:
// subset
Object data ; Array outputData ; byte [ ] vdata = null ; NOWRadheader . Vinfo vinfo ; ByteBuffer bos ; List < Range > ranges = section . getRanges ( ) ; vinfo = ( NOWRadheader . Vinfo ) v2 . getSPobject ( ) ; vdata = headerParser . getData ( ( int ) vinfo . hoff ) ; bos = ByteBuffer . wrap ( vdata ) ; data = readOneScanData ( bos , vinfo , v2 . getShortName ( ) ) ; outputData = Array . factory ( v2 . getDataType ( ) , v2 . getShape ( ) , data ) ; outputData = outputData . flip ( 1 ) ; // outputData = outputData . flip ( 2 ) ;
return ( outputData . sectionNoReduce ( ranges ) . copy ( ) ) ; // return outputData ;


signature:
public class NOWRadiosp { /** * all the work is here , so can be called recursively */
public Object readOneScanData ( ByteBuffer bos , NOWRadheader . Vinfo vinfo , String vName ) throws IOException , InvalidRangeException { } }

implementation:
int doff = ( int ) vinfo . hoff ; int npixel = vinfo . yt * vinfo . xt ; byte [ ] rdata = null ; byte [ ] ldata = new byte [ vinfo . xt ] ; byte [ ] pdata = new byte [ npixel ] ; byte [ ] b2 = new byte [ 2 ] ; bos . position ( doff ) ; // begining of image data
if ( ( DataType . unsignedByteToShort ( bos . get ( ) ) != 0xF0 ) || ( bos . get ( ) != 0x0C ) ) { return null ; } int ecode ; int color ; int datapos ; int offset = 0 ; int roffset = 0 ; boolean newline = true ; int linenum = 0 ; while ( true ) { // line number
if ( newline ) { bos . get ( b2 ) ; linenum = ( DataType . unsignedByteToShort ( b2 [ 1 ] ) << 8 ) + DataType . unsignedByteToShort ( b2 [ 0 ] ) ; // System . out . println ( " Line Number = " + linenum ) ;
} // int linenum = bytesToInt ( b2[0 ] , b2[1 ] , true ) ;
// System . out . println ( " Line Number = " + linenum ) ;
// if ( linenum = = 1225)
// System . out . println ( " HHHHH " ) ;
short b = DataType . unsignedByteToShort ( bos . get ( ) ) ; color = b & 0xF ; ecode = b >> 4 ; datapos = bos . position ( ) ; int datarun ; if ( ecode == 0xF ) { byte bb1 = bos . get ( datapos - 2 ) ; byte bb2 = bos . get ( datapos ) ; if ( ( color == 0x0 ) && ( bb1 == 0x00 ) && ( bb2 == 0x00 ) ) { datapos += 1 ; } bos . position ( datapos ) ; datarun = 0 ; } else if ( ecode == 0xE ) { byte b0 = bos . get ( datapos ) ; datarun = DataType . unsignedByteToShort ( b0 ) + 1 ; datapos += 1 ; bos . position ( datapos ) ; } else if ( ecode == 0xD ) { b2 [ 0 ] = bos . get ( datapos ) ; b2 [ 1 ] = bos . get ( datapos + 1 ) ; datarun = ( DataType . unsignedByteToShort ( b2 [ 1 ] ) << 8 ) + DataType . unsignedByteToShort ( b2 [ 0 ] ) + 1 ; datapos += 2 ; bos . position ( datapos ) ; } else { datarun = ecode + 1 ; } // move the unpacked data in the data line
rdata = new byte [ datarun ] ; for ( int i = 0 ; i < datarun ; i ++ ) { rdata [ i ] = ( byte ) color ; } System . arraycopy ( rdata , 0 , ldata , roffset , datarun ) ; roffset = roffset + datarun ; // System . out . println ( " run ecode = " + ecode + " and data run " + datarun + " and totalrun " + roffset ) ;
// check to see if the beginning of the next line or at the end of the file
short c0 = DataType . unsignedByteToShort ( bos . get ( ) ) ; if ( c0 == 0x00 ) { short c1 = DataType . unsignedByteToShort ( bos . get ( ) ) ; short c2 = DataType . unsignedByteToShort ( bos . get ( ) ) ; // System . out . println ( " c1 and c2 " + c1 + " " + c2 ) ;
if ( ( c0 == 0x00 ) && ( c1 == 0xF0 ) && ( c2 == 0x0C ) ) { // beginning of next line
// System . out . println ( " linenum " + linenum + " and this line total " + roffset ) ;
// if ( roffset ! = 3661 ) {
// System . out . println ( " ERROR missing data , this line total only " + roffset ) ;
System . arraycopy ( ldata , 0 , pdata , offset , roffset ) ; offset = offset + vinfo . xt ; roffset = 0 ; newline = true ; ldata = new byte [ vinfo . xt ] ; } else if ( ( c1 == 0xF0 ) && ( c2 == 0x02 ) ) { // end of the file
break ; } else { datapos = bos . position ( ) - 3 ; bos . position ( datapos ) ; newline = false ; } } else { newline = false ; datapos = bos . position ( ) ; bos . position ( datapos - 1 ) ; } } return pdata ;


signature:
public class NOWRadiosp { /** * Read data from encoded values and run len into regular data array
 * @ param ddata is encoded data values
 * @ return the data array of row data */
public byte [ ] readOneRowData ( byte [ ] ddata , int rLen , int xt ) throws IOException , InvalidRangeException { } }

implementation: int run ; byte [ ] bdata = new byte [ xt ] ; int nbin = 0 ; int total = 0 ; for ( run = 0 ; run < rLen ; run ++ ) { int drun = DataType . unsignedByteToShort ( ddata [ run ] ) >> 4 ; byte dcode1 = ( byte ) ( DataType . unsignedByteToShort ( ddata [ run ] ) & 0Xf ) ; for ( int i = 0 ; i < drun ; i ++ ) { bdata [ nbin ++ ] = dcode1 ; total ++ ; } } if ( total < xt ) { for ( run = total ; run < xt ; run ++ ) { bdata [ run ] = 0 ; } } return bdata ;


signature:
public class NcDDS { /** * take advantage of the work already done by NetcdfDataset */
private void createFromDataset ( NetcdfDataset ncd ) { } }

implementation:
// get coordinate variables , disjunct from variables
for ( CoordinateAxis axis : ncd . getCoordinateAxes ( ) ) { coordvars . put ( axis . getShortName ( ) , axis ) ; } // dup the variable set
ddsvars = new ArrayList < > ( 50 ) ; // collect grid array variables and set of coordinate variables used in grids
for ( Variable v : ncd . getVariables ( ) ) { if ( coordvars . containsKey ( v . getShortName ( ) ) ) continue ; // skip coordinate variables
ddsvars . add ( v ) ; boolean isgridarray = ( v . getRank ( ) > 1 ) && ( v . getDataType ( ) != DataType . STRUCTURE ) && ( v . getParentStructure ( ) == null ) ; if ( ! isgridarray ) continue ; List < Dimension > dimset = v . getDimensions ( ) ; int rank = dimset . size ( ) ; for ( int i = 0 ; isgridarray && i < rank ; i ++ ) { Dimension dim = dimset . get ( i ) ; if ( dim . getShortName ( ) == null ) isgridarray = false ; else { Variable gv = coordvars . get ( dim . getShortName ( ) ) ; if ( gv == null ) isgridarray = false ; } } if ( isgridarray ) { gridarrays . put ( v . getFullName ( ) , v ) ; for ( Dimension dim : dimset ) { Variable gv = coordvars . get ( dim . getShortName ( ) ) ; if ( gv != null ) used . put ( gv . getFullName ( ) , gv ) ; } } } // Create the set of coordinates
for ( Variable cv : ncd . getCoordinateAxes ( ) ) { BaseType bt = createVariable ( ncd , cv ) ; addVariable ( bt ) ; } // Create the set of variables
for ( Variable cv : ddsvars ) { BaseType bt = createVariable ( ncd , cv ) ; addVariable ( bt ) ; }


signature:
public class NcDDS { /** * turn Variable into opendap variable */
private BaseType createVariable ( NetcdfFile ncfile , Variable v ) { } }

implementation:
BaseType bt ; if ( v . getRank ( ) == 0 ) // scalar
bt = createScalarVariable ( ncfile , v ) ; else if ( v . getDataType ( ) == DataType . CHAR ) { if ( v . getRank ( ) > 1 ) bt = new NcSDCharArray ( v ) ; else bt = new NcSDString ( v ) ; } else if ( v . getDataType ( ) == DataType . STRING ) { if ( v . getRank ( ) == 0 ) bt = new NcSDString ( v ) ; else bt = new NcSDArray ( v , new NcSDString ( v ) ) ; } else // non - char multidim array
bt = createArray ( ncfile , v ) ; return bt ;


signature:
public class NcDDS { /** * Returns a clone of this < code > ? < / code > .
 * See BaseType . cloneDAG ( )
 * @ param map track previously cloned nodes
 * @ return a clone of this object . */
public DAPNode cloneDAG ( CloneMap map ) throws CloneNotSupportedException { } }

implementation: NcDDS d = ( NcDDS ) super . cloneDAG ( map ) ; d . coordvars = coordvars ; return d ;


signature:
public class NavigatedPanel { /** * called by Navigation */
void fireMapAreaEvent ( ) { } }

implementation:
if ( debugZoom ) System . out . println ( "NP.fireMapAreaEvent " ) ; // decide if we need a new Projection : for LatLonProjection only
if ( project . isLatLon ( ) ) { LatLonProjection llproj = ( LatLonProjection ) project ; ProjectionRect box = getMapArea ( ) ; double center = llproj . getCenterLon ( ) ; double lonBeg = LatLonPointImpl . lonNormal ( box . getMinX ( ) , center ) ; double lonEnd = lonBeg + box . getMaxX ( ) - box . getMinX ( ) ; boolean showShift = Debug . isSet ( "projection/LatLonShift" ) || debugNewProjection ; if ( showShift ) System . out . println ( "projection/LatLonShift: min,max = " + box . getMinX ( ) + " " + box . getMaxX ( ) + " beg,end= " + lonBeg + " " + lonEnd + " center = " + center ) ; if ( ( lonBeg < center - 180 ) || ( lonEnd > center + 180 ) ) { // got to do it
double wx0 = box . getX ( ) + box . getWidth ( ) / 2 ; llproj . setCenterLon ( wx0 ) ; // shift cylinder seam
double newWx0 = llproj . getCenterLon ( ) ; // normalize wx0 to [ - 180,180]
setWorldCenterX ( newWx0 ) ; // tell navigation panel to shift
if ( showShift ) System . out . println ( "projection/LatLonShift: shift center to " + wx0 + "->" + newWx0 ) ; // send projection event instead of map area event
lmProject . sendEvent ( new NewProjectionEvent ( this , llproj ) ) ; return ; } } // send new map area event
lmMapArea . sendEvent ( new NewMapAreaEvent ( this , getMapArea ( ) ) ) ;


signature:
public class NavigatedPanel { /** * Set the Map Area . */
public void setMapArea ( ProjectionRect ma ) { } }

implementation: if ( debugBB ) System . out . println ( "NP.setMapArea " + ma ) ; navigate . setMapArea ( ma ) ;


signature:
public class NavigatedPanel { /** * Set the Map Area by converting LatLonRect to a ProjectionRect . */
public void setMapArea ( LatLonRect llbb ) { } }

implementation: if ( debugBB ) System . out . println ( "NP.setMapArea (ll) " + llbb ) ; navigate . setMapArea ( project . latLonToProjBB ( llbb ) ) ;


signature:
public class NavigatedPanel { /** * set the center point of the MapArea */
public void setLatLonCenterMapArea ( double lat , double lon ) { } }

implementation: ProjectionPoint center = project . latLonToProj ( lat , lon ) ; ProjectionRect ma = getMapArea ( ) ; ma . setX ( center . getX ( ) - ma . getWidth ( ) / 2 ) ; ma . setY ( center . getY ( ) - ma . getHeight ( ) / 2 ) ; setMapArea ( ma ) ;


signature:
public class NavigatedPanel { /** * Set the Projection , change the Map Area to the projection ' s default . */
public void setProjectionImpl ( ProjectionImpl p ) { } }

implementation:
// transfer selection region to new coord system
if ( geoSelection != null ) { LatLonRect geoLL = project . projToLatLonBB ( geoSelection ) ; setGeoSelection ( p . latLonToProjBB ( geoLL ) ) ; } // switch projections
project = p ; navigate . setMapArea ( project . getDefaultMapArea ( ) ) ; if ( Debug . isSet ( "projection/set" ) || debugNewProjection ) System . out . println ( "projection/set NP=" + project ) ; // transfer reference point to new coord system
if ( hasReference ) { refWorld . setLocation ( project . latLonToProj ( refLatLon ) ) ; }


signature:
public class NavigatedPanel { /** * Add all of the toolbar ' s actions to a menu .
 * @ param menu the menu to add the actions to */
public void addActionsToMenu ( JMenu menu ) { } }

implementation: BAMutil . addActionToMenu ( menu , zoomIn ) ; BAMutil . addActionToMenu ( menu , zoomOut ) ; BAMutil . addActionToMenu ( menu , zoomBack ) ; BAMutil . addActionToMenu ( menu , zoomDefault ) ; menu . addSeparator ( ) ; BAMutil . addActionToMenu ( menu , moveUp ) ; BAMutil . addActionToMenu ( menu , moveDown ) ; BAMutil . addActionToMenu ( menu , moveRight ) ; BAMutil . addActionToMenu ( menu , moveLeft ) ; menu . addSeparator ( ) ; BAMutil . addActionToMenu ( menu , setReferenceAction ) ;


signature:
public class NavigatedPanel { /** * from panning , so wait delay msecs before doing the redraw . */
private void redrawLater ( int delay ) { } }

implementation:
boolean already = ( redrawTimer != null ) && ( redrawTimer . isRunning ( ) ) ; if ( debugThread ) System . out . println ( "redrawLater isRunning= " + already ) ; if ( already ) return ; // initialize Timer the first time
if ( redrawTimer == null ) { redrawTimer = new javax . swing . Timer ( 0 , new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { drawG ( ) ; redrawTimer . stop ( ) ; // one - shot timer
} } ) ; } // start the timer running
redrawTimer . setDelay ( delay ) ; redrawTimer . start ( ) ;


signature:
public class NavigatedPanel { /** * sets whether the user can zoom / pan on this NavigatedPanel . Default = true .
 * @ param mode set to false if user can ' t zoom / pan */
public void setChangeable ( boolean mode ) { } }

implementation: if ( mode == changeable ) return ; changeable = mode ; if ( toolbar != null ) toolbar . setEnabled ( mode ) ;


signature:
public class NavigatedPanel { /** * note : I believe that the RepaintManager is not used on JPanel subclasses ? ? ? */
public void repaint ( long tm , int x , int y , int width , int height ) { } }

implementation: if ( debugDraw ) System . out . println ( "REPAINT " + repaintCount + " x " + x + " y " + y + " width " + width + " heit " + height ) ; if ( debugThread ) System . out . println ( " thread = " + Thread . currentThread ( ) ) ; repaintCount ++ ; super . repaint ( tm , x , y , width , height ) ;


signature:
public class NavigatedPanel { /** * System - triggered redraw . */
public void paintComponent ( Graphics g ) { } }

implementation: if ( debugDraw ) System . out . println ( "System called paintComponent clip= " + g . getClipBounds ( ) ) ; draw ( ( Graphics2D ) g ) ;


signature:
public class NavigatedPanel { /** * User must get this Graphics2D and draw into it when panel needs redrawing */
public Graphics2D getBufferedImageGraphics ( ) { } }

implementation:
if ( bImage == null ) return null ; Graphics2D g2 = bImage . createGraphics ( ) ; // set clipping rectangle into boundingBox
navigate . getMapArea ( boundingBox ) ; if ( debugBB ) System . out . println ( " getBufferedImageGraphics BB = " + boundingBox ) ; // set graphics attributes
g2 . setTransform ( navigate . getTransform ( ) ) ; g2 . setStroke ( new BasicStroke ( 0.0f ) ) ; // default stroke size is one pixel
g2 . setRenderingHint ( RenderingHints . KEY_RENDERING , RenderingHints . VALUE_RENDER_SPEED ) ; Rectangle2D hr = new Rectangle2D . Double ( ) ; hr . setRect ( boundingBox . getX ( ) , boundingBox . getY ( ) , boundingBox . getWidth ( ) , boundingBox . getHeight ( ) ) ; g2 . setClip ( hr ) ; // normalized coord system , because transform is applied
g2 . setBackground ( backColor ) ; return g2 ;


signature:
public class NavigatedPanel { /** * This calculates the Affine Transform that maps the current map area ( in Projection Coordinates )
 * to a display area ( in arbitrary units ) .
 * @ param rotate should the page be rotated ?
 * @ param displayX upper right corner of display area
 * @ param displayY upper right corner of display area
 * @ param displayWidth display area
 * @ param displayHeight display area
 * see Navigation . calcTransform */
public AffineTransform calcTransform ( boolean rotate , double displayX , double displayY , double displayWidth , double displayHeight ) { } }

implementation: return navigate . calcTransform ( rotate , displayX , displayY , displayWidth , displayHeight ) ;


signature:
public class NavigatedPanel { /** * when component resizes we need a new buffer */
private void newScreenSize ( Rectangle b ) { } }

implementation:
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 ) ;


signature:
public class NavigatedPanel { /** * draw and drawG are like " paintImmediately ( ) " */
public void drawG ( ) { } }

implementation:
Graphics g = getGraphics ( ) ; // bypasses double buffering ?
if ( null != g ) { draw ( ( Graphics2D ) g ) ; g . dispose ( ) ; }


signature:
public class DatasetTreeView { /** * Set the currently selected Variable .
 * @ param v select this Variable , must be already in the tree . */
public void setSelected ( VariableIF v ) { } }

implementation:
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 ) ;


signature:
public class CDMArrayAtomic { /** * TODO : add index range checks */
public Class getElementType ( ) { } }

implementation: DataType dt = CDMTypeFcns . daptype2cdmtype ( this . basetype ) ; if ( dt == null ) throw new IllegalArgumentException ( "Unknown datatype: " + this . basetype ) ; return CDMTypeFcns . cdmElementClass ( dt ) ;


signature:
public class CDMArrayAtomic { /** * Convert int base to Index based */
public double getDouble ( int offset ) { } }

implementation: DapVariable d4var = ( DapVariable ) getTemplate ( ) ; long [ ] dimsizes = DapUtil . getDimSizes ( d4var . getDimensions ( ) ) ; return getDouble ( DapUtil . offsetToIndex ( offset , dimsizes ) ) ;


signature:
public class CDMArrayAtomic { /** * Get the array element at a specific dap4 index as a double
 * @ param idx of element to get
 * @ return value at < code > index < / code > cast to double if necessary . */
protected double getDouble ( dap4 . core . util . Index idx ) { } }

implementation: 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 ( ) ) ; }


signature:
public class CDMArrayAtomic { /** * Get the array element at a specific dap4 index as an Object
 * @ param idx of element to get
 * @ return value at < code > index < / code > cast to Object if necessary . */
protected Object getObject ( dap4 . core . util . Index idx ) { } }

implementation: 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 ( ) ) ; }


signature:
public class Giniheader { /** * Return the string of Sector for the GINI image file */
String gini_GetSectorID ( int ent_id ) { } }

implementation: 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 ;


signature:
public class Giniheader { /** * Return the channel ID for the GINI image file */
String gini_GetEntityID ( int ent_id ) { } }

implementation:
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 ;


signature:
public class Giniheader { /** * Return the channel ID for the GINI image file */
String gini_GetPhysElemID ( int phys_elem , int ent_id ) { } }

implementation: 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 ;


signature:
public class Giniheader { /** * Return the channel ID for the GINI image file */
String getPhysElemLongName ( int phys_elem , int ent_id ) { } }

implementation: 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 ; }