Group list in FISH and Python

I’m trying to get the full list of groups that exist in the model, both in Fish and in Python, so I can check how many zones there are in it and delete empty groups. What is the recommended way of doing this? Thank you in advance,

You can export a list of the group for each zone in the model using the file.all command as described in forum post here. e.g.

[file.all("test.txt","text") =]

However, you might also need to consider the slots of your groups, and therefore might want an output file with more structure, which you can then manipulate? If so, something like the following might get you started in python:

import itasca as it
import json
it.command("python-reset-state false")
model restore "test"

output_dict = {}

for z in
        slot_def    =
        slot_example_1  ="Example 1")
        slot_example_2  ="Example 2")
        output_dict[] = {
            "slot = default" : slot_def,
            "slot = 1" : slot_example_1,
            "slot = 2" : slot_example_2
output_file = "test.json"
with open(output_file, 'w') as fout:
    json.dump(output_dict, fout)

There is a hidden command in the code - GROUP LIST -COUNT
This lists of summary of (for examples) the total number of zones, the number of zones with a group in a given slot, and the number of zones using a given group/slot combination.
This could be logged to a file and then imported back for processing either in FISH or Python.

I’m a bit confused about the idea deleting groups however. Groups cannot be deleted, but empty groups cause no overhead so there is no real reason to.

1 Like