MINCGEN(1)
π MINCGEN(1) β a MINC User's Guide moment π
okay bestie, gather round, because this is the manual page for mincgen, part of the MINC User's Guide, and it's honestly giving β¨file-format magicβ¨. no cap.
β¨ NAME β¨
mincgen β Generate a MINC file from a CDL file. π
πΈ SYNOPSIS πΈ
mincgen [-b] [-n] [-o minc_filename] input_file
π¦ DESCRIPTION π¦
so mincgen generates a MINC file. that's the whole vibe. π«Ά
the input to mincgen is a description of a MINC file, written in a little language called CDL (that's network Common Data form Language, and yes it's described below, keep reading bestie).
now here's the plot twist: if you specify no options at all when you invoke mincgen, it literally just checks the syntax of the input CDL file and produces error messages for any violations of CDL syntax. that's it. it's a vibe check for your CDL. no file gets made. π
but the other options can be used to create the corresponding MINC file. that's when things get real.
mincgen may be used with the companion program mincdump to perform some simple operations on MINC files. for example β and this is such a slay β to rename a dimension in a MINC file, you:
- use
mincdumpto get a CDL version of the MINC file - edit the CDL file to change the name of the dimensions
- use
mincgento generate the corresponding MINC file from the edited CDL file
iconic. periodt. π
π OPTIONS π
-bβ Create a (binary) MINC file. π₯ if the-ooption is absent, a default file name will be constructed from the MINC name (the one specified after thenetcdforhdf5keyword in the input) by appending the.mncextension. and heads up bestie β if a file already exists with the specified name, it will be overwritten. like, gone. so watch out. π-o minc_filenameβ Name for the binary MINC file created. π if this option is specified, it implies the-boption (they're kinda a package deal). and why is this option even necessary, you ask? because MINC files cannot be written directly to standard output, since standard output is not seekable. it's giving "the rules are the rules." π
π EXAMPLES π
Check the syntax of the CDL file foo.cdl β just a little vibe check, no file output:
mincgen foo.cdl
From the CDL file foo.cdl, generate an equivalent binary MINC file named x.mnc:
mincgen -o x.mnc foo.cdl
and that's where part 1 leaves us, bestie β more coming, don't go anywhere π
β¨ USAGE β¨
π¦ CDL Syntax Summary π¦
okay so bestie, let's get into it. Here's a whole CDL syntax moment. This example is serving a MINC file with several named dimensions (xspace, yspace, and zspace), variables (zspace, image), variable attributes (valid_range, signtype), and some data. CDL keywords are in boldface. (This example is just to illustrate the syntax; a real CDL file would have a more complete set of attributes so that the data would be more completely self-describing. no cap.)
netcdf foo { // an example MINC specification in CDL
dimensions:
xspace = 8;
yspace = 8;
zspace = 5;
variables:
float xspace;
float yspace;
float zspace(zspace);
short image(zspace,yspace,xspace);
double image-min(zspace)
double image-max(zspace)
// variable attributes
image:valid_range = 0,5;
data:
image-min = -1,-1,-1,-1,-1;
image-max = 1,1,1,1,1;
image =
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5;
zspace = 0,2,3.5,7,10;
}
All CDL statements are terminated by a semicolon. periodt. Spaces, tabs, and newlines can be used freely for readability. Comments may follow the characters // on any line. it's giving flexible.
A CDL description consists of three optional parts: dimensions, variables, and data, beginning with the keyword dimensions:, variables:, and data, respectively. The variable part may contain variable declarations and attribute assignments. slay.
A MINC dimension is used to define the shape of one or more of the multidimensional variables contained in the MINC file. A MINC dimension has a name, a size, and possibly several other attributes. iconic.
A variable represents a multidimensional array of values of the same type. A variable has a name, a data type, and a shape described by its list of dimensions. Each variable may also have associated attributes (see below) as well as data values. The name, data type, and shape of a variable are specified by its declaration in the variable section of a CDL description. A variable may have the same name as a dimension; by convention such a variable is one-dimensional and contains coordinates of the dimension it names. Dimensions need not have corresponding variables. lowkey.
A netCDF attribute contains information about a netCDF variable or about the whole netCDF dataset. Attributes are used to specify such properties as units, special values, maximum and minimum valid values, scaling factors, offsets, and parameters. Attribute information is represented by single values or arrays of values. For example, "units" is an attribute represented by a character array such as "celsius". An attribute has an associated variable, a name, a data type, a length, and a value. In contrast to variables that are intended for data, attributes are intended for metadata (data about data). very meta, bestie.
In CDL, an attribute is designated by a variable and attribute name, separated by :. It is possible to assign global attributes not associated with any variable to the file as a whole by using : before the attribute name. The data type of an attribute in CDL is derived from the type of the value assigned to it. The length of an attribute is the number of data values assigned to it, or the number of characters in the character string assigned to it. Multiple values are assigned to non-character attributes by separating the values with commas. All values assigned to an attribute must be of the same type. periodt.
The names for CDL dimensions, variables, and attributes must begin with an alphabetic character or _, and subsequent characters may be alphanumeric or _ or -. slay.
The optional data section of a CDL specification is where variables may be initialized. The syntax of an initialization is simple: a variable name, an equals sign, and a comma-delimited list of constants (possibly separated by spaces, tabs and newlines) terminated with a semicolon. For multi-dimensional arrays, the last dimension varies fastest. Thus row-order rather than column order is used for matrices. If fewer values are supplied than are needed to fill a variable, it is extended with a type-dependent fill value, which can be overridden by supplying a value for a distinguished variable attribute named _FillValue. The types of constants need not match the type declared for a variable; coercions are done to convert integers to floating point, for example. The constant _ can be used to designate the fill value for a variable. obsessed.
π₯ Primitive Data Types π₯
charβ charactersbyteβ 8-bit datashortβ 16-bit signed integerslongβ 32-bit signed integersintβ (synonymous withlong)floatβ IEEE single precision floating point (32 bits)realβ (synonymous withfloat)doubleβ IEEE double precision floating point (64 bits)
Except for the added data-type byte and the lack of unsigned, CDL supports the same primitive data types as C. The names for the primitive data types are reserved words in CDL, so the names of variables, dimensions, and attributes must not be type names. In declarations, type names may be specified in either upper or lower case. no cap.
Bytes differ from characters in that they are intended to hold a full eight bits of data, and the zero byte has no special significance, as it does for character data. got it.
Shorts can hold values between -32768 and 32767. simple.
Longs can hold values between -2147483648 and 2147483647. int and integer are accepted as synonyms for long in CDL declarations. Now that there are platforms with 64-bit representations for C longs, it may be better to use the int synonym to avoid confusion. lowkey good advice.
Floats can hold values between about -3.4+38 and 3.4+38. Their external representation is as 32-bit IEEE normalized single-precision floating point numbers. real is accepted as a synonym for float in CDL declarations. iconic.
Doubles can hold values between about -1.7+308 and 1.7+308. Their external representation is as 64-bit IEEE standard normalized double-precision floating point numbers. slay.
πΈ CDL Constants πΈ
Constants assigned to attributes or variables may be of any of the basic MINC types. The syntax for constants is similar to C syntax, except that type suffixes must be appended to shorts and floats to distinguish them from longs and doubles. iykyk.
A byte constant is represented by a single character or multiple character escape sequence enclosed in single quotes. For example,
'a' // ASCII `a'
'\0' // a zero byte
'\n' // ASCII newline character
'\33' // ASCII escape character (33 octal)
'\x2b' // ASCII plus (2b hex)
'\377' // 377 octal = 255 decimal, non-ASCII
Character constants are enclosed in double quotes. A character array may be represented as a string enclosed in double quotes. The usual C string escape conventions are honored. For example
"a" // ASCII `a'
"Two\nlines\n" // a 10-character string with two embedded newlines
"a bell:\007" // a string containing an ASCII bell
Note that the character array "a" would fit in a one-element variable, since no terminating NULL character is assumed. However, a zero byte in a character array is interpreted as the end of the significant characters by the mincdump program, following the C convention. Therefore, a NULL byte should not be embedded in a character string unless at the end: use the byte data type instead for byte arrays that contain the zero byte. MINC and CDL have no string type, but only fixed-length character arrays, which may be multi-dimensional. π important.
short integer constants are intended for representing 16-bit signed quantities. The form of a short constant is an integer constant with an s or S appended. If a short constant begins with 0, it is interpreted as octal, except that if it begins with 0x, it is interpreted as a hexadecimal constant. For example:
-2s // a short -2
0123s // octal
0x7ffs //hexadecimal
Long integer constants are intended for representing 32-bit signed quantities. The form of a long constant is an ordinary integer constant, although it is acceptable to append an optional l or L. If a long constant begins with 0, it is interpreted as octal, except that if it begins with 0x, it is interpreted as a hexadecimal constant. Examples of valid long constants include:
-2
1234567890L
0123 // octal
0x7ff // hexadecimal
Floating point constants of type float are appropriate for representing floating point data with about seven significant digits of precision. The form of a float constant is the same as a C floating point constant with an f or F appended. For example the following are all acceptable float constants:
-2.0f
3.14159265358979f // will be truncated to less precision
1.f
Floating point constants of type double are appropriate for representing floating point data with about sixteen significant digits of precision. The form of a double constant is the same as a C floating point constant. An optional d or D may be appended. For example the following are all acceptable double constants:
-2.0
3.141592653589793
1.0e-20
1.d
π AUTHOR π
Originally written by members of the Unidata Program at the University Corporation for Atmospheric Research.
Modified by Bert Vincent (bert@bic.mni.mcgill.ca) for use with both netCDF and HDF5 files. slay.
π COPYRIGHTS π
Copyright Β© University Corporation for Atmospheric Research
π SEE ALSO π
ncdump(1), ncgen(1), netcdf(3)
π BUGS π
okay bestie, sit down for a sec because we gotta talk about the gotchas π not me being the bearer of bad news but you deserve to know fr fr.
- the CDL syntax is lowkey a trap β it makes it so easy to assign something that looks like an array of variable-length strings to a variable. and you're like "slay, an array of strings, exactly what I wanted π₯°" β but nope. those strings just get concatenated into a single array of characters instead. why? because MINC literally cannot represent an array of variable-length strings in one MINC variable. it's not being shady, it just doesn't have the range. π so like... be careful, okay? check your output, don't just trust the vibe.
- and one more thing β MINC and CDL do not yet support a type corresponding to a 64-bit integer. that's it. that's the whole thing. no 64-bit int type, not yet, not here. if you were hoping, bestie, the answer is "not yet" π so plan accordingly and don't come for me, I'm just the messenger.
ngl these are the kind of bugs that don't crash anything, they just silently give you not quite what you meant, which is honestly worse. read your data back. trust. π
and that's the whole page, my love π«Ά this little manual page is MINCGEN(1), hailing from $Date: 2008-10-12 05:07:12 $ β yeah she's an elder but she still serves β¨ go forth and generate your MINC files, and remember: keep every flag, keep every caveat, keep it iconic. periodt. ππ
π¦ where this page comes from
- debian bookworm: minc-tools 2.3.00+dfsg-10 Β· as_is
- nixpkgs unstable: minc-tools 2.3.06-unstable-2024-11-28
- ubuntu jammy: minc-tools 2.3.00+dfsg-8 Β· as_is
- ubuntu noble: minc-tools 2.3.00+dfsg-10build2 Β· as_is
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms