OOC Methods which Write to File

Table of Contents

  1. Method binary
  2. Method hdf
  3. Method netcdf
  4. Method swap

Method binary

ooc_name binary ?tcl_channel?

This writes raw (binary) data to the file specified by tcl_channel, which defaults to stdout (standard output). For example:

% set file [open y.tmp w]
file4
% $y binary $file
% close $file
% set file [open y.tmp]
file4
% [nap_get binary $file f64] all
::NAP::248-248  f64  MissingValue: NaN  References: 0  Unit: (NULL)
Dimension 0   Size: 5      Name: (NULL)    Coordinate-variable: (NULL)
Value:
0 0.25 1 2.25 4
% close $file

Method hdf

ooc_name hdf ?switches? filename sds

This writes data from the NAO to an SDS named sds within an HDF file named filename.

switches can be:
-unlimited: Create sds with unlimited dimension 0
-coordinateVariable expr: boxed NAO which specifies coordinate variables.
-datatype type: HDF datatype: c8, i8, i16, i32, u8, u16, u32, f32 or f64
-range float: HDF valid_range
-scale float: HDF scale_factor
-offset float: HDF add_offset
-index expr: position within SDS where data is to be written.

If "-coordinateVariable expr" is not specified then the coordinate variables of the main NAO are used if these exist.

If "-index expr" is not specified then the coordinate variables of the main NAO are used if these exist, otherwise writing starts at the beginning of the SDS.

Example:

% [nap "3 .. 7"] hdf simple.hdf vec
% exec hdp dumpsds simple.hdf
File name: simple.hdf 

Variable Name = vec
	 Index = 0
	 Type= 32-bit signed integer
	 Ref. = 2
	 Rank = 1
	 Number of attributes = 1
	 Dim0: Name=fakeDim0
		 Size = 5
		 Scale Type = number-type not set
		 Number of attributes = 0
	 Attr0: Name = _FillValue
		 Type = 32-bit signed integer 
		 Count= 1
		 Value = -2147483648 
	 Data : 
                3 4 5 6 7

Method netcdf

ooc_name netcdf ?switches? filename var

This writes data from the NAO to a netCDF variable named var within the netCDF file named filename.

switches can be:
-unlimited: Create variable with unlimited dimension 0
-coordinateVariable expr: boxed NAO which specifies coordinate variables.
-datatype type: netCDF datatype: c8, i16, i32, u8, f32 or f64
-range float: netCDF valid_range
-scale float: netCDF scale_factor
-offset float: netCDF add_offset
-index expr: position within netCDF variable where data is to be written.

If "-coordinateVariable expr" is not specified then the coordinate variables of the main NAO are used if these exist.

If "-index expr" is not specified then the coordinate variables of the main NAO are used if these exist, otherwise writing starts at the beginning of the netCDF variable.

Example:

% $y net sq.nc area -coordinateVariable "x // {3 6 9}"
::NAP::241-241
% exec ncdump sq.nc
netcdf sq {
dimensions:
	x = 8 ;
variables:
	double x(x) ;
	double area(x) ;
		area:_FillValue = nan ;
		area:long_name = "areas of squares" ;
		area:units = "seconds" ;
data:

 x = 0, 0.5, 1, 1.5, 2, 3, 6, 9 ;

 area = 0, 0.25, 1, 2.25, 4, nan, nan, nan ;
}
Note that the netCDF variable area is dimensioned to 8 (the shape of the argument specified by the -coordinateVariable option).

Method swap

ooc_name swap ?tcl_channel?

Method swap is like method binary, except that bytes are swapped. This enables writing of data to be read on a machine with opposite byte-order within words.

Author: Harvey Davies       © 2002, CSIRO Australia.       Legal Notice and Disclaimer
CVS Version Details: $Id: ooc_write.html,v 1.1 2004/08/27 07:14:38 dav480 Exp $