Input:
_more_ [CODESPLIT] public void augmentDataset ( NetcdfDataset ds , CancelTask cancelTask ) throws IOException { Attribute leoAtt = ds . findGlobalAttribute ( "leoId" ) ; if ( leoAtt == null ) { if ( ds . findVariable ( "time" ) == null ) { // create a time variable - assume its linear along the vertical dimension
 double start = ds . readAttributeDouble ( null , "start_time" , Double . NaN ) ; double stop = ds . readAttributeDouble ( null , "stop_time" , Double . NaN ) ; if ( Double . isNaN ( start ) && Double . isNaN ( stop ) ) { double top = ds . readAttributeDouble ( null , "toptime" , Double . NaN ) ; double bot = ds . readAttributeDouble ( null , "bottime" , Double . NaN ) ; this . conventionName = "Cosmic2" ; if ( top > bot ) { stop = top ; start = bot ; } else { stop = bot ; start = top ; } } Dimension dim = ds . findDimension ( "MSL_alt" ) ; Variable dimV = ds . findVariable ( "MSL_alt" ) ; Array dimU = dimV . read ( ) ; int inscr = ( dimU . getFloat ( 1 ) - dimU . getFloat ( 0 ) ) > 0 ? 1 : 0 ; int n = dim . getLength ( ) ; double incr = ( stop - start ) / n ; String timeUnits = "seconds since 1980-01-06 00:00:00" ; Variable timeVar = new VariableDS ( ds , null , null , "time" , DataType . DOUBLE , dim . getShortName ( ) , timeUnits , null ) ; ds . addVariable ( null , timeVar ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , timeUnits ) ) ; timeVar . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Time . toString ( ) ) ) ; int dir = ds . readAttributeInteger ( null , "irs" , 1 ) ; ArrayDouble . D1 data = ( ArrayDouble . D1 ) Array . factory ( DataType . DOUBLE , new int [ ] { n } ) ; if ( inscr == 0 ) { if ( dir == 1 ) { for ( int i = 0 ; i < n ; i ++ ) { data . set ( i , start + i * incr ) ; } } else { for ( int i = 0 ; i < n ; i ++ ) { data . set ( i , stop - i * incr ) ; } } } else { for ( int i = 0 ; i < n ; i ++ ) { data . set ( i , stop - i * incr ) ; } } timeVar . setCachedData ( data , false ) ; } Variable v = ds . findVariable ( "Lat" ) ; if ( v == null ) { v = ds . findVariable ( "GEO_lat" ) ; } v . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lat . toString ( ) ) ) ; Variable v1 = ds . findVariable ( "Lon" ) ; if ( v1 == null ) { v1 = ds . findVariable ( "GEO_lon" ) ; } v1 . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lon . toString ( ) ) ) ; } else { Dimension dim = ds . findDimension ( "time" ) ; int n = dim . getLength ( ) ; Variable latVar = new VariableDS ( ds , null , null , "Lat" , DataType . FLOAT , dim . getShortName ( ) , "degree" , null ) ; latVar . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lat . toString ( ) ) ) ; ds . addVariable ( null , latVar ) ; Variable lonVar = new VariableDS ( ds , null , null , "Lon" , DataType . FLOAT , dim . getShortName ( ) , "degree" , null ) ; lonVar . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Lon . toString ( ) ) ) ; ds . addVariable ( null , lonVar ) ; Variable altVar = new VariableDS ( ds , null , null , "MSL_alt" , DataType . FLOAT , dim . getShortName ( ) , "meter" , null ) ; altVar . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Height . toString ( ) ) ) ; ds . addVariable ( null , altVar ) ; // cal data array
 ArrayFloat . D1 latData = ( ArrayFloat . D1 ) Array . factory ( DataType . FLOAT , new int [ ] { n } ) ; ArrayFloat . D1 lonData = ( ArrayFloat . D1 ) Array . factory ( DataType . FLOAT , new int [ ] { n } ) ; ArrayFloat . D1 altData = ( ArrayFloat . D1 ) Array . factory ( DataType . FLOAT , new int [ ] { n } ) ; ArrayDouble . D1 timeData = ( ArrayDouble . D1 ) Array . factory ( DataType . DOUBLE , new int [ ] { n } ) ; this . conventionName = "Cosmic3" ; int iyr = ds . readAttributeInteger ( null , "year" , 2009 ) ; int mon = ds . readAttributeInteger ( null , "month" , 0 ) ; int iday = ds . readAttributeInteger ( null , "day" , 0 ) ; int ihr = ds . readAttributeInteger ( null , "hour" , 0 ) ; int min = ds . readAttributeInteger ( null , "minute" , 0 ) ; int sec = ds . readAttributeInteger ( null , "second" , 0 ) ; double start = ds . readAttributeDouble ( null , "startTime" , Double . NaN ) ; double stop = ds . readAttributeDouble ( null , "stopTime" , Double . NaN ) ; double incr = ( stop - start ) / n ; int t = 0 ; // double julian = juday(mon, iday, iyr);
 // cal the dtheta based pm attributes
 double dtheta = gast ( iyr , mon , iday , ihr , min , sec , t ) ; Variable tVar = ds . findVariable ( "time" ) ; String timeUnits = "seconds since 1980-01-06 00:00:00" ; //dtime.getUnit().toString();
 tVar . removeAttributeIgnoreCase ( CDM . VALID_RANGE ) ; tVar . removeAttributeIgnoreCase ( CDM . UNITS ) ; tVar . addAttribute ( new Attribute ( CDM . UNITS , timeUnits ) ) ; tVar . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Time . toString ( ) ) ) ; Variable v = ds . findVariable ( "xLeo" ) ; Array xLeo = v . read ( ) ; v = ds . findVariable ( "yLeo" ) ; Array yLeo = v . read ( ) ; v = ds . findVariable ( "zLeo" ) ; Array zLeo = v . read ( ) ; double a = 6378.1370 ; double b = 6356.7523142 ; IndexIterator iiter0 = xLeo . getIndexIterator ( ) ; IndexIterator iiter1 = yLeo . getIndexIterator ( ) ; IndexIterator iiter2 = zLeo . getIndexIterator ( ) ; int i = 0 ; while ( iiter0 . hasNext ( ) ) { double [ ] v_inertial = new double [ 3 ] ; v_inertial [ 0 ] = iiter0 . getDoubleNext ( ) ; //.getDouble(i); //.nextDouble();
 v_inertial [ 1 ] = iiter1 . getDoubleNext ( ) ; //.getDouble(i); //.nextDouble();
 v_inertial [ 2 ] = iiter2 . getDoubleNext ( ) ; //.getDouble(i); //.nextDouble();
 double [ ] uvz = new double [ 3 ] ; uvz [ 0 ] = 0.0 ; uvz [ 1 ] = 0.0 ; uvz [ 2 ] = 1.0 ; // v_ecef should be in the (approximate) ECEF frame
 // double[] v_ecf = execute(v_inertial, julian);
 double [ ] v_ecf = spin ( v_inertial , uvz , - 1 * dtheta ) ; // cal lat/lon here
 // double [] llh = ECFtoLLA(v_ecf[0]*1000, v_ecf[1]*1000, v_ecf[2]*1000, a,  b);
 double [ ] llh = xyzell ( a , b , v_ecf ) ; latData . set ( i , ( float ) llh [ 0 ] ) ; lonData . set ( i , ( float ) llh [ 1 ] ) ; altData . set ( i , ( float ) llh [ 2 ] ) ; timeData . set ( i , start + i * incr ) ; i ++ ; } latVar . setCachedData ( latData , false ) ; lonVar . setCachedData ( lonData , false ) ; altVar . setCachedData ( altData , false ) ; tVar . setCachedData ( timeData , false ) ; } ds . finish ( ) ; }


Input: NAME : XYZELL <p / > CALL XYZELL ( A B XSTAT XSTELL ) <p / > PURPOSE : COMPUTATION OF ELLIPSOIDAL COORDINATES XSTELL GIVEN THE CARTESIAN COORDINATES XSTAT <p / > PARAMETERS : IN : A : SEMI - MAJOR AXIS OF THE REFERENCE R * 8 ELLIPSOID IN METERS B : SEMI - MINOR AXIS OF THE REFERENCE R * 8 ELLIPSOID IN METERS DXELL ( 3 ) : TRANSLATION COMPONENTS FROM THE R * 8 ORIGIN OF THE CART . COORD . SYSTEM ( X Y Z ) TO THE CENTER OF THE REF . ELLIPSOID ( IN METRES ) SCELL : SCALE FACTOR BETWEEN REF . ELLIPSOID R * 8 AND WGS - 84 XSTAT ( 3 ) : CARTESIAN COORDINATES ( M ) R * 8 OUT : XSTELL ( 3 ) : ELLIPSOIDAL COORDINATES R * 8 XSTELL ( 1 ) : ELL . LATITUDE ( RADIAN ) XSTELL ( 2 ) : ELL . LONGITUDE ( RADIAN ) XSTELL ( 3 ) : ELL . HEIGHT ( M ) <p / > SR CALLED : DMLMTV <p / > REMARKS : --- <p / > AUTHOR : M . ROTHACHER <p / > VERSION : 3 . 4 ( JAN 93 ) <p / > CREATED : 87 / 11 / 03 12 : 32 LAST MODIFIED : 88 / 11 / 21 17 : 36 <p / > COPYRIGHT : ASTRONOMICAL INSTITUTE 1987 UNIVERSITY OF BERNE SWITZERLAND [CODESPLIT] public double [ ] xyzell ( double a , double b , double [ ] xstat ) { double [ ] xstell = new double [ 3 ] ; double e2 , s , rlam , zps , h , phi , n , hp , phip ; int i , niter ; e2 = ( a * a - b * b ) / ( a * a ) ; s = Math . sqrt ( xstat [ 0 ] * xstat [ 0 ] + xstat [ 1 ] * xstat [ 1 ] ) ; rlam = Math . atan2 ( xstat [ 1 ] , xstat [ 0 ] ) ; zps = xstat [ 2 ] / s ; h = Math . sqrt ( xstat [ 0 ] * xstat [ 0 ] + xstat [ 1 ] * xstat [ 1 ] + xstat [ 2 ] * xstat [ 2 ] ) - a ; phi = Math . atan ( zps / ( 1.0 - e2 * a / ( a + h ) ) ) ; niter = 0 ; for ( i = 1 ; i <= 10000000 ; i ++ ) { n = a / Math . sqrt ( 1.0 - e2 * Math . sin ( phi ) * Math . sin ( phi ) ) ; hp = h ; phip = phi ; h = s / Math . cos ( phi ) - n ; phi = Math . atan ( zps / ( 1.0 - e2 * n / ( n + h ) ) ) ; niter = niter + 1 ; if ( ( Math . abs ( phip - phi ) <= 1.e-11 ) && ( Math . abs ( hp - h ) <= 1.e-5 ) ) { break ; } if ( niter >= 10 ) { phi = - 999.0 ; rlam = - 999.0 ; h = - 999.0 ; break ; } } xstell [ 0 ] = phi * 180 / 3.1415926 ; xstell [ 1 ] = rlam * 180 / 3.1415926 ; xstell [ 2 ] = h ; return xstell ; }


Input:
---------------------------------------------------------------------- gast . f <p / > This subroutine computes the Greenwich Apparent Siderial Time angle given a UTC date and time . <p / > parameter Input parameters : Inputs : [CODESPLIT] public double gast ( int iyr , int imon , int iday , int ihr , int imin , double sec , double dsec ) { //
 //    implicit double precision (a-h,o-z)
 //    character(len=*), parameter :: header = '$URL: svn://ursa.cosmic.ucar.edu/trunk/src/roam/gast.f $ $Id: gast.f 10129 2008-07-30 17:10:52Z dhunt $'
 //
 // Coordinate transform from the celestial inertial reference frame to the geo-
 // centered Greenwich reference frame.
 // Call a subroutine to calculate the Julian day "djd":
 double djd = juday ( imon , iday , iyr ) ; //djd=julean day.
 double tu = ( djd - 2451545.0 ) / 36525.0 ; double gmst = 24110.548410 + 8640184.8128660 * tu + 0.093104 * tu * tu - 6.2E-6 * Math . pow ( tu , 3 ) ; //       !gmst=Greenwich mean...
 double utco = ( ihr * 3600 ) + ( imin * 60 ) + sec ; return togreenw ( dsec , utco , gmst ) ; }


Input: JDAY calculates the Julian Day number ( JD ) from the Gregorian month day and year ( M D Y ) . ( NOT VALID BEFORE 10 / 15 / 1582 ) [CODESPLIT] public double juday ( int M , int D , int Y ) { double JD ; double IY = Y - ( 12 - M ) / 10 ; double IM = M + 1 + 12 * ( ( 12 - M ) / 10 ) ; double I = IY / 100 ; double J = 2 - I + I / 4 + Math . round ( 365.25 * IY ) + Math . round ( 30.6001 * IM ) ; JD = ( J + D + 1720994.50 ) ; return JD ; }


Input:
This subroutine is to transform the locations and velocities of the GPS and LEO satellites from the celestial inertial reference frame to the Earth centered Greenwich reference frame . The dummy arguments iyear month and iday are the calender year month and day of the occultation event . The dummy arguments ihour minute and sec are the UTC time . Reference : Astronomical Alamanus 1993 <p / > Modified subroutine from Dasheng s code . [CODESPLIT] public double togreenw ( double rectt , double utco , double gmst ) { double pi = Math . acos ( - 1.00 ) ; //
 // For each occultation ID, its TU and GMST are the same.  However, every
 // occultation event takes place at gmst+uts, uts is progressively increasing
 // with every occultation event.
 double utc = ( utco + rectt ) * 1.0027379093 ; gmst = gmst + utc ; //in seconds, without eoe correction.
 //  gmst may be a positive number or may be a negative number.
 while ( gmst < 0.0 ) { gmst = gmst + 86400.00 ; } while ( gmst > 86400.00 ) { gmst = gmst - 86400.00 ; } // gmst = the Greenwich mean sidereal time.
 // This gmst is without the corrections from the equation of equinoxes.  For
 // GPS/MET applications, the corrections from equation of equinoxes is not
 // necessary because of the accurary needed.
 return gmst * 2.0 * pi / 86400.0 ; //!*** This is the THETA in radian.
 }


Input:
---------------------------------------------------------------------- file spin . f <p / > This subroutine rotates vector V1 around vector VS at angle A . V2 is the vector after the rotation . <p / > <p / > parameter Input parameters : v1 - Vector to be rotated vs - Vector around which to rotate v1 a - angle of rotation Output parameters : v2 - output vector <p / > S . V . Sokolovskiy URL : svn : // ursa . cosmic . ucar . edu / trunk / src / roam / spin . f $ $Id : spin . f 10129 2008 - 07 - 30 17 : 10 : 52Z dhunt $ ----------------------------------------------------------------------- [CODESPLIT] public double [ ] spin ( double [ ] v1 , double [ ] vs , double a ) { //     implicit real*8(a-h,o-z)
 //     dimension v1(3),vs(3),vsn(3),v2(3),v3(3),s(3,3)
 //     Calculation of the unit vector around which
 //     the rotation should be done.
 double [ ] v2 = new double [ 3 ] ; double [ ] vsn = new double [ 3 ] ; double [ ] v3 = new double [ 3 ] ; double vsabs = Math . sqrt ( vs [ 0 ] * vs [ 0 ] + vs [ 1 ] * vs [ 1 ] + vs [ 2 ] * vs [ 2 ] ) ; for ( int i = 0 ; i < 3 ; i ++ ) { vsn [ i ] = vs [ i ] / vsabs ; } // Calculation of the rotation matrix.
 double a1 = Math . cos ( a ) ; double a2 = 1.0 - a1 ; double a3 = Math . sin ( a ) ; double [ ] [ ] s = new double [ 3 ] [ 3 ] ; s [ 0 ] [ 0 ] = a2 * vsn [ 0 ] * vsn [ 0 ] + a1 ; s [ 0 ] [ 1 ] = a2 * vsn [ 0 ] * vsn [ 1 ] - a3 * vsn [ 2 ] ; s [ 0 ] [ 2 ] = a2 * vsn [ 0 ] * vsn [ 2 ] + a3 * vsn [ 1 ] ; s [ 1 ] [ 0 ] = a2 * vsn [ 1 ] * vsn [ 0 ] + a3 * vsn [ 2 ] ; s [ 1 ] [ 1 ] = a2 * vsn [ 1 ] * vsn [ 1 ] + a1 ; s [ 1 ] [ 2 ] = a2 * vsn [ 1 ] * vsn [ 2 ] - a3 * vsn [ 0 ] ; s [ 2 ] [ 0 ] = a2 * vsn [ 2 ] * vsn [ 0 ] - a3 * vsn [ 1 ] ; s [ 2 ] [ 1 ] = a2 * vsn [ 2 ] * vsn [ 1 ] + a3 * vsn [ 0 ] ; s [ 2 ] [ 2 ] = a2 * vsn [ 2 ] * vsn [ 2 ] + a1 ; // Calculation of the rotated vector.
 for ( int i = 0 ; i < 3 ; i ++ ) { v3 [ i ] = s [ i ] [ 0 ] * v1 [ 0 ] + s [ i ] [ 1 ] * v1 [ 1 ] + s [ i ] [ 2 ] * v1 [ 2 ] ; } System . arraycopy ( v3 , 0 , v2 , 0 , 3 ) ; return v2 ; }


Input:
_more_ [CODESPLIT] public double [ ] execute ( double [ ] eci , double julian ) { double Xi = eci [ 0 ] ; double Yi = eci [ 1 ] ; double Zi = eci [ 2 ] ; double c , s ; double GHA ; double [ ] ecef = new double [ 3 ] ; //Compute GHAD
 /* System generated locals */ double d__1 , d__2 , d__3 ; /* Local variables */ double tsec , tday , gmst , t , omega , tfrac , tu , dat ; /*     INPUT IS TIME "secondsSince1970" IN SECONDS AND "TDAY" */ /*     WHICH IS WHOLE DAYS FROM 1970 JAN 1 0H */ /*     THE OUTPUT IS GREENWICH HOUR ANGLE IN DEGREES */ /*     XOMEGA IS ROTATION RATE IN DEGREES/SEC */ /*     FOR COMPATABILITY */ tday = ( double ) ( ( int ) ( julian / 86400. ) ) ; tsec = julian - tday * 86400 ; /*     THE NUMBER OF DAYS FROM THE J2000 EPOCH */ /*     TO 1970 JAN 1 0H UT1 IS -10957.5 */ t = tday - ( float ) 10957.5 ; tfrac = tsec / 86400. ; dat = t ; tu = dat / 36525. ; /* Computing 2nd power */ d__1 = tu ; /* Computing 3rd power */ d__2 = tu ; d__3 = d__2 ; gmst = tu * 8640184.812866 + 24110.54841 + d__1 * d__1 * .093104 - d__3 * ( d__2 * d__2 ) * 6.2e-6 ; /*     COMPUTE THE EARTH'S ROTATION RATE */ /* Computing 2nd power */ d__1 = tu ; omega = tu * 5.098097e-6 + 86636.55536790872 - d__1 * d__1 * 5.09e-10 ; /*     COMPUTE THE GMST AND GHA */ //  da is earth nutation - currently unused
 double da = 0.0 ; gmst = gmst + omega * tfrac + da * RTD * 86400. / 360. ; gmst = gmst % 86400 ; if ( gmst < 0. ) { gmst += 86400. ; } gmst = gmst / 86400. * 360. ; //ghan = gmst;
 //  returns gha in radians
 gmst = gmst * DTR ; GHA = gmst ; //RotateZ
 c = Math . cos ( GHA ) ; s = Math . sin ( GHA ) ; double X = c * Xi + s * Yi ; double Y = - s * Xi + c * Yi ; //Set outputs
 ecef [ 0 ] = X ; ecef [ 1 ] = Y ; ecef [ 2 ] = Zi ; return ecef ; }


Input:
comparing api to others [CODESPLIT] public static double [ ] ECFtoLLA ( double x , double y , double z , double a , double b ) { double longitude = Math . atan2 ( y , x ) ; double ePrimeSquared = ( a * a - b * b ) / ( b * b ) ; double p = Math . sqrt ( x * x + y * y ) ; double theta = Math . atan ( ( z * a ) / ( p * b ) ) ; double sineTheta = Math . sin ( theta ) ; double cosTheta = Math . cos ( theta ) ; double f = 1 / 298.257223563 ; double e2 = 2 * f - f * f ; double top = z + ePrimeSquared * b * sineTheta * sineTheta * sineTheta ; double bottom = p - e2 * a * cosTheta * cosTheta * cosTheta ; double geodeticLat = Math . atan ( top / bottom ) ; double sineLat = Math . sin ( geodeticLat ) ; double N = a / Math . sqrt ( 1 - e2 * sineLat * sineLat ) ; double altitude = ( p / Math . cos ( geodeticLat ) ) - N ; // maintain longitude btw -PI and PI
 if ( longitude > Math . PI ) { longitude -= 2 * Math . PI ; } else if ( longitude < - Math . PI ) { longitude += 2 * Math . PI ; } return new double [ ] { geodeticLat , longitude , altitude } ; }


Input: read in lat / lon points one time for this class [CODESPLIT] private static boolean readWorldMap ( ) { java . io . DataInputStream dis ; String filename = "/resources/nj22/ui/maps/cil_100km.mapr" ; java . io . InputStream is = null ; long secs = System . currentTimeMillis ( ) ; is = Resource . getFileResource ( filename ) ; if ( is == null ) { System . err . println ( "WorldMap read failed on resource " + filename ) ; return false ; } else { dis = new java . io . DataInputStream ( is ) ; } // need an AbstractGisFeature for visad worldMapFeature = new WorldMapFeature ( ) ; // need an ArrayList of AbstractGisFeature's for GisFeatureRenderer gisList = new ArrayList ( ) ; gisList . add ( worldMapFeature ) ; partList = new ArrayList ( ) ; while ( true ) { try { int npts = dis . readInt ( ) ; dis . readInt ( ) ; // minx -- not used. dis . readInt ( ) ; // maxx -- not used. dis . readInt ( ) ; // miny -- not used. dis . readInt ( ) ; // maxy -- not used. MapRun run = new MapRun ( npts ) ; for ( int i = 0 ; i < npts ; i ++ ) { run . wx [ i ] = ( ( double ) dis . readInt ( ) ) / SECS_PER_DEG ; run . wy [ i ] = ( ( double ) dis . readInt ( ) ) / SECS_PER_DEG ; } partList . add ( run ) ; total_pts += npts ; } catch ( EOFException ex ) { break ; } catch ( Exception ex ) { System . err . println ( "WorldMap exception " + ex ) ; break ; } } try { is . close ( ) ; } catch ( Exception ex ) { } if ( debugTime ) { secs = System . currentTimeMillis ( ) - secs ; System . out . println ( "WorldMap read file: " + secs * .001 + " seconds" ) ; } return true ; }


Input:
Clean up strings to be used for unit string [CODESPLIT] public static String cleanUnit ( String unit ) { if ( unit == null ) return null ; // These specific words become dimensionless
 if ( unit . equalsIgnoreCase ( "Proportion" ) || unit . equalsIgnoreCase ( "Numeric" ) ) unit = "" ; // So does '-'
 else if ( unit . equalsIgnoreCase ( "-" ) ) { unit = "" ; // Make sure degree(s) true gets concatenated with '_'
 } else if ( unit . startsWith ( "degree" ) && unit . endsWith ( "true" ) ) { unit = unit . replace ( ' ' , ' ' ) ; // And only do the rest of the conversion if it's not a "* table *" entry
 } else if ( ! unit . contains ( " table " ) ) { if ( unit . startsWith ( "/" ) ) unit = "1" + unit ; unit = unit . trim ( ) ; unit = StringUtil2 . remove ( unit , "**" ) ; StringBuilder sb = new StringBuilder ( unit ) ; StringUtil2 . remove ( sb , "^[]" ) ; StringUtil2 . replace ( sb , ' ' , "." ) ; StringUtil2 . replace ( sb , ' ' , "." ) ; unit = sb . toString ( ) ; } return unit ; }


Input: Clean up strings to be used in Netcdf Object names [CODESPLIT] public static String cleanName ( String name ) { if ( name == null ) return null ; int pos = name . indexOf ( "(see" ) ; if ( pos < 0 ) pos = name . indexOf ( "(See" ) ; if ( pos > 0 ) name = name . substring ( 0 , pos ) ; name = StringUtil2 . replace ( name , ' ' , "-" ) ; StringBuilder sb = new StringBuilder ( name ) ; StringUtil2 . replace ( sb , ' ' , "plus" ) ; StringUtil2 . remove ( sb , ".;,=[]()/*\"" ) ; return StringUtil2 . collapseWhitespace ( sb . toString ( ) . trim ( ) ) ; }


Input:
Compare two names from tables trying to ignore superfulous characters . [CODESPLIT] public static boolean equivilantName ( String name1 , String name2 ) { if ( name1 == null || name2 == null ) return ( name1 == name2 ) ; String name1clean = cleanName ( name1 ) . toLowerCase ( ) ; String name2clean = cleanName ( name2 ) . toLowerCase ( ) ; if ( name1 . equals ( name2 ) ) return true ; StringBuilder sb1 = new StringBuilder ( name1clean ) ; StringUtil2 . remove ( sb1 , " -’'");
  StringBuilder sb2 = new StringBuilder ( name2clean ) ; StringUtil2 . remove ( sb2 , " -’'");
  return sb1 . toString ( ) . equals ( sb2 . toString ( ) ) ; }


Input: The given unit is unitless . [CODESPLIT] public static boolean isUnitless ( String unit ) { if ( unit == null ) return true ; String munge = unit . toLowerCase ( ) . trim ( ) ; munge = StringUtil2 . remove ( munge , ' ' ) ; return munge . length ( ) == 0 || munge . startsWith ( "numeric" ) || munge . startsWith ( "non-dim" ) || munge . startsWith ( "see" ) || munge . startsWith ( "proportion" ) || munge . startsWith ( "code" ) || munge . startsWith ( "0=" ) || munge . equals ( "1" ) ; }


Input: Return a URL ready to use in a generated HTML page from a URL that is either absolute or relative to the webapp context path . That is if relative it is relative to http : // server : port / thredds / . <p / > <p > For simplicity all relative URLs are converted to URLs that are absolute paths . For instance catalog . xml becomes / thredds / catalog . xml . [CODESPLIT] public String prepareUrlStringForHtml ( String url ) { if ( url == null ) return null ; URI uri ; try { uri = new URI ( url ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( "Given a bad URL [" + url + "]." , e ) ; } if ( uri . isAbsolute ( ) ) return uri . toString ( ) ; if ( url . startsWith ( "/" ) ) return url ; return this . getWebappContextPath ( ) + "/" + url ; }


Input: input is xml file with just the <featureCollection > [CODESPLIT] static public FeatureCollectionConfig getConfigFromSnippet ( String filename ) { org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( filename ) ; } catch ( Exception e ) { System . out . printf ( "Error parsing featureCollection %s err = %s" , filename , e . getMessage ( ) ) ; return null ; } return FeatureCollectionReader . readFeatureCollection ( doc . getRootElement ( ) ) ; }


Input: Convert this GisFeature to a java . awt . Shape using the default coordinate system mapping gisFeature ( x y ) - > screen ( x y ) . LOOK STILL HAVE TO crossSeam () [CODESPLIT] public Shape getShape ( ) { int npts = getNumPoints ( ) ; GeneralPath path = new GeneralPath ( GeneralPath . WIND_EVEN_ODD , npts ) ; java . util . Iterator pi = getGisParts ( ) ; while ( pi . hasNext ( ) ) { GisPart gp = ( GisPart ) pi . next ( ) ; double [ ] xx = gp . getX ( ) ; double [ ] yy = gp . getY ( ) ; int np = gp . getNumPoints ( ) ; if ( np > 0 ) path . moveTo ( ( float ) xx [ 0 ] , ( float ) yy [ 0 ] ) ; for ( int i = 1 ; i < np ; i ++ ) { path . lineTo ( ( float ) xx [ i ] , ( float ) yy [ i ] ) ; } } return path ; }


Input: Convert this GisFeature to a java . awt . Shape . The data coordinate system is assumed to be ( lat lon ) use the projection to transform points so project . latLonToProj ( gisFeature ( x y )) - > screen ( x y ) . [CODESPLIT] public Shape getProjectedShape ( ProjectionImpl displayProject ) { LatLonPointImpl workL = new LatLonPointImpl ( ) ; ProjectionPointImpl lastW = new ProjectionPointImpl ( ) ; GeneralPath path = new GeneralPath ( GeneralPath . WIND_EVEN_ODD , getNumPoints ( ) ) ; boolean showPts = ucar . util . prefs . ui . Debug . isSet ( "projection/showPoints" ) ; java . util . Iterator pi = getGisParts ( ) ; while ( pi . hasNext ( ) ) { GisPart gp = ( GisPart ) pi . next ( ) ; double [ ] xx = gp . getX ( ) ; double [ ] yy = gp . getY ( ) ; boolean skipPrev = false ; int count = 0 ; for ( int i = 0 ; i < gp . getNumPoints ( ) ; i ++ ) { workL . set ( yy [ i ] , xx [ i ] ) ; ProjectionPoint pt = displayProject . latLonToProj ( workL ) ; if ( showPts ) { System . out . println ( "AbstractGisFeature getProjectedShape 1 " + xx [ i ] + " " + yy [ i ] + " === " + pt . getX ( ) + " " + pt . getY ( ) ) ; if ( displayProject . crossSeam ( pt , lastW ) ) System . out . println ( "***cross seam" ) ; } // deal with possible NaNs if ( Double . isNaN ( pt . getX ( ) ) || Double . isNaN ( pt . getY ( ) ) ) { skipPrev = true ; continue ; } if ( ( count == 0 ) || skipPrev || displayProject . crossSeam ( pt , lastW ) ) path . moveTo ( ( float ) pt . getX ( ) , ( float ) pt . getY ( ) ) ; else path . lineTo ( ( float ) pt . getX ( ) , ( float ) pt . getY ( ) ) ; count ++ ; skipPrev = false ; lastW . setLocation ( pt ) ; } } return path ; }


Input: Convert this GisFeature to a java . awt . Shape . The data coordinate system is in the coordinates of dataProject and the screen is in the coordinates of displayProject . So : displayProject . latLonToProj ( dataProject . projToLatLon ( gisFeature ( x y ))) - > screen ( x y ) . [CODESPLIT] public Shape getProjectedShape ( ProjectionImpl dataProject , ProjectionImpl displayProject ) { ProjectionPointImpl pt1 = new ProjectionPointImpl ( ) ; ProjectionPointImpl lastW = new ProjectionPointImpl ( ) ; GeneralPath path = new GeneralPath ( GeneralPath . WIND_EVEN_ODD , getNumPoints ( ) ) ; boolean showPts = ucar . util . prefs . ui . Debug . isSet ( "projection/showPoints" ) ; java . util . Iterator pi = getGisParts ( ) ; while ( pi . hasNext ( ) ) { GisPart gp = ( GisPart ) pi . next ( ) ; double [ ] xx = gp . getX ( ) ; double [ ] yy = gp . getY ( ) ; boolean skipPrev = false ; int count = 0 ; for ( int i = 0 ; i < gp . getNumPoints ( ) ; i ++ ) { pt1 . setLocation ( xx [ i ] , yy [ i ] ) ; LatLonPoint llpt = dataProject . projToLatLon ( pt1 ) ; ProjectionPoint pt2 = displayProject . latLonToProj ( llpt ) ; if ( showPts ) { System . out . println ( "AbstractGisFeature getProjectedShape 2 " + xx [ i ] + " " + yy [ i ] + " === " + pt2 . getX ( ) + " " + pt2 . getY ( ) ) ; if ( displayProject . crossSeam ( pt2 , lastW ) ) System . out . println ( "***cross seam" ) ; } // deal with possible NaNs if ( Double . isNaN ( pt2 . getX ( ) ) || Double . isNaN ( pt2 . getY ( ) ) ) { skipPrev = true ; continue ; } if ( ( count == 0 ) || skipPrev || displayProject . crossSeam ( pt2 , lastW ) ) path . moveTo ( ( float ) pt2 . getX ( ) , ( float ) pt2 . getY ( ) ) ; else path . lineTo ( ( float ) pt2 . getX ( ) , ( float ) pt2 . getY ( ) ) ; count ++ ; skipPrev = false ; lastW . setLocation ( pt2 ) ; } } return path ; }


Input: / * taken from http : // www . nssl . noaa . gov / projects / mrms / operational / tables . php [CODESPLIT] private void init ( ) { add ( 209 , 2 , 0 , "LightningDensityNLDN1min" , "CG Lightning Density 1-min - NLDN" , "flashes/km^2/min" , - 3 , - 1 ) ; add ( 209 , 2 , 1 , "LightningDensityNLDN5min" , "CG Lightning Density 5-min - NLDN" , "flashes/km^2/min" , - 3 , - 1 ) ; add ( 209 , 2 , 2 , "LightningDensityNLDN15min" , "CG Lightning Density 15-min - NLDN" , "flashes/km^2/min" , - 3 , - 1 ) ; add ( 209 , 2 , 3 , "LightningDensityNLDN30min" , "CG Lightning Density 30-min - NLDN" , "flashes/km^2/min" , - 3 , - 1 ) ; add ( 209 , 2 , 4 , "LightningProbabilityNext30min" , "Lightning Probability 0-30 minutes - NLDN" , "%" , 0 , 0 ) ; add ( 209 , 3 , 0 , "MergedAzShear0to2kmAGL" , "Azimuth Shear 0-2km AGL" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 1 , "MergedAzShear3to6kmAGL" , "Azimuth Shear 3-6km AGL" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 2 , "RotationTrack30min" , "Rotation Track 0-2km AGL 30-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 3 , "RotationTrack60min" , "Rotation Track 0-2km AGL 60-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 4 , "RotationTrack120min" , "Rotation Track 0-2km AGL 120-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 5 , "RotationTrack240min" , "Rotation Track 0-2km AGL 240-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 6 , "RotationTrack360min" , "Rotation Track 0-2km AGL 360-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 7 , "RotationTrack1440min" , "Rotation Track 0-2km AGL 1440-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 14 , "RotationTrackML30min" , "Rotation Track 0-3km AGL 30-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 15 , "RotationTrackML60min" , "Rotation Track 0-3km AGL 60-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 16 , "RotationTrackML120min" , "Rotation Track 0-3km AGL 120-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 17 , "RotationTrackML240min" , "Rotation Track 0-3km AGL 240-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 18 , "RotationTrackML360min" , "Rotation Track 0-3km AGL 360-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 19 , "RotationTrackML1440min" , "Rotation Track 0-3km AGL 1440-min" , "0.001/s" , 0 , 0 ) ; add ( 209 , 3 , 26 , "SHI" , "Severe Hail Index" , "index" , - 3 , - 1 ) ; add ( 209 , 3 , 27 , "POSH" , "Prob of Severe Hail" , "%" , - 3 , - 1 ) ; add ( 209 , 3 , 28 , "MESH" , "Maximum Estimated Size of Hail (MESH)" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 29 , "MESHMax30min" , "MESH Hail Swath 30-min" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 30 , "MESHMax60min" , "MESH Hail Swath 60-min" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 31 , "MESHMax120min" , "MESH Hail Swath 120-min" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 32 , "MESHMax240min" , "MESH Hail Swath 240-min" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 33 , "MESHMax360min" , "MESH Hail Swath 360-min" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 34 , "MESHMax1440min" , "MESH Hail Swath 1440-min" , "mm" , - 3 , - 1 ) ; add ( 209 , 3 , 41 , "VIL" , "Vertically Integrated Liquid" , "kg/m^2" , - 3 , - 1 ) ; add ( 209 , 3 , 42 , "VILDensity" , "Vertically Integrated Liquid Density" , "g/m^3" , - 3 , - 1 ) ; add ( 209 , 3 , 43 , "VII" , "Vertically Integrated Ice" , "kg/m^2" , - 3 , - 1 ) ; add ( 209 , 3 , 44 , "EchoTop18" , "Echo Top - 18 dBZ MSL" , "km" , - 3 , - 1 ) ; add ( 209 , 3 , 45 , "EchoTop30" , "Echo Top - 30 dBZ MSL" , "km" , - 3 , - 1 ) ; add ( 209 , 3 , 46 , "EchoTop50" , "Echo Top - 50 dBZ MSL" , "km" , - 3 , - 1 ) ; add ( 209 , 3 , 47 , "EchoTop60" , "Echo Top - 60 dBZ MSL" , "km" , - 3 , - 1 ) ; add ( 209 , 3 , 48 , "H50AboveM20C" , "Thickness [50 dBZ top - (-20C)]" , "km" , - 999 , - 99 ) ; add ( 209 , 3 , 49 , "H50Above0C" , "Thickness [50 dBZ top - 0C]" , "km" , - 999 , - 99 ) ; add ( 209 , 3 , 50 , "H60AboveM20C" , "Thickness [60 dBZ top - (-20C)]" , "km" , - 999 , - 99 ) ; add ( 209 , 3 , 51 , "H60Above0C" , "Thickness [60 dBZ top - 0C]" , "km" , - 999 , - 99 ) ; add ( 209 , 3 , 52 , "Reflectivity0C" , "Isothermal Reflectivity at 0C" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 3 , 53 , "ReflectivityM5C" , "Isothermal Reflectivity at -5C" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 3 , 54 , "ReflectivityM10C" , "Isothermal Reflectivity at -10C" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 3 , 55 , "ReflectivityM15C" , "Isothermal Reflectivity at -15C" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 3 , 56 , "ReflectivityM20C" , "Isothermal Reflectivity at -20C" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 3 , 57 , "ReflectivityAtLowestAltitude" , "ReflectivityAtLowestAltitude" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 3 , 58 , "MergedReflectivityAtLowestAltitude" , "Non Quality Controlled Reflectivity At Lowest Altitude" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 4 , 0 , "IRband4" , "Infrared (E/W blend)" , "K" , - 999 , - 99 ) ; add ( 209 , 4 , 1 , "Visible" , "Visible (E/W blend)" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 4 , 2 , "WaterVapor" , "Water Vapor (E/W blend)" , "K" , - 999 , - 99 ) ; add ( 209 , 4 , 3 , "CloudCover" , "Cloud Cover" , "K" , - 999 , - 99 ) ; add ( 209 , 6 , 0 , "PrecipFlag" , "Surface Precipitation Type (Convective, Stratiform, Tropical, Hail, Snow)" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 6 , 1 , "PrecipRate" , "Radar Precipitation Rate" , "mm/hr" , - 3 , - 1 ) ; add ( 209 , 6 , 2 , "RadarOnlyQPE01H" , "Radar precipitation accumulation 1-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 3 , "RadarOnlyQPE03H" , "Radar precipitation accumulation 3-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 4 , "RadarOnlyQPE06H" , "Radar precipitation accumulation 6-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 5 , "RadarOnlyQPE12H" , "Radar precipitation accumulation 12-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 6 , "RadarOnlyQPE24H" , "Radar precipitation accumulation 24-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 7 , "RadarOnlyQPE48H" , "Radar precipitation accumulation 48-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 8 , "RadarOnlyQPE72H" , "Radar precipitation accumulation 72-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 9 , "GaugeCorrQPE01H" , "Local gauge bias corrected radar precipitation accumulation 1-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 10 , "GaugeCorrQPE03H" , "Local gauge bias corrected radar precipitation accumulation 3-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 11 , "GaugeCorrQPE06H" , "Local gauge bias corrected radar precipitation accumulation 6-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 12 , "GaugeCorrQPE12H" , "Local gauge bias corrected radar precipitation accumulation 12-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 13 , "GaugeCorrQPE24H" , "Local gauge bias corrected radar precipitation accumulation 24-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 14 , "GaugeCorrQPE48H" , "Local gauge bias corrected radar precipitation accumulation 48-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 15 , "GaugeCorrQPE72H" , "Local gauge bias corrected radar precipitation accumulation 72-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 16 , "GaugeOnlyQPE01H" , "Gauge only precipitation accumulation 1-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 17 , "GaugeOnlyQPE03H" , "Gauge only precipitation accumulation 3-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 18 , "GaugeOnlyQPE06H" , "Gauge only precipitation accumulation 6-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 19 , "GaugeOnlyQPE12H" , "Gauge only precipitation accumulation 12-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 20 , "GaugeOnlyQPE24H" , "Gauge only precipitation accumulation 24-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 21 , "GaugeOnlyQPE48H" , "Gauge only precipitation accumulation 48-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 22 , "GaugeOnlyQPE72H" , "Gauge only precipitation accumulation 72-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 23 , "MountainMapperQPE01H" , "Mountain Mapper precipitation accumulation 1-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 24 , "MountainMapperQPE03H" , "Mountain Mapper precipitation accumulation 3-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 25 , "MountainMapperQPE06H" , "Mountain Mapper precipitation accumulation 6-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 26 , "MountainMapperQPE12H" , "Mountain Mapper precipitation accumulation 12-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 27 , "MountainMapperQPE24H" , "Mountain Mapper precipitation accumulation 24-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 28 , "MountainMapperQPE48H" , "Mountain Mapper precipitation accumulation 48-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 6 , 29 , "MountainMapperQPE72H" , "Mountain Mapper precipitation accumulation 72-hour" , "mm" , - 3 , - 1 ) ; add ( 209 , 7 , 0 , "ModelSurfaceTemp" , "Model Surface temperature [RAP 13km]" , "C" , - 999 , - 99 ) ; add ( 209 , 7 , 1 , "ModelWetBulbTemp" , "Model Surface wet bulb temperature [RAP 13km]" , "C" , - 999 , - 99 ) ; add ( 209 , 7 , 2 , "WarmRainProbability" , "Probability of warm rain [RAP 13km derived]" , "%" , - 3 , - 1 ) ; add ( 209 , 7 , 3 , "ModelHeight0C" , "Model Freezing Level Height [RAP 13km] MSL" , "m" , - 3 , - 1 ) ; add ( 209 , 7 , 4 , "BrightBandTopHeight" , "Brightband Top Radar [RAP 13km derived] AGL" , "m" , - 3 , - 1 ) ; add ( 209 , 7 , 5 , "BrightBandBottomHeight" , "Brightband Bottom Radar [RAP 13km derived] AGL" , "m" , - 3 , - 1 ) ; add ( 209 , 8 , 0 , "RadarQualityIndex" , "Radar Quality Index" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 1 , "GaugeInflIndex01H" , "Gauge Influence Index for 1-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 2 , "GaugeInflIndex03H" , "Gauge Influence Index for 3-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 3 , "GaugeInflIndex06H" , "Gauge Influence Index for 6-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 4 , "GaugeInflIndex12H" , "Gauge Influence Index for 12-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 5 , "GaugeInflIndex24H" , "Gauge Influence Index for 24-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 6 , "GaugeInflIndex48H" , "Gauge Influence Index for 48-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 7 , "GaugeInflIndex72H" , "Gauge Influence Index for 72-hour QPE" , "dimensionless" , - 3 , - 1 ) ; add ( 209 , 8 , 8 , "SeamlessHSR" , "Seamless Hybrid Scan Reflectivity with VPR correction" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 8 , 9 , "SeamlessHSRHeight" , "Height of Seamless Hybrid Scan Reflectivity AGL" , "km" , - 3 , - 1 ) ; add ( 209 , 9 , 0 , "ConusMergedReflectivityQC" , "WSR-88D 3D Reflectivity Mosaic - 33 CAPPIS (500-19000m)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 9 , 1 , "ConusPlusMergedReflectivityQC" , "All Radar 3D Reflectivity Mosaic - 33 CAPPIS (500-19000m)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 0 , "MergedReflectivityQCComposite" , "Composite Reflectivity Mosaic (optimal method)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 1 , "HeightCompositeReflectivity" , "Height of Composite Reflectivity Mosaic (optimal method) MSL" , "m" , - 3 , - 1 ) ; add ( 209 , 10 , 2 , "LowLevelCompositeReflectivity" , "Low-Level Composite Reflectivity Mosaic (0-4km)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 3 , "HeightLowLevelCompositeReflectivity" , "Height of Low-Level Composite Reflectivity Mosaic (0-4km) MSL" , "m" , - 3 , - 1 ) ; add ( 209 , 10 , 4 , "LayerCompositeReflectivity_Low" , "Layer Composite Reflectivity Mosaic 0-24kft (low altitude)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 5 , "LayerCompositeReflectivity_High" , "Layer Composite Reflectivity Mosaic 24-60 kft (highest altitude)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 6 , "LayerCompositeReflectivity_Super" , "Layer Composite Reflectivity Mosaic 33-60 kft (super high altitude)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 7 , "ReflectivityCompositeHourlyMax" , "Composite Reflectivity Hourly Maximum" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 10 , 8 , "ReflectivityMaxAboveM10C" , "Maximum Reflectivity at -10 deg C height and above" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 11 , 0 , "MergedBaseReflectivityQC" , "Mosaic Base Reflectivity (optimal method)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 11 , 1 , "MergedReflectivityComposite" , "UnQc'd Composite Reflectivity Mosaic (max ref)" , "dBZ" , - 999 , - 99 ) ; add ( 209 , 11 , 2 , "MergedReflectivityQComposite" , "Composite Reflectivity Mosaic (max ref)" , "dBZ" , - 999 , - 99 ) ; }


Input: Use a factory so we can debug constructor calls [CODESPLIT] static Notes factory ( NoteSort ns , int g , int id , Nc4DSP dsp ) { Notes note = null ; switch ( ns ) { case TYPE : note = new TypeNotes ( g , id , dsp ) ; break ; case VAR : note = new VarNotes ( g , id , dsp ) ; break ; case DIM : note = new DimNotes ( g , id , dsp ) ; break ; case GROUP : note = new GroupNotes ( g , id , dsp ) ; break ; } return note ; }


Input: Manage the compound id for variables [CODESPLIT] static public long getVarId ( VarNotes note ) { return getVarId ( note . gid , note . id , note . getFieldIndex ( ) ) ; }


Input:
Parse the DDS creating a tree of DodsV objects . The root node is only a container ie it has no BaseType . The Darray object ( which has the dimension info ) becomes a field of the DodsV rather than being in the tree . [CODESPLIT] static DodsV parseDDS ( DDS dds ) { DodsV root = new DodsV ( null , null ) ; // recursively get the Variables from the DDS
 Enumeration variables = dds . getVariables ( ) ; parseVariables ( root , variables ) ; // assign depth first sequence number
 root . assignSequence ( root ) ; return root ; }


Input:
Recursively build the dodsV tree . 1 ) put all Variables into a DodsV 2 ) unravel DConstructors ( DSequence DStructure DGrid ) 3 ) for Darray we put Variable = elemType and store the darray seperately not in the heirarchy . [CODESPLIT] static private void parseVariables ( DodsV parent , Enumeration children ) { while ( children . hasMoreElements ( ) ) { opendap . dap . BaseType bt = ( opendap . dap . BaseType ) children . nextElement ( ) ; if ( bt instanceof DList ) { String mess = "Variables of type " + bt . getClass ( ) . getName ( ) + " are not supported." ; logger . warn ( mess ) ; continue ; } DodsV dodsV = new DodsV ( parent , bt ) ; if ( bt instanceof DConstructor ) { DConstructor dcon = ( DConstructor ) bt ; java . util . Enumeration enumerate2 = dcon . getVariables ( ) ; parseVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DArray ) { DArray da = ( DArray ) bt ; // Check to see if the array has any zero-length dimension; if so then ignore
 for ( Enumeration e = da . getDimensions ( ) ; e . hasMoreElements ( ) ; ) { DArrayDimension dim = ( DArrayDimension ) e . nextElement ( ) ; if ( dim . getSize ( ) <= 0 ) return ; } BaseType elemType = da . getPrimitiveVector ( ) . getTemplate ( ) ; dodsV . bt = elemType ; dodsV . darray = da ; if ( ( elemType instanceof DGrid ) || ( elemType instanceof DSequence ) || ( elemType instanceof DList ) ) { String mess = "Arrays of type " + elemType . getClass ( ) . getName ( ) + " are not supported." ; logger . warn ( mess ) ; continue ; } if ( elemType instanceof DStructure ) { // note that for DataDDS, cant traverse this further to find the data.
 DConstructor dcon = ( DConstructor ) elemType ; java . util . Enumeration nestedVariables = dcon . getVariables ( ) ; parseVariables ( dodsV , nestedVariables ) ; } } parent . children . add ( dodsV ) ; } }


Input:
Parse the DDS creating a tree of DodsV objects . The root node is only a container ie it has no BaseType . The Darray object ( which has the dimension info ) becomes a field of the DodsV rather than being in the tree . [CODESPLIT] static DodsV parseDataDDS ( DataDDS dds ) throws NoSuchVariableException { DodsV root = new DodsV ( null , null ) ; // recursively get the Variables from the DDS
 Enumeration variables = dds . getVariables ( ) ; parseDataVariables ( root , variables ) ; // assign depth first sequence number
 root . assignSequence ( root ) ; return root ; }


Input:
Recursively build the dodsV tree . 1 ) put all Variables into a DodsV 2 ) unravel DConstructors ( DSequence DStructure DGrid ) 3 ) for Darray we put Variable = elemType and store the darray seperately not in the heirarchy . [CODESPLIT] static private void parseDataVariables ( DodsV parent , Enumeration children ) throws NoSuchVariableException { while ( children . hasMoreElements ( ) ) { opendap . dap . BaseType bt = ( opendap . dap . BaseType ) children . nextElement ( ) ; DodsV dodsV = new DodsV ( parent , bt ) ; parent . children . add ( dodsV ) ; if ( bt instanceof DGrid ) { DGrid dgrid = ( DGrid ) bt ; if ( dodsV . parent . bt == null ) { // is top level
 // top level grids are replaced by their "data array"
 dodsV . darray = ( DArray ) dgrid . getVar ( 0 ) ; processDArray ( dodsV ) ; } else { // nested grids are made into Structures
 dodsV . makeAllDimensions ( ) ; } java . util . Enumeration enumerate2 = dgrid . getVariables ( ) ; parseDataVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DSequence ) { DSequence dseq = ( DSequence ) bt ; int seqlen = dseq . getRowCount ( ) ; if ( seqlen > 0 ) { DArrayDimension ddim = new DArrayDimension ( seqlen , null ) ; dodsV . dimensions . add ( ddim ) ; } dodsV . makeAllDimensions ( ) ; java . util . Enumeration enumerate2 = dseq . getVariables ( ) ; parseDataVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DConstructor ) { DStructure dcon = ( DStructure ) bt ; // LOOK DConstructor != DStructure?
 dodsV . makeAllDimensions ( ) ; java . util . Enumeration enumerate2 = dcon . getVariables ( ) ; parseDataVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DArray ) { dodsV . darray = ( DArray ) bt ; processDArray ( dodsV ) ; dodsV . bt = dodsV . elemType ; if ( dodsV . elemType instanceof DStructure ) { DStructure dcon = ( DStructure ) dodsV . elemType ; java . util . Enumeration nestedVariables = dcon . getVariables ( ) ; parseDataVariables ( dodsV , nestedVariables ) ; } } else { dodsV . makeAllDimensions ( ) ; } } }


Input:
Parse the DAS assign attribute tables to the DodsV objects . Nested attribute tables are supposed to follow the tree we construct with dodsV so its easy to assign to correct dodsV . [CODESPLIT] void parseDAS ( DAS das ) throws IOException { Enumeration tableNames = das . getNames ( ) ; while ( tableNames . hasMoreElements ( ) ) { String tableName = ( String ) tableNames . nextElement ( ) ; AttributeTable attTable = das . getAttributeTableN ( tableName ) ; if ( tableName . equals ( "NC_GLOBAL" ) || tableName . equals ( "HDF_GLOBAL" ) ) { addAttributeTable ( this , attTable , tableName , true ) ; } else if ( tableName . equals ( "DODS_EXTRA" ) || tableName . equals ( "EXTRA_DIMENSION" ) ) { // handled seperately in DODSNetcdfFile
 continue ; } else { DodsV dodsV = findDodsV ( tableName , false ) ; // short name matches the table name
 if ( dodsV != null ) { addAttributeTable ( dodsV , attTable , tableName , true ) ; } else { dodsV = findTableDotDelimited ( tableName ) ; if ( dodsV != null ) { addAttributeTable ( dodsV , attTable , tableName , true ) ; } else { if ( debugAttributes ) System . out . println ( "DODSNetcdf getAttributes CANT find <" + tableName + "> add to globals" ) ; addAttributeTable ( this , attTable , tableName , false ) ; } } } } }


Input:
Search the immediate children for a BaseType with given name . [CODESPLIT] DodsV findDodsV ( String name , boolean useDone ) { for ( DodsV dodsV : children ) { if ( useDone && dodsV . isDone ) continue ; // LOOK useDone ??
 if ( ( name == null ) || ( dodsV == null ) || ( dodsV . bt == null ) ) { logger . warn ( "Corrupted structure" ) ; continue ; } if ( name . equals ( dodsV . bt . getEncodedName ( ) ) ) return dodsV ; } return null ; }


Input:
find the DodsV object in the dataVlist corresponding to the ddsV [CODESPLIT] DodsV findDataV ( DodsV ddsV ) { if ( ddsV . parent . bt != null ) { DodsV parentV = findDataV ( ddsV . parent ) ; if ( parentV == null ) // dataDDS may not have the structure wrapper
 return findDodsV ( ddsV . bt . getEncodedName ( ) , true ) ; return parentV . findDodsV ( ddsV . bt . getEncodedName ( ) , true ) ; } DodsV dataV = findDodsV ( ddsV . bt . getEncodedName ( ) , true ) ; /* if ((dataV == null) && (ddsV.bt instanceof DGrid)) { // when asking for the Grid array
      DodsV gridArray = (DodsV) ddsV.children.get(0);
      return findDodsV( gridArray.bt.getName(), dataVlist, true);
    } */ return dataV ; }


Input: Return a child by index [CODESPLIT] DodsV findByIndex ( int index ) { if ( children . size ( ) <= index ) return null ; return children . get ( index ) ; }


Input:
////////////////////////////////////////////////////////////////////////////// [CODESPLIT] private static void doit ( String urlName ) throws IOException , DAP2Exception { System . out . println ( "DODSV read =" + urlName ) ; try ( DConnect2 dodsConnection = new DConnect2 ( urlName , true ) ) { // get the DDS
 DDS dds = dodsConnection . getDDS ( ) ; dds . print ( System . out ) ; DodsV root = DodsV . parseDDS ( dds ) ; // get the DAS
 DAS das = dodsConnection . getDAS ( ) ; das . print ( System . out ) ; root . parseDAS ( das ) ; // show the dodsV tree
 root . show ( System . out , "" ) ; } }


Input: Get the shape : length of Variable in each dimension . A scalar ( rank 0 ) will have an int [ 0 ] shape . [CODESPLIT] public int [ ] getShape ( ) { int [ ] result = new int [ shape . length ] ; // optimization over clone() System . arraycopy ( shape , 0 , result , 0 , shape . length ) ; return result ; }


Input: Get the parent group . [CODESPLIT] public Group getParentGroup ( ) { Group g = super . getParentGroup ( ) ; if ( g == null ) { g = ncfile . getRootGroup ( ) ; super . setParentGroup ( g ) ; } assert g != null ; return g ; }


Input: Get the ith dimension . [CODESPLIT] public Dimension getDimension ( int i ) { if ( ( i < 0 ) || ( i >= getRank ( ) ) ) return null ; return dimensions . get ( i ) ; }


Input: Find the index of the named Dimension in this Variable . [CODESPLIT] public int findDimensionIndex ( String name ) { for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { Dimension d = dimensions . get ( i ) ; if ( name . equals ( d . getShortName ( ) ) ) return i ; } return - 1 ; }


Input: Get the Unit String for the Variable . Looks for the CDM . UNITS attribute value [CODESPLIT] public String getUnitsString ( ) { String units = null ; Attribute att = findAttribute ( CDM . UNITS ) ; if ( att == null ) att = findAttributeIgnoreCase ( CDM . UNITS ) ; if ( ( att != null ) && att . isString ( ) ) { units = att . getStringValue ( ) ; if ( units != null ) units = units . trim ( ) ; } return units ; }


Input: Get shape as a Section object . [CODESPLIT] public Section getShapeAsSection ( ) { if ( shapeAsSection == null ) { try { List < Range > list = new ArrayList <> ( ) ; for ( Dimension d : dimensions ) { int len = d . getLength ( ) ; if ( len > 0 ) list . add ( new Range ( d . getShortName ( ) , 0 , len - 1 ) ) ; else if ( len == 0 ) list . add ( Range . EMPTY ) ; // LOOK empty not named else { assert d . isVariableLength ( ) ; list . add ( Range . VLEN ) ; // LOOK vlen not named } } shapeAsSection = new Section ( list ) . makeImmutable ( ) ; } catch ( InvalidRangeException e ) { log . error ( "Bad shape in variable " + getFullName ( ) , e ) ; throw new IllegalStateException ( e . getMessage ( ) ) ; } } return shapeAsSection ; }


Input: Create a new Variable that is a logical subsection of this Variable . No data is read until a read method is called on it . [CODESPLIT] public Variable section ( List < Range > ranges ) throws InvalidRangeException { return section ( new Section ( ranges , shape ) . makeImmutable ( ) ) ; }


Input: Create a new Variable that is a logical subsection of this Variable . No data is read until a read method is called on it . [CODESPLIT] public Variable section ( Section subsection ) throws InvalidRangeException { subsection = Section . fill ( subsection , shape ) ; // create a copy of this variable with a proxy reader Variable sectionV = copy ( ) ; // subclasses must override sectionV . setProxyReader ( new SectionReader ( this , subsection ) ) ; sectionV . shape = subsection . getShape ( ) ; sectionV . createNewCache ( ) ; // dont share the cache sectionV . setCaching ( false ) ; // dont cache // replace dimensions if needed !! LOOK not shared sectionV . dimensions = new ArrayList <> ( ) ; for ( int i = 0 ; i < getRank ( ) ; i ++ ) { Dimension oldD = getDimension ( i ) ; Dimension newD = ( oldD . getLength ( ) == sectionV . shape [ i ] ) ? oldD : new Dimension ( oldD . getShortName ( ) , sectionV . shape [ i ] , false ) ; newD . setUnlimited ( oldD . isUnlimited ( ) ) ; sectionV . dimensions . add ( newD ) ; } sectionV . resetShape ( ) ; return sectionV ; }


Input: Create a new Variable that is a logical slice of this Variable by fixing the specified dimension at the specified index value . This reduces rank by 1 . No data is read until a read method is called on it . [CODESPLIT] public Variable slice ( int dim , int value ) throws InvalidRangeException { if ( ( dim < 0 ) || ( dim >= shape . length ) ) throw new InvalidRangeException ( "Slice dim invalid= " + dim ) ; // ok to make slice of record dimension with length 0 boolean recordSliceOk = false ; if ( ( dim == 0 ) && ( value == 0 ) ) { Dimension d = getDimension ( 0 ) ; recordSliceOk = d . isUnlimited ( ) ; } // otherwise check slice in range if ( ! recordSliceOk ) { if ( ( value < 0 ) || ( value >= shape [ dim ] ) ) throw new InvalidRangeException ( "Slice value invalid= " + value + " for dimension " + dim ) ; } // create a copy of this variable with a proxy reader Variable sliceV = copy ( ) ; // subclasses must override Section slice = new Section ( getShapeAsSection ( ) ) ; slice . replaceRange ( dim , new Range ( value , value ) ) . makeImmutable ( ) ; sliceV . setProxyReader ( new SliceReader ( this , dim , slice ) ) ; sliceV . createNewCache ( ) ; // dont share the cache sliceV . setCaching ( false ) ; // dont cache // remove that dimension - reduce rank sliceV . dimensions . remove ( dim ) ; sliceV . resetShape ( ) ; return sliceV ; }


Input: Create a new Variable that is a logical view of this Variable by eliminating the specified dimension ( s ) of length 1 . No data is read until a read method is called on it . [CODESPLIT] public Variable reduce ( List < Dimension > dims ) throws InvalidRangeException { List < Integer > dimIdx = new ArrayList <> ( dims . size ( ) ) ; for ( Dimension d : dims ) { assert dimensions . contains ( d ) ; assert d . getLength ( ) == 1 ; dimIdx . add ( dimensions . indexOf ( d ) ) ; } // create a copy of this variable with a proxy reader Variable sliceV = copy ( ) ; // subclasses must override sliceV . setProxyReader ( new ReduceReader ( this , dimIdx ) ) ; sliceV . createNewCache ( ) ; // dont share the cache sliceV . setCaching ( false ) ; // dont cache // remove dimension(s) - reduce rank for ( Dimension d : dims ) sliceV . dimensions . remove ( ) ; sliceV . resetShape ( ) ; return sliceV ; }


Input: Public by accident . [CODESPLIT] public void setEnumTypedef ( EnumTypedef enumTypedef ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( ! dataType . isEnum ( ) ) throw new UnsupportedOperationException ( "Can only call Variable.setEnumTypedef() on enum types" ) ; this . enumTypedef = enumTypedef ; }


Input: Read a section of the data for this Variable and return a memory resident Array . The Array has the same element type as the Variable and the requested shape . Note that this does not do rank reduction so the returned Array has the same rank as the Variable . Use Array . reduce () for rank reduction . <p / > <code > assert ( origin [ ii ] + shape [ ii ] * stride [ ii ] < = Variable . shape [ ii ] ) ; < / code > <p / > [CODESPLIT] public Array read ( int [ ] origin , int [ ] shape ) throws IOException , InvalidRangeException { if ( ( origin == null ) && ( shape == null ) ) return read ( ) ; if ( origin == null ) return read ( new Section ( shape ) ) ; if ( shape == null ) return read ( new Section ( origin , this . shape ) ) ; return read ( new Section ( origin , shape ) ) ; }


Input: Read a section of the data for this Variable from the netcdf file and return a memory resident Array . [CODESPLIT] public Array read ( List < Range > ranges ) throws IOException , InvalidRangeException { if ( null == ranges ) return _read ( ) ; return read ( new Section ( ranges ) ) ; }


Input: Read a section of the data for this Variable from the netcdf file and return a memory resident Array . The Array has the same element type as the Variable and the requested shape . Note that this does not do rank reduction so the returned Array has the same rank as the Variable . Use Array . reduce () for rank reduction . <p / > If the Variable is a member of an array of Structures this returns only the variable s data in the first Structure so that the Array shape is the same as the Variable . To read the data in all structures use ncfile . readSectionSpec () . <p / > Note this only allows you to specify a subset of this variable . If the variable is nested in a array of structures and you want to subset that use NetcdfFile . read ( String sectionSpec boolean flatten ) ; [CODESPLIT] public Array read ( ucar . ma2 . Section section ) throws java . io . IOException , ucar . ma2 . InvalidRangeException { return ( section == null ) ? _read ( ) : _read ( Section . fill ( section , shape ) ) ; }


Input: Get the value as a String for a scalar Variable . May also be one - dimensional of length 1 . May also be one - dimensional of type CHAR which wil be turned into a scalar String . [CODESPLIT] public String readScalarString ( ) throws IOException { Array data = getScalarData ( ) ; if ( dataType == DataType . STRING ) return ( String ) data . getObject ( Index . scalarIndexImmutable ) ; else if ( dataType == DataType . CHAR ) { ArrayChar dataC = ( ArrayChar ) data ; return dataC . getString ( ) ; } else throw new IllegalArgumentException ( "readScalarString not STRING or CHAR " + getFullName ( ) ) ; }


Input: non - structure - member Variables . [CODESPLIT] protected Array _read ( ) throws IOException { // caching overrides the proxyReader // check if already cached if ( cache . data != null ) { if ( debugCaching ) System . out . println ( "got data from cache " + getFullName ( ) ) ; return cache . data . copy ( ) ; } Array data = proxyReader . reallyRead ( this , null ) ; // optionally cache it if ( isCaching ( ) ) { setCachedData ( data ) ; if ( debugCaching ) System . out . println ( "cache " + getFullName ( ) ) ; return cache . data . copy ( ) ; // dont let users get their nasty hands on cached data } else { return data ; } }


Input: public by accident do not call directly . [CODESPLIT] @ Override public Array reallyRead ( Variable client , CancelTask cancelTask ) throws IOException { if ( isMemberOfStructure ( ) ) { // LOOK should be UnsupportedOperationException ?? List < String > memList = new ArrayList <> ( ) ; memList . add ( this . getShortName ( ) ) ; Structure s = getParentStructure ( ) . select ( memList ) ; ArrayStructure as = ( ArrayStructure ) s . read ( ) ; return as . extractMemberArray ( as . findMember ( getShortName ( ) ) ) ; } try { return ncfile . readData ( this , getShapeAsSection ( ) ) ; } catch ( InvalidRangeException e ) { e . printStackTrace ( ) ; throw new IOException ( e . getMessage ( ) ) ; // cant happen haha } }


Input: assume filled validated Section [CODESPLIT] protected Array _read ( Section section ) throws IOException , InvalidRangeException { // check if its really a full read if ( ( null == section ) || section . computeSize ( ) == getSize ( ) ) return _read ( ) ; // full read was cached if ( isCaching ( ) ) { if ( cache . data == null ) { setCachedData ( _read ( ) ) ; // read and cache entire array if ( debugCaching ) System . out . println ( "cache " + getFullName ( ) ) ; } if ( debugCaching ) System . out . println ( "got data from cache " + getFullName ( ) ) ; return cache . data . sectionNoReduce ( section . getRanges ( ) ) . copy ( ) ; // subset it, return copy } return proxyReader . reallyRead ( this , section , null ) ; }


Input: public by accident do not call directly . [CODESPLIT] @ Override public Array reallyRead ( Variable client , Section section , CancelTask cancelTask ) throws IOException , InvalidRangeException { if ( isMemberOfStructure ( ) ) { throw new UnsupportedOperationException ( "Cannot directly read section of Member Variable=" + getFullName ( ) ) ; } // read just this section return ncfile . readData ( this , section ) ; }


Input: / * structure - member Variable ; section has a Range for each array in the parent stuctures ( s ) and for the Variable . private Array _readMemberData ( List<Range > section boolean flatten ) throws IOException InvalidRangeException { / * Variable useVar = ( ioVar ! = null ) ? ioVar : this ; NetcdfFile useFile = ( ncfileIO ! = null ) ? ncfileIO : ncfile ; return useFile . readMemberData ( useVar section flatten ) ; } [CODESPLIT] public long readToByteChannel ( Section section , WritableByteChannel wbc ) throws IOException , InvalidRangeException { if ( ( ncfile == null ) || hasCachedData ( ) ) return IospHelper . copyToByteChannel ( read ( section ) , wbc ) ; return ncfile . readToByteChannel ( this , section , wbc ) ; }


Input: Get the display name plus the dimensions eg float name ( dim1 dim2 ) [CODESPLIT] public String getNameAndDimensions ( ) { Formatter buf = new Formatter ( ) ; getNameAndDimensions ( buf , true , false ) ; return buf . toString ( ) ; }


Input: Get the display name plus the dimensions eg float name ( dim1 dim2 ) [CODESPLIT] public String getNameAndDimensions ( boolean strict ) { Formatter buf = new Formatter ( ) ; getNameAndDimensions ( buf , false , strict ) ; return buf . toString ( ) ; }


Input: Get the display name plus the dimensions eg name ( dim1 dim2 ) [CODESPLIT] public void getNameAndDimensions ( StringBuffer buf ) { Formatter proxy = new Formatter ( ) ; getNameAndDimensions ( proxy , true , false ) ; buf . append ( proxy . toString ( ) ) ; }


Input: Add display name plus the dimensions to the StringBuffer [CODESPLIT] public void getNameAndDimensions ( StringBuilder buf , boolean useFullName , boolean strict ) { Formatter proxy = new Formatter ( ) ; getNameAndDimensions ( proxy , useFullName , strict ) ; buf . append ( proxy . toString ( ) ) ; }


Input: Add display name plus the dimensions to the StringBuffer [CODESPLIT] public void getNameAndDimensions ( Formatter buf , boolean useFullName , boolean strict ) { useFullName = useFullName && ! strict ; String name = useFullName ? getFullName ( ) : getShortName ( ) ; if ( strict ) name = NetcdfFile . makeValidCDLName ( getShortName ( ) ) ; buf . format ( "%s" , name ) ; if ( shape != null ) { if ( getRank ( ) > 0 ) buf . format ( "(" ) ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { Dimension myd = dimensions . get ( i ) ; String dimName = myd . getShortName ( ) ; if ( ( dimName != null ) && strict ) dimName = NetcdfFile . makeValidCDLName ( dimName ) ; if ( i != 0 ) buf . format ( ", " ) ; if ( myd . isVariableLength ( ) ) { buf . format ( "*" ) ; } else if ( myd . isShared ( ) ) { if ( ! strict ) buf . format ( "%s=%d" , dimName , myd . getLength ( ) ) ; else buf . format ( "%s" , dimName ) ; } else { if ( dimName != null ) { buf . format ( "%s=" , dimName ) ; } buf . format ( "%d" , myd . getLength ( ) ) ; } } if ( getRank ( ) > 0 ) buf . format ( ")" ) ; } }


Input: CDL representation of a Variable . [CODESPLIT] public String writeCDL ( boolean useFullName , boolean strict ) { Formatter buf = new Formatter ( ) ; writeCDL ( buf , new Indent ( 2 ) , useFullName , strict ) ; return buf . toString ( ) ; }


Input: String representation of Variable and its attributes . [CODESPLIT] public String toStringDebug ( ) { Formatter f = new Formatter ( ) ; f . format ( "Variable %s" , getFullName ( ) ) ; if ( ncfile != null ) { f . format ( " in file %s" , getDatasetLocation ( ) ) ; String extra = ncfile . toStringDebug ( this ) ; if ( extra != null ) f . format ( " %s" , extra ) ; } return f . toString ( ) ; }


Input:
Set the data type [CODESPLIT] public void setDataType ( DataType dataType ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; this . dataType = dataType ; this . elementSize = getDataType ( ) . getSize ( ) ; /* why is this needed ??
    EnumTypedef etd = getEnumTypedef();
    if (etd != null) {
      DataType etdtype = etd.getBaseType();
      if (dataType != etdtype)
        log.error("Variable.setDataType: enum basetype mismatch: {} != {}", etdtype, dataType);

      /* DataType basetype = null;
      if (dataType == DataType.ENUM1) basetype = DataType.BYTE;
      else if (dataType == DataType.ENUM2) basetype = DataType.SHORT;
      else if (dataType == DataType.ENUM4) basetype = DataType.INT;
      else basetype = etdtype;

      if (etdtype != null && dataType != etdtype)
      else
        etd.setBaseType(basetype);
    }  */ }


Input: Set the shape with a list of Dimensions . The Dimensions may be shared or not . Dimensions are in order slowest varying first . Send a null for a scalar . Technically you can use Dimensions from any group ; pragmatically you should only use Dimensions contained in the Variable s parent groups . [CODESPLIT] public void setDimensions ( List < Dimension > dims ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; this . dimensions = ( dims == null ) ? new ArrayList <> ( ) : new ArrayList <> ( dims ) ; resetShape ( ) ; }


Input: Use when dimensions have changed to recalculate the shape . [CODESPLIT] public void resetShape ( ) { // if (immutable) throw new IllegalStateException("Cant modify");  LOOK allow this for unlimited dimension updating this . shape = new int [ dimensions . size ( ) ] ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { Dimension dim = dimensions . get ( i ) ; shape [ i ] = dim . getLength ( ) ; //shape[i] = Math.max(dim.getLength(), 0); // LOOK // if (dim.isUnlimited() && (i != 0)) // LOOK only true for Netcdf-3 //   throw new IllegalArgumentException("Unlimited dimension must be outermost"); if ( dim . isVariableLength ( ) ) { //if (dimensions.size() != 1) //  throw new IllegalArgumentException("Unknown dimension can only be used in 1 dim array"); //else isVariableLength = true ; } } this . shapeAsSection = null ; // recalc next time its asked for }


Input: Set the dimensions using the dimensions names . The dimension is searched for recursively in the parent groups . [CODESPLIT] public void setDimensions ( String dimString ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; try { setDimensions ( Dimension . makeDimensionsList ( getParentGroup ( ) , dimString ) ) ; //this.dimensions = Dimension.makeDimensionsList(getParentGroup(), dimString); resetShape ( ) ; } catch ( IllegalStateException e ) { throw new IllegalArgumentException ( "Variable " + getFullName ( ) + " setDimensions = '" + dimString + "' FAILED: " + e . getMessage ( ) + " file = " + getDatasetLocation ( ) ) ; } }


Input: Reset the dimension array . Anonymous dimensions are left alone . Shared dimensions are searched for recursively in the parent groups . [CODESPLIT] public void resetDimensions ( ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; ArrayList < Dimension > newDimensions = new ArrayList <> ( ) ; for ( Dimension dim : dimensions ) { if ( dim . isShared ( ) ) { Dimension newD = getParentGroup ( ) . findDimension ( dim . getShortName ( ) ) ; if ( newD == null ) throw new IllegalArgumentException ( "Variable " + getFullName ( ) + " resetDimensions  FAILED, dim doesnt exist in parent group=" + dim ) ; newDimensions . add ( newD ) ; } else { newDimensions . add ( dim ) ; } } this . dimensions = newDimensions ; resetShape ( ) ; }


Input: Set the dimensions using all anonymous ( unshared ) dimensions [CODESPLIT] public void setDimensionsAnonymous ( int [ ] shape ) throws InvalidRangeException { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; this . dimensions = new ArrayList <> ( ) ; for ( int i = 0 ; i < shape . length ; i ++ ) { if ( ( shape [ i ] < 1 ) && ( shape [ i ] != - 1 ) ) throw new InvalidRangeException ( "shape[" + i + "]=" + shape [ i ] + " must be > 0" ) ; Dimension anon ; if ( shape [ i ] == - 1 ) { anon = Dimension . VLEN ; isVariableLength = true ; } else { anon = new Dimension ( null , shape [ i ] , false , false , false ) ; } dimensions . add ( anon ) ; } resetShape ( ) ; }


Input: Replace a dimension with an equivalent one . [CODESPLIT] public void setDimension ( int idx , Dimension dim ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; dimensions . set ( idx , dim ) ; resetShape ( ) ; }


Input: Will this Variable be cached when read . Set externally or calculated based on total size < sizeToCache . <p > This will always return { @code false } if { @link #permitCaching caching isn t permitted } . [CODESPLIT] public boolean isCaching ( ) { if ( ! permitCaching ) { return false ; } if ( ! this . cache . cachingSet ) { cache . isCaching = ! isVariableLength && ( getSize ( ) * getElementSize ( ) < getSizeToCache ( ) ) ; if ( debugCaching ) System . out . printf ( "  cache %s %s %d < %d%n" , getFullName ( ) , cache . isCaching , getSize ( ) * getElementSize ( ) , getSizeToCache ( ) ) ; this . cache . cachingSet = true ; } return cache . isCaching ; }


Input: Set the data cache [CODESPLIT] public void setCachedData ( Array cacheData , boolean isMetadata ) { if ( ( cacheData != null ) && ( cacheData . getElementType ( ) != getDataType ( ) . getPrimitiveClassType ( ) ) ) throw new IllegalArgumentException ( "setCachedData type=" + cacheData . getElementType ( ) + " incompatible with variable type=" + getDataType ( ) ) ; this . cache . data = cacheData ; this . isMetadata = isMetadata ; this . cache . cachingSet = true ; this . cache . isCaching = true ; }


Input: Get list of Dimensions including parents if any . [CODESPLIT] public List < Dimension > getDimensionsAll ( ) { List < Dimension > dimsAll = new ArrayList <> ( ) ; addDimensionsAll ( dimsAll , this ) ; return dimsAll ; }


Input: Calculate if this is a classic coordinate variable : has same name as its first dimension . If type char must be 2D else must be 1D . [CODESPLIT] public boolean isCoordinateVariable ( ) { if ( ( dataType == DataType . STRUCTURE ) || isMemberOfStructure ( ) ) // Structures and StructureMembers cant be coordinate variables return false ; int n = getRank ( ) ; if ( n == 1 && dimensions . size ( ) == 1 ) { Dimension firstd = dimensions . get ( 0 ) ; if ( getShortName ( ) . equals ( firstd . getShortName ( ) ) ) { //  : short names match return true ; } } if ( n == 2 && dimensions . size ( ) == 2 ) { // two dimensional Dimension firstd = dimensions . get ( 0 ) ; if ( shortName . equals ( firstd . getShortName ( ) ) && // short names match ( getDataType ( ) == DataType . CHAR ) ) { // must be char valued (really a String) return true ; } } return false ; }


Input: you must set EarthLocation before you call this . [CODESPLIT] protected void setBoundingBox ( ) { LatLonRect largestBB = null ; // look through all the coord systems for ( Object o : csHash . values ( ) ) { RadialCoordSys sys = ( RadialCoordSys ) o ; sys . setOrigin ( origin ) ; LatLonRect bb = sys . getBoundingBox ( ) ; if ( largestBB == null ) largestBB = bb ; else if ( bb != null ) largestBB . extend ( bb ) ; } boundingBox = largestBB ; }


Input:
call after adding all runs [CODESPLIT] void finish ( ) { gridList = new ArrayList <> ( uvHash . values ( ) ) ; Collections . sort ( gridList ) ; // find the common coordinates
 for ( GridVariable grid : gridList ) { grid . finish ( ) ; } // assign sequence number for time
 int seqno = 0 ; for ( TimeCoord tc : timeCoords ) tc . setId ( seqno ++ ) ; // assign sequence number for vertical coords with same name
 HashMap < String , List < VertCoord > > map = new HashMap <> ( ) ; for ( VertCoord vc : vertCoords ) { List < VertCoord > list = map . get ( vc . getName ( ) ) ; if ( list == null ) { list = new ArrayList <> ( ) ; map . put ( vc . getName ( ) , list ) ; } list . add ( vc ) ; } for ( List < VertCoord > list : map . values ( ) ) { if ( list . size ( ) > 0 ) { int count = 0 ; for ( VertCoord vc : list ) { if ( count > 0 ) vc . setName ( vc . getName ( ) + count ) ; count ++ ; } } } }


Input: ////////////////////////////////////// [CODESPLIT] private void parseTemporalExtentForm ( ) { // from the form if ( temporal == null ) { errs . format ( "form must have temporal=(all|range|point)%n" ) ; fatal = true ; return ; } if ( temporal . equalsIgnoreCase ( "all" ) ) temporalSelection = TemporalSelection . all ; else if ( temporal . equalsIgnoreCase ( "range" ) ) temporalSelection = TemporalSelection . range ; else if ( temporal . equalsIgnoreCase ( "point" ) ) temporalSelection = TemporalSelection . point ; if ( temporal . equalsIgnoreCase ( "range" ) ) { try { parseTimeExtent ( ) ; } catch ( Throwable t ) { errs . format ( "badly specified time range" ) ; fatal = true ; } } else if ( temporal . equalsIgnoreCase ( "point" ) ) { timePoint = parseDate ( "time" , time ) ; } }


Input: get all datasets contained directly in this catalog [CODESPLIT] public Iterable < Dataset > getAllDatasets ( ) { List < Dataset > all = new ArrayList <> ( ) ; addAll ( this , all ) ; return all ; }


Input: A path is a Synthetic path if it ends in . dmr or . syn [CODESPLIT] public boolean dspMatch ( String path , DapContext context ) { for ( String ext : SYNEXTENSIONS ) { if ( path . endsWith ( ext ) ) return true ; } return false ; }


Input: Provide an extra API for use in testing [CODESPLIT] public CDMDSP open ( NetcdfDataset ncd ) throws DapException { assert this . context != null ; this . dmrfactory = new DMRFactory ( ) ; this . ncdfile = ncd ; setLocation ( this . ncdfile . getLocation ( ) ) ; buildDMR ( ) ; return this ; }


Input: Track generic CDMNode < - > DapNode [CODESPLIT] protected void recordNode ( CDMNode cdm , DapNode dap ) { assert this . nodemap . get ( cdm ) == null && this . nodemap . get ( dap ) == null ; this . nodemap . put ( cdm , dap ) ; }


Input: Track Variable < - > DapVariable [CODESPLIT] protected void recordVar ( Variable cdm , DapVariable dap ) { cdm = CDMUtil . unwrap ( cdm ) ; assert varmap . get ( cdm ) == null && varmap . get ( dap ) == null ; varmap . put ( cdm , dap ) ; }


Input: Track Variable < - > DapStructure [CODESPLIT] protected void recordStruct ( Variable cdm , DapStructure dap ) { cdm = CDMUtil . unwrap ( cdm ) ; assert this . nodemap . get ( cdm ) == null && this . nodemap . get ( dap ) == null ; compoundmap . put ( cdm , dap ) ; }


Input: Track Variable < - > DapSequence [CODESPLIT] protected void recordSeq ( Variable cdm , DapSequence dap ) { cdm = CDMUtil . unwrap ( cdm ) ; assert this . vlenmap . get ( cdm ) == null && this . vlenmap . get ( dap ) == null ; vlenmap . put ( cdm , dap ) ; }


Input: Extract the metadata from the NetcdfDataset and build the DMR . [CODESPLIT] public void buildDMR ( ) throws DapException { if ( getDMR ( ) != null ) return ; try { if ( DUMPCDL ) { System . out . println ( "writecdl:" ) ; this . ncdfile . writeCDL ( System . out , false ) ; System . out . flush ( ) ; } // Use the file path to define the dataset name String name = this . ncdfile . getLocation ( ) ; // Normalize the name name = DapUtil . canonicalpath ( name ) ; // Remove any path prefix int index = name . lastIndexOf ( ' ' ) ; if ( index >= 0 ) name = name . substring ( index + 1 , name . length ( ) ) ; // Initialize the root dataset node setDMR ( ( DapDataset ) dmrfactory . newDataset ( name ) . annotate ( NetcdfDataset . class , this . ncdfile ) ) ; // Map the CDM root group to this group recordNode ( this . ncdfile . getRootGroup ( ) , getDMR ( ) ) ; getDMR ( ) . setBase ( DapUtil . canonicalpath ( this . ncdfile . getLocation ( ) ) ) ; // Now recursively build the tree. Start by // Filling the dataset with the contents of the ncfile // root group. fillgroup ( getDMR ( ) , this . ncdfile . getRootGroup ( ) ) ; // Add an order index to the tree getDMR ( ) . sort ( ) ; // Now locate the coordinate variables for maps /* Walk looking for VariableDS instances */ processmappedvariables ( this . ncdfile . getRootGroup ( ) ) ; // Now set the view getDMR ( ) . finish ( ) ; } catch ( DapException e ) { setDMR ( null ) ; throw new DapException ( e ) ; } }


Input: Actions [CODESPLIT] protected void fillgroup ( DapGroup dapgroup , Group cdmgroup ) throws DapException { // Create decls in dap group for Dimensions for ( Dimension cdmdim : cdmgroup . getDimensions ( ) ) { DapDimension dapdim = builddim ( cdmdim ) ; } // Create decls in dap group for Enumerations for ( EnumTypedef cdmenum : cdmgroup . getEnumTypedefs ( ) ) { String name = cdmenum . getShortName ( ) ; DapEnumeration dapenum = buildenum ( cdmenum ) ; dapenum . setShortName ( name ) ; dapgroup . addDecl ( dapenum ) ; } // Create decls in dap group for vlen induced Sequences // Do this before building compound types for ( Variable cdmvar0 : cdmgroup . getVariables ( ) ) { Variable cdmvar = CDMUtil . unwrap ( cdmvar0 ) ; buildseqtypes ( cdmvar ) ; } // Create decls in dap group for Compound Types for ( Variable cdmvar0 : cdmgroup . getVariables ( ) ) { Variable cdmvar = CDMUtil . unwrap ( cdmvar0 ) ; if ( cdmvar . getDataType ( ) != DataType . STRUCTURE && cdmvar . getDataType ( ) != DataType . SEQUENCE ) continue ; DapStructure struct = buildcompoundtype ( cdmvar , dapgroup ) ; } // Create decls in dap group for Variables for ( Variable cdmvar0 : cdmgroup . getVariables ( ) ) { Variable cdmvar = CDMUtil . unwrap ( cdmvar0 ) ; DapNode newvar = buildvariable ( cdmvar , dapgroup , cdmvar . getDimensions ( ) ) ; } // Create decls in dap group for subgroups for ( Group subgroup : cdmgroup . getGroups ( ) ) { DapGroup newgroup = buildgroup ( subgroup ) ; dapgroup . addDecl ( newgroup ) ; } // Create decls in dap group for group-level attributes buildattributes ( dapgroup , cdmgroup . getAttributes ( ) ) ; }


Input: Declaration Builders [CODESPLIT] protected DapDimension builddim ( Dimension cdmdim ) throws DapException { if ( cdmdim . isVariableLength ( ) ) throw new DapException ( "* dimensions not supported" ) ; DapDimension dapdim = null ; long cdmsize = dapsize ( cdmdim ) ; String name = cdmdim . getShortName ( ) ; if ( name != null && name . length ( ) == 0 ) name = null ; boolean shared = cdmdim . isShared ( ) ; if ( ! shared ) { // Unlike the parser, since we are working // from a NetcdfDataset instance, there might // be multiple anonymous dimension objects // the same size. So, just go ahead and create // multiple instances. dapdim = ( DapDimension ) dmrfactory . newDimension ( null , cdmsize ) ; getDMR ( ) . addDecl ( dapdim ) ; } else { // Non anonymous; create in current group dapdim = ( DapDimension ) dmrfactory . newDimension ( name , cdmsize ) ; dapdim . setShared ( true ) ; if ( cdmdim . isUnlimited ( ) ) { dapdim . setUnlimited ( true ) ; } Group cdmparent = cdmdim . getGroup ( ) ; DapGroup dapparent = ( DapGroup ) this . nodemap . get ( cdmparent ) ; assert dapparent != null ; assert ( dapparent != null ) ; dapparent . addDecl ( dapdim ) ; } recordNode ( cdmdim , dapdim ) ; return dapdim ; }


Input: / * Create a sequence from a variable with a variable length last dimension . Suppose we have cdm equivalent to this : T var [ d1 ] ... [ dn ]] [ * ] We convert to the following <Sequence name = var > <T name = var / > <Dim name = d1 / > ... <Dim name = dn / > < / Sequence > [CODESPLIT] protected DapSequence buildseqtype ( Variable cdmvar ) throws DapException { cdmvar = CDMUtil . unwrap ( cdmvar ) ; assert ( CDMUtil . hasVLEN ( cdmvar ) ) ; DataType dt = cdmvar . getDataType ( ) ; DapType daptype = CDMTypeFcns . cdmtype2daptype ( dt ) ; DapSequence seq = ( DapSequence ) dmrfactory . newSequence ( cdmvar . getShortName ( ) ) ; // fill DapSequence with a single field; note that the dimensions // are elided because they will attach to the sequence variable, // not the field DapVariable field = dmrfactory . newVariable ( cdmvar . getShortName ( ) , daptype ) ; seq . addField ( field ) ; field . setParent ( seq ) ; recordSeq ( cdmvar , seq ) ; return seq ; }


Input: Walk this variable including fields to construct sequence types for any contained vlen dimensions [CODESPLIT] protected void buildseqtypes ( Variable cdmvar ) throws DapException { if ( CDMUtil . hasVLEN ( cdmvar ) ) { buildseqtype ( cdmvar ) ; } if ( cdmvar . getDataType ( ) == DataType . STRUCTURE || cdmvar . getDataType ( ) == DataType . SEQUENCE ) { Structure struct = ( Structure ) cdmvar ; List < Variable > fields = struct . getVariables ( ) ; for ( int i = 0 ; i < fields . size ( ) ; i ++ ) { Variable field = fields . get ( i ) ; buildseqtypes ( field ) ; // recurse for inner vlen dims } } }


Input: Assign dimensions to a variable [CODESPLIT] protected void builddimrefs ( DapVariable dapvar , List < Dimension > cdmdims ) throws DapException { if ( cdmdims == null || cdmdims . size ( ) == 0 ) return ; // It is unfortunately the case that the dimensions // associated with the variable are not // necessarily the same object as those dimensions // as declared, so we need to use a non-trivial // matching algorithm. for ( Dimension cdmdim : cdmdims ) { DapDimension dapdim = null ; if ( cdmdim . isShared ( ) ) { Dimension declareddim = finddimdecl ( cdmdim ) ; if ( declareddim == null ) throw new DapException ( "Unprocessed cdm dimension: " + cdmdim ) ; dapdim = ( DapDimension ) this . nodemap . get ( declareddim ) ; assert dapdim != null ; } else if ( cdmdim . isVariableLength ( ) ) { // ignore continue ; } else { //anonymous dapdim = builddim ( cdmdim ) ; } assert ( dapdim != null ) : "Internal error" ; dapvar . addDimension ( dapdim ) ; } }


Input:
Unfortunately the CDM Iosp does not actually use the declared enums . Rather for every enum type d variable a new enum decl is defined . So we need to find the original enum decl that matches the variable s enum . [CODESPLIT] protected EnumTypedef findMatchingEnum ( EnumTypedef varenum ) throws DapException { List < EnumTypedef > candidates = new ArrayList <> ( ) ; for ( Map . Entry < DapNode , CDMNode > entry : this . nodemap . getCDMMap ( ) . entrySet ( ) ) { CDMNode cdmnode = entry . getValue ( ) ; if ( cdmnode . getSort ( ) != CDMSort . ENUMERATION ) continue ; // Compare the enumeration (note names will differ) EnumTypedef target = ( EnumTypedef ) cdmnode ; /* Ideally, we should test the types of the enums,
               but, unfortunately, the var enum is always enum4.
            if(target.getBaseType() != varenum.getBaseType())
                continue;
            */ Map < Integer , String > targetmap = target . getMap ( ) ; Map < Integer , String > varmap = varenum . getMap ( ) ; if ( targetmap . size ( ) != varmap . size ( ) ) continue ; boolean match = true ; // until otherwise shown for ( Map . Entry < Integer , String > tpair : targetmap . entrySet ( ) ) { String tname = tpair . getValue ( ) ; int value = ( int ) tpair . getKey ( ) ; boolean found = false ; for ( Map . Entry < Integer , String > vpair : varmap . entrySet ( ) ) { if ( tname . equals ( vpair . getValue ( ) ) && value == ( int ) vpair . getKey ( ) ) { found = true ; break ; } } if ( ! found ) { match = false ; break ; } } if ( ! match ) continue ; // Save it unless it is shadowed by a closer enum boolean shadowed = false ; for ( EnumTypedef etd : candidates ) { if ( shadows ( etd . getGroup ( ) , target . getGroup ( ) ) ) { shadowed = true ; break ; } } if ( ! shadowed ) candidates . add ( target ) ; } switch ( candidates . size ( ) ) { case 0 : throw new DapException ( "CDMDSP: No matching enum type decl: " + varenum . getShortName ( ) ) ; case 1 : break ; default : throw new DapException ( "CDMDSP: Multiple matching enum type decls: " + varenum . getShortName ( ) ) ; } return candidates . get ( 0 ) ; }


Input: //////////////////////////////////////////////// [CODESPLIT] protected NetcdfFile createNetcdfFile ( String location , CancelTask canceltask ) throws DapException { try { NetcdfFile ncfile = NetcdfFile . open ( location , - 1 , canceltask , getContext ( ) ) ; return ncfile ; } catch ( DapException de ) { if ( DEBUG ) de . printStackTrace ( ) ; throw de ; } catch ( Exception e ) { if ( DEBUG ) e . printStackTrace ( ) ; throw new DapException ( e ) ; } }


Input: Strip vlen dimensions from a set of dimensions [CODESPLIT] static List < Dimension > getCoreDimset ( List < Dimension > dimset ) throws DapException { if ( dimset == null ) return null ; List < Dimension > core = new ArrayList <> ( ) ; int pos = - 1 ; int count = 0 ; for ( int i = 0 ; i < dimset . size ( ) ; i ++ ) { if ( dimset . get ( i ) . isVariableLength ( ) ) { pos = i ; count ++ ; } else core . add ( dimset . get ( i ) ) ; } if ( ( pos != dimset . size ( ) - 1 ) || count > 1 ) throw new DapException ( "Unsupported use of (*) Dimension" ) ; return core ; }


Input: Some attributes that are added by the NetcdfDataset need to be kept out of the DMR . This function defines that set . [CODESPLIT] protected boolean suppress ( String attrname ) { if ( attrname . startsWith ( "_Coord" ) ) return true ; if ( attrname . equals ( CDM . UNSIGNED ) ) return true ; return false ; }


Input: ///////////// [CODESPLIT] public java . util . List < FileBean > scan ( String top , Formatter errlog ) { List < FileBean > result = new ArrayList <> ( ) ; File topFile = new File ( top ) ; if ( ! topFile . exists ( ) ) { errlog . format ( "File %s does not exist" , top ) ; return result ; } if ( topFile . isDirectory ( ) ) scanDirectory ( topFile , false , result , errlog ) ; else { FileBean fdb = null ; try { fdb = new FileBean ( topFile ) ; } catch ( IOException e ) { System . out . printf ( "FAIL, skip %s%n" , topFile . getPath ( ) ) ; } result . add ( fdb ) ; } return result ; }


Input: Prints the original string representation of this clause . For use in debugging . [CODESPLIT] public void printConstraint ( PrintWriter os ) { if ( constant ) { value . printVal ( os , "" , false ) ; } else { value . printConstraint ( os ) ; } }


Input: gml : description [CODESPLIT] public static StringOrRefType initDescription ( StringOrRefType description , StationTimeSeriesFeature stationFeat ) { // TEXT description . setStringValue ( stationFeat . getDescription ( ) ) ; return description ; }


Input: open the file and extract BUFR messages [CODESPLIT] public int scanBufrFile ( String filename , Counter total ) throws Exception { int count = 0 ; try ( RandomAccessFile raf = new RandomAccessFile ( filename , "r" ) ) { MessageScanner scan = new MessageScanner ( raf ) ; while ( scan . hasNext ( ) ) { Message m = scan . next ( ) ; if ( m == null ) continue ; try { if ( showMess ) out . format ( "%sMessage %d header=%s%n" , indent , count , m . getHeader ( ) ) ; count ++ ; Counter counter = new Counter ( ) ; processBufrMessageAsDataset ( scan , m , counter ) ; if ( showMess ) out . format ( "%scount=%d miss=%d%n" , indent , counter . nvals , counter . nmiss ) ; total . add ( counter ) ; } catch ( Exception e ) { System . out . printf ( "  BARF:%s on %s%n" , e . getMessage ( ) , m . getHeader ( ) ) ; indent . setIndentLevel ( 0 ) ; } } } return count ; }


Input: convert one message ino a NetcdfDataset and print data [CODESPLIT] private void processBufrMessageAsDataset ( MessageScanner scan , Message m , Counter counter ) throws Exception { byte [ ] mbytes = scan . getMessageBytes ( m ) ; NetcdfFile ncfile = NetcdfFile . openInMemory ( "test" , mbytes , "ucar.nc2.iosp.bufr.BufrIosp" ) ; Sequence obs = ( Sequence ) ncfile . findVariable ( BufrIosp2 . obsRecord ) ; StructureDataIterator sdataIter = obs . getStructureIterator ( - 1 ) ; processSequence ( obs , sdataIter , counter ) ; }


Input: iterate through the observations [CODESPLIT] private void processSequence ( Structure s , StructureDataIterator sdataIter , Counter counter ) throws IOException { indent . incr ( ) ; int count = 0 ; try { while ( sdataIter . hasNext ( ) ) { if ( showData ) out . format ( "%sSequence %s count=%d%n" , indent , s . getShortName ( ) , count ++ ) ; StructureData sdata = sdataIter . next ( ) ; indent . incr ( ) ; for ( StructureMembers . Member m : sdata . getMembers ( ) ) { Variable v = s . findVariable ( m . getName ( ) ) ; if ( m . getDataType ( ) . isString ( ) || m . getDataType ( ) . isNumeric ( ) ) { processVariable ( v , sdata . getArray ( m ) , counter ) ; } else if ( m . getDataType ( ) == DataType . STRUCTURE ) { Structure sds = ( Structure ) v ; ArrayStructure data = ( ArrayStructure ) sdata . getArray ( m ) ; processSequence ( sds , data . getStructureDataIterator ( ) , counter ) ; } else if ( m . getDataType ( ) == DataType . SEQUENCE ) { Sequence sds = ( Sequence ) v ; ArraySequence data = ( ArraySequence ) sdata . getArray ( m ) ; processSequence ( sds , data . getStructureDataIterator ( ) , counter ) ; } } indent . decr ( ) ; } } finally { sdataIter . close ( ) ; } indent . decr ( ) ; }


Input: private ArrayInt . D1 parentArray = new ArrayInt . D1 ( 1 ) ; [CODESPLIT] private void createRecordVariables ( List < ? extends VariableSimpleIF > dataVars ) { ncfileOut . addDimension ( null , new Dimension ( recordDimName , 0 , true , true , false ) ) ; // time variable Variable timeVar = ncfileOut . addVariable ( null , timeName , DataType . DOUBLE , recordDimName ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "secs since 1970-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( CDM . LONG_NAME , "date/time of observation" ) ) ; recordVars . add ( timeVar ) ; // latitude variable Variable latVar = ncfileOut . addVariable ( null , latName , DataType . DOUBLE , recordDimName ) ; latVar . addAttribute ( new Attribute ( CDM . UNITS , "degrees_north" ) ) ; latVar . addAttribute ( new Attribute ( CDM . LONG_NAME , "latitude of observation" ) ) ; latVar . addAttribute ( new Attribute ( "standard_name" , "latitude" ) ) ; recordVars . add ( latVar ) ; // longitude variable Variable lonVar = ncfileOut . addVariable ( null , lonName , DataType . DOUBLE , recordDimName ) ; lonVar . addAttribute ( new Attribute ( CDM . UNITS , "degrees_east" ) ) ; lonVar . addAttribute ( new Attribute ( CDM . LONG_NAME , "longitude of observation" ) ) ; lonVar . addAttribute ( new Attribute ( "standard_name" , "longitude" ) ) ; recordVars . add ( lonVar ) ; if ( useAlt ) { // altitude variable Variable altVar = ncfileOut . addVariable ( null , altName , DataType . DOUBLE , recordDimName ) ; altVar . addAttribute ( new Attribute ( CDM . UNITS , altUnits ) ) ; altVar . addAttribute ( new Attribute ( CDM . LONG_NAME , "altitude of observation" ) ) ; altVar . addAttribute ( new Attribute ( "standard_name" , "longitude" ) ) ; altVar . addAttribute ( new Attribute ( CF . POSITIVE , CF1Convention . getZisPositive ( altName , altUnits ) ) ) ; recordVars . add ( altVar ) ; } String coordinates = timeName + " " + latName + " " + lonName ; if ( useAlt ) coordinates = coordinates + " " + altName ; Attribute coordAtt = new Attribute ( CF . COORDINATES , coordinates ) ; // find all dimensions needed by the data variables for ( VariableSimpleIF var : dataVars ) { List < Dimension > dims = var . getDimensions ( ) ; dimSet . addAll ( dims ) ; } // add them for ( Dimension d : dimSet ) { if ( isExtraDimension ( d ) ) ncfileOut . addDimension ( null , new Dimension ( d . getShortName ( ) , d . getLength ( ) , true , false , d . isVariableLength ( ) ) ) ; } // add the data variables all using the record dimension for ( VariableSimpleIF oldVar : dataVars ) { if ( ncfileOut . findVariable ( oldVar . getShortName ( ) ) != null ) continue ; List < Dimension > dims = oldVar . getDimensions ( ) ; StringBuilder dimNames = new StringBuilder ( recordDimName ) ; for ( Dimension d : dims ) { if ( isExtraDimension ( d ) ) dimNames . append ( " " ) . append ( d . getShortName ( ) ) ; } Variable newVar = ncfileOut . addVariable ( null , oldVar . getShortName ( ) , oldVar . getDataType ( ) , dimNames . toString ( ) ) ; recordVars . add ( newVar ) ; List < Attribute > atts = oldVar . getAttributes ( ) ; for ( Attribute att : atts ) newVar . addAttribute ( att ) ; newVar . addAttribute ( coordAtt ) ; } }


Input: Write a ucar . nc2 . ft . PointFeatureCollection in CF point format . [CODESPLIT] public static int writePointFeatureCollection ( FeatureDatasetPoint pfDataset , String fileOut ) throws IOException { // extract the PointFeatureCollection PointFeatureCollection pointFeatureCollection = null ; List < DsgFeatureCollection > featureCollectionList = pfDataset . getPointFeatureCollectionList ( ) ; for ( DsgFeatureCollection featureCollection : featureCollectionList ) { if ( featureCollection instanceof PointFeatureCollection ) pointFeatureCollection = ( PointFeatureCollection ) featureCollection ; } if ( null == pointFeatureCollection ) throw new IOException ( "There is no PointFeatureCollection in  " + pfDataset . getLocation ( ) ) ; long start = System . currentTimeMillis ( ) ; FileOutputStream fos = new FileOutputStream ( fileOut ) ; DataOutputStream out = new DataOutputStream ( new BufferedOutputStream ( fos , 10000 ) ) ; WriterCFPointDataset writer = null ; // LOOK BAD List < VariableSimpleIF > dataVars = new ArrayList < VariableSimpleIF > ( ) ; ucar . nc2 . NetcdfFile ncfile = pfDataset . getNetcdfFile ( ) ; if ( ( ncfile == null ) || ! ( ncfile instanceof NetcdfDataset ) ) { dataVars . addAll ( pfDataset . getDataVariables ( ) ) ; } else { NetcdfDataset ncd = ( NetcdfDataset ) ncfile ; for ( VariableSimpleIF vs : pfDataset . getDataVariables ( ) ) { if ( ncd . findCoordinateAxis ( vs . getShortName ( ) ) == null ) dataVars . add ( vs ) ; } } int count = 0 ; for ( PointFeature pointFeature : pointFeatureCollection ) { StructureData data = pointFeature . getDataAll ( ) ; if ( count == 0 ) { EarthLocation loc = pointFeature . getLocation ( ) ; // LOOK we dont know this until we see the obs String altUnits = Double . isNaN ( loc . getAltitude ( ) ) ? null : "meters" ; // LOOK units may be wrong writer = new WriterCFPointDataset ( out , pfDataset . getGlobalAttributes ( ) , altUnits ) ; writer . writeHeader ( dataVars , - 1 ) ; } writer . writeRecord ( pointFeature , data ) ; count ++ ; } writer . finish ( ) ; out . flush ( ) ; out . close ( ) ; long took = System . currentTimeMillis ( ) - start ; System . out . printf ( "Write %d records from %s to %s took %d msecs %n" , count , pfDataset . getLocation ( ) , fileOut , took ) ; return count ; }


Input: Open a ucar . nc2 . dt . PointObsDataset write out in CF point format . [CODESPLIT] public static void rewritePointObsDataset ( String fileIn , String fileOut , boolean inMemory ) throws IOException { System . out . println ( "Rewrite .nc files from " + fileIn + " to " + fileOut + "inMem= " + inMemory ) ; long start = System . currentTimeMillis ( ) ; // do it in memory for speed NetcdfFile ncfile = inMemory ? NetcdfFile . openInMemory ( fileIn ) : NetcdfFile . open ( fileIn ) ; NetcdfDataset ncd = new NetcdfDataset ( ncfile ) ; StringBuilder errlog = new StringBuilder ( ) ; PointObsDataset pobsDataset = ( PointObsDataset ) TypedDatasetFactory . open ( FeatureType . POINT , ncd , null , errlog ) ; FileOutputStream fos = new FileOutputStream ( fileOut ) ; DataOutputStream out = new DataOutputStream ( fos ) ; WriterCFPointDataset writer = null ; DataIterator iter = pobsDataset . getDataIterator ( 1000 * 1000 ) ; while ( iter . hasNext ( ) ) { PointObsDatatype pobsData = ( PointObsDatatype ) iter . nextData ( ) ; StructureData sdata = pobsData . getData ( ) ; if ( writer == null ) { ucar . unidata . geoloc . EarthLocation loc = pobsData . getLocation ( ) ; String altUnits = Double . isNaN ( loc . getAltitude ( ) ) ? null : "meters" ; writer = new WriterCFPointDataset ( out , ncfile . getGlobalAttributes ( ) , altUnits ) ; writer . writeHeader ( pobsDataset . getDataVariables ( ) , - 1 ) ; } writer . writeRecord ( pobsData , sdata ) ; } writer . finish ( ) ; long took = System . currentTimeMillis ( ) - start ; System . out . println ( "Rewrite " + fileIn + " to " + fileOut + " took = " + took ) ; }


Input: GET handles the case where its a remote URL ( dods or http ) [CODESPLIT] public void doGet ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { log . info ( "doGet(): " + UsageLog . setupRequestContext ( req ) ) ; String urlString = req . getParameter ( "URL" ) ; if ( urlString == null ) { log . info ( "doGet(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_BAD_REQUEST , 0 ) ) ; res . sendError ( HttpServletResponse . SC_BAD_REQUEST , "Must have a URL parameter" ) ; return ; } // validate the url String try { URI uri = new URI ( urlString ) ; urlString = uri . toASCIIString ( ) ; // LOOK do we want just toString() ? Is this useful "input validation" ? } catch ( URISyntaxException e ) { log . info ( "doGet(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_BAD_REQUEST , 0 ) ) ; res . sendError ( HttpServletResponse . SC_BAD_REQUEST , "URISyntaxException on URU parameter" ) ; return ; } String xml = req . getParameter ( "xml" ) ; boolean wantXml = ( xml != null ) && xml . equals ( "true" ) ; try { int len = showValidatorResults ( res , urlString , wantXml ) ; log . info ( "doGet(): URL = " + urlString ) ; log . info ( "doGet(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_OK , len ) ) ; } catch ( Exception e ) { log . info ( "doGet(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_BAD_REQUEST , 0 ) ) ; res . sendError ( HttpServletResponse . SC_BAD_REQUEST , "Invalid input" ) ; } catch ( Throwable e ) { log . error ( "doGet(): Validator internal error" , e ) ; log . info ( "doGet(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_INTERNAL_SERVER_ERROR , 0 ) ) ; res . sendError ( HttpServletResponse . SC_INTERNAL_SERVER_ERROR , "Validator internal error" ) ; } }


Input: POST handles uploaded files [CODESPLIT] public void doPost ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { log . info ( "doPost(): " + UsageLog . setupRequestContext ( req ) ) ; // Check that we have a file upload request boolean isMultipart = ServletFileUpload . isMultipartContent ( req ) ; if ( ! isMultipart ) { log . info ( "doPost(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_BAD_REQUEST , 0 ) ) ; res . sendError ( HttpServletResponse . SC_BAD_REQUEST ) ; return ; } //Create a new file upload handler ServletFileUpload upload = new ServletFileUpload ( this . cdmValidatorContext . getFileuploadFileItemFactory ( ) ) ; upload . setSizeMax ( this . cdmValidatorContext . getMaxFileUploadSize ( ) ) ; // maximum bytes before a FileUploadException will be thrown List < FileItem > fileItems ; try { fileItems = ( List < FileItem > ) upload . parseRequest ( req ) ; } catch ( FileUploadException e ) { log . info ( "doPost(): Validator FileUploadException" , e ) ; log . info ( "doPost(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_BAD_REQUEST , 0 ) ) ; if ( ! res . isCommitted ( ) ) res . sendError ( HttpServletResponse . SC_BAD_REQUEST ) ; return ; } //Process the uploaded items String username = null ; boolean wantXml = false ; for ( FileItem item : fileItems ) { if ( item . isFormField ( ) ) { if ( "username" . equals ( item . getFieldName ( ) ) ) username = item . getString ( ) ; if ( "xml" . equals ( item . getFieldName ( ) ) ) wantXml = item . getString ( ) . equals ( "true" ) ; } } for ( FileItem item : fileItems ) { if ( ! item . isFormField ( ) ) { try { processUploadedFile ( req , res , ( DiskFileItem ) item , username , wantXml ) ; return ; } catch ( Exception e ) { log . info ( "doPost(): Validator processUploadedFile" , e ) ; log . info ( "doPost(): " + UsageLog . closingMessageForRequestContext ( HttpServletResponse . SC_BAD_REQUEST , 0 ) ) ; res . sendError ( HttpServletResponse . SC_BAD_REQUEST , e . getMessage ( ) ) ; } } } }


Input: /////////////////////////////////////////////////////////////////////////////////// [CODESPLIT] @ Override public Iterator < TrajectoryFeature > iterator ( ) { try { PointFeatureCollectionIterator pfIterator = getPointFeatureCollectionIterator ( ) ; return new CollectionIteratorAdapter <> ( pfIterator ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }


Input: Get the affine transform based on screen size and world bounding box [CODESPLIT] public AffineTransform getTransform ( ) { at . setTransform ( pix_per_world , 0.0 , 0.0 , - pix_per_world , pix_x0 , pix_y0 ) ; if ( debug ) { System . out . println ( "Navigation getTransform = " + pix_per_world + " " + pix_x0 + " " + pix_y0 ) ; System . out . println ( "  transform = " + at ) ; } return at ; }


Input: calculate if we want to rotate based on aspect ratio [CODESPLIT] public boolean wantRotate ( double displayWidth , double displayHeight ) { getMapArea ( bb ) ; // current world bounding box boolean aspectDisplay = displayHeight < displayWidth ; boolean aspectWorldBB = bb . getHeight ( ) < bb . getWidth ( ) ; return ( aspectDisplay ^ aspectWorldBB ) ; // aspects are different }