def test_get_axis_ungridded(self): from cis.plotting.plot import get_axis from cis.test.util.mock import make_dummy_2d_ungridded_data d = make_dummy_2d_ungridded_data() assert get_axis(d, "x").name() == 'latitude' assert get_axis(d, "x", 'latitude').name() == 'latitude' assert get_axis(d, "x", 'bad_name').name() == 'latitude' # Falls back on axis name assert get_axis(d, "y").name() == 'longitude' assert get_axis(d, "y", 'longitude').name() == 'longitude' assert get_axis(d, "y", 'bad_name').name() == 'longitude' # Falls back on axis name
def test_ungridded_write_attributes(self): data = make_dummy_2d_ungridded_data() attrs = {'attr_name': 'attr_val', 'standard_name': 'std_val', 'long_name': 'lg_val', 'units': 'units'} data.add_attributes(attrs) write(data, tmp_file) self.d = Dataset(tmp_file) for key, val in attrs.items(): assert getattr(self.d.variables['rain'], key) == val
def test_get_axis_ungridded(self): from cis.plotting.plot import get_axis from cis.test.util.mock import make_dummy_2d_ungridded_data d = make_dummy_2d_ungridded_data() assert get_axis(d, "x").name() == 'latitude' assert get_axis(d, "x", 'latitude').name() == 'latitude' assert get_axis( d, "x", 'bad_name').name() == 'latitude' # Falls back on axis name assert get_axis(d, "y").name() == 'longitude' assert get_axis(d, "y", 'longitude').name() == 'longitude' assert get_axis( d, "y", 'bad_name').name() == 'longitude' # Falls back on axis name
def test_ungridded_write_attributes(self): data = make_dummy_2d_ungridded_data() attrs = { 'attr_name': 'attr_val', 'standard_name': 'std_val', 'long_name': 'lg_val', 'units': 'units' } data.add_attributes(attrs) write(data, tmp_file) self.d = Dataset(tmp_file) for key, val in attrs.items(): assert getattr(self.d.variables['rainfall_flux'], key) == val
def test_ungridded_write_units(self): data = make_dummy_2d_ungridded_data() data.units = 'kg' write(data, tmp_file) self.d = Dataset(tmp_file) assert self.d.variables['rainfall_flux'].units == 'kg'
def test_write_netcdf(self): data_object = make_dummy_2d_ungridded_data() write(data_object, tmp_file)
def test_ungridded_write_units(self): data = make_dummy_2d_ungridded_data() data.units = 'kg' write(data, tmp_file) self.d = Dataset(tmp_file) assert self.d.variables['rain'].units == 'kg'