diff --git a/.mailmap b/.mailmap index 4a4ca333f4..ca636e36af 100644 --- a/.mailmap +++ b/.mailmap @@ -29,6 +29,7 @@ Meabh NicGuidhir <43375279+neilCrosswaite@users.noreply.github.com> Paul Abernethy Peter Jordan <52462411+mo-peterjordan@users.noreply.github.com> +Phoebe Lambert Sam Griffiths <122271903+SamGriffithsMO@users.noreply.github.com> Shafiat Dewan <87321907+ShafiatDewan@users.noreply.github.com> <87321907+ShafiatDewan@users.noreply.github.com> Shubhendra Singh Chauhan diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8dd2566698..9e8f748d1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,6 +59,7 @@ below: - Caroline Jones (Met Office, UK) - Peter Jordan (Met Office, UK) - Bruno P. Kinoshita (NIWA, NZ) + - Phoebe Lambert (Met Office, UK) - Lucy Liu (Bureau of Meteorology, Australia) - Daniel Mentiplay (Bureau of Meteorology, Australia) - Stephen Moseley (Met Office, UK) diff --git a/improver/standardise.py b/improver/standardise.py index d1a655a964..4937fea071 100644 --- a/improver/standardise.py +++ b/improver/standardise.py @@ -236,6 +236,15 @@ def _discard_redundant_cell_methods(cube: Cube) -> None: cube.cell_methods = updated_cms + @staticmethod + def _remove_long_name_if_standard_name(cube: Cube) -> None: + """ + Remove the long_name attribute from cubes if the cube also has a standard_name defined + """ + + if cube.standard_name and cube.long_name: + cube.long_name = None + def process(self, cube: Cube) -> Cube: """ Perform compulsory and user-configurable metadata adjustments. The @@ -269,6 +278,7 @@ def process(self, cube: Cube) -> Cube: if self._attributes_dict: amend_attributes(cube, self._attributes_dict) self._discard_redundant_cell_methods(cube) + self._remove_long_name_if_standard_name(cube) # this must be done after unit conversion as if the input is an integer # field, unit conversion outputs the new data as float64 diff --git a/improver_tests/standardise/test_StandardiseMetadata.py b/improver_tests/standardise/test_StandardiseMetadata.py index a54f45113b..971b1f33b3 100644 --- a/improver_tests/standardise/test_StandardiseMetadata.py +++ b/improver_tests/standardise/test_StandardiseMetadata.py @@ -292,6 +292,14 @@ def test_air_temperature_status_flag_coord_without_realization(self): self.assertArrayEqual(result.data, target.data) self.assertEqual(result.coords(), target.coords()) + def test_long_name_removed(self): + cube = self.cube.copy() + cube.long_name = "kittens" + result = StandardiseMetadata().process(cube) + assert ( + result.long_name is None + ), "long_name removal expected, but long_name is not None" + if __name__ == "__main__": unittest.main()