NetcdfVariable(NetcdfMutableVariable) Class Reference

Provides methods to create, modify or write array data in the underlying netCDF dataset. More...

#import <NetcdfMutableVariable.h>

List of all members.

Public Member Functions

(id) - createByOwner:fromSchema:
 Creates a new variable in the data set.
(NSString *) - renameAs:error:
 Modifies the name of the variable.
(int) - ncSetFillMode:
 sets new fill mode, either NC_FILL or NC_NOFILL and returns old mode
Attributes
Methods for adding, deleting or renaming attributes associated with the variable

(NetcdfAttribute *) - addAttributeWithSchema:error:
 Creates and adds a new attribute to the NetcdfVariable and dataset.
(NetcdfAttribute *) - addAttribute:type:values:error:
 Creates and adds a new attribute to the NetcdfVariable and dataset.
(BOOL) - deleteAttribute:error:
 Deletes an attribute from the NetcdfVariable and the dataset.
Data writing methods
These methods write data to the variable.
Refer to the netCDF documentation for the correct layout of the input data arrays. The ...PutData methods take a C array wrapped in NSData, and require the data type to be identified. Data conversion between the C type and the netCDF type is automatic. Conversions that result in a numeric overflow will cause an error; truncation does not cause an error, but may be undesirable. The length of the NSData must be at least as large as the count of data times the size of data, or else an error will result. Use the corresponding countVar, countVara, countVars, or countVarm to obtain the count of the pending write operation.
The ...PutStrings methods take an NSArray of NSString. The strings must all have a length no greater than the last dimension or offset of the NetcdfVariable.

All data writing methods return YES if successful. On failure, returns NO and sets ncErrNo; use -lastError to get a descriptive NSError object.

(BOOL) - var1PutNumber:
 Writes one number at the index location. Returns YES if successful.
(BOOL) - varPutData:ofType:
 Writes the entire variable from an NSData buffer of the specified type. Returns YES if successful.
(BOOL) - varPutStrings:
 Write the entire variable as string data from an NSArray of NSString.
(BOOL) - varaPutData:ofType:
 Writes the NSData buffer to a slice of the variable starting at index. Returns YES if successful.
(BOOL) - varaPutStrings:
 Writes a slice of the variable as string data from an NSArray of NSString.
(BOOL) - varsPutData:ofType:
 Writes the NSData buffer to a sub-sampled slice of the variable. Returns YES if successful.
(BOOL) - varsPutStrings:
 Writes a sampled slice of the variable as string data from an NSArray of NSString.
(BOOL) - varmPutData:ofType:
 Writes the NSData buffer to a mapped and sampled slice of the variable. Returns YES if successful.
(BOOL) - varmPutStrings:
 Writes a sampled slice of the variable as string data from an NSArray of NSString.


Detailed Description

Provides methods to create, modify or write array data in the underlying netCDF dataset.

A category on NetcdfVariable that adds methods to write data to an existing netCDF dataset using the corresponding netCDF function calls. Also may add a new variable to the dataset. Also may delete existing or add new attributes to the variable.


Member Function Documentation

- (NetcdfAttribute *) addAttribute: (NSString *)  attName
type: (nc_type)  attType
values: (id)  values
error: (NSError **)  errorP 

Creates and adds a new attribute to the NetcdfVariable and dataset.

Values may be NSString, NSNumber, NSArray of NSNumber, or a compatible subclass. Type conversion and data size are automatically handled, but type conversions that result in data overflow will cause an error; truncation does not cause an error, but may be undesirable.

Returns a pointer to the newly created NetcdfAttribute.

On error returns nil and an NSError. If errorP is NULL, no error information is returned.

- (NetcdfAttribute *) addAttributeWithSchema: (NSDictionary *)  schema
error: (NSError **)  errorP 

Creates and adds a new attribute to the NetcdfVariable and dataset.

The attribute is defined by the schema which is an NSDictionary with the following keys:
key: "name" value: the name string (NSString)
key: "type" value: the nc_type (NSNumber)
key: "values" value: NSString, NSNumber, or NSArray of NSNumber or a compatible subclass
Type conversion and data size are automatically handled. Type conversions that result in data overflow will cause an error; truncation does not cause an error, but may be undesirable.

Returns a pointer to the new attribute.

On error, returns nil and an NSError. If errorP is NULL, no error information is returned.

- (id) createByOwner: (NetcdfDataset *)  newOwner
fromSchema: (NSDictionary *)  schema 

Creates a new variable in the data set.

This is an initializer that not only initializes a newly allocated NetcdfVariable, it also creates the new variable in the underlying netCDF dataset. If the defining schema includes any attributes, they will also be created. The dataset must be opened for read/write access. The dataset must be in Define Mode. Normally, this method is only called by the owning NetcdfDataset that will be the new owner. The owner object coordinates entering and leaving define mode.

On failure, returns an object with isValid = NO and ncErrNo = error code. The owner should extract the error information from the failed object and release it.

- (BOOL) deleteAttribute: (NSString *)  attName
error: (NSError **)  errorP 

Deletes an attribute from the NetcdfVariable and the dataset.

Returns YES if deletion is successful. On failure, returns NO and an NSError. If errorP is NULL, no error information is returned.

- (NSString *) renameAs: (NSString *)  newName
error: (NSError **)  errorP 

Modifies the name of the variable.

If the new name is longer than the old one, the dataset will be automatically enter and leave Define Mode, which is an expensive operation.

Returns the new name, possibly recoded.

On error, return nil and an NSError. If errorP is NULL, no error information is returned.

- (BOOL) var1PutNumber: (NSNumber *)  number  

Writes one number at the index location. Returns YES if successful.

Type conversion is automatic for supported types: char, unsigned char, short, int, long, float and double. Unsupported types set ncErrNo = NCS_TYPE_E.

This is method is capable of writing beyond the current length of an unlimited variable.

- (BOOL) varaPutData: (NSData *)  data
ofType: (const char *)  objCType 

Writes the NSData buffer to a slice of the variable starting at index. Returns YES if successful.

objCType should use the form of "@encode( type )" where type is one of char, signed char, unsigned char, short, int, long, float or double. Unsupported types set ncErrNo = NC_EBADTYPE. [data length] must be at least countVara*sizeof(type), else sets ncErrNo = NCS_DATASIZE_E.

The start of writing is determined by the index array and the extent by the offset array.

This is method is capable of writing beyond the current length of an unlimited variable.

- (BOOL) varaPutStrings: (NSArray *)  arrayOfNSString  

Writes a slice of the variable as string data from an NSArray of NSString.

The NetcdfVariable must be of type NC_CHAR, otherwise it returns NO. This accepts as input an NSArray of NSString as produced by -varaAsString. The strings must all have a length no greater than the last dimension of the offset array, else an error will occur. Shorter strings will be null-padded to length. The input array must contain at least as many strings as countVara/stringLength.

The start of writing is determined by the index array and the extent by the offset array.

This is method is capable of writing beyond the current length of an unlimited variable.

- (BOOL) varmPutData: (NSData *)  data
ofType: (const char *)  objCType 

Writes the NSData buffer to a mapped and sampled slice of the variable. Returns YES if successful.

objCType should take the form of "@encode( type )" where type is one of char, signed char, unsigned char, short, int, long, float or double. Unsupported types set ncErrNo = NC_EBADTYPE. [data length] must be at least countVarm*sizeof(type), else sets ncErrNo = NCS_DATASIZE_E.

The start of writing is determined by the index array and the extent by the offset array. The sample interval is determined by the stride array. The data is re-ordered according to the map array.

This is method is capable of writing beyond the current length of an unlimited variable.

- (BOOL) varmPutStrings: (NSArray *)  arrayOfNSString  

Writes a sampled slice of the variable as string data from an NSArray of NSString.

The NetcdfVariable must be of type NC_CHAR, otherwise it returns NO. This accepts as input an NSArray of NSString as produced by -varmAsString. The strings must all have a length no greater than the last dimension of the offset array, else an error will occur. Shorter strings will be null-padded to length. The input array must contain at least as many strings as countVarm/stringLength, else an error will occur.

The start of writing is determined by the index array and the extent by the offset array. The sample interval is determided by the stride array. Normally the stride will be one in the string dimension.The data is re-ordered according to the map array.

This is method is capable of writing beyond the current length of an unlimited variable.

- (BOOL) varPutData: (NSData *)  data
ofType: (const char *)  objCType 

Writes the entire variable from an NSData buffer of the specified type. Returns YES if successful.

objCType should use the form of "@encode( type )" where type is one of char, signed char, unsigned char, short, int, long, float or double. Unsupported types set ncErrNo = NC_EBADTYPE. [data length] must be at least countVar*sizeof(type), else sets ncErrNo = NCS_DATASIZE_E. Excess data will be ignored.

For an unlimited variable, this method can write only the current length of data.

- (BOOL) varPutStrings: (NSArray *)  arrayOfNSString  

Write the entire variable as string data from an NSArray of NSString.

The NetcdfVariable must be of type NC_CHAR, otherwise it returns NO. This accepts as input an NSArray of NSString as produced by -varAsString. The strings must all have a length no greater than the last dimension of the NetcdfVariable, else an error will occur. Shorter strings will be null-padded to length. The input array must contain at least as many strings as countVar/stringLength, else an error will occur.

For an unlimited variable, this method can write only the current length of data.

- (BOOL) varsPutData: (NSData *)  data
ofType: (const char *)  objCType 

Writes the NSData buffer to a sub-sampled slice of the variable. Returns YES if successful.

objCType should take for form of "@encode( type )" where type is one of char, signed char, unsigned char, short, int, long, float or double. Unsupported types set ncErrNo = NC_EBADTYPE. [data length] must be at least countVars*sizeof(type), else sets ncErrNo = NCS_DATASIZE_E.

The start of writing is determined by the index array and the extent by the offset array. The sample interval is determined by the stride array.

This is method is capable of writing beyond the current length of an unlimited variable.

- (BOOL) varsPutStrings: (NSArray *)  arrayOfNSString  

Writes a sampled slice of the variable as string data from an NSArray of NSString.

The NetcdfVariable must be of type NC_CHAR, otherwise it returns NO. This accepts as input an NSArray of NSString as produced by -varsAsString. The strings must all have a length no greater than the last dimension of the offset array, else an error will occur. Shorter strings will be null-padded to length. The input array must contain at least as many strings as countVars/stringLength, else an error will occur.

The start of writing is determined by the index array and the extent by the offset array. The sample interval is determined by the stride array. Normally the stride will be one in the string dimension.

This is method is capable of writing beyond the current length of an unlimited variable.


Generated on Thu Sep 24 23:22:20 2009 for NetcdfStep by  doxygen 1.5.7.1