Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/iris/example_code/Meteorology/lagged_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def realization_metadata(cube, field, fname):
import iris.coords

realization_coord = iris.coords.AuxCoord(
np.int32(realization_number), "realization"
np.int32(realization_number), "realization", units="1"
)
cube.add_aux_coord(realization_coord)

Expand Down
2 changes: 1 addition & 1 deletion docs/iris/src/userguide/navigating_a_cube.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ by field basis *before* they are automatically merged together:
# Add our own realization coordinate if it doesn't already exist.
if not cube.coords('realization'):
realization = np.int32(filename[-6:-3])
ensemble_coord = icoords.AuxCoord(realization, standard_name='realization')
ensemble_coord = icoords.AuxCoord(realization, standard_name='realization', units="1")
cube.add_aux_coord(ensemble_coord)

filename = iris.sample_data_path('GloSea4', '*.pp')
Expand Down
4 changes: 3 additions & 1 deletion lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,9 @@ def post_process(self, collapsed_cube, data_result, coords, **kwargs):
# order cube.
for point in points:
cube = collapsed_cube.copy()
coord = iris.coords.AuxCoord(point, long_name=coord_name)
coord = iris.coords.AuxCoord(
point, long_name=coord_name, units="percent"
)
cube.add_aux_coord(coord)
cubes.append(cube)

Expand Down
12 changes: 6 additions & 6 deletions lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
standard_name=None,
long_name=None,
var_name=None,
units="no-unit",
units=None,
attributes=None,
):
"""
Expand Down Expand Up @@ -688,7 +688,7 @@ def __init__(
standard_name=None,
long_name=None,
var_name=None,
units="no-unit",
units=None,
attributes=None,
):
"""
Expand Down Expand Up @@ -788,7 +788,7 @@ def __init__(
standard_name=None,
long_name=None,
var_name=None,
units="1",
units=None,
attributes=None,
measure=None,
):
Expand Down Expand Up @@ -1440,7 +1440,7 @@ def __init__(
standard_name=None,
long_name=None,
var_name=None,
units="1",
units=None,
bounds=None,
attributes=None,
coord_system=None,
Expand Down Expand Up @@ -2411,7 +2411,7 @@ def from_regular(
standard_name=None,
long_name=None,
var_name=None,
units="1",
units=None,
attributes=None,
coord_system=None,
circular=False,
Expand Down Expand Up @@ -2474,7 +2474,7 @@ def __init__(
standard_name=None,
long_name=None,
var_name=None,
units="1",
units=None,
bounds=None,
attributes=None,
coord_system=None,
Expand Down
18 changes: 14 additions & 4 deletions lib/iris/fileformats/pp_load_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def _convert_vertical_coords(
model_level_number,
standard_name="model_level_number",
attributes={"positive": "down"},
units="1",
)
coords_and_dims.append((coord, dim))

Expand Down Expand Up @@ -197,6 +198,7 @@ def _convert_vertical_coords(
model_level_number,
long_name="soil_model_level_number",
attributes={"positive": "down"},
units="1",
)
coords_and_dims.append((coord, dim))
elif np.any(brsvd1 != brlev):
Expand Down Expand Up @@ -235,6 +237,7 @@ def _convert_vertical_coords(
model_level_number,
standard_name="model_level_number",
attributes={"positive": "up"},
units="1",
)
level_pressure = _dim_or_aux(
bhlev,
Expand All @@ -243,7 +246,10 @@ def _convert_vertical_coords(
bounds=np.vstack((bhrlev, brsvd2)).T,
)
sigma = AuxCoord(
blev, long_name="sigma", bounds=np.vstack((brlev, brsvd1)).T
blev,
long_name="sigma",
bounds=np.vstack((brlev, brsvd1)).T,
units="1",
)
coords_and_dims.extend(
[(model_level_number, dim), (level_pressure, dim), (sigma, dim)]
Expand All @@ -265,6 +271,7 @@ def _convert_vertical_coords(
model_level_number,
standard_name="model_level_number",
attributes={"positive": "up"},
units="1",
)
level_height = _dim_or_aux(
blev,
Expand All @@ -274,7 +281,10 @@ def _convert_vertical_coords(
attributes={"positive": "up"},
)
sigma = AuxCoord(
bhlev, long_name="sigma", bounds=np.vstack((bhrlev, brsvd2)).T
bhlev,
long_name="sigma",
bounds=np.vstack((bhrlev, brsvd2)).T,
units="1",
)
coords_and_dims.extend(
[(model_level_number, dim), (level_height, dim), (sigma, dim)]
Expand Down Expand Up @@ -846,7 +856,7 @@ def _convert_scalar_realization_coords(lbrsvd4):
coords_and_dims = []
if lbrsvd4 != 0:
coords_and_dims.append(
(DimCoord(lbrsvd4, standard_name="realization"), None)
(DimCoord(lbrsvd4, standard_name="realization", units="1"), None)
)
return coords_and_dims

Expand Down Expand Up @@ -1078,7 +1088,7 @@ def _all_other_rules(f):
and f.lbmon == f.lbmond
):
aux_coords_and_dims.append(
(AuxCoord(f.lbmon, long_name="month_number"), None)
(AuxCoord(f.lbmon, long_name="month_number", units="1"), None)
)
aux_coords_and_dims.append(
(
Expand Down
4 changes: 3 additions & 1 deletion lib/iris/tests/integration/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def test_hybrid_height_and_pressure(self):
1200.0, long_name="level_pressure", units="hPa"
)
)
cube.add_aux_coord(iris.coords.DimCoord(0.5, long_name="other sigma"))
cube.add_aux_coord(
iris.coords.DimCoord(0.5, long_name="other sigma", units="1")
)
cube.add_aux_coord(
iris.coords.DimCoord(
1000.0, long_name="surface_air_pressure", units="hPa"
Expand Down
14 changes: 10 additions & 4 deletions lib/iris/tests/integration/test_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_hybrid_height_with_non_standard_coords(self):
delta_lower, delta, delta_upper = 150, 200, 250

cube = Cube(np.zeros((ny, nx)), "air_temperature")
level_coord = AuxCoord(0, "model_level_number")
level_coord = AuxCoord(0, "model_level_number", units="1")
cube.add_aux_coord(level_coord)
delta_coord = AuxCoord(
delta,
Expand All @@ -308,7 +308,10 @@ def test_hybrid_height_with_non_standard_coords(self):
units="m",
)
sigma_coord = AuxCoord(
sigma, bounds=[[sigma_lower, sigma_upper]], long_name="mavis"
sigma,
bounds=[[sigma_lower, sigma_upper]],
long_name="mavis",
units="1",
)
surface_altitude_coord = AuxCoord(
np.zeros((ny, nx)), "surface_altitude", units="m"
Expand Down Expand Up @@ -343,7 +346,7 @@ def test_hybrid_pressure_with_non_standard_coords(self):
delta_lower, delta, delta_upper = 0.15, 0.2, 0.25

cube = Cube(np.zeros((ny, nx)), "air_temperature")
level_coord = AuxCoord(0, "model_level_number")
level_coord = AuxCoord(0, "model_level_number", units="1")
cube.add_aux_coord(level_coord)
delta_coord = AuxCoord(
delta,
Expand All @@ -352,7 +355,10 @@ def test_hybrid_pressure_with_non_standard_coords(self):
units="Pa",
)
sigma_coord = AuxCoord(
sigma, bounds=[[sigma_lower, sigma_upper]], long_name="mavis"
sigma,
bounds=[[sigma_lower, sigma_upper]],
long_name="mavis",
units="1",
)
surface_air_pressure_coord = AuxCoord(
np.zeros((ny, nx)), "surface_air_pressure", units="Pa"
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/analysis/first_quartile_foo_1d.cml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dimCoord bounds="[[0, 11]]" id="b0d35dcf" long_name="foo" points="[5]" shape="(1,)" units="Unit('1')" value_type="int32"/>
</coord>
<coord>
<dimCoord id="3d9231d0" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="f5bc1733" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dimCoord bounds="[[0, 11]]" id="b0d35dcf" long_name="foo" points="[5]" shape="(1,)" units="Unit('1')" value_type="int32"/>
</coord>
<coord>
<dimCoord id="3d9231d0" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="f5bc1733" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/analysis/first_quartile_foo_2d.cml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dimCoord bounds="[[-15, 45]]" id="b0d35dcf" long_name="foo" points="[15.0]" shape="(1,)" units="Unit('1')" value_type="float64"/>
</coord>
<coord>
<dimCoord id="3d9231d0" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="f5bc1733" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dimCoord bounds="[[-15, 45]]" id="b0d35dcf" long_name="foo" points="[15.0]" shape="(1,)" units="Unit('1')" value_type="float64"/>
</coord>
<coord>
<dimCoord id="3d9231d0" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="f5bc1733" long_name="percentile_over_foo" points="[25]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<dimCoord bounds="[[-15, 45]]" id="b0d35dcf" long_name="foo" points="[15.0]" shape="(1,)" units="Unit('1')" value_type="float64"/>
</coord>
<coord>
<dimCoord id="3a1fa26e" long_name="percentile_over_foo_bar" points="[25]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="59a64095" long_name="percentile_over_foo_bar" points="[25]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<dimCoord bounds="[[-15, 45]]" id="b0d35dcf" long_name="foo" points="[15.0]" shape="(1,)" units="Unit('1')" value_type="float64"/>
</coord>
<coord>
<dimCoord id="3a1fa26e" long_name="percentile_over_foo_bar" points="[25]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="59a64095" long_name="percentile_over_foo_bar" points="[25]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<dimCoord circular="True" id="62e940e0" points="[-180, -90, 0, 90]" shape="(4,)" standard_name="longitude" units="Unit('degrees')" value_type="int64"/>
</coord>
<coord>
<dimCoord id="cf515091" long_name="percentile_over_wibble" points="[75]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="47527651" long_name="percentile_over_wibble" points="[75]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
<coord>
<dimCoord bounds="[[10.0, 30.0]]" id="10b8e1fc" long_name="wibble" points="[20.0]" shape="(1,)" units="Unit('1')" value_type="float32"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<dimCoord circular="True" id="62e940e0" points="[-180, -90, 0, 90]" shape="(4,)" standard_name="longitude" units="Unit('degrees')" value_type="int64"/>
</coord>
<coord>
<dimCoord id="cf515091" long_name="percentile_over_wibble" points="[75]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="47527651" long_name="percentile_over_wibble" points="[75]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
<coord>
<dimCoord bounds="[[10.0, 30.0]]" id="10b8e1fc" long_name="wibble" points="[20.0]" shape="(1,)" units="Unit('1')" value_type="float32"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<dimCoord circular="True" id="62e940e0" points="[-180, -90, 0, 90]" shape="(4,)" standard_name="longitude" units="Unit('degrees')" value_type="int64"/>
</coord>
<coord>
<dimCoord id="cf515091" long_name="percentile_over_wibble" points="[75]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="47527651" long_name="percentile_over_wibble" points="[75]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
<coord>
<dimCoord bounds="[[10.0, 30.0]]" id="10b8e1fc" long_name="wibble" points="[20.0]" shape="(1,)" units="Unit('1')" value_type="float32"/>
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/analysis/third_quartile_foo_1d.cml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dimCoord bounds="[[0, 11]]" id="b0d35dcf" long_name="foo" points="[5]" shape="(1,)" units="Unit('1')" value_type="int32"/>
</coord>
<coord>
<dimCoord id="3d9231d0" long_name="percentile_over_foo" points="[75]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="f5bc1733" long_name="percentile_over_foo" points="[75]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dimCoord bounds="[[0, 11]]" id="b0d35dcf" long_name="foo" points="[5]" shape="(1,)" units="Unit('1')" value_type="int32"/>
</coord>
<coord>
<dimCoord id="3d9231d0" long_name="percentile_over_foo" points="[75]" shape="(1,)" units="Unit('1')" value_type="int64"/>
<dimCoord id="f5bc1733" long_name="percentile_over_foo" points="[75]" shape="(1,)" units="Unit('percent')" value_type="int64"/>
</coord>
</coords>
<cellMethods/>
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/coord_api/minimal.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" ?>
<dimCoord id="3658c2fd" points="[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" shape="(10,)" units="Unit('1')" value_type="int32"/>
<dimCoord id="2d33cf28" points="[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" shape="(10,)" units="Unit('unknown')" value_type="int32"/>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ variables:
double time_climatology(time, bnds) ;
double latitude(latitude) ;
latitude:axis = "Y" ;
latitude:units = "1" ;
latitude:units = "degrees_north" ;
latitude:standard_name = "latitude" ;
double longitude(longitude) ;
longitude:axis = "X" ;
longitude:units = "1" ;
longitude:units = "degrees_east" ;
longitude:standard_name = "longitude" ;

// global attributes:
Expand Down
1 change: 0 additions & 1 deletion lib/iris/tests/results/netcdf/netcdf_save_no_name.cdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ variables:
double unknown(dim0, dim1) ;
unknown:coordinates = "unknown_scalar" ;
double dim0(dim0) ;
dim0:units = "1" ;
double dim1(dim1) ;
dim1:units = "m" ;
char unknown_scalar(string6) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ variables:
double time_climatology(time, bnds) ;
double latitude(latitude) ;
latitude:axis = "Y" ;
latitude:units = "1" ;
latitude:units = "degrees_north" ;
latitude:standard_name = "latitude" ;
double longitude(longitude) ;
longitude:axis = "X" ;
longitude:units = "1" ;
longitude:units = "degrees_east" ;
longitude:standard_name = "longitude" ;
}
4 changes: 2 additions & 2 deletions lib/iris/tests/stock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,8 @@ def jan_offset(day, year):
units="days since 1970-01-01 00:00:00-00",
climatological=True,
)
lon_dim = DimCoord(lon, standard_name="longitude")
lat_dim = DimCoord(lat, standard_name="latitude")
lon_dim = DimCoord(lon, standard_name="longitude", units="degrees")
lat_dim = DimCoord(lat, standard_name="latitude", units="degrees")

data_shape = (len(time_points), len(lat), len(lon))
values = np.zeros(shape=data_shape, dtype=np.int8)
Expand Down
8 changes: 6 additions & 2 deletions lib/iris/tests/test_aggregate_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def setUp(self):
)

model_level = iris.coords.DimCoord(
np.arange(z_points.size), standard_name="model_level_number"
np.arange(z_points.size),
standard_name="model_level_number",
units="1",
)

self.cube_single.add_aux_coord(self.coord_z_single, 0)
Expand Down Expand Up @@ -124,7 +126,9 @@ def setUp(self):
)

model_level = iris.coords.DimCoord(
np.arange(z1_points.size), standard_name="model_level_number"
np.arange(z1_points.size),
standard_name="model_level_number",
units="1",
)

self.cube_multi.add_aux_coord(self.coord_z1_multi, 0)
Expand Down
Loading