File: test_pt.rb

package info (click to toggle)
ruby-hdfeos5 1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 18,180 kB
  • ctags: 783
  • sloc: ansic: 13,294; ruby: 2,807; makefile: 13
file content (267 lines) | stat: -rw-r--r-- 6,961 bytes parent folder | download | duplicates (6)
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
# -*- coding: utf-8 -*-
require 'numru/hdfeos5'
include NumRu


############################################################################### OK
##### MLS データを読み込んで作業ができるようにする
############################################################################################
# HDF-EOS5 sample program ( HDFEOS5_ug_vol1_may_2004.pdf )
############################################################################### OK
# sample 1
############################################################################### OK
filename1 = "test/test_pt.he5"
#print "creating ",filename1,"...\n"
file1=HE5.open(filename1,"w")
point1=file1.ptcreate("Simple point")
point2=file1.ptcreate("FixedBuoy point")
point3=file1.ptcreate("FloatBuoy point")

point1.detach
point2.detach
point3.detach
file1.close
############################################################################### ok
# sample 2
############################################################################### OK
#print "add2 ",filename1,"...\n"
file2=HE5.open(filename1,"a")

point4=file2.point("Simple point")
nflds=3
rank=[1,1,1]
fieldlist="Time,Concentration,Species"
dims = NArray.int(4)
dims[0] = [1,0]
dims[1] = [1,0]
dims[2] = [1,0]
dtype="float,sfloat,int"
point4.deflevel("Sensor", nflds, rank, fieldlist, dims, dtype)
point4.detach

point5=file2.point("FixedBuoy point")
nflds=5
rank=[1,1,1,1,1]
fieldlist="Label,Longitude,Latitude,DeployDate,ID"
dims = NArray.int(6)
dims[0] = [1,0]
dims[1] = [1,0]
dims[2] = [1,0]
dims[3] = [1,0]
dims[4] = [1,0]
dtype="int,float,float,int,int"
point5.deflevel("Desc-Loc", nflds, rank, fieldlist, dims, dtype)

nflds=4
rank=[1,1,1,1]
fieldlist="Time,Rainfall,Temperature,ID"
dims = NArray.int(5)
dims[0] = [1,0]
dims[1] = [1,0]
dims[2] = [1,0]
dims[3] = [1,0]
dtype="float,sfloat,sfloat,int"
point5.deflevel("observations", nflds, rank, fieldlist, dims, dtype)
point5.deflinkage("Desc-Loc","observations", "ID")
point5.detach

point6=file2.point("FloatBuoy point")
nflds=4
rank=[1,1,1,1]
fieldlist="Label,DaployDate,Weight,ID"
dims = NArray.int(5)
dims[0] = [1,0]
dims[1] = [1,0]
dims[2] = [1,0]
dims[3] = [1,0]
dtype="int,int,int,int"
point6.deflevel("Description", nflds, rank, fieldlist, dims, dtype)

nflds=6
rank=[1,1,1,1,1,1]
fieldlist="Time,Longitude,Latitude,Rainfall,Temperature,ID"
dims = NArray.int(7)
dims[0] = [1,0]
dims[1] = [1,0]
dims[2] = [1,0]
dims[3] = [1,0]
dims[4] = [1,0]
dims[5] = [1,0]
dtype="float,float,float,sfloat,sfloat,int"
point6.deflevel("Measurements", nflds, rank, fieldlist, dims, dtype)
point6.deflinkage("Description","Measurements", "ID")
point6.detach
file2.close
############################################################################### ok
# sample 3
############################################################################### OK
#print "add3 ",filename1,"...\n"
file3=HE5.open(filename1,"a")
point7=file2.point("Simple point")
dname1=point7.var("Time")
count =[15]
time = NArray.float(16)
time[] = 1.5555
dname1.put(time)
dname1=point7.var("Concentration")
count =[15]
tmp = NArray.sfloat(1,16)
conc= tmp * NArray.sfloat(5,1)
conc[] = 0.2
dname1.writelevel(count,conc,"sfloat")
dname1=point7.var("Species")
spc= NArray.int(16)
spc = 10
dname1.put(spc)

point8=file2.point("FixedBuoy point")
dname1=point8.var("Longitude")
count =[5]
time = NArray.float(6)
time= [100,110,120,130,140]
dname1.writelevel(count, time,"float")

dname1=point8.var("Latitude")
count =[3]
#time = NArray.float(6)
time = [10,10,20]
dname1.writelevel(count, time,"float")

dname1=point8.var("DeployDate")
count =[5]
time = NArray.int(6)
time = [140,141,141,141,142]
dname1.writelevel(count, time,"int")

dname1=point8.var("ID","Desc-Loc")
count =[5]
time = NArray.int(6)
time = [1,2,3,4,5]
dname1.writelevel(count, time,"int")

dname1=point8.var("Time")
count =[15]
time = NArray.float(16)
time[] = 0.002
dname1.writelevel(count, time,"float")

dname1=point8.var("Rainfall")
count =[15]
time = NArray.sfloat(16)
time[] = 0.234
dname1.put(time)

dname1=point8.var("Temperature")
count =[15]
time = NArray.sfloat(16)
time[] = 233.43
dname1.put(time)

dname1=point8.var("ID","observations")
count =[15]
time = NArray.int(16)
time = [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
dname1.writelevel(count, time,"int")

count = [4]
attr1 = [1, 2, 3, 4]
point8.writeattr("GlobalAttribute","int",count,attr1)

count = [8]
attr1 = "ABCDEFGH"
point8.writeattr("GLOBAL_CHAR_ATTR","char",count,attr1)
count = [3]
attr1 = "abc"
point8.writeattr("GLOBAL_CHAR_ATTR_11","char",count,attr1)

attr1 = [1.111111,2.222222,3.333333,4.444444]
count = [4]
point8.writeattr("GLOBAL_DOUBLE_ATTR","float",count,attr1)
count = [4]
attr1 = [10, 20, 30, 40]
point8.writegrpattr("GroupAttribute","int",count,attr1)
count = [18]
attr1 = "ababababababababab"
dname1=point8.var("Temperature")
dname1.writelocattr("LOCAL_CHAR_ATTR","char",count,attr1)
point8.detach
file3.close
############################################################################### OK
# sample 4
############################################################################### OK
#print "info1 ",filename1,"...\n"
file4=HE5.open(filename1,"a")
#p file4.has_swath?()
#p file4.has_grid?()
#p file4.has_za?()
#p file4.has_point?()

point8=file4.point("FixedBuoy point")
#p point8.getlevelname()
dname1=point8.var("Temperature")
#p dname1.get_vars_float()  # error message is shown but it's normal
dname1=point8.var("Latitude")
#p dname1.get_vars_double()
dname1=point8.var("DeployDate")
#p dname1.get_vars_int()
#p dname1.ntype
#p dname1.shape
#p dname1.ndims
#p dname1.dim_names
#p dname1.natts
#p dname1.fieldinfo()
#p dname1.get
#p dname1.fwdlink
#p dname1.bcklink
point8.detach

point8=file4.point("FixedBuoy point")
#p point8.get_att_("GlobalAttribute")
#p point8.get_grpatt_("GroupAttribute")
#p point8.nrecs(1)
#p point8.nfields
#p point8.nlevels
point8.detach
file4.close

file4=HE5.open(filename1,"r")
point9=file4.point("Simple point")
dname1=point9.var("Time")
#p dname1.point
#p dname1.ntype
#p dname1.shape
#p dname1.ndims
#p dname1.dim_names
#p dname1.natts
#p dname1.fieldinfo()
#p dname1.get                # error message is shown but it's normal
#p dname1.get_vars_double()  # error message is shown but it's normal
point9.detach
file4.close

file4=HE5.open(filename1,"r")
point7=file4.point("FixedBuoy point")
dname1=point7.var("Latitude")
#p dname1.point
#p dname1.ntype
#p dname1.shape
#p dname1.ndims
#p dname1.dim_names
#p dname1.natts
#p dname1.fieldinfo()
#p dname1.get
point7.detach
file4.close
############################################################################### OK
# sample 5
############################################################################### OK
#print "info2 ",filename1,"...\n"
file5=HE5.open(filename1,"a")
point8=file5.point("FixedBuoy point")
dname1=point8.var("Latitude")
dname1.updatelevel(1,[0],13.0,"float")
point8.detach
file5.close

exit
############################################################################### ok