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