def test_2d_cell_fields(self): # Create a field that looks like this, # # (0) --- (1) --- (2) # | | | # | 0 | 1 | # | | | # (3) --- (4) --- (5) g = RasterField((2, 3), (1, 2), (0, 0), indexing="ij") data = np.arange(6) g.add_field("point_var_1", data, centering="point") g.add_field("point_var_2", data * 2, centering="point") data = np.arange(2) g.add_field("cell_var_1", data, centering="zonal") g.add_field("cell_var_2", data * 2, centering="zonal") fields = g.get_cell_fields() self.assertEqual(len(fields), 2) self.assertTrue("cell_var_1" in fields) self.assertTrue("cell_var_2" in fields) self.assert_field_values(g, "cell_var_1", [0, 1]) self.assert_field_values(g, "cell_var_2", [0, 2])
def test_2d_cell_fields(self): # Create a field that looks like this, # # (0) --- (1) --- (2) # | | | # | 0 | 1 | # | | | # (3) --- (4) --- (5) g = RasterField((2, 3), (1, 2), (0, 0), indexing="ij") data = np.arange(6) g.add_field("point_var_1", data, centering="point") g.add_field("point_var_2", data * 2, centering="point") data = np.arange(2) g.add_field("cell_var_1", data, centering="zonal") g.add_field("cell_var_2", data * 2, centering="zonal") fields = g.get_cell_fields() self.assertEqual(len(fields), 2) self.assertTrue("cell_var_1" in fields) self.assertTrue("cell_var_2" in fields) self.assert_field_values(g, "cell_var_1", [0, 1]) self.assert_field_values(g, "cell_var_2", [0, 2])
def test_2d_cell_fields (self): # Create a field that looks like this, # # (0) --- (1) --- (2) # | | | # | 0 | 1 | # | | | # (3) --- (4) --- (5) g = RasterField ((2,3), (1,2), (0, 0), indexing='ij') data = np.arange (6) g.add_field ('point_var_1', data, centering='point') g.add_field ('point_var_2', data*2, centering='point') data = np.arange (2) g.add_field ('cell_var_1', data, centering='zonal') g.add_field ('cell_var_2', data*2, centering='zonal') fields = g.get_cell_fields () self.assertEqual (len (fields), 2) self.assertTrue (fields.has_key ('cell_var_1')) self.assertTrue (fields.has_key ('cell_var_2')) self.assert_field_values (g, 'cell_var_1', [0, 1]) self.assert_field_values (g, 'cell_var_2', [0, 2])