nc_from_objΒΆ
nc_from_obj creates a netCDF file from a special structured UniScript object.
- bool = nc_from_obj(obj, ssNCFilename)
Return Value
bool is TRUE (1) if the function was successful and otherwise FALSE (0).
Parameters
- obj
obj is an object that contains the channel data and the following elements:
globals,channel_infoandorder.globalsis an optional object containing elements saved as global attributes in the nc file.channel_infois an optional object containing channel attributes. The optional elementordersets the order of the channels in the netCDF file.
- ssNCFilename
ssNCFilename is the complete file name of the new netCDF file.
Comment
The function saves the channels in the netCDF file with the data type
double or char. If the element channel_info contains the element
datatype it will be used to define the data type in the NC file.
Example o.channel_info["speed"].datatype = "real4" will create
a channel of type NC_FLOAT in the NC file.
See also Datatype.
The element order is optional. If the element exists, it must contain
all channels. order[1] contains the first channel, order[2] the second
and so forth.
Example
ssNCFileName = GetUserDirectory() + "test.nc";
nc_from_obj([. x = [1,2,3], y = [4,5,2]], ssNCFileName);
NC_Edit(ssNCFileName);
Example
def test()
{
ssNCFileName = GetUserDirectory() + "test.nc";
x = linspace(0,2*PI*100, 1e6);
y = sin(x);
o = [.
x = x,
y = y,
order = [. 1 = "y", 2 = "x"],
globals = [.
Comment = "Simple Test"
],
channel_info = [. x = [. units = "Nm", a = 1], y = [. units = "kg", b = 2]]
];
nc_from_obj(o, ssNCFileName);
NC_Edit(ssNCFileName);
return o;
}
o = test()
History
Version |
Description |
|---|---|
R2013.11 |
Channel attribute datatype will be used to specify the channel type in the NC file. |
5.14.7 |
New. |
See also
id-54330