Skip to content

Instantly share code, notes, and snippets.

@pshriwise
Created March 25, 2024 06:45
Show Gist options
  • Save pshriwise/9e643b9d2e6a985c8c7e599fdf41afb6 to your computer and use it in GitHub Desktop.
Save pshriwise/9e643b9d2e6a985c8c7e599fdf41afb6 to your computer and use it in GitHub Desktop.
Convert old DAGMC group names that appear from MCNP imports to the current DAGMC naming format
#!python
for (group_name, group_id) in cubit.group_names_ids():
# ignore group "picked". It is always present by default and isn't
# relevant for DAGMC metadata
if group_name == 'picked':
continue
tokens = group_name.split('_')
properties = [f'{p}:{v}' for p, v in zip(tokens[::2], tokens[1::2])]
new_name = '/'.join(properties)
print(f'Renaming group {group_id} to {new_name}')
cubit.set_entity_name("Group", group_id, new_name)
cubit.silent_cmd(f'group {group_id} rename "{new_name}"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment