Command Line Execution#

This section provides a step-by-step guide on how to run the SPyIce package using the command line interface. It covers the necessary commands and options to execute the main script and manage the simulation runs effectively.

Running SpyIce#

To run SpyIce from the command line:

Terminal command#
python main_config.py

You can use the --help flag to see available options and arguments:

Help command#
python main_config.py --help

Hydra Command-Line Overrides#

You can automate multiple runs with different configurations using Hydra’s command-line overrides for fast-run parameters.

Example: run the model with a specific time step and maximum iterations:

Terminal command with overrides#
python main_config.py iter_max=iter_max1500 dt=dt47 dz=dz0p1 S_IC=S34

Fast-run parameters include:

  • iter_max: Maximum number of iterations (e.g., iter_max1500)

  • dt: Time step size (e.g., dt47)

  • dz: Spatial step size (e.g., dz0p1)

  • constants: Debug mode or realistic mode (real)

Hydra Multirun#

You can run multiple jobs for all combinations of parameters using Hydra’s multirun feature (-m flag).

Example 1: Keep dt fixed at 47 s

Multirun example#
python main_config.py -m dt=dt47

Example 2: Keep iter_max fixed at 1500

Multirun example#
python main_config.py -m iter_max=iter_max1500

Example 3: Keep dt and S_IC fixed

Multirun example#
python main_config.py -m dt=dt47 S_IC=S34

Output Directory Structure#

The outputs for each run will be located in the outputs directory:

YOUR_ROOT
├── ...
├── docs
├── outputs
├── src/spyice
├── ...

Adding New Parameters for Automation#

  1. Create configuration files for the new parameter:

example/
└── conf/
    └── parameter/
        ├── param1.yaml
        └── param2.yaml
  1. Define values inside the YAML files.

Float example:

# param1.yaml
parameter: 1.0

String argument example:

# param2.yaml
parameter: "Argument"
  1. Modify config_sort.py

Add the new parameter inside the get_config_params() function (similar to get_ownconfig_params()):

def get_config_params():
    self.new_parameter = config.get(
        "parameter_directory", {}
    ).get("parameter_from_yaml", "default")
    return config_params
  1. Modify pre_process.py

Inside the PreprocessData class:

class PreprocessData:
    def __init__(self):
        ...

    if config_data.constants_type == "real":
        UserInput.__init__(
            self,
            new_parameter=config_data.new_parameter,
            ...
        )

Main Script Modifications#

To modify the main execution workflow, refer to the implementation inside main_config.py.

Note

Adding new parameters and modifying main_config.py is recommended only for developers.