Skip to content

Commit 6bef30b

Browse files
author
Jeff Whitaker
authored
Merge pull request #1390 from danny-lloyd/improve-docs-datatype-table
Rewrite datatype list as table in docs
2 parents a371621 + bacab64 commit 6bef30b

File tree

2 files changed

+89
-26
lines changed

2 files changed

+89
-26
lines changed

docs/index.html

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,27 +297,83 @@ <h2 id="variables-in-a-netcdf-file">Variables in a netCDF file</h2>
297297
unlike numpy arrays, netCDF4 variables can be appended to along one or
298298
more 'unlimited' dimensions. To create a netCDF variable, use the
299299
<code><a title="netCDF4.Dataset.createVariable" href="#netCDF4.Dataset.createVariable">Dataset.createVariable()</a></code> method of a <code><a title="netCDF4.Dataset" href="#netCDF4.Dataset">Dataset</a></code> or
300-
<code><a title="netCDF4.Group" href="#netCDF4.Group">Group</a></code> instance. The <code><a title="netCDF4.Dataset.createVariable" href="#netCDF4.Dataset.createVariable">Dataset.createVariable()</a></code>j method
300+
<code><a title="netCDF4.Group" href="#netCDF4.Group">Group</a></code> instance. The <code><a title="netCDF4.Dataset.createVariable" href="#netCDF4.Dataset.createVariable">Dataset.createVariable()</a></code> method
301301
has two mandatory arguments, the variable name (a Python string), and
302302
the variable datatype. The variable's dimensions are given by a tuple
303303
containing the dimension names (defined previously with
304304
<code><a title="netCDF4.Dataset.createDimension" href="#netCDF4.Dataset.createDimension">Dataset.createDimension()</a></code>). To create a scalar
305305
variable, simply leave out the dimensions keyword. The variable
306306
primitive datatypes correspond to the dtype attribute of a numpy array.
307307
You can specify the datatype as a numpy dtype object, or anything that
308-
can be converted to a numpy dtype object.
309-
Valid datatype specifiers
310-
include: <code>'f4'</code> (32-bit floating point), <code>'f8'</code> (64-bit floating
311-
point), <code>'i4'</code> (32-bit signed integer), <code>'i2'</code> (16-bit signed
312-
integer), <code>'i8'</code> (64-bit signed integer), <code>'i1'</code> (8-bit signed
313-
integer), <code>'u1'</code> (8-bit unsigned integer), <code>'u2'</code> (16-bit unsigned
314-
integer), <code>'u4'</code> (32-bit unsigned integer), <code>'u8'</code> (64-bit unsigned
315-
integer), or <code>'S1'</code> (single-character string).
316-
The old Numeric
317-
single-character typecodes (<code>'f'</code>,<code>'d'</code>,<code>'h'</code>,
318-
<code>'s'</code>,<code>'b'</code>,<code>'B'</code>,<code>'c'</code>,<code>'i'</code>,<code>'l'</code>), corresponding to
319-
(<code>'f4'</code>,<code>'f8'</code>,<code>'i2'</code>,<code>'i2'</code>,<code>'i1'</code>,<code>'i1'</code>,<code>'S1'</code>,<code>'i4'</code>,<code>'i4'</code>),
320-
will also work. The unsigned integer types and the 64-bit integer type
308+
can be converted to a numpy dtype object. Valid datatype specifiers
309+
include:</p>
310+
<table>
311+
<thead>
312+
<tr>
313+
<th>Specifier</th>
314+
<th>Datatype</th>
315+
<th>Old typecodes</th>
316+
</tr>
317+
</thead>
318+
<tbody>
319+
<tr>
320+
<td><code>'f4'</code></td>
321+
<td>32-bit floating point</td>
322+
<td><code>'f'</code></td>
323+
</tr>
324+
<tr>
325+
<td><code>'f8'</code></td>
326+
<td>64-bit floating point</td>
327+
<td><code>'d'</code></td>
328+
</tr>
329+
<tr>
330+
<td><code>'i4'</code></td>
331+
<td>32-bit signed integer</td>
332+
<td><code>'i'</code> <code>'l'</code></td>
333+
</tr>
334+
<tr>
335+
<td><code>'i2'</code></td>
336+
<td>16-bit signed integer</td>
337+
<td><code>'h'</code> <code>'s'</code></td>
338+
</tr>
339+
<tr>
340+
<td><code>'i8'</code></td>
341+
<td>64-bit signed integer</td>
342+
<td></td>
343+
</tr>
344+
<tr>
345+
<td><code>'i1'</code></td>
346+
<td>8-bit signed integer</td>
347+
<td><code>'b'</code> <code>'B'</code></td>
348+
</tr>
349+
<tr>
350+
<td><code>'u1'</code></td>
351+
<td>8-bit unsigned integer</td>
352+
<td></td>
353+
</tr>
354+
<tr>
355+
<td><code>'u2'</code></td>
356+
<td>16-bit unsigned integer</td>
357+
<td></td>
358+
</tr>
359+
<tr>
360+
<td><code>'u4'</code></td>
361+
<td>32-bit unsigned integer</td>
362+
<td></td>
363+
</tr>
364+
<tr>
365+
<td><code>'u8'</code></td>
366+
<td>64-bit unsigned integer</td>
367+
<td></td>
368+
</tr>
369+
<tr>
370+
<td><code>'S1'</code></td>
371+
<td>single-character string</td>
372+
<td><code>'c'</code></td>
373+
</tr>
374+
</tbody>
375+
</table>
376+
<p>The unsigned integer types and the 64-bit integer type
321377
can only be used if the file format is <code>NETCDF4</code>.</p>
322378
<p>The dimensions themselves are usually also defined as variables, called
323379
coordinate variables. The <code><a title="netCDF4.Dataset.createVariable" href="#netCDF4.Dataset.createVariable">Dataset.createVariable()</a></code>

src/netCDF4/_netCDF4.pyx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,25 +295,32 @@ supplied by the [numpy module](http://numpy.scipy.org). However,
295295
unlike numpy arrays, netCDF4 variables can be appended to along one or
296296
more 'unlimited' dimensions. To create a netCDF variable, use the
297297
`Dataset.createVariable` method of a `Dataset` or
298-
`Group` instance. The `Dataset.createVariable`j method
298+
`Group` instance. The `Dataset.createVariable` method
299299
has two mandatory arguments, the variable name (a Python string), and
300300
the variable datatype. The variable's dimensions are given by a tuple
301301
containing the dimension names (defined previously with
302302
`Dataset.createDimension`). To create a scalar
303303
variable, simply leave out the dimensions keyword. The variable
304304
primitive datatypes correspond to the dtype attribute of a numpy array.
305305
You can specify the datatype as a numpy dtype object, or anything that
306-
can be converted to a numpy dtype object. Valid datatype specifiers
307-
include: `'f4'` (32-bit floating point), `'f8'` (64-bit floating
308-
point), `'i4'` (32-bit signed integer), `'i2'` (16-bit signed
309-
integer), `'i8'` (64-bit signed integer), `'i1'` (8-bit signed
310-
integer), `'u1'` (8-bit unsigned integer), `'u2'` (16-bit unsigned
311-
integer), `'u4'` (32-bit unsigned integer), `'u8'` (64-bit unsigned
312-
integer), or `'S1'` (single-character string). The old Numeric
313-
single-character typecodes (`'f'`,`'d'`,`'h'`,
314-
`'s'`,`'b'`,`'B'`,`'c'`,`'i'`,`'l'`), corresponding to
315-
(`'f4'`,`'f8'`,`'i2'`,`'i2'`,`'i1'`,`'i1'`,`'S1'`,`'i4'`,`'i4'`),
316-
will also work. The unsigned integer types and the 64-bit integer type
306+
can be converted to a numpy dtype object. Valid datatype specifiers
307+
include:
308+
309+
| Specifier | Datatype | Old typecodes |
310+
|-----------|-------------------------|---------------|
311+
| `'f4'` | 32-bit floating point | `'f'` |
312+
| `'f8'` | 64-bit floating point | `'d'` |
313+
| `'i4'` | 32-bit signed integer | `'i'` `'l'` |
314+
| `'i2'` | 16-bit signed integer | `'h'` `'s'` |
315+
| `'i8'` | 64-bit signed integer | |
316+
| `'i1'` | 8-bit signed integer | `'b'` `'B'` |
317+
| `'u1'` | 8-bit unsigned integer | |
318+
| `'u2'` | 16-bit unsigned integer | |
319+
| `'u4'` | 32-bit unsigned integer | |
320+
| `'u8'` | 64-bit unsigned integer | |
321+
| `'S1'` | single-character string | `'c'` |
322+
323+
The unsigned integer types and the 64-bit integer type
317324
can only be used if the file format is `NETCDF4`.
318325
319326
The dimensions themselves are usually also defined as variables, called

0 commit comments

Comments
 (0)