Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
Hi, > I believe this is not a good idea to set something different > as scalars as attributes. There is no dimension information stored about > attribut > sizes and what kind of coordination parameter should be used. > > > At the moment I don't know if it's a bug or a feature. It is definitely not a bug. Here is some info from the netCDF documentation: **************************************************************************** A netCDF attribute has a netCDF variable to which it is assigned, a name, a type, a length, and a sequence of one or more values. An attribute is designated by its variable ID and name. When an attribute name is not known, it may be designated by its variable ID and number in order to determine its name, using the function nc_inq_attname. The attributes associated with a variable are typically defined immediately after the variable is created, while still in define mode. The data type, length, and value of an attribute may be changed even when in data mode, as long as the changed attribute requires no more space than the attribute as originally defined. **************************************************************************** Note that a netCDF attribute has a "length" and "sequence of one or more values". One very good reason for this is simply to support strings. netCDF does not have a string data type, only an array of chars. Thus to support the very common attribute "units" requires an array of chars. Attribute arrays can only be one-dimensional. The following section of the documentation explains the difference between attributes and variables. **************************************************************************** 2.5 Differences between Attributes and Variables -------------------------------------------------------------------------------- In contrast to variables, which are intended for bulk data, attributes are intended for ancillary data, or information about the data. The total amount of ancillary data associated with a netCDF object, and stored in its attributes, is typically small enough to be memory-resident. However variables are often too large to entirely fit in memory and must be split into sections for processing. Another difference between attributes and variables is that variables may be multidimensional. Attributes are all either scalars (single-valued) or vectors (a single, fixed dimension). Variables are created with a name, type, and shape before they are assigned data values, so a variable may exist with no values. The value of an attribute must be specified when it is created, so no attribute ever exists without a value. A variable may have attributes, but an attribute cannot have attributes. Attributes assigned to variables may have the same units as the variable (for example, valid_range) or have no units (for example, scale_factor). If you want to store data that requires units different from those of the associated variable, it is better to use a variable than an attribute. More generally, if data require ancillary data to describe them, are multidimensional, require any of the defined netCDF dimensions to index their values, or require a significant amount of storage, that data should be represented using variables rather than attributes. *************************************************************************** > If arrays on attributes are common the fileformat does not describe > them. The next question is if it's allowed to use arrays is there a > limitiation for the size or did a large attribute array corrupt the > other data? It does not corrupt the data, netCDF keeps track of the size of the arrays. As seen in the documentation above, the size is limited by the amount of memory (RAM for good performance, virtual memory if performance does not matter), because attributes are kept in the header and read in all at once. You can't read just part of an attribute array as you can for a variable array. Cheers, Mark Rivers
netcdfgroup
archives: