Skip to content

Commit ac85e45

Browse files
authored
Merge pull request #409 from xylar/fix_string_length_for_moc_regions
Make make sure all strings in MOC files have 64 char
2 parents 25756f2 + a677dd2 commit ac85e45

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = (0, 5, 0)
1+
__version_info__ = (0, 5, 1)
22
__version__ = '.'.join(str(vi) for vi in __version_info__)

conda_package/mpas_tools/ocean/moc.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,13 @@ def _add_transects_to_moc(mesh, mocMask, southernBoundaryEdges,
290290
mocMask['transectVertexGlobalIDs'] = \
291291
(('nTransects', 'maxVerticesInTransect'), transectVertexGlobalIDs)
292292

293-
mocMask['transectNames'] = mocMask.regionNames.rename(
294-
{'nRegions': 'nTransects'})
295-
296293
if 'nRegionsInGroup' not in mocMask:
297294
nRegions = mocMask.sizes['nRegions']
298295
nRegionGroups = 2
299296
nRegionsInGroup = nRegions*numpy.ones(nRegionGroups, dtype=int)
300297
regionsInGroup = numpy.zeros((nRegionGroups, nRegions), dtype=int)
301298
regionGroupNames = ['MOCBasinRegionsGroup', 'all']
299+
regionNames = mocMask.regionNames.values
302300
nChar = 64
303301
for index in range(nRegionGroups):
304302
regionsInGroup[index, :] = numpy.arange(1, nRegions+1)
@@ -315,6 +313,17 @@ def _add_transects_to_moc(mesh, mocMask, southernBoundaryEdges,
315313
for index in range(nRegionGroups):
316314
mocMask['regionGroupNames'][index] = regionGroupNames[index]
317315

316+
# we need to make sure the region names use the same string length
317+
mocMask['regionNames'] = \
318+
(('nRegions',), numpy.zeros((nRegions,),
319+
dtype='|S{}'.format(nChar)))
320+
321+
for index in range(nRegions):
322+
mocMask['regionNames'][index] = regionNames[index]
323+
324+
mocMask['transectNames'] = mocMask.regionNames.rename(
325+
{'nRegions': 'nTransects'})
326+
318327
mocMask['nTransectsInGroup'] = mocMask.nRegionsInGroup.rename(
319328
{'nRegionGroups': 'nTransectGroups'})
320329

conda_package/recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set name = "mpas_tools" %}
2-
{% set version = "0.5.0" %}
2+
{% set version = "0.5.1" %}
33

44
package:
55
name: {{ name|lower }}

0 commit comments

Comments
 (0)