CF Conformance Requirements and Recommendations
- The following is a list of requirements and recommendations for a CF conforming netCDF file. They are organized by the section of the CF document that they pertain to.
- This document is intended to be a concise summary of the CF conventions 1.3 document. If there are any discrepencies between the two, the conventions document is the ultimate authority.
- This document will updated as required to correct mistakes or add new material required for completeness or clarity.
- Filename must have ".nc" suffix.
2.2 Data TypesRequirements:
- CF attributes that take string values must be 1D character arrays.
2.3 Naming ConventionsRequirements:
- Variable, dimension and attribute names must begin with a letter and be composed of letters, digits, and underscores.
- No two variable names should be identical when case is ignored.
- The dimensions of a variable must all have different names.
- If any or all of the dimensions of a variable have the interpretations (as given by their units or axis attribute) of time (T), height or depth (Z), latitude (Y), or longitude (X) then those dimensions should appear in the relative order T, then Z, then Y, then X in the CDL definition corresponding to the file.
- In files that are meant to conform to the COARDS subset of CF, any dimensions of a variable other than space and time dimensions should be added "to the left" of the space and time dimensions as represented in CDL.
2.5.1 Missing DataRequirements:
- The valid_range attribute must not be present if the valid_min and/or valid_max attributes are present.
- The _FillValue attribute must be the same type as its associated variable.
- The missing_value attribute must be the same type as its associated variable.
- The value of the _FillValue attribute should not be within a specified valid range.
- The missing_value attribute is deprecated and should no longer be used. However, if it's use is required for reasons of backwards compatibility with processing tools that only recognize the missing_value attribute, then we recommend that both missing_value and _FillValue be used, and they must have the same value.
2.6.1 Identification of ConventionsRequirements:
- Files that conform to the CF version 1.3 conventions must indicate this by setting the global Conventions attribute to the string value "CF-1.3".
2.6.2 Description of File ContentsRequirements:
- The title, history, institution, source, references, and comment attributes are all type string.
- The title and history attributes are only defined as global attributes. If they are used as per variable attributes a CF compliant application should treat them exactly as it would treat any other unrecognized attribute.
3 Description of the DataRecommendations:
- All variables should use either the long_name or the standard_name attributes to describe their contents. Exceptions are boundary and climatology variables.
- The units attribute is required for all variables that represent dimensional quantities (except for boundary variables defined in section 7.1 and climatology variables defined in section 7.4).
- The type of the units attribute is a string that must be recognizable by the udunits package. Exceptions are the units level, layer, and sigma_level.
- The units of a variable that specifies a standard_name must be consistent with the units given in the standard name table. The units must also be consistent with a specified cell_methods attribute, if one is present.
- The units level, layer, and sigma_level are deprecated.
3.3 Standard NameRequirements:
- The standard_name attribute takes a string value comprised of a standard name optionally followed by one or more blanks and a standard name modifier.
- The legal values for the standard name are contained in the standard name table.
- The legal values for the standard name modifier are contained in Appendix C, Standard Name Modifiers.
- The flag_values attribute must have the same type as the variable to which it is attached.
The number of flag_values attribute values must equal the number of words or phrases appearing in the flag_meanings string.
- The number of flag_masks attribute values must equal the number of words or phrases appearing in the flag_meanings string.
- Variables with a flag_masks attribute must have a type that is compatible with bit field expression (char, byte, short and int), not floating-point (float, real, double), and the flag_masks attribute must have the same type.
- The flag_masks attribute values must be non-zero.
- The flag_values attribute values must be mutually exclusive among the set of flag_values attribute values defined for that variable.
- When flag_masks and flag_values are both defined, the Boolean AND of each entry in flag_values with its corresponding entry in flag_masks should equal the flag_values entry, ie, the mask selects all the bits required to express the value.
4 Coordinate TypesRequirements:
- The axis attribute may only be attached to a coordinate variable.
- The only legal values of axis are X, Y, Z, and T (case insensitive).
- The axis attribute must be consistent with the coordinate type deduced from units and positive.
- The axis attribute is not allowed for auxiliary coordinate variables.
- A data variable must not have more than one coordinate variable with a particular value of the axis attribute.
4.3 Vertical (height or depth) CoordinateRequirements:
- The only legal values for the positive attribute are up or down (case insensitive).
4.3.2 Dimensionless Vertical CoordinatesRequirements:
- The formula_terms attribute is only allowed on a coordinate variable which has a standard_name listed in Appendix C.
- The type of the formula_terms attribute is a string whose value is list of blank separated word pairs in the form term: var. The legal values term are contained in Appendix C for each valid standard_name. The values of var must be variables that exist in the file.
4.4 Time CoordinateRequirements:
- The time units of a time coordinate variable must contain a reference time.
- The reference time of a time coordinate variable must be a legal time in the specified calendar.
- The use of a reference time in the year 0 to indicate climatological time is deprecated. This restriction only applies to the real-world calendar as used by the udunits package.
- Units of year and month and any equivalent units should be used with caution.
- The attributes calendar, month_lengths, leap_year, and leap_month may only be attached to time coordinate variables.
- The standardized values of the calendar attribute are gregorian, standard, proleptic_gregorian, noleap, 365_day, all_leap, 366_day, 360_day, julian, and none (case insensitive). If the calendar attribute is given a non-standard value, then the attribute month_lengths is required, along with leap_year and leap_month as appropriate.
- The type of the month_lengths attribute must be an integer array of size 12.
- The values of the leap_month attribute must be in the range 1-12.
- The values of the leap_year and leap_month attributes are integer scalars.
- The attribute leap_month should not appear unless the attribute leap_year is present.
- The time coordinate should not cross the date 1582-10-15 when the default mixed Gregorian/Julian calendar is in use.
5 Coordinate SystemsRequirements:
- All of a variable's dimensions that are latitude, longitude, vertical, or time dimensions must have corresponding coordinate variables.
- A coordinate variable must have values that are strictly monotonic (increasing or decreasing).
- A coordinate variable must not have the _FillValue or missing_value attributes.
- The type of the coordinates attribute is a string whose value is a blank separated list of variable names. All specified variable names must exist in the file.
- The dimensions of each auxiliary coordinate must be a subset of the dimensions of the variable they are attached to. An exception is a label variable which will have a trailing dimension for the maximum string length.
- The name of a multidimensional coordinate variable should not match the name of any of its dimensions.
- All horizontal coordinate variables (in the Unidata sense) should have an axis attribute.
5.6 Grid Mappings and Projections
- The type of the grid_mapping attribute is a string whose value is a single variable name.
- The specified variable name (known as a grid mapping variable) must exist in the file.
- The grid mapping variable must have the grid_mapping_name attribute. The legal values for the grid_mapping_name attribute are contained in Appendix F.
- The data types of the attributes of the grid mapping variable must be specified in Table 1 of Appendix F.
- The grid mapping variable should have 0 dimensions.
- A variable of character type that is named by a coordinates attribute is a label variable. This variable must have two dimensions. The leading dimension (CDL order) must match one of those of the associated variable, and the trailing dimension is for the maximum string length.
7.1 Cell BoundariesRequirements:
- The type of the bounds attribute is a string whose value is a single variable name. The specified variable must exist in the file.
- A boundary variable must have the same dimensions as its associated variable, plus have a trailing dimension (CDL order) for the maximum number of vertices in a cell.
- A boundary variable must be a numeric data type.
- If a boundary variable has units or standard_name attributes, they must agree with those of its associated variable.
- The points specified by a coordinate or auxiliary coordinate variable should lie within, or on the boundary, of the cells specified by the associated boundary variable.
- Boundary variables should not have the _FillValue or missing_value attributes.
7.2 Cell MeasuresRequirements:
- The type of the cell_measures attribute is a string whose value is list of blank separated word pairs in the form measure: var. The valid values for measure are area or volume. The var token specifies a variable that must exist in the file. The dimensions of the variable specified by var must be the same as, or be a subset of, the dimensions of the variable to which they are related.
- A measure variable must have units that are consistent with the measure type, i.e., square meters for area measures and cubic meters for volume measures.
7.3 Cell MethodsRequirements:
- The type of the cell_methods attribute is a
string whose value is one or more blank separated word lists, each with the
dim1: [dim2: [dim3: ...] ] method [(comment)]where brackets indicate optional words. The valid values for dim1 [dim2 [dim3 ...] ] are dimension names of the associated variable or valid standard names. The valid values of method are contained in Appendix D. When the method refers to a climatological time axis, the values in Appendix D may have the suffixes "within days", "over days", "within years", or "over years" or appended.
- A given dimension name may only occur once in a cell_methods string. An exception is a climatological time dimension.
- The comment, if present, must take the form
([interval: value unit [interval: ...] comment:] remainder)The remainder text is not standardized. If no interval clauses are present, the entire comment is therefore not standardized. There may be zero interval clauses, one interval clause, or exactly as many interval clauses as there are dims to which the method applies. The value must be a valid number and the unit a string that is recognizable by the udunits package.
7.4 Climatological StatisticsRequirements:
- The climatology attribute may only be attached to a time coordinate variable.
- The type of the climatology attribute is a string whose value is a single variable name. The specified variable must exist in the file.
- A climatology variable must have the same dimension as its associated time coordinate variable, and have a trailing dimension (CDL order) of size 2.
- A climatology variable must be a numeric data type.
- If a climatology variable has units, standard_name, or calendar attributes, they must agree with those of its associated variable.
- A climatology variable must not have _FillValue or missing_value attributes.
8.1 Packed DataRequirements:
- The scale_factor and add_offset attributes must be the same numeric data type.
- If scale_factor and add_offset are a different type than the variable, then they must be either type float or type double.
- If scale_factor and add_offset are a different type than the variable, then the variable must be type byte, short or int.
- If scale_factor and add_offset are type float, the variable should not be of type int.
8.2 Compression by GatheringRequirements:
- The compress attribute may only be attached to a coordinate variable with an integer data type.
- The type of the compress attribute is a string whose value is a blank separated list of dimension names. The specified dimensions must exist in the file.
- The values of the associated coordinate variable must be in the range starting with 0 and going up to the product of the compressed dimension sizes minus 1 (CDL index conventions).