summaryrefslogtreecommitdiffstats
path: root/doc/html/Tutor/select.html
blob: b4109b00391cb81356cd46771ff8dfd45b3a2f61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<HTML><HEAD>
<TITLE>HDF5 Tutorial - Hyperslab Selections  
</TITLE> 
</HEAD>

<body bgcolor="#ffffff">

<!-- BEGIN MAIN BODY -->


 [ <A HREF="title.html"><I>HDF5 Tutorial Top</I></A> ]
<H1>
<BIG><BIG><BIG><FONT COLOR="#c101cd">Hyperslab Selections</FONT>
</BIG></BIG></BIG></H1>

<hr noshade size=1>

<BODY>
<H2>Contents:</H2>
<UL>
    <LI><A HREF="#def">Selecting a Portion of a Dataspace</A>
    <LI>Programming Example 
<UL>
      <LI> <A HREF="#desc">Description</A> 
      <LI> <A HREF="#rem">Remarks</A> 
<!--
      <LI> <A HREF="#fc">File Contents</A>
-->
</UL>
</UL>
<HR>
<A NAME="def">
<H2>Selecting a Portion of a Dataspace</H2>
Hyperslabs are portions of datasets. A hyperslab selection can be a 
logically contiguous collection of points in a dataspace, or it
can be a regular pattern of points or blocks in a dataspace.
You can select a hyperslab to write to or read from with the function 
<CODE>H5Sselect_hyperslab</CODE> / <CODE>h5sselect_hyperslab_f</CODE>.
<P>
<H2> Programming Example</H2>
<A NAME="desc">
<H3><U>Description</U></H3>      
This example creates a 5 x 6 integer array in a file called <code>sds.h5</code>
(<code>sdsf.h5</code> in FORTRAN).  It 
selects a 3 x 4 hyperslab from the dataset as follows (Dimension 0 is 
offset by 1 and Dimension 1 is offset by 2): 
<P>
<B>5 x 6 array:</B> 
<TABLE BORDER CELLSPACING=1 CELLPADDING=7 WIDTH=172>
<TR><TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
</TR>
<TR><TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
</TR>
<TR><TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="17%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
</TR>
<TR><TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
</TR>
</TABLE>
<P>
Then it reads the hyperslab from this file into a 2-dimensional plane 
(size 7 x 7) of a 3-dimensional array (size 7 x 7 x 3), as
follows (with Dimension 0 offset by 3):
<P>
<TABLE BORDER CELLSPACING=1 CELLPADDING=7 WIDTH=201>
<TR><TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT SIZE=2><P> X</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
<TR><TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="14%" VALIGN="TOP">&nbsp;</TD>
</TR>
</TABLE>
<P>

To obtain the example, download:
<UL>
[ <A HREF="examples/h5_hyperslab.c">C example</A> ] 
    - <code>h5_hyperslab.c</code><BR>
[ <A HREF="examples/hyperslab.f90">FORTRAN example</A> ] 
    - <code>hyperslab.f90</code><BR>
[ <A HREF="examples/java/HyperSlab.java">Java example</A> ] 
    - <code>HyperSlab.java</code>
</UL>
<B>NOTE:</B> To download a tar file of the examples, including a Makefile,
please go to the <A HREF="references.html">References</A> page.
<P>

<A NAME="rem">
<H3><U>Remarks</U></H3>
<UL>
<LI><CODE>H5Sselect_hyperslab</CODE> / <CODE>h5sselect_hyperslab_f</CODE> 
selects a hyperslab region to 
add to the current selected region for a specified dataspace.
<P>
<I><B>C</B></I>:
<pre>
    herr_t H5Sselect_hyperslab (hid_t space_id, H5S_seloper_t operator,
        const hsize_t *start, const hsize_t *stride,
        const hsize_t *count, const hsize_t *block ) 
</pre>
<P>
<I><B>FORTRAN</B></I>:
<pre>
    h5sselect_hyperslab_f (space_id, operator, start, count, &
                           hdferr, stride, block)

            space_id    IN: INTEGER(HID_T) 
            operator    IN: INTEGER 
            start       IN: INTEGER(HSIZE_T), DIMENSION(*)
            count       IN: INTEGER(HSIZE_T), DIMENSION(*)
            hdferr     OUT: INTEGER
            stride      IN: INTEGER(HSIZE_T), DIMENSION(*), OPTIONAL
            block       IN: INTEGER(HSIZE_T), DIMENSION(*), OPTIONAL 
</pre>
<P>
<UL>
<LI>The parameter <I>space_id</I> is the dataspace identifier for the
    specified dataspace.
<P>
<LI>The parameter <I>operator</I> can be set to one of the following: 
   <dir><DL>
    <dt><CODE>H5S_SELECT_SET</CODE> (<CODE>H5S_SELECT_SET_F</CODE> in FORTRAN)
    <dd>Replace the existing selection with the parameters from this call.
        Overlapping blocks are not supported with this operator.

    <dt><CODE>H5S_SELECT_OR</CODE> (<CODE>H5S_SELECT_OR_F</CODE> in FORTRAN)
    <dd>Add the new selection to the existing selection.
    </DL></dir>

<P>
<LI>The <I>start</I> array determines the starting coordinates of the 
hyperslab to select. 
<P>
<LI>The <I>stride</I> array indicates which elements along a dimension are to 
be selected.    
<P>
<LI>The <I>count</I> array determines how many positions to select from the 
    dataspace in each dimension. 
<P>
<LI>The <I>block</I> array determines the size of the element block selected
    by the dataspace.
<P>
<LI>In C, a non-negative value is returned if successful, and a negative
value otherwise. In FORTRAN, the return value is returned in <I>hdferr</I>:
0 if successful and -1 otherwise.
</UL>
<P>
The <I>start</I>, <I>stride</I>, <I>count</I>, and <I>block</I> arrays must 
be the same size as the rank of the dataspace.
<P>
<LI>The examples introduce the following call: 
<dir><dl>
      <dt><code>H5Dget_space / h5dget_space_f:</code>
      <dd>Returns an identifier for a copy of the dataspace of a dataset.<P>
</dl></dir>
<LI>The C example also introduces the following calls: 
<dir><dl>
      <dt><code>H5Sget_simple_extent_dims:</code> 
      <dd>Returns the size and maximum size of each dimension of a dataspace.
      <dt><code>H5Sget_simple_extent_ndims:</code>
      <dd>Determines the dimensionality (or rank) of a dataspace. 
</dl></dir>
<P>
The FORTRAN example does not use these calls, though they
are available as <CODE>h5sget_simple_extent_dims_f</CODE> and
<CODE>h5sget_simple_extent_ndims_f</CODE>.

</UL>
</UL>
</UL>
</PRE>
<P>

<!--
<A NAME="fc">
<H3><U>File Contents</U></H3>
-->





<!-- BEGIN FOOTER INFO -->

<P><hr noshade size=1>
<font face="arial,helvetica" size="-1">
  <a href="http://www.ncsa.uiuc.edu/"><img border=0
     src="footer-ncsalogo.gif"
     width=78 height=27 alt="NCSA"><br>
  The National Center for Supercomputing Applications</A><br>
  <a href="http://www.uiuc.edu/">University of Illinois
    at Urbana-Champaign</a><br>
  <br>
<!-- <A HREF="helpdesk.mail.html"> -->
<A HREF="mailto:hdfhelp@ncsa.uiuc.edu">
hdfhelp@ncsa.uiuc.edu</A>
<br>
<BR> <H6>Last Modified: June 22, 2001</H6><BR>
<!-- modified by Barbara Jones - bljones@ncsa.uiuc.edu -->
<!-- modified by Frank Baker - fbaker@ncsa.uiuc.edu -->
</FONT>
<BR>
<!-- <A HREF="mailto:hdfhelp@ncsa.uiuc.edu"> -->

</BODY>
</HTML>