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