Skip to content

Commit 038091b

Browse files
committed
Store variable values under key 'data' instead of 'values'
1 parent 79e9729 commit 038091b

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

ncwriter/template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def update_dimensinos(self):
329329
consistent with variable array sizes.
330330
"""
331331
for name, var in self.variables.iteritems():
332-
values = var.get('values')
332+
values = var.get('data')
333333
if values is None:
334334
continue
335335

@@ -407,7 +407,7 @@ def createVariables(self, **kwargs):
407407
varname, datatype, dimensions=dimensions, **var_c_opts)
408408

409409
# add variable values
410-
ncvar[:] = var['values']
410+
ncvar[:] = var['data']
411411

412412
# add variable attributes
413413
if var.get('attributes'):

test_ncwriter/test_template.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def test_add_variable_attributes(self):
132132

133133
def test_set_variable_values(self):
134134
template = DatasetTemplate.from_json(TEMPLATE_JSON)
135-
template.variables['TEMP']['values'] = self.values10
136-
self.assertTrue(all(template.variables['TEMP']['values'] == self.values10))
135+
template.variables['TEMP']['data'] = self.values10
136+
self.assertTrue(all(template.variables['TEMP']['data'] == self.values10))
137137

138138
def test_create_empty_file(self):
139139
template = DatasetTemplate()
@@ -142,9 +142,9 @@ def test_create_empty_file(self):
142142

143143
def test_create_file(self):
144144
template = DatasetTemplate.from_json(TEMPLATE_JSON)
145-
template.variables['TIME']['values'] = self.values10
146-
template.variables['DEPTH']['values'] = self.values1
147-
template.variables['TEMP']['values'] = self.values10.reshape((10, 1))
145+
template.variables['TIME']['data'] = self.values10
146+
template.variables['DEPTH']['data'] = self.values1
147+
template.variables['TEMP']['data'] = self.values10.reshape((10, 1))
148148
template.to_netcdf(self.temp_nc_file)
149149

150150
dataset = Dataset(self.temp_nc_file)
@@ -180,7 +180,7 @@ def test_fill_values(self):
180180
'attributes': {'_FillValue': -999.}
181181
}
182182
x = np.array([-999., -999., -999., -999., -999., 1., 2., 3., 4., 5])
183-
template.variables['X']['values'] = x
183+
template.variables['X']['data'] = x
184184
template.to_netcdf(self.temp_nc_file)
185185

186186
dataset = Dataset(self.temp_nc_file)
@@ -197,10 +197,9 @@ def test_fill_values_from_masked_array(self):
197197
'attributes': {'_FillValue': -999.}
198198
}
199199
x = np.array([-4, -3, -2, -1, 0, 1., 2., 3., 4., 5])
200-
template.variables['X']['values'] = np.ma.masked_array(x,
201-
mask=[True, True, True, True, True,
202-
False, False, False, False, False]
203-
)
200+
template.variables['X']['data'] = np.ma.masked_array(x, mask=[True, True, True, True, True,
201+
False, False, False, False, False]
202+
)
204203
template.to_netcdf(self.temp_nc_file)
205204

206205
dataset = Dataset(self.temp_nc_file)

0 commit comments

Comments
 (0)