Skip to content

Commit 046183b

Browse files
committed
Remove iris width control (not in this layer).
1 parent 4b17638 commit 046183b

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

lib/iris/fileformats/netcdf/_bytecoding_datasets.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,20 @@ def _get_byte_width(self) -> int | None:
241241
def _get_string_width(self):
242242
"""Return the string-length defined for this variable."""
243243
if not hasattr(self, "_strlen"):
244-
if hasattr(self, "iris_string_width"):
245-
strlen = self.get_ncattr("iris_string_width")
246-
else:
247-
# Work out the actual byte width from the parent dataset dimensions.
248-
strlen = self._get_byte_width()
249-
# Convert the string dimension length (i.e. bytes) to a sufficiently-long
250-
# string width, depending on the encoding used.
251-
encoding = self._get_encoding() or DEFAULT_READ_ENCODING
252-
# regularise the name for comparison with recognised ones
253-
encoding = codecs.lookup(encoding).name
254-
if "utf-16" in encoding:
255-
# Each char needs at least 2 bytes -- including a terminator char
256-
strlen = (strlen // 2) - 1
257-
elif "utf-32" in encoding:
258-
# Each char needs exactly 4 bytes -- including a terminator char
259-
strlen = (strlen // 4) - 1
260-
# "ELSE": assume there can be (at most) as many chars as bytes
244+
# Work out the actual byte width from the parent dataset dimensions.
245+
strlen = self._get_byte_width()
246+
# Convert the string dimension length (i.e. bytes) to a sufficiently-long
247+
# string width, depending on the encoding used.
248+
encoding = self._get_encoding() or DEFAULT_READ_ENCODING
249+
# regularise the name for comparison with recognised ones
250+
encoding = codecs.lookup(encoding).name
251+
if "utf-16" in encoding:
252+
# Each char needs at least 2 bytes -- including a terminator char
253+
strlen = (strlen // 2) - 1
254+
elif "utf-32" in encoding:
255+
# Each char needs exactly 4 bytes -- including a terminator char
256+
strlen = (strlen // 4) - 1
257+
# "ELSE": assume there can be (at most) as many chars as bytes
261258

262259
# Cache this length control on the variable -- but not as a netcdf attribute
263260
self.__dict__["_strlen"] = strlen

0 commit comments

Comments
 (0)