signature:
public class GridDatasetInfo { /** * Create the " Grid Form " XML document from this GridDataset .
 * Used to create the Grid HTML form , cause I dont know XSLT
 * @ return the JDOM Document */
public Document makeGridForm ( ) { } }

implementation:
Element rootElem = new Element ( "gridForm" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "location" , gds . getLocation ( ) ) ; if ( null != path ) rootElem . setAttribute ( "path" , path ) ; // its all about grids
List < GridDatatype > grids = gds . getGrids ( ) ; Collections . sort ( grids , new GridComparator ( ) ) ; // sort by time axis , vert axis , grid name
CoordinateAxis currentTime = null ; CoordinateAxis currentVert = null ; Element timeElem = null ; Element vertElem = null ; boolean newTime ; for ( int i = 0 ; i < grids . size ( ) ; i ++ ) { GeoGrid grid = ( GeoGrid ) grids . get ( i ) ; GridCoordSystem gcs = grid . getCoordinateSystem ( ) ; CoordinateAxis time = gcs . getTimeAxis ( ) ; CoordinateAxis vert = gcs . getVerticalAxis ( ) ; /* System . out . println ( " grid " + grid . getName ( )
 + " time = " + ( time = = null ? " null " : time . hashCode ( ) )
 + " vert = " + ( vert = = null ? " null " : vert . hashCode ( ) ) ) ; */
// Assuming all variables in dataset has ensemble dim if one has
if ( i == 0 ) { CoordinateAxis1D ens = gcs . getEnsembleAxis ( ) ; if ( ens != null ) { Element ensAxisEl = writeAxis2 ( ens , "ensemble" ) ; rootElem . addContent ( ensAxisEl ) ; } } if ( ( i == 0 ) || ! compareAxis ( time , currentTime ) ) { timeElem = new Element ( "timeSet" ) ; rootElem . addContent ( timeElem ) ; Element timeAxisElement = writeAxis2 ( time , "time" ) ; if ( timeAxisElement != null ) timeElem . addContent ( timeAxisElement ) ; currentTime = time ; newTime = true ; } else { newTime = false ; } if ( newTime || ! compareAxis ( vert , currentVert ) ) { vertElem = new Element ( "vertSet" ) ; timeElem . addContent ( vertElem ) ; Element vertAxisElement = writeAxis2 ( vert , "vert" ) ; if ( vertAxisElement != null ) vertElem . addContent ( vertAxisElement ) ; currentVert = vert ; } vertElem . addContent ( writeGrid ( grid ) ) ; } // add lat / lon bounding box
LatLonRect bb = gds . getBoundingBox ( ) ; if ( bb != null ) rootElem . addContent ( writeBoundingBox ( bb ) ) ; // add projected bounding box
// - - > Asuming all gridSets have the same coordinates and bbox
ProjectionRect rect = grids . get ( 0 ) . getCoordinateSystem ( ) . getBoundingBox ( ) ; Element projBBOX = new Element ( "projectionBox" ) ; Element minx = new Element ( "minx" ) ; minx . addContent ( Double . valueOf ( rect . getMinX ( ) ) . toString ( ) ) ; projBBOX . addContent ( minx ) ; Element maxx = new Element ( "maxx" ) ; maxx . addContent ( Double . valueOf ( rect . getMaxX ( ) ) . toString ( ) ) ; projBBOX . addContent ( maxx ) ; Element miny = new Element ( "miny" ) ; miny . addContent ( Double . valueOf ( rect . getMinY ( ) ) . toString ( ) ) ; projBBOX . addContent ( miny ) ; Element maxy = new Element ( "maxy" ) ; maxy . addContent ( Double . valueOf ( rect . getMaxY ( ) ) . toString ( ) ) ; projBBOX . addContent ( maxy ) ; rootElem . addContent ( projBBOX ) ; // add date range
CalendarDate start = gds . getCalendarDateStart ( ) ; CalendarDate end = gds . getCalendarDateEnd ( ) ; if ( ( start != null ) && ( end != null ) ) { Element dateRange = new Element ( "TimeSpan" ) ; dateRange . addContent ( new Element ( "begin" ) . addContent ( start . toString ( ) ) ) ; dateRange . addContent ( new Element ( "end" ) . addContent ( end . toString ( ) ) ) ; rootElem . addContent ( dateRange ) ; } // add accept list
addAcceptList ( rootElem ) ; // Element elem = new Element ( " AcceptList " ) ;
// elem . addContent ( new Element ( " accept " ) . addContent ( " xml " ) ) ;
// elem . addContent ( new Element ( " accept " ) . addContent ( " csv " ) ) ;
// elem . addContent ( new Element ( " accept " ) . addContent ( " netcdf " ) ) ;
// rootElem . addContent ( elem ) ;
return doc ;


signature:
public class GridDatasetInfo { /** * / * private List getDimensions ( ucar . nc2 . dt . GridDataset gds ) {
 * HashSet dimHash = new HashSet ( ) ;
 * List grids = gds . getGrids ( ) ;
 * for ( int i = 0 ; i < grids . size ( ) ; i + + ) {
 * GeoGrid grid = ( GeoGrid ) grids . get ( i ) ;
 * List dims = grid . getDimensions ( ) ;
 * for ( int j = 0 ; j < dims . size ( ) ; j + + ) {
 * Dimension dim = ( Dimension ) dims . get ( j ) ;
 * dimHash . add ( dim ) ;
 * List list = Arrays . asList ( dimHash . toArray ( ) ) ;
 * Collections . sort ( list ) ;
 * return list ; */
private Element writeAxis ( CoordinateAxis axis ) { } }

implementation:
NcMLWriter ncmlWriter = new NcMLWriter ( ) ; Element varElem = new Element ( "axis" ) ; varElem . setAttribute ( "name" , axis . getFullName ( ) ) ; varElem . setAttribute ( "shape" , getShapeString ( axis . getShape ( ) ) ) ; // axis . getDimensionsString ( ) ) ;
DataType dt = axis . getDataType ( ) ; varElem . setAttribute ( "type" , dt . toString ( ) ) ; AxisType axisType = axis . getAxisType ( ) ; if ( null != axisType ) varElem . setAttribute ( "axisType" , axisType . toString ( ) ) ; // attributes
for ( Attribute att : axis . getAttributes ( ) ) { varElem . addContent ( ncmlWriter . makeAttributeElement ( att ) ) ; } if ( axis . getRank ( ) == 1 ) { try { Element values = ncmlWriter . makeValuesElement ( axis , true ) ; varElem . addContent ( values ) ; } catch ( IOException e ) { String message = String . format ( "Couldn't read values for %s. Omitting <values> element." , axis . getFullName ( ) ) ; logger . warn ( message , e ) ; } } return varElem ;


signature:
public class GridDatasetInfo { /** * display name plus the dimensions */
private String getShapeString ( int [ ] shape ) { } }

implementation: StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < shape . length ; i ++ ) { if ( i != 0 ) buf . append ( " " ) ; buf . append ( shape [ i ] ) ; } return buf . toString ( ) ;


signature:
public class GridDatasetInfo { /** * / * private Element writeCoordSys ( GridCoordSystem cs ) {
 * Element csElem = new Element ( " coordSys " ) ;
 * csElem . setAttribute ( " name " , cs . getName ( ) ) ;
 * List axes = cs . getCoordinateAxes ( ) ;
 * for ( int i = 0 ; i < axes . size ( ) ; i + + ) {
 * CoordinateAxis axis = ( CoordinateAxis ) axes . get ( i ) ;
 * Element axisElem = new Element ( " axisRef " ) ;
 * axisElem . setAttribute ( " name " , axis . getName ( ) ) ;
 * csElem . addContent ( axisElem ) ;
 * List cts = cs . getCoordinateTransforms ( ) ;
 * for ( int j = 0 ; j < cts . size ( ) ; j + + ) {
 * CoordinateTransform ct = ( CoordinateTransform ) cts . get ( j ) ;
 * Element elem = new Element ( " coordTransRef " ) ;
 * elem . setAttribute ( " name " , ct . getName ( ) ) ;
 * csElem . addContent ( elem ) ;
 * return csElem ; */
private Element writeCoordTransform ( CoordinateTransform ct ) { } }

implementation: Element ctElem = new Element ( "coordTransform" ) ; ctElem . setAttribute ( "name" , ct . getName ( ) ) ; ctElem . setAttribute ( "transformType" , ct . getTransformType ( ) . toString ( ) ) ; for ( Parameter param : ct . getParameters ( ) ) { Element pElem = new Element ( "parameter" ) ; pElem . setAttribute ( "name" , param . getName ( ) ) ; pElem . setAttribute ( "value" , param . getStringValue ( ) ) ; ctElem . addContent ( pElem ) ; } return ctElem ;


signature:
public class GridDatasetInfo { /** * debug
 * @ param args ignored
 * @ throws java . io . IOException on io error */
public static void main ( String args [ ] ) throws IOException { } }

implementation: String url = "cdmremote:http://localhost:8080/thredds/cdmremote/grib/NCDC/CFSR/NCDC-CFSR/PGB-LatLon0p5" ; GridDataset ncd = ucar . nc2 . dt . grid . GridDataset . open ( url ) ; GridDatasetInfo info = new GridDatasetInfo ( ncd , null ) ; FileOutputStream fos2 = new FileOutputStream ( "C:/tmp2/gridInfo.xml" ) ; info . writeXML ( info . makeGridForm ( ) , fos2 ) ; fos2 . close ( ) ; String infoString = info . writeXML ( info . makeGridForm ( ) ) ; System . out . println ( infoString ) ;


signature:
public class Slice { /** * Perform sanity checks on a slice and repair where possible .
 * @ return this ( fluent interface )
 * @ throws dap4 . core . util . DapException if slice is malformed */
public Slice finish ( ) throws DapException { } }

implementation:
// Attempt to repair undefined values
if ( this . first == UNDEFINED ) this . first = 0 ; // default
if ( this . stride == UNDEFINED ) this . stride = 1 ; // default
if ( this . stop == UNDEFINED && this . maxsize != UNDEFINED ) this . stop = this . maxsize ; if ( this . stop == UNDEFINED && this . maxsize == UNDEFINED ) this . stop = this . first + 1 ; if ( this . maxsize == UNDEFINED && this . stop != UNDEFINED ) this . maxsize = this . stop ; // else ( this . stop ! = UNDEFINED & & this . maxsize ! = UNDEFINED )
assert ( this . first != UNDEFINED ) ; assert ( this . stride != UNDEFINED ) ; assert ( this . stop != UNDEFINED ) ; // sanity checks
if ( this . first > this . maxsize ) throw new DapException ( "Slice: first index > max size" ) ; if ( this . stop > ( this . maxsize + 1 ) ) throw new DapException ( "Slice: stop > max size" ) ; if ( this . first < 0 ) throw new DapException ( "Slice: first index < 0" ) ; if ( this . stop < 0 ) throw new DapException ( "Slice: stop index < 0" ) ; if ( this . stride <= 0 ) throw new DapException ( "Slice: stride index <= 0" ) ; if ( this . first > this . stop ) throw new DapException ( "Slice: first index > last" ) ; return this ; // fluent interface


signature:
public class Slice { /** * Compute the number of elements in
 * the slice . Note that this is different from
 * getStop ( ) because stride is taken into account . */
public long getCount ( ) { } }

implementation: assert this . first != UNDEFINED && this . stride != UNDEFINED && this . stop != UNDEFINED ; long count = ( this . stop ) - this . first ; count = ( count + this . stride - 1 ) ; count /= this . stride ; return count ;


signature:
public class Slice { /** * Convert this slice to a string
 * suitable for use in a constraint
 * @ return constraint usable string
 * @ throws DapException */
public String toConstraintString ( ) throws DapException { } }

implementation: assert this . first != UNDEFINED && this . stride != UNDEFINED && this . stop != UNDEFINED ; if ( ( this . stop - this . first ) == 0 ) { return String . format ( "[0]" ) ; } else if ( this . stride == 1 ) { if ( ( this . stop - this . first ) == 1 ) return String . format ( "[%d]" , this . first ) ; else return String . format ( "[%d:%d]" , this . first , this . stop - 1 ) ; } else return String . format ( "[%d:%d:%d]" , this . first , this . stride , this . stop - 1 ) ;


signature:
public class Slice { /** * Take two slices and compose src wrt target
 * Assume neither argument is null . This code
 * should match ucar . ma2 . Section in thredds
 * and dceconstraint . c in the netcdf - c library .
 * @ param target
 * @ param src
 * @ return new , composed Range
 * @ throws DapException */
static public Slice compose ( Slice target , Slice src ) throws DapException { } }

implementation:
long sr_stride = target . getStride ( ) * src . getStride ( ) ; long sr_first = MAP ( target , src . getFirst ( ) ) ; long lastx = MAP ( target , src . getLast ( ) ) ; long sr_last = ( target . getLast ( ) < lastx ? target . getLast ( ) : lastx ) ; // min ( last ( ) , lastx )
return new Slice ( sr_first , sr_last + 1 , sr_stride , sr_last + 1 ) . finish ( ) ;


signature:
public class Slice { /** * Map ith element of one range wrt a target range
 * @ param target the target range
 * @ param i index of the element
 * @ return the i - th element of a range
 * @ throws DapException if index is invalid */
static long MAP ( Slice target , long i ) throws DapException { } }

implementation: if ( i < 0 ) throw new DapException ( "Slice.compose: i must be >= 0" ) ; if ( i > target . getStop ( ) ) throw new DapException ( "i must be < stop" ) ; return target . getFirst ( ) + i * target . getStride ( ) ;


signature:
public class DapDump { /** * Provide a simple dump of binary data */
static public void dumpbytes ( ByteBuffer buf0 , boolean skipdmr ) { } }

implementation:
int savepos = buf0 . position ( ) ; int limit0 = buf0 . limit ( ) ; int skipcount = 0 ; if ( limit0 > MAXLIMIT ) limit0 = MAXLIMIT ; if ( limit0 >= buf0 . limit ( ) ) limit0 = buf0 . limit ( ) ; if ( skipdmr ) { ByteOrder saveorder = buf0 . order ( ) ; buf0 . order ( ByteOrder . BIG_ENDIAN ) ; // must read in network order
skipcount = buf0 . getInt ( ) ; // dmr count
buf0 . order ( saveorder ) ; skipcount &= 0xFFFFFF ; // mask off the flags to get true count
skipcount += 4 ; // skip the count also
} byte [ ] bytes = new byte [ ( limit0 + 8 ) - skipcount ] ; Arrays . fill ( bytes , ( byte ) 0 ) ; buf0 . position ( savepos + skipcount ) ; buf0 . get ( bytes , 0 , limit0 - skipcount ) ; buf0 . position ( savepos ) ; System . err . println ( "order=" + buf0 . order ( ) ) ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) . order ( buf0 . order ( ) ) ; dumpbytes ( buf ) ;


signature:
public class DapDump { /** * Dump the contents of a buffer from 0 to position
 * @ param buf0 byte buffer to dump */
static public void dumpbytes ( ByteBuffer buf0 ) { } }

implementation:
int stop = buf0 . limit ( ) ; int size = stop + 8 ; int savepos = buf0 . position ( ) ; assert savepos == 0 ; byte [ ] bytes = new byte [ size ] ; Arrays . fill ( bytes , ( byte ) 0 ) ; buf0 . get ( bytes , 0 , stop ) ; buf0 . position ( savepos ) ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) . order ( buf0 . order ( ) ) ; buf . position ( 0 ) ; buf . limit ( size ) ; int i = 0 ; try { for ( i = 0 ; buf . position ( ) < stop ; i ++ ) { savepos = buf . position ( ) ; int iv = buf . getInt ( ) ; buf . position ( savepos ) ; long lv = buf . getLong ( ) ; buf . position ( savepos ) ; short sv = buf . getShort ( ) ; buf . position ( savepos ) ; byte b = buf . get ( ) ; int ub = ( ( int ) b ) & 0x000000FF ; long uiv = ( ( long ) iv ) & 0xFFFFFFFFL ; int usv = ( ( int ) sv ) & 0xFFFF ; int ib = ( int ) b ; char c = ( char ) ub ; String s = Character . toString ( c ) ; if ( c == '\r' ) s = "\\r" ; else if ( c == '\n' ) s = "\\n" ; else if ( c < ' ' || c >= 0x7f ) s = "?" ; System . err . printf ( "[%03d] %02x %03d %4d '%s'" , i , ub , ub , ib , s ) ; System . err . printf ( "\t%12d 0x%08x" , iv , uiv ) ; System . err . printf ( "\t%5d\t0x%04x" , sv , usv ) ; System . err . println ( ) ; System . err . flush ( ) ; } } catch ( Exception e ) { System . err . println ( "failure:" + e ) ; } finally { System . err . flush ( ) ; // new Exception ( ) . printStackTrace ( System . err ) ;
System . err . flush ( ) ; }


signature:
public class EarthEllipsoid { /** * Find the EarthEllipsoid that matches this name .
 * @ param name : name to match
 * @ return EarthEllipsoid or null if no match . */
public static EarthEllipsoid getType ( String name ) { } }

implementation: if ( name == null ) return null ; return hash . get ( name ) ;


signature:
public class EarthEllipsoid { /** * Find the EarthEllipsoid that matches this EPSG Id .
 * @ param epsgId : epsg Id to match
 * @ return EarthEllipsoid or null if no match . */
public static EarthEllipsoid getType ( int epsgId ) { } }

implementation: Collection < EarthEllipsoid > all = getAll ( ) ; for ( EarthEllipsoid ellipsoid : all ) { if ( ellipsoid . epsgId == epsgId ) { return ellipsoid ; } } return null ;


signature:
public class NcStreamDataCol { /** * message DataCol {
 * string name = 1 ; / / fullname for top , shortname for member
 * DataType dataType = 2;
 * Section section = 3;
 * bool bigend = 4;
 * uint32 version = 5;
 * bool isVlen = 7;
 * uint32 nelems = 9;
 * oneof
 * bytes primdata = 10 ; / / rectangular , primitive array
 * repeated string stringdata = 11 ; / / string dataType
 * repeated uint32 vlens = 12 ; / / isVlen true
 * repeated bytes opaquedata = 13 ; / / opaque dataType
 * structures
 * ArrayStructureCol structdata = 14 ; / / structure / seq dataType
 * message ArrayStructureCol {
 * repeated DataCol memberData = 1;
 * primdata has nelems * sizeof ( dataType ) bytes , turn into multidim array of primitives with section info and bigend
 * stringdata has nelems strings , turn into multidim array of String with section info
 * vlens has section . size array lengths ; section does not include the last ( vlen ) dimension ; data in primdata
 * opaquedata has nelems opaque objects , turn into multidim array of Opaque with section info
 * structdata has nelems StructureData objects , turn into multidim array of StructureData with section info and bigend */
public NcStreamProto . DataCol encodeData2 ( String name , boolean isVlen , Section section , Array data ) { } }

implementation:
NcStreamProto . DataCol . Builder builder = NcStreamProto . DataCol . newBuilder ( ) ; DataType dataType = data . getDataType ( ) ; builder . setName ( name ) ; builder . setDataType ( NcStream . convertDataType ( data . getDataType ( ) ) ) ; builder . setBigend ( ByteOrder . nativeOrder ( ) == ByteOrder . BIG_ENDIAN ) ; builder . setVersion ( NcStream . ncstream_data_version ) ; if ( ! isVlen ) { builder . setNelems ( ( int ) data . getSize ( ) ) ; builder . setSection ( NcStream . encodeSection ( section ) ) ; } if ( isVlen ) { builder . setIsVlen ( true ) ; encodeVlenData ( builder , section , data ) ; } else if ( dataType == DataType . STRING ) { if ( data instanceof ArrayChar ) { // is this possible ?
ArrayChar cdata = ( ArrayChar ) data ; for ( String s : cdata ) builder . addStringdata ( s ) ; Section ssection = section . removeLast ( ) ; builder . setSection ( NcStream . encodeSection ( ssection ) ) ; } else if ( data instanceof ArrayObject ) { IndexIterator iter = data . getIndexIterator ( ) ; while ( iter . hasNext ( ) ) builder . addStringdata ( ( String ) iter . next ( ) ) ; } else { throw new IllegalStateException ( "Unknown class for STRING =" + data . getClass ( ) . getName ( ) ) ; } } else if ( dataType == DataType . OPAQUE ) { if ( data instanceof ArrayObject ) { IndexIterator iter = data . getIndexIterator ( ) ; while ( iter . hasNext ( ) ) { ByteBuffer bb = ( ByteBuffer ) iter . next ( ) ; // Need to use duplicate so that internal state of bb isn ' t affected
builder . addOpaquedata ( ByteString . copyFrom ( bb . duplicate ( ) ) ) ; } } else { throw new IllegalStateException ( "Unknown class for OPAQUE =" + data . getClass ( ) . getName ( ) ) ; } } else if ( dataType == DataType . STRUCTURE ) { builder . setStructdata ( encodeStructureData ( data ) ) ; } else if ( dataType == DataType . SEQUENCE ) { throw new UnsupportedOperationException ( "Not implemented yet SEQUENCE =" + data . getClass ( ) . getName ( ) ) ; } else { // normal case
builder . setPrimdata ( copyArrayToByteString ( data ) ) ; } return builder . build ( ) ;


signature: public class NcStreamDataCol { public Array decode ( NcStreamProto . DataCol dproto , Section parentSection ) throws IOException { } }

implementation:
ByteOrder bo = dproto . getBigend ( ) ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; DataType dataType = NcStream . convertDataType ( dproto . getDataType ( ) ) ; Section section = ( dataType == DataType . SEQUENCE ) ? new Section ( ) : NcStream . decodeSection ( dproto . getSection ( ) ) ; if ( ! dproto . getIsVlen ( ) ) { assert dproto . getNelems ( ) == section . computeSize ( ) ; } // special cases
if ( dproto . getIsVlen ( ) ) { if ( parentSection == null ) return decodeVlenData ( dproto ) ; else return decodeVlenData ( dproto , parentSection ) ; } else if ( dataType == DataType . STRING ) { Array data = Array . factory ( dataType , section . getShape ( ) ) ; IndexIterator ii = data . getIndexIterator ( ) ; for ( String s : dproto . getStringdataList ( ) ) { ii . setObjectNext ( s ) ; } return data ; } else if ( dataType == DataType . STRUCTURE ) { return decodeStructureData ( dproto , parentSection ) ; } else if ( dataType == DataType . OPAQUE ) { Array data = Array . factory ( dataType , section . getShape ( ) ) ; IndexIterator ii = data . getIndexIterator ( ) ; for ( ByteString s : dproto . getOpaquedataList ( ) ) { ii . setObjectNext ( s . asReadOnlyByteBuffer ( ) ) ; } return data ; } else { // common case
ByteBuffer bb = dproto . getPrimdata ( ) . asReadOnlyByteBuffer ( ) ; bb . order ( bo ) ; return Array . factory ( dataType , section . getShape ( ) , bb ) ; }


signature:
public class NcStreamDataCol { /** * top level vlen */
public Array decodeVlenData ( NcStreamProto . DataCol dproto ) throws IOException { } }

implementation:
DataType dataType = NcStream . convertDataType ( dproto . getDataType ( ) ) ; ByteBuffer bb = dproto . getPrimdata ( ) . asReadOnlyByteBuffer ( ) ; ByteOrder bo = dproto . getBigend ( ) ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; bb . order ( bo ) ; Array alldata = Array . factory ( dataType , new int [ ] { dproto . getNelems ( ) } , bb ) ; // flat array
IndexIterator all = alldata . getIndexIterator ( ) ; Section section = NcStream . decodeSection ( dproto . getSection ( ) ) ; Array [ ] data = new Array [ ( int ) section . computeSize ( ) ] ; // divide the primitive data into variable length arrays
int count = 0 ; for ( int len : dproto . getVlensList ( ) ) { Array primdata = Array . factory ( dataType , new int [ ] { len } ) ; IndexIterator prim = primdata . getIndexIterator ( ) ; for ( int i = 0 ; i < len ; i ++ ) { prim . setObjectNext ( all . getObjectNext ( ) ) ; // generic
} data [ count ++ ] = primdata ; } // return Array . makeObjectArray ( dataType , data [ 0 ] . getClass ( ) , section . getShape ( ) , data ) ;
return Array . makeVlenArray ( section . getShape ( ) , data ) ;


signature:
public class NcStreamDataCol { /** * vlen inside a Structure */
private Array decodeVlenData ( NcStreamProto . DataCol dproto , Section parentSection ) throws IOException { } }

implementation:
DataType dataType = NcStream . convertDataType ( dproto . getDataType ( ) ) ; ByteBuffer bb = dproto . getPrimdata ( ) . asReadOnlyByteBuffer ( ) ; ByteOrder bo = dproto . getBigend ( ) ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; bb . order ( bo ) ; Array alldata = Array . factory ( dataType , new int [ ] { dproto . getNelems ( ) } , bb ) ; // 1D array
IndexIterator all = alldata . getIndexIterator ( ) ; int psize = ( int ) parentSection . computeSize ( ) ; Section section = NcStream . decodeSection ( dproto . getSection ( ) ) ; Section vsection = section . removeFirst ( parentSection ) ; int vsectionSize = ( int ) vsection . computeSize ( ) ; // the # of varlen Arrays at the inner structure
// LOOK check for scalar
// divide the primitive data into variable length arrays
int countInner = 0 ; Array [ ] pdata = new Array [ psize ] ; for ( int pCount = 0 ; pCount < psize ; pCount ++ ) { Array [ ] vdata = new Array [ vsectionSize ] ; for ( int vCount = 0 ; vCount < vsectionSize ; vCount ++ ) { int vlen = dproto . getVlens ( countInner ++ ) ; Array primdata = Array . factory ( dataType , new int [ ] { vlen } ) ; IndexIterator prim = primdata . getIndexIterator ( ) ; for ( int i = 0 ; i < vlen ; i ++ ) { prim . setObjectNext ( all . getObjectNext ( ) ) ; // generic
} vdata [ vCount ] = primdata ; } pdata [ pCount ] = Array . makeVlenArray ( vsection . getShape ( ) , vdata ) ; } // ArrayObject ( parentShape )
return Array . makeVlenArray ( parentSection . getShape ( ) , pdata ) ;


signature:
public class DodsURLExtractor { /** * Extract all A - HREF contained URLS from the given URL and return in List */
public ArrayList extract ( String url ) throws IOException { } }

implementation: if ( debug ) System . out . println ( " URLextract=" + url ) ; baseURL = new URL ( url ) ; InputStream in = baseURL . openStream ( ) ; InputStreamReader r = new InputStreamReader ( filterTag ( in ) , CDM . UTF8 ) ; HTMLEditorKit . ParserCallback callback = new CallerBacker ( ) ; urlList = new ArrayList ( ) ; wantURLS = true ; wantText = false ; parser . parse ( r , callback , false ) ; return urlList ;


signature:
public class DodsURLExtractor { /** * Extract text content from the given URL and return in String */
public String getTextContent ( String url ) throws IOException { } }

implementation: if ( debug ) System . out . println ( " URL.getTextContent=" + url ) ; baseURL = new URL ( url ) ; InputStream in = baseURL . openStream ( ) ; InputStreamReader r = new InputStreamReader ( filterTag ( in ) , CDM . UTF8 ) ; HTMLEditorKit . ParserCallback callback = new CallerBacker ( ) ; textBuffer = new StringBuffer ( 3000 ) ; wantURLS = false ; wantText = true ; parser . parse ( r , callback , false ) ; return textBuffer . toString ( ) ;


signature:
public class DodsURLExtractor { /** * workaround for HTMLEditorKit . Parser , cant deal with " content - encoding " */
private InputStream filterTag ( InputStream in ) throws IOException { } }

implementation:
BufferedReader buffIn = new BufferedReader ( new InputStreamReader ( in , CDM . UTF8 ) ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( 10000 ) ; String line = buffIn . readLine ( ) ; while ( line != null ) { String lline = line . toLowerCase ( ) ; if ( lline . contains ( "<meta " ) ) // skip meta tags
continue ; // System . out . println ( " - - " + line ) ;
bos . write ( line . getBytes ( CDM . utf8Charset ) ) ; line = buffIn . readLine ( ) ; } buffIn . close ( ) ; return new ByteArrayInputStream ( bos . toByteArray ( ) ) ;


signature:
public class AbstractIOServiceProvider { /** * LOOK DataOutputStream uses big - endian */
@ Override public long readToByteChannel ( ucar . nc2 . Variable v2 , Section section , WritableByteChannel channel ) throws java . io . IOException , ucar . ma2 . InvalidRangeException { } }

implementation: Array data = readData ( v2 , section ) ; return IospHelper . copyToByteChannel ( data , channel ) ;


signature:
public class CoverageDatasetCapabilities { /** * Create the " Dataset Description " XML document from this GridDataset
 * @ return a JDOM Document */
public Document makeDatasetDescription ( ) throws IOException { } }

implementation:
Element rootElem = new Element ( "gridDataset" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "location" , gcd . getName ( ) ) ; if ( null != path ) rootElem . setAttribute ( "path" , path ) ; // coordinate axes
for ( CoverageCoordAxis axis : gcd . getCoordAxes ( ) ) { rootElem . addContent ( writeAxis ( axis ) ) ; } // gridSets
for ( CoordSysSet gridset : gcd . getCoverageSets ( ) ) { rootElem . addContent ( writeCoverageSet ( gridset . getCoordSys ( ) , gridset . getCoverages ( ) , gcd . getProjBoundingBox ( ) ) ) ; } // coordinate transforms
for ( CoverageTransform ct : gcd . getCoordTransforms ( ) ) { rootElem . addContent ( writeCoordTransform ( ct ) ) ; } /* global attributes
 Iterator atts = gds . getGlobalAttributes ( ) . iterator ( ) ;
 while ( atts . hasNext ( ) ) {
 ucar . nc2 . Attribute att = ( ucar . nc2 . Attribute ) atts . next ( ) ;
 rootElem . addContent ( ucar . nc2 . ncml . NcMLWriter . writeAttribute ( att , " attribute " , null ) ) ; */
// add lat / lon bounding box
LatLonRect bb = gcd . getLatlonBoundingBox ( ) ; if ( bb != null ) rootElem . addContent ( writeBoundingBox ( bb ) ) ; // add date range
CalendarDateRange calDateRange = gcd . getCalendarDateRange ( ) ; if ( calDateRange != null ) { Element dateRange = new Element ( "TimeSpan" ) ; dateRange . addContent ( new Element ( "begin" ) . addContent ( calDateRange . getStart ( ) . toString ( ) ) ) ; dateRange . addContent ( new Element ( "end" ) . addContent ( calDateRange . getEnd ( ) . toString ( ) ) ) ; rootElem . addContent ( dateRange ) ; } return doc ;


signature:
public class CoverageDatasetCapabilities { /** * / * private Element writeCoordSys ( GridCoordSystem cs ) {
 * Element csElem = new Element ( " coordSys " ) ;
 * csElem . setAttribute ( " name " , cs . getName ( ) ) ;
 * List axes = cs . getCoordinateAxes ( ) ;
 * for ( int i = 0 ; i < axes . size ( ) ; i + + ) {
 * CoordinateAxis axis = ( CoordinateAxis ) axes . get ( i ) ;
 * Element axisElem = new Element ( " axisRef " ) ;
 * axisElem . setAttribute ( " name " , axis . getName ( ) ) ;
 * csElem . addContent ( axisElem ) ;
 * List cts = cs . getCoordinateTransforms ( ) ;
 * for ( int j = 0 ; j < cts . size ( ) ; j + + ) {
 * CoordinateTransform ct = ( CoordinateTransform ) cts . get ( j ) ;
 * Element elem = new Element ( " coordTransRef " ) ;
 * elem . setAttribute ( " name " , ct . getName ( ) ) ;
 * csElem . addContent ( elem ) ;
 * return csElem ; */
private Element writeCoordTransform ( CoverageTransform ct ) { } }

implementation: Element ctElem = new Element ( "coordTransform" ) ; ctElem . setAttribute ( "name" , ct . getName ( ) ) ; ctElem . setAttribute ( "transformType" , ct . isHoriz ( ) ? "Projection" : "Vertical" ) ; for ( Attribute param : ct . getAttributes ( ) ) { Element pElem = ncmlWriter . makeAttributeElement ( param ) ; pElem . setName ( "parameter" ) ; ctElem . addContent ( pElem ) ; } return ctElem ;


signature:
public class AttributeContainerHelper { /** * Add all ; replace old if has same name */
@ Override public void addAll ( Iterable < Attribute > atts ) { } }

implementation: for ( Attribute att : atts ) addAttribute ( att ) ;


signature:
public class AttributeContainerHelper { /** * Remove an Attribute by name .
 * @ param attName if exists , remove this attribute
 * @ return true if was found and removed */
@ Override public boolean removeAttribute ( String attName ) { } }

implementation: Attribute att = findAttribute ( attName ) ; return att != null && atts . remove ( att ) ;


signature:
public class AttributeContainerHelper { /** * Remove an Attribute by name , ignoring case
 * @ param attName if exists , remove this attribute
 * @ return true if was found and removed */
@ Override public boolean removeAttributeIgnoreCase ( String attName ) { } }

implementation: Attribute att = findAttributeIgnoreCase ( attName ) ; return att != null && atts . remove ( att ) ;


signature:
public class CoordinateRuntime { /** * Get offsets from firstDate , in units of timeUnit
 * @ return for each runtime , a list of values from firstdate */
public List < Double > getOffsetsInTimeUnits ( ) { } }

implementation: double start = firstDate . getMillis ( ) ; List < Double > result = new ArrayList < > ( runtimes . length ) ; for ( int idx = 0 ; idx < runtimes . length ; idx ++ ) { double runtime = ( double ) getRuntime ( idx ) ; double msecs = ( runtime - start ) ; result . add ( msecs / timeUnit . getValueInMillisecs ( ) ) ; } return result ;


signature:
public class ActionCoordinator { /** * add an ActionSource listener */
public void addActionSourceListener ( ActionSourceListener l ) { } }

implementation: if ( ! eventType . equals ( l . getEventTypeName ( ) ) ) throw new IllegalArgumentException ( "ActionCoordinator: tried to add ActionSourceListener for wrong kind of Action " + eventType + " != " + l . getEventTypeName ( ) ) ; lm . addListener ( l ) ; l . addActionValueListener ( this ) ;


signature:
public class ActionCoordinator { /** * add an ActionValue listener
 * public void addActionValueListener ( ActionValueListener l ) {
 * lm . addListener ( l ) ;
 * remove an ActionValue listener
 * public void removeActionValueListener ( ActionValueListener l ) {
 * lm . removeListener ( l ) ; */
static public void main ( String [ ] argv ) { } }

implementation:
ActionCoordinator ac = new ActionCoordinator ( "test" ) ; /* System . out . println ( " failure test - - - - - " ) ;
 try {
 ac . addActionSourceListener ( new ActionSourceListener ( " that " ) {
 public void actionPerformed ( java . awt . event . ActionEvent e ) {
 System . out . println ( " event ok " ) ;
 System . out . println ( " good dog ! " ) ;
 } catch ( IllegalArgumentException e ) {
 System . out . println ( " bad dog ! = " + e ) ;
 System . out . println ( " next test - - - - - " ) ; */
ActionSourceListener as1 = new ActionSourceListener ( "test" ) { public void actionPerformed ( ActionValueEvent e ) { System . out . println ( " first listener got event " + e . getValue ( ) ) ; } } ; ac . addActionSourceListener ( as1 ) ; ActionSourceListener as2 = new ActionSourceListener ( "test" ) { public void actionPerformed ( ActionValueEvent e ) { System . out . println ( " second listener got event " + e . getValue ( ) ) ; } } ; ac . addActionSourceListener ( as2 ) ; ActionSourceListener as3 = new ActionSourceListener ( "test" ) { public void actionPerformed ( ActionValueEvent e ) { System . out . println ( " third listener got event " + e . getValue ( ) ) ; } } ; ac . addActionSourceListener ( as3 ) ; as1 . fireActionValueEvent ( "testing" , "newValue 1" ) ; as2 . fireActionValueEvent ( "testing" , "newValue 2" ) ;


signature:
public class OpendapSessionAttributeListener { /** * HttpSessionAttributeListener */
public void attributeRemoved ( HttpSessionBindingEvent e ) { } }

implementation:
if ( e . getValue ( ) instanceof GuardedDataset ) { GuardedDataset gdataset = ( GuardedDataset ) e . getValue ( ) ; gdataset . close ( ) ; // System . out . printf ( " close gdataset % s in session % s % n " , gdataset , e . getSession ( ) . getId ( ) ) ;
// if ( log . isDebugEnabled ( ) ) log . debug ( " close gdataset " + gdataset + " in session " + e . getSession ( ) . getId ( ) ) ;
}


signature:
public class EsriShapefileRenderer { /** * Use factory to obtain a EsriShapefileRenderer . This caches the EsriShapefile for reuse .
 * Implementation note : should switch to weak references . */
static public EsriShapefileRenderer factory ( String filename ) { } }

implementation:
if ( sfileHash == null ) sfileHash = new HashMap < String , EsriShapefileRenderer > ( ) ; if ( sfileHash . containsKey ( filename ) ) return sfileHash . get ( filename ) ; try { EsriShapefileRenderer sfile = new EsriShapefileRenderer ( filename ) ; sfileHash . put ( filename , sfile ) ; return sfile ; } catch ( Exception ex ) { // System . err . println ( " EsriShapefileRenderer failed on " + filename + " \ n " + ex ) ;
// ex . printStackTrace ( ) ;
return null ; }


signature:
public class NcSDInt16 { /** * Read the value ( parameters are ignored ) . */
public boolean read ( String datasetName , Object specialO ) throws IOException { } }

implementation: setData ( ncVar . read ( ) ) ; return ( false ) ;


signature:
public class DString { /** * Prints the value of the variable , with its declaration . This
 * function is primarily intended for debugging OPeNDAP applications and
 * text - based clients such as geturl .
 * @ param os the < code > PrintWriter < / code > on which to print the value .
 * @ param space this value is passed to the < code > printDecl < / code > method ,
 * and controls the leading spaces of the output .
 * @ param print _ decl _ p a boolean value controlling whether the
 * variable declaration is printed as well as the value .
 * @ see BaseType # printVal ( PrintWriter , String , boolean ) */
public void printVal ( PrintWriter os , String space , boolean print_decl_p ) { } }

implementation: if ( print_decl_p ) { printDecl ( os , space , false ) ; os . println ( " = \"" + Util . escattr ( val ) + "\";" ) ; } else os . print ( "\"" + Util . escattr ( val ) + "\"" ) ;


signature:
public class DString { /** * Reads data from a < code > DataInputStream < / code > . This method is only used
 * on the client side of the OPeNDAP client / server connection .
 * @ param source a < code > DataInputStream < / code > to read from .
 * @ param sv the < code > ServerVersion < / code > returned by the server .
 * @ param statusUI the < code > StatusUI < / code > object to use for GUI updates
 * and user cancellation notification ( may be null ) .
 * @ throws EOFException if EOF is found before the variable is completely
 * deserialized .
 * @ throws IOException thrown on any other InputStream exception .
 * @ throws DataReadException if a negative string length was read .
 * @ see ClientIO # deserialize ( DataInputStream , ServerVersion , StatusUI ) */
public synchronized void deserialize ( DataInputStream source , ServerVersion sv , StatusUI statusUI ) throws IOException , EOFException , DataReadException { } }

implementation:
int dap_len = source . readInt ( ) ; // LogStream . out . println ( " DString deserialize string dap _ length : " + dap _ len ) ;
if ( dap_len < 0 ) throw new DataReadException ( "Negative string length (dap_length: " + dap_len + ") read." ) ; if ( dap_len > Short . MAX_VALUE ) throw new DataReadException ( "DString deserialize string length (dap_length: " + dap_len + ") too large." ) ; int modFour = dap_len % 4 ; // number of bytes to pad
int pad = ( modFour != 0 ) ? ( 4 - modFour ) : 0 ; byte byteArray [ ] = new byte [ dap_len ] ; // With blackdown JDK1.1.8v3 ( comes with matlab 6 ) read ( ) didn ' t always
// finish reading a string . readFully ( ) insures that it gets all < dap _ len >
// characters it requested . rph 08/20/01.
// source . read ( byteArray , 0 , dap _ len ) ;
source . readFully ( byteArray , 0 , dap_len ) ; // pad out to a multiple of four bytes
byte unused ; for ( int i = 0 ; i < pad ; i ++ ) unused = source . readByte ( ) ; if ( statusUI != null ) statusUI . incrementByteCount ( 4 + dap_len + pad ) ; // convert bytes to a new String using ISO8859_1 ( Latin 1 ) encoding .
// This was chosen because it converts each byte to its Unicode value
// with no translation ( the first 256 glyphs in Unicode are ISO8859_1)
try { val = new String ( byteArray , 0 , dap_len , "ISO8859_1" ) ; hasValue = true ; } catch ( UnsupportedEncodingException e ) { // this should never happen
throw new UnsupportedEncodingException ( "ISO8859_1 encoding not supported by this VM!" ) ; }


signature:
public class DString { /** * Writes data to a < code > DataOutputStream < / code > . This method is used
 * primarily by GUI clients which need to download OPeNDAP data , manipulate
 * it , and then re - save it as a binary file .
 * @ param sink a < code > DataOutputStream < / code > to write to .
 * @ throws IOException thrown on any < code > OutputStream < / code >
 * exception . */
public void externalize ( DataOutputStream sink ) throws IOException { } }

implementation:
// convert String to a byte array using ISO8859_1 ( Latin 1 ) encoding .
// This was chosen because it converts each byte to its Unicode value
// with no translation ( the first 256 glyphs in Unicode are ISO8859_1)
try { byte byteArray [ ] = val . getBytes ( "ISO8859_1" ) ; sink . writeInt ( byteArray . length ) ; int modFour = byteArray . length % 4 ; // number of bytes to pad
int pad = ( modFour != 0 ) ? ( 4 - modFour ) : 0 ; sink . write ( byteArray , 0 , byteArray . length ) ; for ( int i = 0 ; i < pad ; i ++ ) { sink . writeByte ( 0 ) ; } } catch ( UnsupportedEncodingException e ) { // this should never happen
throw new UnsupportedEncodingException ( "ISO8859_1 encoding not supported by this VM!" ) ; }


signature:
public class ProjectionPointImpl { /** * See if either coordinate is + / - infinite . This happens sometimes
 * in projective geometry .
 * @ return true if either coordinate is + / - infinite . */
public boolean isInfinite ( ) { } }

implementation: return ( x == java . lang . Double . POSITIVE_INFINITY ) || ( x == java . lang . Double . NEGATIVE_INFINITY ) || ( y == java . lang . Double . POSITIVE_INFINITY ) || ( y == java . lang . Double . NEGATIVE_INFINITY ) ;


signature:
public class ProjectionPointImpl { /** * See if either coordinate in < code > pt < / code > is + / - infinite .
 * This happens sometimes in projective geometry .
 * @ param pt point to check
 * @ return true if either coordinate is + / - infinite . */
static public boolean isInfinite ( ProjectionPoint pt ) { } }

implementation: return ( pt . getX ( ) == java . lang . Double . POSITIVE_INFINITY ) || ( pt . getX ( ) == java . lang . Double . NEGATIVE_INFINITY ) || ( pt . getY ( ) == java . lang . Double . POSITIVE_INFINITY ) || ( pt . getY ( ) == java . lang . Double . NEGATIVE_INFINITY ) ;


signature:
public class ChunkingIndex { /** * Computes the shape of the largest possible < b > contiguous < / b > chunk , starting at { @ link # getCurrentCounter ( ) }
 * and with { @ code numElems < = maxChunkElems } .
 * @ param maxChunkElems the maximum number of elements in the chunk shape . The actual element count of the shape
 * returned is likely to be different , and can be found with { @ link Index # computeSize } .
 * @ return the shape of the largest possible contiguous chunk . */
public int [ ] computeChunkShape ( long maxChunkElems ) { } }

implementation: int [ ] chunkShape = new int [ rank ] ; for ( int iDim = 0 ; iDim < rank ; ++ iDim ) { int size = ( int ) ( maxChunkElems / stride [ iDim ] ) ; size = ( size == 0 ) ? 1 : size ; size = Math . min ( size , shape [ iDim ] - current [ iDim ] ) ; chunkShape [ iDim ] = size ; } return chunkShape ;


signature:
public class SizeTByReference { /** * public void setValue ( NativeLong value ) {
 * getPointer ( ) . setNativeLong ( 0 , value ) ;
 * public NativeLong getValue ( ) {
 * return getPointer ( ) . getNativeLong ( 0 ) ; */
public void setValue ( SizeT value ) { } }

implementation: Pointer p = getPointer ( ) ; if ( Native . SIZE_T_SIZE == 8 ) { p . setLong ( 0 , value . longValue ( ) ) ; } else { p . setInt ( 0 , value . intValue ( ) ) ; }


signature:
public class DateUnit { /** * Create a java . util . Date from this udunits String .
 * @ param text a udunit string .
 * < pre > [ number ] ( units ) since [ - ] Y [ Y [ Y [ Y ] ] ] - MM - DD [ ( T | ) hh [ : mm [ : ss [ . sss * ] ] ] [ [ + | - ] hh [ [ : ] mm ] ] ] < / pre >
 * @ return Date or null if not date unit . */
static public Date getStandardDate ( String text ) { } }

implementation:
double value ; String udunitString ; text = text . trim ( ) ; StringTokenizer stoker = new StringTokenizer ( text ) ; String firstToke = stoker . nextToken ( ) ; try { value = Double . parseDouble ( firstToke ) ; udunitString = text . substring ( firstToke . length ( ) ) ; } catch ( NumberFormatException e ) { // stupid way to test if it starts with a number
value = 0.0 ; udunitString = text ; } DateUnit du ; try { du = new DateUnit ( udunitString ) ; } catch ( Exception e ) { return null ; } return du . makeDate ( value ) ;


signature:
public class DateUnit { /** * Create a java . util . Date from a udunit or ISO String .
 * @ param text a udunit or ISO string .
 * @ return Date or null if not date unit .
 * @ see # getStandardDate
 * @ see DateFormatter # getISODate */
static public Date getStandardOrISO ( String text ) { } }

implementation: Date result = getStandardDate ( text ) ; if ( result == null ) { DateFormatter formatter = new DateFormatter ( ) ; result = formatter . getISODate ( text ) ; } return result ;


signature:
public class DateUnit { /** * Get the origin Date .
 * @ return Date or null if not a time unit . */
public Date getDateOrigin ( ) { } }

implementation: if ( ! ( uu instanceof TimeScaleUnit ) ) return null ; TimeScaleUnit tu = ( TimeScaleUnit ) uu ; return tu . getOrigin ( ) ;


signature:
public class DateUnit { /** * Get the equivalent java . util . Date .
 * @ return Date or null if failure */
public Date getDate ( ) { } }

implementation: double secs = timeUnit . getValueInSeconds ( value ) ; return new Date ( getDateOrigin ( ) . getTime ( ) + ( long ) ( 1000 * secs ) ) ;


signature:
public class DateUnit { /** * Create a Date from this base unit and the given value .
 * @ param val value in the units of this base unit , eg sec since base date
 * @ return Date . */
public Date makeDate ( double val ) { } }

implementation: if ( Double . isNaN ( val ) ) return null ; double secs = timeUnit . getValueInSeconds ( val ) ; return new Date ( getDateOrigin ( ) . getTime ( ) + ( long ) ( 1000 * secs ) ) ;


signature:
public class DateUnit { /** * Create the equivalent value from this base unit and the given Date .
 * Inverse of makeDate .
 * @ param date to convert .
 * @ return value in units of this base unit . */
public double makeValue ( Date date ) { } }

implementation: double secs = date . getTime ( ) / 1000.0 ; double origin_secs = getDateOrigin ( ) . getTime ( ) / 1000.0 ; double diff = secs - origin_secs ; try { timeUnit . setValueInSeconds ( diff ) ; } catch ( Exception e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } return timeUnit . getValue ( ) ;


signature:
public class DateUnit { /** * Make a standard GMT string representation from this unit and given value .
 * @ param value of time in these units .
 * @ return String or null if not time unit . */
public String makeStandardDateString ( double value ) { } }

implementation: Date date = makeDate ( value ) ; if ( date == null ) return null ; DateFormatter formatter = new DateFormatter ( ) ; return formatter . toDateTimeStringISO ( date ) ;


signature:
public class GridHorizCoordSys { /** * Get the grid spacing in kilometers
 * @ param type param name
 * @ return the grid spacing in kilometers */
private double getGridSpacingInKm ( String type ) { } }

implementation: double value = gds . getDouble ( type ) ; if ( Double . isNaN ( value ) ) return value ; String gridUnit = gds . getParam ( GridDefRecord . GRID_UNITS ) ; SimpleUnit unit ; if ( gridUnit == null || gridUnit . length ( ) == 0 ) { unit = SimpleUnit . meterUnit ; } else { unit = SimpleUnit . factory ( gridUnit ) ; } if ( unit != null && SimpleUnit . isCompatible ( unit . getUnitString ( ) , "km" ) ) { value = unit . convertTo ( value , SimpleUnit . kmUnit ) ; } return value ;


signature:
public class GridHorizCoordSys { /** * Add the dimensions associated with this coord sys to the netCDF file
 * @ param ncfile netCDF file to add to */
void addDimensionsToNetcdfFile ( NetcdfFile ncfile ) { } }

implementation: if ( isLatLon ) { ncfile . addDimension ( g , new Dimension ( "lat" , gds . getInt ( GridDefRecord . NY ) , true ) ) ; ncfile . addDimension ( g , new Dimension ( "lon" , gds . getInt ( GridDefRecord . NX ) , true ) ) ; } else { ncfile . addDimension ( g , new Dimension ( "y" , gds . getInt ( GridDefRecord . NY ) , true ) ) ; ncfile . addDimension ( g , new Dimension ( "x" , gds . getInt ( GridDefRecord . NX ) , true ) ) ; }


signature:
public class GridHorizCoordSys { /** * Add the variables to the netCDF file
 * @ param ncfile the netCDF file */
void addToNetcdfFile ( NetcdfFile ncfile ) { } }

implementation:
if ( isLatLon ) { double dy ; if ( gds . getDouble ( GridDefRecord . DY ) == GridDefRecord . UNDEFINED ) { dy = setLatLonDxDy ( ) ; } else { dy = ( gds . getDouble ( GridDefRecord . LA2 ) < gds . getDouble ( GridDefRecord . LA1 ) ) ? - gds . getDouble ( GridDefRecord . DY ) : gds . getDouble ( GridDefRecord . DY ) ; } // lat
if ( isGaussian ) { addGaussianLatAxis ( ncfile , "lat" , "degrees_north" , "latitude coordinate" , "latitude" , AxisType . Lat ) ; } else { addCoordAxis ( ncfile , "lat" , gds . getInt ( GridDefRecord . NY ) , gds . getDouble ( GridDefRecord . LA1 ) , dy , "degrees_north" , "latitude coordinate" , "latitude" , AxisType . Lat ) ; } // lon
addCoordAxis ( ncfile , "lon" , gds . getInt ( GridDefRecord . NX ) , gds . getDouble ( GridDefRecord . LO1 ) , gds . getDouble ( GridDefRecord . DX ) , "degrees_east" , "longitude coordinate" , "longitude" , AxisType . Lon ) ; // add dummy variable for lat / lon coord system
addCoordSystemVariable ( ncfile , "latLonCoordSys" , "time lat lon" ) ; } else { int projType = lookup . getProjectionType ( gds ) ; if ( makeProjection ( ncfile , projType ) ) { double [ ] yData , xData ; if ( projType == GridTableLookup . RotatedLatLon ) { double dy = ( gds . getDouble ( "La2" ) < gds . getDouble ( GridDefRecord . LA1 ) ? - gds . getDouble ( GridDefRecord . DY ) : gds . getDouble ( GridDefRecord . DY ) ) ; yData = addCoordAxis ( ncfile , "y" , gds . getInt ( GridDefRecord . NY ) , gds . getDouble ( GridDefRecord . LA1 ) , dy , "degrees" , "y coordinate of projection" , "projection_y_coordinate" , AxisType . GeoY ) ; xData = addCoordAxis ( ncfile , "x" , gds . getInt ( GridDefRecord . NX ) , gds . getDouble ( GridDefRecord . LO1 ) , gds . getDouble ( GridDefRecord . DX ) , "degrees" , "x coordinate of projection" , "projection_x_coordinate" , AxisType . GeoX ) ; } else if ( projType == GridTableLookup . Orthographic ) { yData = addCoordAxis ( ncfile , "y" , gds . getInt ( GridDefRecord . NY ) , starty , incry , "km" , // fake km - really pixel
"y coordinate of projection" , "projection_y_coordinate" , AxisType . GeoY ) ; // dunno what the 3 is
xData = addCoordAxis ( ncfile , "x" , gds . getInt ( GridDefRecord . NX ) , startx , incrx , "km" , "x coordinate of projection" , "projection_x_coordinate" , AxisType . GeoX ) ; } else if ( projType == GridTableLookup . Curvilinear ) { yData = null ; xData = null ; } else { yData = addCoordAxis ( ncfile , "y" , gds . getInt ( GridDefRecord . NY ) , starty , getDyInKm ( ) , "km" , "y coordinate of projection" , "projection_y_coordinate" , AxisType . GeoY ) ; xData = addCoordAxis ( ncfile , "x" , gds . getInt ( GridDefRecord . NX ) , startx , getDxInKm ( ) , "km" , "x coordinate of projection" , "projection_x_coordinate" , AxisType . GeoX ) ; } // optional 2D lat / lon
if ( GridServiceProvider . addLatLon && ( projType != GridTableLookup . Curvilinear ) ) addLatLon2D ( ncfile , xData , yData ) ; } }


signature:
public class GridHorizCoordSys { /** * Add a coordinate axis
 * @ param ncfile the netCDF file to add to
 * @ param name name of the axis
 * @ param n number of points
 * @ param start starting value
 * @ param incr increment between points
 * @ param units units
 * @ param desc description
 * @ param standard _ name standard name
 * @ param axis axis type
 * @ return the coordinate values */
private double [ ] addCoordAxis ( NetcdfFile ncfile , String name , int n , double start , double incr , String units , String desc , String standard_name , AxisType axis ) { } }

implementation:
// ncfile . addDimension ( g , new Dimension ( name , n , true ) ) ;
Variable v = new Variable ( ncfile , g , null , name ) ; v . setDataType ( DataType . DOUBLE ) ; v . setDimensions ( name ) ; // create the data
double [ ] data = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = start + incr * i ; } Array dataArray = Array . factory ( DataType . DOUBLE , new int [ ] { n } , data ) ; v . setCachedData ( dataArray , false ) ; v . addAttribute ( new Attribute ( "units" , units ) ) ; v . addAttribute ( new Attribute ( "long_name" , desc ) ) ; v . addAttribute ( new Attribute ( "standard_name" , standard_name ) ) ; v . addAttribute ( new Attribute ( "grid_spacing" , incr + " " + units ) ) ; v . addAttribute ( new Attribute ( _Coordinate . AxisType , axis . toString ( ) ) ) ; ncfile . addVariable ( g , v ) ; return data ;


signature:
public class GridHorizCoordSys { /** * Add a gaussian lat axis
 * @ param ncfile netCDF file to add to
 * @ param name name of the axis
 * @ param units units
 * @ param desc description
 * @ param standard _ name standard name
 * @ param axis axis type
 * @ return the values */
private double [ ] addGaussianLatAxis ( NetcdfFile ncfile , String name , String units , String desc , String standard_name , AxisType axis ) { } }

implementation:
double np = gds . getDouble ( GridDefRecord . NUMBERPARALLELS ) ; if ( Double . isNaN ( np ) ) np = gds . getDouble ( "Np" ) ; if ( Double . isNaN ( np ) ) throw new IllegalArgumentException ( "Gaussian Lat/Lon grid must have 'NumberParallels' or 'Np' (number of parallels) parameter" ) ; double startLat = gds . getDouble ( GridDefRecord . LA1 ) ; double endLat = gds . getDouble ( GridDefRecord . LA2 ) ; int nlats = ( int ) ( 2 * np ) ; GaussianLatitudes gaussLats = GaussianLatitudes . factory ( nlats ) ; int bestStartIndex = 0 , bestEndIndex = 0 ; double bestStartDiff = Double . MAX_VALUE ; double bestEndDiff = Double . MAX_VALUE ; for ( int i = 0 ; i < nlats ; i ++ ) { double diff = Math . abs ( gaussLats . latd [ i ] - startLat ) ; if ( diff < bestStartDiff ) { bestStartDiff = diff ; bestStartIndex = i ; } diff = Math . abs ( gaussLats . latd [ i ] - endLat ) ; if ( diff < bestEndDiff ) { bestEndDiff = diff ; bestEndIndex = i ; } } int ny = gds . getInt ( GridDefRecord . NY ) ; if ( Math . abs ( bestEndIndex - bestStartIndex + 1 ) != ny ) { log . warn ( "GRIB gaussian lats: NP != NY, use NY" ) ; // see email from Toussaint @ dkrz . de datafil :
nlats = ny ; gaussLats = GaussianLatitudes . factory ( nlats ) ; bestStartIndex = 0 ; bestEndIndex = ny - 1 ; } boolean goesUp = bestEndIndex > bestStartIndex ; Variable v = new Variable ( ncfile , g , null , name ) ; v . setDataType ( DataType . DOUBLE ) ; v . setDimensions ( name ) ; // create the data
int useIndex = bestStartIndex ; double [ ] data = new double [ ny ] ; double [ ] gaussw = new double [ ny ] ; for ( int i = 0 ; i < ny ; i ++ ) { data [ i ] = gaussLats . latd [ useIndex ] ; gaussw [ i ] = gaussLats . gaussw [ useIndex ] ; if ( goesUp ) { useIndex ++ ; } else { useIndex -- ; } } Array dataArray = Array . factory ( DataType . DOUBLE , new int [ ] { ny } , data ) ; v . setCachedData ( dataArray , false ) ; v . addAttribute ( new Attribute ( "units" , units ) ) ; v . addAttribute ( new Attribute ( "long_name" , desc ) ) ; v . addAttribute ( new Attribute ( "standard_name" , standard_name ) ) ; v . addAttribute ( new Attribute ( "weights" , "gaussw" ) ) ; v . addAttribute ( new Attribute ( _Coordinate . AxisType , axis . toString ( ) ) ) ; ncfile . addVariable ( g , v ) ; v = new Variable ( ncfile , g , null , "gaussw" ) ; v . setDataType ( DataType . DOUBLE ) ; v . setDimensions ( name ) ; v . addAttribute ( new Attribute ( "long_name" , "gaussian weights (unnormalized)" ) ) ; dataArray = Array . factory ( DataType . DOUBLE , new int [ ] { ny } , gaussw ) ; v . setCachedData ( dataArray , false ) ; ncfile . addVariable ( g , v ) ; return data ;


signature:
public class GridHorizCoordSys { /** * Make a projection and add it to the netCDF file
 * @ param ncfile netCDF file
 * @ return true if projection was added and coordinates need to be added , false means do nothing */
private boolean makeProjection ( NetcdfFile ncfile , int projType ) { } }

implementation:
switch ( projType ) { case GridTableLookup . RotatedLatLon : makeRotatedLatLon ( ncfile ) ; break ; case GridTableLookup . PolarStereographic : makePS ( ) ; break ; case GridTableLookup . LambertConformal : makeLC ( ) ; break ; case GridTableLookup . Mercator : makeMercator ( ) ; break ; case GridTableLookup . Orthographic : // makeSpaceViewOrOthographic ( ) ;
makeMSGgeostationary ( ) ; break ; case GridTableLookup . Curvilinear : makeCurvilinearAxis ( ncfile ) ; break ; default : throw new UnsupportedOperationException ( "unknown projection = " + gds . getInt ( GridDefRecord . GRID_TYPE ) ) ; } // dummy coordsys variable
Variable v = new Variable ( ncfile , g , null , grid_name ) ; v . setDataType ( DataType . CHAR ) ; v . setDimensions ( "" ) ; // scalar
char [ ] data = new char [ ] { 'd' } ; Array dataArray = Array . factory ( DataType . CHAR , new int [ 0 ] , data ) ; v . setCachedData ( dataArray , false ) ; for ( Attribute att : attributes ) v . addAttribute ( att ) ; // add CF Conventions attributes
v . addAttribute ( new Attribute ( GridCF . EARTH_SHAPE , shape_name ) ) ; // LOOK - spherical earth ? ?
double radius_spherical_earth = gds . getDouble ( GridDefRecord . RADIUS_SPHERICAL_EARTH ) ; // have to check both because Grib1 and Grib2 used different names
if ( Double . isNaN ( radius_spherical_earth ) ) radius_spherical_earth = gds . getDouble ( "radius_spherical_earth" ) ; if ( ! Double . isNaN ( radius_spherical_earth ) ) { // inconsistent - sometimes in km , sometimes in m .
if ( radius_spherical_earth < 10000.00 ) // then its in km
radius_spherical_earth *= 1000.0 ; // convert to meters
v . addAttribute ( new Attribute ( GridCF . EARTH_RADIUS , radius_spherical_earth ) ) ; // this attribute needs to be meters
} else { // oblate earth
double major_axis = gds . getDouble ( GridDefRecord . MAJOR_AXIS_EARTH ) ; if ( Double . isNaN ( major_axis ) ) major_axis = gds . getDouble ( "major_axis_earth" ) ; double minor_axis = gds . getDouble ( GridDefRecord . MINOR_AXIS_EARTH ) ; if ( Double . isNaN ( minor_axis ) ) minor_axis = gds . getDouble ( "minor_axis_earth" ) ; if ( ! Double . isNaN ( major_axis ) && ! Double . isNaN ( minor_axis ) ) { v . addAttribute ( new Attribute ( GridCF . SEMI_MAJOR_AXIS , major_axis ) ) ; v . addAttribute ( new Attribute ( GridCF . SEMI_MINOR_AXIS , minor_axis ) ) ; } } addGDSparams ( v ) ; ncfile . addVariable ( g , v ) ; return true ;


signature:
public class GridHorizCoordSys { /** * Add the GDS params to the variable as attributes
 * @ param v the GDS params . */
private void addGDSparams ( Variable v ) { } }

implementation:
// add all the gds parameters
List < String > keyList = new ArrayList < > ( gds . getKeys ( ) ) ; Collections . sort ( keyList ) ; String pre = getGDSprefix ( ) ; for ( String key : keyList ) { String name = pre + "_param_" + key ; String vals = gds . getParam ( key ) ; try { int vali = Integer . parseInt ( vals ) ; if ( key . equals ( GridDefRecord . VECTOR_COMPONENT_FLAG ) ) { String cf = GridCF . VectorComponentFlag . of ( vali ) ; v . addAttribute ( new Attribute ( name , cf ) ) ; } else { v . addAttribute ( new Attribute ( name , vali ) ) ; } } catch ( Exception e ) { try { double vald = Double . parseDouble ( vals ) ; v . addAttribute ( new Attribute ( name , vald ) ) ; } catch ( Exception e2 ) { v . addAttribute ( new Attribute ( name , vals ) ) ; } } }


signature:
public class GridHorizCoordSys { /** * Add coordinate system variable
 * @ param ncfile netCDF file
 * @ param name name of the variable
 * @ param dims dimensions */
private void addCoordSystemVariable ( NetcdfFile ncfile , String name , String dims ) { } }

implementation:
Variable v = new Variable ( ncfile , g , null , name ) ; v . setDataType ( DataType . CHAR ) ; v . setDimensions ( "" ) ; // scalar
Array dataArray = Array . factory ( DataType . CHAR , new int [ 0 ] , new char [ ] { '0' } ) ; v . setCachedData ( dataArray , false ) ; v . addAttribute ( new Attribute ( _Coordinate . Axes , dims ) ) ; if ( isLatLon ( ) ) v . addAttribute ( new Attribute ( _Coordinate . Transforms , "" ) ) ; // to make sure its identified as a Coordinate System Variable
else v . addAttribute ( new Attribute ( _Coordinate . Transforms , getGridName ( ) ) ) ; addGDSparams ( v ) ; ncfile . addVariable ( g , v ) ;


signature:
public class GridHorizCoordSys { /** * Make a LambertConformalConic projection */
private void makeLC ( ) { } }

implementation:
// we have to project in order to find the origin
proj = new LambertConformal ( gds . getDouble ( GridDefRecord . LATIN1 ) , gds . getDouble ( GridDefRecord . LOV ) , gds . getDouble ( GridDefRecord . LATIN1 ) , gds . getDouble ( GridDefRecord . LATIN2 ) ) ; LatLonPointImpl startLL = new LatLonPointImpl ( gds . getDouble ( GridDefRecord . LA1 ) , gds . getDouble ( GridDefRecord . LO1 ) ) ; ProjectionPointImpl start = ( ProjectionPointImpl ) proj . latLonToProj ( startLL ) ; startx = start . getX ( ) ; starty = start . getY ( ) ; if ( Double . isNaN ( getDxInKm ( ) ) ) { setDxDy ( startx , starty , proj ) ; } if ( GridServiceProvider . debugProj ) { System . out . println ( "GridHorizCoordSys.makeLC start at latlon " + startLL ) ; double Lo2 = gds . getDouble ( GridDefRecord . LO2 ) ; double La2 = gds . getDouble ( GridDefRecord . LA2 ) ; LatLonPointImpl endLL = new LatLonPointImpl ( La2 , Lo2 ) ; System . out . println ( "GridHorizCoordSys.makeLC end at latlon " + endLL ) ; ProjectionPointImpl endPP = ( ProjectionPointImpl ) proj . latLonToProj ( endLL ) ; System . out . println ( "   end at proj coord " + endPP ) ; double endx = startx + getNx ( ) * getDxInKm ( ) ; double endy = starty + getNy ( ) * getDyInKm ( ) ; System . out . println ( "   should be x=" + endx + " y=" + endy ) ; } attributes . add ( new Attribute ( GridCF . GRID_MAPPING_NAME , "lambert_conformal_conic" ) ) ; if ( gds . getDouble ( GridDefRecord . LATIN1 ) == gds . getDouble ( GridDefRecord . LATIN2 ) ) { attributes . add ( new Attribute ( GridCF . STANDARD_PARALLEL , gds . getDouble ( GridDefRecord . LATIN1 ) ) ) ; } else { double [ ] data = new double [ ] { gds . getDouble ( GridDefRecord . LATIN1 ) , gds . getDouble ( GridDefRecord . LATIN2 ) } ; attributes . add ( new Attribute ( GridCF . STANDARD_PARALLEL , Array . factory ( DataType . DOUBLE , new int [ ] { 2 } , data ) ) ) ; } // attributes . add ( new Attribute ( " longitude _ of _ central _ meridian " ,
attributes . add ( new Attribute ( GridCF . LONGITUDE_OF_CENTRAL_MERIDIAN , gds . getDouble ( GridDefRecord . LOV ) ) ) ; // attributes . add ( new Attribute ( " latitude _ of _ projection _ origin " ,
attributes . add ( new Attribute ( GridCF . LATITUDE_OF_PROJECTION_ORIGIN , gds . getDouble ( GridDefRecord . LATIN1 ) ) ) ;


signature:
public class GridHorizCoordSys { /** * Make a PolarStereographic projection */
private void makePS ( ) { } }

implementation:
String nproj = gds . getParam ( GridDefRecord . NPPROJ ) ; double latOrigin = ( nproj == null || nproj . equalsIgnoreCase ( "true" ) ) ? 90.0 : - 90.0 ; // Why the scale factor ? . according to GRIB docs :
// " Grid lengths are in units of meters , at the 60 degree latitude circle nearest to the pole "
// since the scale factor at 60 degrees = k = 2 * k0 / ( 1 + sin ( 60 ) ) [ Snyder , Working Manual p157]
// then to make scale = 1 at 60 degrees , k0 = ( 1 + sin ( 60 ) ) / 2 = . 933
double scale ; double lad = gds . getDouble ( GridDefRecord . LAD ) ; if ( Double . isNaN ( lad ) ) { scale = .933 ; } else { scale = ( 1.0 + Math . sin ( Math . toRadians ( Math . abs ( lad ) ) ) ) / 2 ; } proj = new Stereographic ( latOrigin , gds . getDouble ( GridDefRecord . LOV ) , scale ) ; // we have to project in order to find the origin
ProjectionPointImpl start = ( ProjectionPointImpl ) proj . latLonToProj ( new LatLonPointImpl ( gds . getDouble ( GridDefRecord . LA1 ) , gds . getDouble ( GridDefRecord . LO1 ) ) ) ; startx = start . getX ( ) ; starty = start . getY ( ) ; if ( Double . isNaN ( getDxInKm ( ) ) ) setDxDy ( startx , starty , proj ) ; if ( GridServiceProvider . debugProj ) { System . out . printf ( "starting proj coord %s lat/lon %s%n" , start , proj . projToLatLon ( start ) ) ; System . out . println ( "   should be LA1=" + gds . getDouble ( GridDefRecord . LA1 ) + " l)1=" + gds . getDouble ( GridDefRecord . LO1 ) ) ; } attributes . add ( new Attribute ( GridCF . GRID_MAPPING_NAME , "polar_stereographic" ) ) ; // attributes . add ( new Attribute ( " longitude _ of _ projection _ origin " ,
attributes . add ( new Attribute ( GridCF . LONGITUDE_OF_PROJECTION_ORIGIN , gds . getDouble ( GridDefRecord . LOV ) ) ) ; // attributes . add ( new Attribute ( " straight _ vertical _ longitude _ from _ pole " ,
attributes . add ( new Attribute ( GridCF . STRAIGHT_VERTICAL_LONGITUDE_FROM_POLE , gds . getDouble ( GridDefRecord . LOV ) ) ) ; // attributes . add ( new Attribute ( " scale _ factor _ at _ projection _ origin " ,
attributes . add ( new Attribute ( GridCF . SCALE_FACTOR_AT_PROJECTION_ORIGIN , scale ) ) ; attributes . add ( new Attribute ( GridCF . LATITUDE_OF_PROJECTION_ORIGIN , latOrigin ) ) ;


signature:
public class GridHorizCoordSys { /** * RotatedLatLon */
private void makeRotatedLatLon ( NetcdfFile ncfile ) { } }

implementation:
double splat = gds . getDouble ( GridDefRecord . SPLAT ) ; double splon = gds . getDouble ( GridDefRecord . SPLON ) ; double spangle = gds . getDouble ( GridDefRecord . ROTATIONANGLE ) ; // Given projection coordinates , need LatLon coordinates
proj = new RotatedLatLon ( splat , splon , spangle ) ; LatLonPoint startLL = proj . projToLatLon ( new ProjectionPointImpl ( gds . getDouble ( GridDefRecord . LO1 ) , gds . getDouble ( GridDefRecord . LA1 ) ) ) ; startx = startLL . getLongitude ( ) ; starty = startLL . getLatitude ( ) ; addCoordSystemVariable ( ncfile , "latLonCoordSys" , "time y x" ) ; // splat , splon , spangle
attributes . add ( new Attribute ( GridCF . GRID_MAPPING_NAME , "rotated_latlon_grib" ) ) ; attributes . add ( new Attribute ( "grid_south_pole_latitude" , splat ) ) ; attributes . add ( new Attribute ( "grid_south_pole_longitude" , splon ) ) ; attributes . add ( new Attribute ( "grid_south_pole_angle" , spangle ) ) ; if ( GridServiceProvider . debugProj ) { System . out . println ( "Location of pole of rotated grid:" ) ; System . out . println ( "Lon=" + splon + ", Lat=" + splat ) ; System . out . println ( "Axial rotation about pole of rotated grid:" + spangle ) ; System . out . println ( "Location of LL in rotated grid:" ) ; System . out . println ( "Lon=" + gds . getDouble ( GridDefRecord . LO1 ) + ", " + "Lat=" + gds . getDouble ( GridDefRecord . LA1 ) ) ; System . out . println ( "Location of LL in non-rotated grid:" ) ; System . out . println ( "Lon=" + startx + ", Lat=" + starty ) ; double Lo2 = gds . getDouble ( GridDefRecord . LO2 ) ; double La2 = gds . getDouble ( GridDefRecord . LA2 ) ; System . out . println ( "Location of UR in rotated grid:" ) ; System . out . println ( "Lon=" + Lo2 + ", Lat=" + La2 ) ; System . out . println ( "Location of UR in non-rotated grid:" ) ; LatLonPoint endUR = proj . projToLatLon ( new ProjectionPointImpl ( Lo2 , La2 ) ) ; System . out . println ( "Lon=" + endUR . getLongitude ( ) + ", Lat=" + endUR . getLatitude ( ) ) ; double dy = ( La2 < gds . getDouble ( GridDefRecord . LA1 ) ) ? - gds . getDouble ( GridDefRecord . DY ) : gds . getDouble ( GridDefRecord . DY ) ; double endx = gds . getDouble ( GridDefRecord . LO1 ) + ( getNx ( ) - 1 ) * gds . getDouble ( GridDefRecord . DX ) ; double endy = gds . getDouble ( GridDefRecord . LA1 ) + ( getNy ( ) - 1 ) * dy ; System . out . println ( "End point rotated grid should be x=" + endx + " y=" + endy ) ; }


signature:
public class GridHorizCoordSys { /** * Make a Space View Orthographic projection */
private void makeSpaceViewOrOthographic ( ) { } }

implementation:
double Lat0 = gds . getDouble ( GridDefRecord . LAP ) ; // sub - satellite point lat
double Lon0 = gds . getDouble ( GridDefRecord . LOP ) ; // sub - satellite point lon
double xp = gds . getDouble ( GridDefRecord . XP ) ; // sub - satellite point in grid lengths
double yp = gds . getDouble ( GridDefRecord . YP ) ; double dx = gds . getDouble ( GridDefRecord . DX ) ; // apparent diameter in units of grid lengths
double dy = gds . getDouble ( GridDefRecord . DY ) ; // have to check both names because Grib1 and Grib2 used different names
double major_axis = gds . getDouble ( GridDefRecord . MAJOR_AXIS_EARTH ) ; // km
if ( Double . isNaN ( major_axis ) ) major_axis = gds . getDouble ( "major_axis_earth" ) ; double minor_axis = gds . getDouble ( GridDefRecord . MINOR_AXIS_EARTH ) ; // km
if ( Double . isNaN ( minor_axis ) ) minor_axis = gds . getDouble ( "minor_axis_earth" ) ; // Nr = altitude of camera from center , in units of radius
double nr = gds . getDouble ( GridDefRecord . NR ) * 1e-6 ; double apparentDiameter = 2 * Math . sqrt ( ( nr - 1 ) / ( nr + 1 ) ) ; // apparent diameter , units of radius ( see Snyder p 173)
// app diameter kmeters / app diameter grid lengths = m per grid length
double gridLengthX = major_axis * apparentDiameter / dx ; double gridLengthY = minor_axis * apparentDiameter / dy ; // have to add to both for consistency
gds . addParam ( GridDefRecord . DX , String . valueOf ( 1000 * gridLengthX ) ) ; // meters
gds . addParam ( GridDefRecord . DX , new Double ( 1000 * gridLengthX ) ) ; gds . addParam ( GridDefRecord . DY , String . valueOf ( 1000 * gridLengthY ) ) ; // meters
gds . addParam ( GridDefRecord . DY , new Double ( 1000 * gridLengthY ) ) ; startx = - gridLengthX * xp ; // km
starty = - gridLengthY * yp ; double radius = Earth . getRadius ( ) / 1000.0 ; // km
if ( nr == 1111111111.0 ) { // LOOK : not sure how all ones will appear as a double , need example
proj = new Orthographic ( Lat0 , Lon0 , radius ) ; attributes . add ( new Attribute ( GridCF . GRID_MAPPING_NAME , "orthographic" ) ) ; attributes . add ( new Attribute ( GridCF . LONGITUDE_OF_PROJECTION_ORIGIN , Lon0 ) ) ; attributes . add ( new Attribute ( GridCF . LATITUDE_OF_PROJECTION_ORIGIN , Lat0 ) ) ; } else { // " space view perspective "
double height = ( nr - 1.0 ) * radius ; // height = the height of the observing camera in km
proj = new VerticalPerspectiveView ( Lat0 , Lon0 , radius , height ) ; attributes . add ( new Attribute ( GridCF . GRID_MAPPING_NAME , "vertical_perspective" ) ) ; attributes . add ( new Attribute ( GridCF . LONGITUDE_OF_PROJECTION_ORIGIN , Lon0 ) ) ; attributes . add ( new Attribute ( GridCF . LATITUDE_OF_PROJECTION_ORIGIN , Lat0 ) ) ; attributes . add ( new Attribute ( "height_above_earth" , height ) ) ; } if ( GridServiceProvider . debugProj ) { double Lo2 = gds . getDouble ( GridDefRecord . LO2 ) + 360.0 ; double La2 = gds . getDouble ( GridDefRecord . LA2 ) ; LatLonPointImpl endLL = new LatLonPointImpl ( La2 , Lo2 ) ; System . out . println ( "GridHorizCoordSys.makeOrthographic end at latlon " + endLL ) ; ProjectionPointImpl endPP = ( ProjectionPointImpl ) proj . latLonToProj ( endLL ) ; System . out . println ( "   end at proj coord " + endPP ) ; double endx = startx + getNx ( ) * getDxInKm ( ) ; double endy = starty + getNy ( ) * getDyInKm ( ) ; System . out . println ( "   should be x=" + endx + " y=" + endy ) ; }


signature:
public class GridHorizCoordSys { /** * Make a Eumetsat MSG " Normalized Geostationary Projection " projection .
 * Fake coordinates for now , then see if this can be generalized .
 * from FM 92 GRIB - 2 doc :
 * Grid Definition Template 3.90 : Space view perspective or orthographic
 * Octet Number ( s ) Contents
 * 15 Shape of the earth ( see Code Table 3.2)
 * 16 Scale factor of radius of spherical earth
 * 17-20 Scaled value of radius of spherical earth
 * 21 Scale factor of major axis of oblate spheroid earth
 * 22-25 Scaled value of major axis of oblate spheroid earth
 * 26 Scale factor of minor axis of oblate spheroid earth
 * 27-30 Scaled value of minor axis of oblate spheroid earth
 * 31-34 Nx - number of points along X - axis ( columns )
 * 35-38 Ny - number of points along Y - axis ( rows or lines )
 * 39-42 Lap - latitude of sub - satellite point
 * 43-46 Lop - longitude of sub - satellite point
 * 47 Resolution and component flags ( see Flag Table 3.3)
 * 48-51 dx - apparent diameter of Earth in grid lengths , in X - direction
 * 52-55 dy - apparent diameter of Earth in grid lengths , in Y - direction
 * 56-59 Xp - X - coordinate of sub - satellite point ( in units of 10-3 grid length expressed as an integer )
 * 60-63 Yp - Y - coordinate of sub - satellite point ( in units of 10-3 grid length expressed as an integer )
 * 64 Scanning mode ( flags - see Flag Table 3.4)
 * 65-68 Orientation of the grid ; i . e . , the angle between the increasing Y - axis and the meridian of the sub - satellite point in the direction of increasing latitude ( see Note 3)
 * 69-72 Nr - altitude of the camera from the Earths centre , measured in units of the Earth ( equatorial ) radius multiplied by a scale factor of 10 6 ( see Notes 4 and 5)
 * 73-76 Xo - X - coordinate of origin of sector image
 * 77-80 Yo - Y - coordinate of origin of sector image
 * Notes :
 * ( 1 ) It is assumed that the satellite is at its nominal position , i . e . , it is looking directly at its sub - satellite point .
 * ( 2 ) Octets 69-72 shall be set to all ones ( missing ) to indicate the orthographic view ( from infinite distance )
 * ( 3 ) It is the angle between the increasing Y - axis and the meridian 180E if the sub - satellite point is the North Pole ; or the meridian 0 if the sub - satellite point is the South Pole .
 * ( 4 ) The apparent angular size of the Earth will be given by 2 * Arcsin ( 10 ^ 6 ) / Nr ) .
 * ( 5 ) For orthographic view from infinite distance , the value of Nr should be encoded as missing ( all bits set to 1 ) .
 * ( 6 ) The horizontal and vertical angular resolutions of the sensor ( Rx and Ry ) , needed for navigation equation , can be calculated from the following :
 * Rx = 2 * Arcsin ( 106 ) / Nr ) / dx
 * Ry = 2 * Arcsin ( 106 ) / Nr ) / dy
 * from simon . elliott @ eumetsat . int
 * For products on a single pixel resolution grid , the scan angle is 83.84333 E - 6 rad .
 * So dx = 2 * arcsin ( 10e6 / Nr ) / 83.84333 E - 6 = 3622.30 , which encoded to the nearest integer is 3622.
 * This is correctly encoded in our products .
 * For products on a 3x3 pixel resolution grid , the scan angle is 3 * 83.84333 E - 6 rad = 251.52999 E - 6 rad .
 * So dx = 2 * arcsin ( 10e6 / Nr ) / 251.52999 E - 6 = 1207.43 , which encoded to the nearest integer is 1207.
 * This is correctly encoded in our products .
 * Due to the elliptical shape of the earth , the calculation is a bit different in the y direction ( Nr is in multiples of
 * the equatorial radius , but the tangent point is much closer to the polar radius from the earth ' s centre .
 * Approximating that the tangent point is actually at the polar radius from the earth ' s centre :
 * The sine of the angle subtended by the Earths centre and the tangent point on the equator as seen from the spacecraft
 * = Rp / ( ( Nr * Re ) / 10 ^ 6 ) = ( Rp * 10 ^ 6 ) / ( Re * Nr )
 * The angle subtended by the Earth equator as seen by the spacecraft is , by symmetry twice the inverse sine above ,
 * = 2 * arcsine ( ( Rp * 10 ^ 6 ) / ( Re * Nr ) )
 * For products on a single pixel resolution grid , the scan angle is 83.84333 E - 6 rad .
 * So dy = 2 * arcsine ( ( Rp * 10 ^ 6 ) / ( Re * Nr ) ) / 83.84333 E - 6 = 3610.06 , which encoded to the nearest integer is 3610.
 * This is currently encoded in our products as 3568.
 * For products on a 3x3 pixel resolution grid , the scan angle is 3 * 83.84333 E - 6 rad = 251.52999 E - 6 rad .
 * So dy = 2 * arcsine ( ( Rp * 10 ^ 6 ) / ( Re * Nr ) ) / 251.52999 E - 6 = 1203.35 , which encoded to the nearest integer is 1203.
 * This is currently encoded in our products as 1189.
 * As you can see the dx and dy values we are using will lead to an error of around 1 % in the y direction .
 * I will ensure that the values are corrected to those explained here ( 3610 and 1203 ) as soon as possible . */
private void makeMSGgeostationary ( ) { } }

implementation:
double Lat0 = gds . getDouble ( GridDefRecord . LAP ) ; // sub - satellite point lat
double Lon0 = gds . getDouble ( GridDefRecord . LOP ) ; // sub - satellite point lon
// int nx = gds . getInt ( GridDefRecord . NX ) ;
int ny = gds . getInt ( GridDefRecord . NY ) ; int x_off = gds . getInt ( GridDefRecord . XP ) ; // sub - satellite point in grid lengths
int y_off = gds . getInt ( GridDefRecord . YP ) ; double dx ; // = gds . getDouble ( GridDefRecord . DX ) ; / / apparent diameter of earth in units of grid lengths
double dy = gds . getDouble ( GridDefRecord . DY ) ; // per Simon Eliot 1/18/2010 , there is a bug in Eumetsat grib files ,
// we need to " correct for ellipsoidal earth "
// ( Note we should check who the originating center is
// " Originating _ center " = " EUMETSAT Operation Centre " in the GRIB id ( section 1 ) )
// although AFAIK , eumetsat is only one using this projection .
if ( dy < 2100 ) { dx = 1207 ; dy = 1203 ; } else { dx = 3622 ; dy = 3610 ; } // have to check both names because Grib1 and Grib2 used different names
double major_axis = gds . getDouble ( GridDefRecord . MAJOR_AXIS_EARTH ) ; if ( Double . isNaN ( major_axis ) ) major_axis = gds . getDouble ( "major_axis_earth" ) ; double minor_axis = gds . getDouble ( GridDefRecord . MINOR_AXIS_EARTH ) ; if ( Double . isNaN ( minor_axis ) ) minor_axis = gds . getDouble ( "minor_axis_earth" ) ; // Nr = altitude of camera from center , in units of radius
double nr = gds . getDouble ( GridDefRecord . NR ) * 1e-6 ; // altitude of the camera from the Earths centre , measured in units of the Earth ( equatorial ) radius
// CFAC = 2 ^ 16 / { [ 2 * arcsine ( 10 ^ 6 / Nr ) ] / dx }
double as = 2 * Math . asin ( 1.0 / nr ) ; double cfac = dx / as ; double lfac = dy / as ; // use km , so scale by the earth radius
double scale_factor = ( nr - 1 ) * major_axis / 1000 ; // this sets the units of the projection x , y coords in km
double scale_x = scale_factor ; // LOOK fake neg need scan value
double scale_y = - scale_factor ; // LOOK fake neg need scan value
startx = scale_factor * ( 1 - x_off ) / cfac ; starty = scale_factor * ( y_off - ny ) / lfac ; incrx = scale_factor / cfac ; incry = scale_factor / lfac ; attributes . add ( new Attribute ( GridCF . GRID_MAPPING_NAME , "MSGnavigation" ) ) ; attributes . add ( new Attribute ( GridCF . LONGITUDE_OF_PROJECTION_ORIGIN , Lon0 ) ) ; attributes . add ( new Attribute ( GridCF . LATITUDE_OF_PROJECTION_ORIGIN , Lat0 ) ) ; // attributes . add ( new Attribute ( " semi _ major _ axis " , new Double ( major _ axis ) ) ) ;
// attributes . add ( new Attribute ( " semi _ minor _ axis " , new Double ( minor _ axis ) ) ) ;
attributes . add ( new Attribute ( "height_from_earth_center" , nr * major_axis ) ) ; attributes . add ( new Attribute ( "scale_x" , scale_x ) ) ; attributes . add ( new Attribute ( "scale_y" , scale_y ) ) ; proj = new MSGnavigation ( Lat0 , Lon0 , major_axis , minor_axis , nr * major_axis , scale_x , scale_y ) ; if ( GridServiceProvider . debugProj ) { double Lo2 = gds . getDouble ( GridDefRecord . LO2 ) + 360.0 ; double La2 = gds . getDouble ( GridDefRecord . LA2 ) ; LatLonPointImpl endLL = new LatLonPointImpl ( La2 , Lo2 ) ; System . out . println ( "GridHorizCoordSys.makeMSGgeostationary end at latlon " + endLL ) ; ProjectionPointImpl endPP = ( ProjectionPointImpl ) proj . latLonToProj ( endLL ) ; System . out . println ( "   end at proj coord " + endPP ) ; double endx = 1 + getNx ( ) ; double endy = 1 + getNy ( ) ; System . out . println ( "   should be x=" + endx + " y=" + endy ) ; }


signature:
public class GridHorizCoordSys { /** * CurvilinearAxis
 * Make lat / lon axis from variables that start with Latitude / Longitude and then
 * add the coordinates to the variables . This code is based on the ofs _ atl files
 * received from Rich Signell . This code is rigid because it expects coordinate names
 * to start with Latitude / Longitude and other coordinate of depth .
 * @ param ncfile NetcdfFile */
private void makeCurvilinearAxis ( NetcdfFile ncfile ) { } }

implementation:
List < Variable > vars = ncfile . getRootGroup ( ) . getVariables ( ) ; String latpp = null , lonpp = null , latU = null , lonU = null , latV = null , lonV = null ; // has to be done twice because there ' s no guarantee that the
// coordinate variables will be accessed first
List < String > timeDimLL = new ArrayList < > ( ) ; List < String > timeDimV = new ArrayList < > ( ) ; for ( Variable var : vars ) { if ( var . getShortName ( ) . startsWith ( "Latitude" ) ) { // remove time dependency
int [ ] shape = var . getShape ( ) ; if ( var . getRank ( ) == 3 && shape [ 0 ] == 1 ) { // remove time dependencies - MAJOR KLUDGE
List < Dimension > dims = var . getDimensions ( ) ; if ( ! timeDimLL . contains ( dims . get ( 0 ) . getShortName ( ) ) ) timeDimLL . add ( dims . get ( 0 ) . getShortName ( ) ) ; dims . remove ( 0 ) ; var . setDimensions ( dims ) ; } // add lat attributes
var . addAttribute ( new Attribute ( "units" , "degrees_north" ) ) ; var . addAttribute ( new Attribute ( "long_name" , "latitude coordinate" ) ) ; var . addAttribute ( new Attribute ( "standard_name" , "latitude" ) ) ; var . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lat . toString ( ) ) ) ; if ( var . getShortName ( ) . contains ( "U_Wind_Component" ) ) { latU = var . getFullName ( ) ; } else if ( var . getShortName ( ) . contains ( "V_Wind_Component" ) ) { latV = var . getFullName ( ) ; } else { latpp = var . getFullName ( ) ; } } else if ( var . getShortName ( ) . startsWith ( "Longitude" ) ) { // remove time dependency
int [ ] shape = var . getShape ( ) ; if ( var . getRank ( ) == 3 && shape [ 0 ] == 1 ) { // remove time dependencies - MAJOR KLUDGE
List < Dimension > dims = var . getDimensions ( ) ; if ( ! timeDimLL . contains ( dims . get ( 0 ) . getShortName ( ) ) ) timeDimLL . add ( dims . get ( 0 ) . getShortName ( ) ) ; dims . remove ( 0 ) ; var . setDimensions ( dims ) ; } // add lon attributes
var . addAttribute ( new Attribute ( "units" , "degrees_east" ) ) ; var . addAttribute ( new Attribute ( "long_name" , "longitude coordinate" ) ) ; var . addAttribute ( new Attribute ( "standard_name" , "longitude" ) ) ; var . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lon . toString ( ) ) ) ; if ( var . getShortName ( ) . contains ( "U_Wind_Component" ) ) { lonU = var . getFullName ( ) ; } else if ( var . getShortName ( ) . contains ( "V_Wind_Component" ) ) { lonV = var . getFullName ( ) ; } else { lonpp = var . getFullName ( ) ; } } } // add coordinates attribute to variables
for ( Variable var : vars ) { List < Dimension > dims = var . getDimensions ( ) ; if ( var . getShortName ( ) . startsWith ( "U-component" ) ) { var . addAttribute ( new Attribute ( "coordinates" , latU + " " + lonU ) ) ; if ( ! timeDimV . contains ( dims . get ( 0 ) . getShortName ( ) ) ) timeDimV . add ( dims . get ( 0 ) . getShortName ( ) ) ; } else if ( var . getShortName ( ) . startsWith ( "V-component" ) ) { var . addAttribute ( new Attribute ( "coordinates" , latV + " " + lonV ) ) ; if ( ! timeDimV . contains ( dims . get ( 0 ) . getShortName ( ) ) ) timeDimV . add ( dims . get ( 0 ) . getShortName ( ) ) ; // rest of variables default to Pressure _ Point
} else { var . addAttribute ( new Attribute ( "coordinates" , latpp + " " + lonpp ) ) ; if ( ! timeDimV . contains ( dims . get ( 0 ) . getShortName ( ) ) ) timeDimV . add ( dims . get ( 0 ) . getShortName ( ) ) ; } } /* remove Latitude / Longitude time dimension and variable if possible
 for ( String tdLL : timeDimLL ) {
 if ( timeDimV . contains ( tdLL ) )
 continue ;
 / / else only used with Lat / Lon
 ncfile . getRootGroup ( ) . removeDimension ( tdLL ) ;
 ncfile . getRootGroup ( ) . removeVariable ( tdLL ) ; */


signature:
public class GridHorizCoordSys { /** * Calculate the dx and dy from startx , starty and projection .
 * @ param startx starting x projection point
 * @ param starty starting y projection point
 * @ param proj projection for transform */
private void setDxDy ( double startx , double starty , ProjectionImpl proj ) { } }

implementation: double Lo2 = gds . getDouble ( GridDefRecord . LO2 ) ; double La2 = gds . getDouble ( GridDefRecord . LA2 ) ; if ( Double . isNaN ( Lo2 ) || Double . isNaN ( La2 ) ) { return ; } LatLonPointImpl endLL = new LatLonPointImpl ( La2 , Lo2 ) ; ProjectionPointImpl end = ( ProjectionPointImpl ) proj . latLonToProj ( endLL ) ; double dx = Math . abs ( end . getX ( ) - startx ) / ( gds . getInt ( GridDefRecord . NX ) - 1 ) ; double dy = Math . abs ( end . getY ( ) - starty ) / ( gds . getInt ( GridDefRecord . NY ) - 1 ) ; gds . addParam ( GridDefRecord . DX , String . valueOf ( dx ) ) ; gds . addParam ( GridDefRecord . DY , String . valueOf ( dy ) ) ; gds . addParam ( GridDefRecord . GRID_UNITS , "km" ) ;


signature:
public class GridHorizCoordSys { /** * Calculate Dx Dy Lat Lon Grid
 * Note : this assumes lo1 < lo2 and dx is positive going east
 * @ return dy double */
private double setLatLonDxDy ( ) { } }

implementation:
double lo1 = gds . getDouble ( GridDefRecord . LO1 ) ; double la1 = gds . getDouble ( GridDefRecord . LA1 ) ; double lo2 = gds . getDouble ( GridDefRecord . LO2 ) ; double la2 = gds . getDouble ( GridDefRecord . LA2 ) ; if ( Double . isNaN ( lo2 ) || Double . isNaN ( la2 ) ) { return Double . NaN ; } if ( lo2 < lo1 ) lo2 += 360 ; double dx = Math . abs ( lo2 - lo1 ) / ( gds . getInt ( GridDefRecord . NX ) - 1 ) ; double dy = Math . abs ( la2 - la1 ) / ( gds . getInt ( GridDefRecord . NY ) - 1 ) ; gds . addParam ( GridDefRecord . DX , String . valueOf ( dx ) ) ; gds . addParam ( GridDefRecord . DY , String . valueOf ( dy ) ) ; // in case someone checked on these before , we need to override
gds . addParam ( GridDefRecord . DX , new Double ( dx ) ) ; gds . addParam ( GridDefRecord . DY , new Double ( dy ) ) ; gds . addParam ( GridDefRecord . GRID_UNITS , "degree" ) ; return dy ;


signature: public class InvCatalogFactory10 { protected InvAccessImpl readAccess ( InvDatasetImpl dataset , Element accessElem ) { } }

implementation: String urlPath = accessElem . getAttributeValue ( "urlPath" ) ; String serviceName = accessElem . getAttributeValue ( "serviceName" ) ; String dataFormat = accessElem . getAttributeValue ( "dataFormat" ) ; return new InvAccessImpl ( dataset , urlPath , serviceName , null , dataFormat , readDataSize ( accessElem ) ) ;


signature:
public class InvCatalogFactory10 { /** * read a dataset element */
protected InvDatasetImpl readDataset ( InvCatalogImpl catalog , InvDatasetImpl parent , Element dsElem , URI base ) { } }

implementation:
// deal with aliases
String name = dsElem . getAttributeValue ( "name" ) ; String alias = dsElem . getAttributeValue ( "alias" ) ; if ( alias != null ) { InvDatasetImpl ds = ( InvDatasetImpl ) catalog . findDatasetByID ( alias ) ; if ( ds == null ) { factory . appendErr ( " ** Parse error: dataset named " + name + " has illegal alias = " + alias + "\n" ) ; return null ; } return new InvDatasetImplProxy ( name , ds ) ; } InvDatasetImpl dataset = new InvDatasetImpl ( parent , name ) ; readDatasetInfo ( catalog , dataset , dsElem , base ) ; if ( InvCatalogFactory . debugXML ) System . out . println ( " Dataset added: " + dataset . dump ( ) ) ; return dataset ;


signature:
public class InvCatalogFactory10 { /** * read a dataset scan element */
protected InvDatasetScan readDatasetScan ( InvCatalogImpl catalog , InvDatasetImpl parent , Element dsElem , URI base ) { } }

implementation: InvDatasetScan datasetScan ; if ( dsElem . getAttributeValue ( "dirLocation" ) == null ) { if ( dsElem . getAttributeValue ( "location" ) == null ) { logger . error ( "readDatasetScan(): datasetScan has neither a \"location\" nor a \"dirLocation\" attribute." ) ; datasetScan = null ; } else { return readDatasetScanNew ( catalog , parent , dsElem , base ) ; } } else { String name = dsElem . getAttributeValue ( "name" ) ; factory . appendWarning ( "**Warning: Dataset " + name + " using old form of DatasetScan (dirLocation instead of location)\n" ) ; String path = dsElem . getAttributeValue ( "path" ) ; String scanDir = expandAliasForPath ( dsElem . getAttributeValue ( "dirLocation" ) ) ; String filter = dsElem . getAttributeValue ( "filter" ) ; String addDatasetSizeString = dsElem . getAttributeValue ( "addDatasetSize" ) ; String addLatest = dsElem . getAttributeValue ( "addLatest" ) ; String sortOrderIncreasingString = dsElem . getAttributeValue ( "sortOrderIncreasing" ) ; boolean sortOrderIncreasing = false ; if ( sortOrderIncreasingString != null ) if ( sortOrderIncreasingString . equalsIgnoreCase ( "true" ) ) sortOrderIncreasing = true ; boolean addDatasetSize = true ; if ( addDatasetSizeString != null ) if ( addDatasetSizeString . equalsIgnoreCase ( "false" ) ) addDatasetSize = false ; if ( path != null ) { if ( path . charAt ( 0 ) == '/' ) path = path . substring ( 1 ) ; int last = path . length ( ) - 1 ; if ( path . charAt ( last ) == '/' ) path = path . substring ( 0 , last ) ; } if ( scanDir != null ) { int last = scanDir . length ( ) - 1 ; if ( scanDir . charAt ( last ) != '/' ) scanDir = scanDir + '/' ; } Element atcElem = dsElem . getChild ( "addTimeCoverage" , defNS ) ; String dsNameMatchPattern = null ; String startTimeSubstitutionPattern = null ; String duration = null ; if ( atcElem != null ) { dsNameMatchPattern = atcElem . getAttributeValue ( "datasetNameMatchPattern" ) ; startTimeSubstitutionPattern = atcElem . getAttributeValue ( "startTimeSubstitutionPattern" ) ; duration = atcElem . getAttributeValue ( "duration" ) ; } try { datasetScan = new InvDatasetScan ( catalog , parent , name , path , scanDir , filter , addDatasetSize , addLatest , sortOrderIncreasing , dsNameMatchPattern , startTimeSubstitutionPattern , duration ) ; readDatasetInfo ( catalog , datasetScan , dsElem , base ) ; if ( InvCatalogFactory . debugXML ) System . out . println ( " Dataset added: " + datasetScan . dump ( ) ) ; } catch ( Exception e ) { logger . error ( "Reading DatasetScan" , e ) ; datasetScan = null ; } } return datasetScan ;


signature: public class InvCatalogFactory10 { protected DatasetEnhancer readDatasetScanAddTimeCoverage ( Element addTimeCovElem ) { } }

implementation: DatasetEnhancer timeCovEnhancer = null ; String matchName = addTimeCovElem . getAttributeValue ( "datasetNameMatchPattern" ) ; String matchPath = addTimeCovElem . getAttributeValue ( "datasetPathMatchPattern" ) ; String subst = addTimeCovElem . getAttributeValue ( "startTimeSubstitutionPattern" ) ; String duration = addTimeCovElem . getAttributeValue ( "duration" ) ; if ( matchName != null && subst != null && duration != null ) { timeCovEnhancer = RegExpAndDurationTimeCoverageEnhancer . getInstanceToMatchOnDatasetName ( matchName , subst , duration ) ; } else if ( matchPath != null && subst != null && duration != null ) { timeCovEnhancer = RegExpAndDurationTimeCoverageEnhancer . getInstanceToMatchOnDatasetPath ( matchPath , subst , duration ) ; } return timeCovEnhancer ;


signature:
public class InvCatalogFactory10 { /** * / * MetadataConverterIF */
public Object readMetadataContent ( InvDataset dataset , org . jdom2 . Element mdataElement ) { } }

implementation: InvMetadata m = readMetadata ( dataset . getParentCatalog ( ) , ( InvDatasetImpl ) dataset , mdataElement ) ; return m . getThreddsMetadata ( ) ;


signature:
public class InvCatalogFactory10 { /** * this is only called for ThredddsMetadata */
public Object readMetadataContentFromURL ( InvDataset dataset , java . net . URI uri ) throws java . io . IOException { } }

implementation: Element elem = readContentFromURL ( uri ) ; Object contentObject = readMetadataContent ( dataset , elem ) ; if ( debugMetadataRead ) System . out . println ( " convert to " + contentObject . getClass ( ) . getName ( ) ) ; return contentObject ;


signature:
public class InvCatalogFactory10 { /** * Write the catalog as an XML document to the specified stream .
 * @ param catalog write this catalog
 * @ param os write to this OutputStream
 * @ param raw write raw file if true ( for server configuration )
 * @ throws IOException */
public void writeXML ( InvCatalogImpl catalog , OutputStream os , boolean raw ) throws IOException { } }

implementation: this . raw = raw ; writeXML ( catalog , os ) ; this . raw = false ;


signature:
public class InvCatalogFactory10 { /** * / * protected void writeCat6InheritedMetadata ( Element elem , ThreddsMetadata tmi ) {
 * if ( ( tmi . getDataType ( ) = = null ) & & ( tmi . getServiceName ( ) = = null ) & &
 * ( tmi . getAuthority ( ) = = null ) & & ( tmi . getProperties ( ) . size ( ) = = 0 ) )
 * return ;
 * Element mdataElem = new Element ( " metadata " , defNS ) ;
 * mdataElem . setAttribute ( " inherited " , " true " ) ;
 * writeThreddsMetadata ( mdataElem , tmi ) ;
 * elem . addContent ( mdataElem ) ; */
protected void writeInheritedMetadata ( Element elem , ThreddsMetadata tmi ) { } }

implementation: Element mdataElem = new Element ( "metadata" , defNS ) ; mdataElem . setAttribute ( "inherited" , "true" ) ; writeThreddsMetadata ( mdataElem , tmi ) ; if ( mdataElem . getChildren ( ) . size ( ) > 0 ) elem . addContent ( mdataElem ) ;


signature:
public class McIDASGridRecord { /** * Get the type for the first level of this GridRecord
 * @ return level type */
public int getLevelType1 ( ) { } }

implementation:
// TODO : flush this out
int gribLevel = getDirBlock ( ) [ 51 ] ; int levelType = 0 ; if ( ! ( ( gribLevel == McIDASUtil . MCMISSING ) || ( gribLevel == 0 ) ) ) { levelType = gribLevel ; } else { levelType = 1 ; } return levelType ;


signature:
public class Nldn { /** * Check if this is a valid file for this IOServiceProvider .
 * You must make this method thread safe , ie dont keep any state .
 * @ param raf RandomAccessFile
 * @ return true if valid .
 * @ throws IOException if read error */
public boolean isValidFile ( RandomAccessFile raf ) throws IOException { } }

implementation: raf . seek ( 0 ) ; String test = raf . readString ( MAGIC . length ( ) ) ; return test . equals ( MAGIC ) ;


signature:
public class Nldn { /** * Open existing file , and populate ncfile with it . This method is only
 * called by the NetcdfFile constructor on itself . The provided NetcdfFile
 * object will be empty except for the location String and the
 * IOServiceProvider associated with this NetcdfFile object .
 * @ param raf the file to work on , it has already passed the
 * isValidFile ( ) test .
 * @ param ncfile add objects to this empty NetcdfFile
 * @ param cancelTask used to monitor user cancellation ; may be null .
 * @ throws IOException if read error */
public void open ( RandomAccessFile raf , NetcdfFile ncfile , CancelTask cancelTask ) throws IOException { } }

implementation:
super . open ( raf , ncfile , cancelTask ) ; Structure seq = new Sequence ( ncfile , null , null , RECORD ) ; ncfile . addVariable ( null , seq ) ; /* makeLightningVariable ( NetcdfFile ncfile , Group group ,
 Structure seq , String name ,
 DataType dataType , String dims ,
 String longName , String cfName ,
 String units , AxisType type ) { */
Variable v = makeLightningVariable ( ncfile , null , seq , TSEC , DataType . INT , "" , "time of stroke" , null , secondsSince1970 , AxisType . Time ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , "nsec" , DataType . INT , "" , "nanoseconds since tsec" , null , "1.0e-9 s" , null ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , LAT , DataType . INT , "" , "latitude" , "latitude" , CDM . LAT_UNITS , AxisType . Lat ) ; v . addAttribute ( new Attribute ( CDM . SCALE_FACTOR , new Float ( 1.0e-3 ) ) ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , LON , DataType . INT , "" , "longitude" , "longitude" , CDM . LON_UNITS , AxisType . Lon ) ; v . addAttribute ( new Attribute ( CDM . SCALE_FACTOR , new Float ( 1.0e-3 ) ) ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , SIGNAL , DataType . SHORT , "" , "signal strength/polarity [150 NLDN measures ~= 30 kAmps]" , null , "" , null ) ; v . addAttribute ( new Attribute ( CDM . SCALE_FACTOR , new Float ( 1.0e-1 ) ) ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , MULTIPLICITY , DataType . BYTE , "" , "multiplicity [#strokes per flash]" , null , "" , null ) ; seq . addMemberVariable ( v ) ; v = new Variable ( ncfile , null , seq , FILL ) ; v . setDataType ( DataType . BYTE ) ; v . setDimensions ( "" ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , MAJOR_AXIS , DataType . BYTE , "" , "error ellipse semi-major axis" , null , "" , null ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , ECCENTRICITY , DataType . BYTE , "" , "error ellipse eccentricity " , null , "" , null ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , ELLIPSE_ANGLE , DataType . BYTE , "" , "error ellipse axis angle of orientation " , null , "degrees" , null ) ; seq . addMemberVariable ( v ) ; v = makeLightningVariable ( ncfile , null , seq , CHISQR , DataType . BYTE , "" , "chi-squared" , null , "" , null ) ; seq . addMemberVariable ( v ) ; addLightningGlobalAttributes ( ncfile ) ; ncfile . finish ( ) ; sm = seq . makeStructureMembers ( ) ; sm . findMember ( TSEC ) . setDataParam ( 0 ) ; sm . findMember ( NSEC ) . setDataParam ( 4 ) ; sm . findMember ( LAT ) . setDataParam ( 8 ) ; sm . findMember ( LON ) . setDataParam ( 12 ) ; sm . findMember ( SIGNAL ) . setDataParam ( 18 ) ; sm . findMember ( MULTIPLICITY ) . setDataParam ( 22 ) ; sm . findMember ( FILL ) . setDataParam ( 23 ) ; sm . findMember ( MAJOR_AXIS ) . setDataParam ( 24 ) ; sm . findMember ( ECCENTRICITY ) . setDataParam ( 25 ) ; sm . findMember ( ELLIPSE_ANGLE ) . setDataParam ( 26 ) ; sm . findMember ( CHISQR ) . setDataParam ( 27 ) ; sm . setStructureSize ( recSize ) ;


signature:
public class Nldn { /** * Add the global attributes .
 * @ param ncfile the file to add to */
protected void addLightningGlobalAttributes ( NetcdfFile ncfile ) { } }

implementation: super . addLightningGlobalAttributes ( ncfile ) ; ncfile . addAttribute ( null , new Attribute ( "title" , "NLDN Lightning Data" ) ) ; ncfile . addAttribute ( null , new Attribute ( CDM . CONVENTIONS , "NLDN-CDM" ) ) ;


signature:
public class Nldn { /** * Read data from a top level Variable and return a memory resident Array .
 * This Array has the same element type as the Variable , and the requested shape .
 * @ param v2 a top - level Variable
 * @ param section the section of data to read .
 * There must be a Range for each Dimension in the variable , in order .
 * Note : no nulls allowed . IOSP may not modify .
 * @ return the requested data in a memory - resident Array
 * @ throws IOException if read error
 * @ throws InvalidRangeException if invalid section
 * @ see ucar . ma2 . Range */
public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation: return new ArraySequence ( sm , new SeqIter ( ) , nelems ) ;


signature:
public class DummySink { /** * Writes an array of bytes to the compressed output stream . This
 * method will block until all the bytes are written .
 * @ param off the start offset of the data
 * @ param len the length of the data
 * @ throws IOException if an I / O error has occurred */
public void write ( byte [ ] b , int off , int len ) throws IOException { } }

implementation: count += len ; super . write ( b , off , len ) ;


signature:
public class SDUInt32 { /** * Prints the value of the variable , with its declaration . This
 * function is primarily intended for debugging OPeNDAP applications and
 * text - based clients such as geturl .
 * < h2 > Important Note < / h2 >
 * This method overrides the BaseType method of the same name and
 * type signature and it significantly changes the behavior for all versions
 * of < code > printVal ( ) < / code > for this type :
 * < b > < i > All the various versions of printVal ( ) will only
 * print a value , or a value with declaration , if the variable is
 * in the projection . < / i > < / b >
 * < br >
 * < br > In other words , if a call to
 * < code > isProject ( ) < / code > for a particular variable returns
 * < code > true < / code > then < code > printVal ( ) < / code > will print a value
 * ( or a declaration and a value ) .
 * < br >
 * < br > If < code > isProject ( ) < / code > for a particular variable returns
 * < code > false < / code > then < code > printVal ( ) < / code > is basically a No - Op .
 * < br >
 * < br >
 * @ param os the < code > PrintWriter < / code > on which to print the value .
 * @ param space this value is passed to the < code > printDecl < / code > method ,
 * and controls the leading spaces of the output .
 * @ param print _ decl _ p a boolean value controlling whether the
 * variable declaration is printed as well as the value .
 * @ see BaseType # printVal ( PrintWriter , String , boolean )
 * @ see ServerMethods # isProject ( ) */
public void printVal ( PrintWriter os , String space , boolean print_decl_p ) { } }

implementation: if ( ! isProject ( ) ) return ; super . printVal ( os , space , print_decl_p ) ;