Skip to content

emod_file

ClimateFiles

Bases: InputFilesList

Source code in emodpy/emod_file.py
class ClimateFiles(InputFilesList):

    def __init__(self):
        super().__init__("climate")
        self.files_by_type = {}
        self.Climate_Model = ClimateModel.CLIMATE_OFF
        self.Climate_Update_Resolution = None
        self.climate_params = {}
        self.Enable_Climate_Stochasticity = False

    def set_task_config(self, task: 'EMODTask'):
        """
        Set the task Config. Set all the correct files for the climate.

        Args:
            task (EMODTask): Task to config.
        """
        # Set the files
        for climate_type, asset in self.files_by_type.items():
            task.set_parameter(f"{climate_type.value}_Filename", f"{self.relative_path}\\{asset.filename}")

        # Set other parameters
        task.set_parameter("Climate_Model", self.Climate_Model.value)
        task.set_parameter("Enable_Climate_Stochasticity", 1 if self.Enable_Climate_Stochasticity else 0)
        if self.Climate_Update_Resolution:
            task.set_parameter("Climate_Update_Resolution", self.Climate_Update_Resolution)

        for p, v in self.climate_params.items():
            task.set_parameter(p, v)

    def add_climate_files(self, file_type, file_path):
        # Create an asset for the given file
        asset = Asset(absolute_path=file_path, relative_path=self.relative_path)

        # Make sure we get a .bin file
        if asset.extension != "bin":
            raise Exception("Please add the binary (.bin) path for the `add_climate_files` function!")

        # Add the asset to our dictionary for the given type
        self.files_by_type[file_type] = asset

        # Automatically switch the climate model
        self.Climate_Model = ClimateModel.CLIMATE_BY_DATA

    def gather_assets(self):
        """
        Gather assets for Climate files. Called by EMODTask.
        """
        # Skip if the climate model is not by data
        if self.Climate_Model != ClimateModel.CLIMATE_BY_DATA:
            return super().gather_assets()

        # Go through all the assets.
        # If the asset is already persisted -> skip
        # If not persist the bin and add the bin.json file too
        for asset in self.files_by_type.values():
            if asset.persisted:
                continue
            self.add_asset(asset, fail_on_duplicate=False)
            self.add_asset(Asset(absolute_path=asset.absolute_path + ".json", relative_path=self.relative_path),
                           fail_on_duplicate=False)

        return super().gather_assets()

    def set_climate_constant(self, Base_Air_Temperature, Base_Rainfall, Base_Land_Temperature=None,
                             Base_Relative_Humidity=None):
        self.Climate_Model = ClimateModel.CLIMATE_CONSTANT
        self.Climate_Update_Resolution = "CLIMATE_UPDATE_YEAR"
        self.climate_params["Base_Air_Temperature"] = Base_Air_Temperature
        self.climate_params["Base_Rainfall"] = Base_Rainfall
        self.climate_params[
            "Base_Land_Temperature"] = Base_Land_Temperature if Base_Land_Temperature is not None else Base_Air_Temperature
        self.climate_params[
            "Base_Relative_Humidity"] = Base_Relative_Humidity if Base_Relative_Humidity is not None else .1

    def read_config_file(self, config_path: str, asset_path: str):
        """
        Try to recreate the climate based on a given config file and an asset path.

        Args:
            config_path (str): path to the config
            asset_path (str): path containing the assets
        """
        config = json.load(open(config_path))
        params = config["parameters"]

        # Look for files
        for climate_type in ClimateFileType:
            file_path = params.get(f"{climate_type.value}_Filename", None)
            if file_path:
                self.add_climate_files(climate_type, os.path.join(asset_path, file_path))

        # Look for parameters
        self.Climate_Model = ClimateModel[params.get("Climate_Model", ClimateModel.CLIMATE_OFF.value)]
        self.Climate_Update_Resolution = params.get("Climate_Update_Resolution", "CLIMATE_UPDATE_DAY")
        self.climate_params["Base_Rainfall"] = params.get("Base_Rainfall", 0)
        self.climate_params["Base_Air_Temperature"] = params.get("Base_Air_Temperature", 0)
        self.Enable_Climate_Stochasticity = params.get("Enable_Climate_Stochasticity", 0)

gather_assets()

Gather assets for Climate files. Called by EMODTask.

Source code in emodpy/emod_file.py
def gather_assets(self):
    """
    Gather assets for Climate files. Called by EMODTask.
    """
    # Skip if the climate model is not by data
    if self.Climate_Model != ClimateModel.CLIMATE_BY_DATA:
        return super().gather_assets()

    # Go through all the assets.
    # If the asset is already persisted -> skip
    # If not persist the bin and add the bin.json file too
    for asset in self.files_by_type.values():
        if asset.persisted:
            continue
        self.add_asset(asset, fail_on_duplicate=False)
        self.add_asset(Asset(absolute_path=asset.absolute_path + ".json", relative_path=self.relative_path),
                       fail_on_duplicate=False)

    return super().gather_assets()

read_config_file(config_path, asset_path)

Try to recreate the climate based on a given config file and an asset path.

Parameters:

Name Type Description Default
config_path str

path to the config

required
asset_path str

path containing the assets

required
Source code in emodpy/emod_file.py
def read_config_file(self, config_path: str, asset_path: str):
    """
    Try to recreate the climate based on a given config file and an asset path.

    Args:
        config_path (str): path to the config
        asset_path (str): path containing the assets
    """
    config = json.load(open(config_path))
    params = config["parameters"]

    # Look for files
    for climate_type in ClimateFileType:
        file_path = params.get(f"{climate_type.value}_Filename", None)
        if file_path:
            self.add_climate_files(climate_type, os.path.join(asset_path, file_path))

    # Look for parameters
    self.Climate_Model = ClimateModel[params.get("Climate_Model", ClimateModel.CLIMATE_OFF.value)]
    self.Climate_Update_Resolution = params.get("Climate_Update_Resolution", "CLIMATE_UPDATE_DAY")
    self.climate_params["Base_Rainfall"] = params.get("Base_Rainfall", 0)
    self.climate_params["Base_Air_Temperature"] = params.get("Base_Air_Temperature", 0)
    self.Enable_Climate_Stochasticity = params.get("Enable_Climate_Stochasticity", 0)

set_task_config(task)

Set the task Config. Set all the correct files for the climate.

Parameters:

Name Type Description Default
task EMODTask

Task to config.

required
Source code in emodpy/emod_file.py
def set_task_config(self, task: 'EMODTask'):
    """
    Set the task Config. Set all the correct files for the climate.

    Args:
        task (EMODTask): Task to config.
    """
    # Set the files
    for climate_type, asset in self.files_by_type.items():
        task.set_parameter(f"{climate_type.value}_Filename", f"{self.relative_path}\\{asset.filename}")

    # Set other parameters
    task.set_parameter("Climate_Model", self.Climate_Model.value)
    task.set_parameter("Enable_Climate_Stochasticity", 1 if self.Enable_Climate_Stochasticity else 0)
    if self.Climate_Update_Resolution:
        task.set_parameter("Climate_Update_Resolution", self.Climate_Update_Resolution)

    for p, v in self.climate_params.items():
        task.set_parameter(p, v)

DemographicsFiles

Bases: InputFilesList

Source code in emodpy/emod_file.py
class DemographicsFiles(InputFilesList):
    def set_task_config(self, task: 'EMODTask', extend: bool = False):
        """
        Set the simulation level config. If `extend` is true, the demographics files are appended to the list.

        Args:
            task (EMODTask): The task to update.
            extend (bool): If true, the demographics files are appended to the list.
        """
        dfiles = [os.path.join(df.relative_path, df.filename) for df in self.assets]
        if dfiles:
            if extend:
                demo_list = task.config["Demographics_Filenames"]
                for file in dfiles:
                    if file not in demo_list:
                        demo_list.append(file)
                task.config["Demographics_Filenames"] = demo_list
            else:
                task.config["Demographics_Filenames"] = dfiles
            task.config["Enable_Demographics_Builtin"] = 0

    def add_demographics_from_files(self, absolute_path: str, filename: Optional[str] = None):
        """
        Add demographics files into the demographics.assets from a file or from a directory.

        Args:
            absolute_path (str): Path to file, including the filename or folder. All .json files in the folder
                will be added as demographics files and used in the experiment.
            filename (str): Optional filename. If not provided, the file name of source file will be used.
        """
        filename = filename or os.path.basename(absolute_path)

        def add_asset(file_name, abs_path):
            asset = Asset(filename=file_name, relative_path=self.relative_path, absolute_path=abs_path)
            if asset in self.assets:
                raise Exception("Duplicated demographics file")
            self.assets.append(asset)

        if os.path.isfile(absolute_path):
            if absolute_path.endswith(".json"):
                add_asset(file_name=filename, abs_path=absolute_path)
            else:
                raise ValueError(f" {absolute_path} is not a *.json file")
        elif os.listdir(absolute_path):  # it's a directory
            files_added = 0
            for entry_name in os.listdir(absolute_path):
                full_path = os.path.join(absolute_path, entry_name)
                if full_path.endswith(".json"):
                    add_asset(file_name=filename, abs_path=absolute_path)
                    files_added += 1
            if not files_added:
                raise ValueError(f"No *.json demographics files found in {absolute_path}")
        else:
            raise ValueError(f"{absolute_path} is not a file or a directory")

    def add_demographics_from_dict(self, content: Dict, filename: str):
        """
        Add demographics from a dictionary object.

        Args:
            content (Dict): Dictionary Content.
            filename (str): Filename to call demographics file.
        """
        asset = Asset(filename=filename, content=content, relative_path=self.relative_path, handler=json_handler)
        if asset in self.assets:
            raise Exception("Duplicated demographics file")

        self.assets.append(asset)

add_demographics_from_dict(content, filename)

Add demographics from a dictionary object.

Parameters:

Name Type Description Default
content Dict

Dictionary Content.

required
filename str

Filename to call demographics file.

required
Source code in emodpy/emod_file.py
def add_demographics_from_dict(self, content: Dict, filename: str):
    """
    Add demographics from a dictionary object.

    Args:
        content (Dict): Dictionary Content.
        filename (str): Filename to call demographics file.
    """
    asset = Asset(filename=filename, content=content, relative_path=self.relative_path, handler=json_handler)
    if asset in self.assets:
        raise Exception("Duplicated demographics file")

    self.assets.append(asset)

add_demographics_from_files(absolute_path, filename=None)

Add demographics files into the demographics.assets from a file or from a directory.

Parameters:

Name Type Description Default
absolute_path str

Path to file, including the filename or folder. All .json files in the folder will be added as demographics files and used in the experiment.

required
filename str

Optional filename. If not provided, the file name of source file will be used.

None
Source code in emodpy/emod_file.py
def add_demographics_from_files(self, absolute_path: str, filename: Optional[str] = None):
    """
    Add demographics files into the demographics.assets from a file or from a directory.

    Args:
        absolute_path (str): Path to file, including the filename or folder. All .json files in the folder
            will be added as demographics files and used in the experiment.
        filename (str): Optional filename. If not provided, the file name of source file will be used.
    """
    filename = filename or os.path.basename(absolute_path)

    def add_asset(file_name, abs_path):
        asset = Asset(filename=file_name, relative_path=self.relative_path, absolute_path=abs_path)
        if asset in self.assets:
            raise Exception("Duplicated demographics file")
        self.assets.append(asset)

    if os.path.isfile(absolute_path):
        if absolute_path.endswith(".json"):
            add_asset(file_name=filename, abs_path=absolute_path)
        else:
            raise ValueError(f" {absolute_path} is not a *.json file")
    elif os.listdir(absolute_path):  # it's a directory
        files_added = 0
        for entry_name in os.listdir(absolute_path):
            full_path = os.path.join(absolute_path, entry_name)
            if full_path.endswith(".json"):
                add_asset(file_name=filename, abs_path=absolute_path)
                files_added += 1
        if not files_added:
            raise ValueError(f"No *.json demographics files found in {absolute_path}")
    else:
        raise ValueError(f"{absolute_path} is not a file or a directory")

set_task_config(task, extend=False)

Set the simulation level config. If extend is true, the demographics files are appended to the list.

Parameters:

Name Type Description Default
task EMODTask

The task to update.

required
extend bool

If true, the demographics files are appended to the list.

False
Source code in emodpy/emod_file.py
def set_task_config(self, task: 'EMODTask', extend: bool = False):
    """
    Set the simulation level config. If `extend` is true, the demographics files are appended to the list.

    Args:
        task (EMODTask): The task to update.
        extend (bool): If true, the demographics files are appended to the list.
    """
    dfiles = [os.path.join(df.relative_path, df.filename) for df in self.assets]
    if dfiles:
        if extend:
            demo_list = task.config["Demographics_Filenames"]
            for file in dfiles:
                if file not in demo_list:
                    demo_list.append(file)
            task.config["Demographics_Filenames"] = demo_list
        else:
            task.config["Demographics_Filenames"] = dfiles
        task.config["Enable_Demographics_Builtin"] = 0

InputFilesList

Bases: AssetCollection

Source code in emodpy/emod_file.py
class InputFilesList(AssetCollection, metaclass=ABCMeta):
    def __init__(self, relative_path=None):
        super().__init__()
        self.relative_path = relative_path

    @abstractmethod
    def set_task_config(self, simulation):
        pass

    def gather_assets(self) -> List[Asset]:
        """
        Gather input files for Input File List.
        """
        assets = [a for a in self.assets if not a.persisted]
        for a in assets:
            a.persisted = True
        return assets

gather_assets()

Gather input files for Input File List.

Source code in emodpy/emod_file.py
def gather_assets(self) -> List[Asset]:
    """
    Gather input files for Input File List.
    """
    assets = [a for a in self.assets if not a.persisted]
    for a in assets:
        a.persisted = True
    return assets

MigrationFiles

Bases: InputFilesList

Source code in emodpy/emod_file.py
class MigrationFiles(InputFilesList):
    def __init__(self, relative_path=None):
        super().__init__(relative_path)
        self.migration_files = {}
        self.migration_multipliers = {}
        self.migration_model = None
        self.migration_pattern = None
        self.migration_other_params = {}

    def enable_migration(self):
        """
        Enables migration and sets the pattern if defined. If there are no other parameters, it also sets
        *Enable_Migration_Heterogeneity* to 0.
        """
        self.migration_model = MigrationModel.FIXED_RATE_MIGRATION
        if not self.migration_pattern:
            self.migration_pattern = MigrationPattern.RANDOM_WALK_DIFFUSION
        if not self.migration_other_params:
            self.migration_other_params["Enable_Migration_Heterogeneity"] = 0

    def update_migration_pattern(self, migration_pattern: MigrationPattern, **kwargs: Any) -> None:
        """
        Update migration pattern.

        Args:
            migration_pattern (MigrationPattern): Migration Pattern to use
            **kwargs (Any): Additional migration parameters supplied as keyword
                arguments (for example `Enable_Migration_Heterogeneity=1`).
        """
        self.enable_migration()
        self.migration_pattern = migration_pattern
        for param, value in kwargs.items():
            self.migration_other_params[param] = value

    def add_migration_from_file(self, migration_type: MigrationType, file_path: str, multiplier: float = 1):
        """
        Add migration info from a file.

        Args:
            migration_type (MigrationTypes): Type of migration
            file_path (str): Path to file
            multiplier (float): Multiplier
        """
        self.enable_migration()
        asset = Asset(absolute_path=file_path, relative_path=self.relative_path)
        if asset.extension != "bin":
            raise Exception("Please add the binary (.bin) path for the `add_migration_from_file` function!")
        self.migration_files[migration_type] = asset
        self.migration_multipliers[migration_type] = multiplier

    def set_task_config(self, task: 'EMODTask'):
        """
        Update the task with the migration configuration.

        Args:
            task (EMODTask): Task to update
        """
        # Set the migration  model if present
        if self.migration_model:
            task.set_parameter("Migration_Model", self.migration_model.value)

        # Set the migration pattern if present
        if self.migration_pattern:
            task.set_parameter("Migration_Pattern", self.migration_pattern.value)

        # Set the extra parameters
        for parameter in self.migration_other_params:
            task.set_parameter(parameter, self.migration_other_params[parameter])

        # Enable or disable migrations depending on the available files
        for migration_type in MigrationType:
            prefix = migration_type.value.title()
            if migration_type in self.migration_files:
                task.set_parameter(f"Enable_{prefix}_Migration", 1)

                migration_file = self.migration_files[migration_type]
                task.set_parameter(f"{prefix}_Migration_Filename",
                                   os.path.join(migration_file.relative_path, migration_file.filename))

                migration_multiplier = self.migration_multipliers.get(migration_type, 1)
                task.set_parameter(f"x_{prefix}_Migration", migration_multiplier)

            else:
                task.set_parameter(f"Enable_{prefix}_Migration", 0)

    def gather_assets(self):
        """
        Gather assets for Migration files. Called by EMODTask.
        """
        for asset in self.migration_files.values():
            if asset.persisted:
                continue
            self.add_asset(asset, fail_on_duplicate=False)
            self.add_asset(Asset(absolute_path=asset.absolute_path + ".json", relative_path=self.relative_path),
                           fail_on_duplicate=False)

        return super().gather_assets()

    def set_all_persisted(self):
        """
        Set all migration assets as persisted.
        """
        for asset in self.migration_files.values():
            asset.persisted = True
        super().set_all_persisted()

    def merge_with(self, mf: 'MigrationFiles', left_precedence: bool = True) -> None:
        """
        Merge migration file with other Migration file.

        Args:
            mf (MigrationFiles): Other migration file to merge with.
            left_precedence (bool): Does the current object have precedence or the other object?
        """
        if not left_precedence:
            self.migration_files.update(mf.migration_files)
            self.migration_other_params.update(mf.migration_other_params)
            self.migration_multipliers.update(mf.migration_multipliers)

        else:
            for migration_type in set(mf.migration_files.keys()).difference(self.migration_files.keys()):
                self.migration_files[migration_type] = mf.migration_files[migration_type]

            for migration_param in set(mf.migration_other_params.keys()).difference(self.migration_other_params.keys()):
                self.migration_other_params[migration_param] = mf.migration_other_params[migration_param]

            for migration_multiplier in set(mf.migration_multipliers.keys()).difference(
                    self.migration_multipliers.keys()):
                self.migration_multipliers[migration_multiplier] = mf.migration_multipliers[migration_multiplier]

        self.migration_pattern = mf.migration_pattern
        self.migration_model = mf.migration_model

    def read_config_file(self, config_path, asset_path):
        """
        Try to recreate the migration based on a given config file and an asset path.
        Args:
            config_path: path to the config.
            asset_path: path containing the assets.
        """
        config = json.load(open(config_path))
        params = config["parameters"]

        # Look for files
        for migration_type in MigrationType:
            prefix = migration_type.value.title()
            file_path = params.get(f"{prefix}_Migration_Filename", None)
            if file_path:
                self.add_migration_from_file(migration_type, os.path.join(asset_path, file_path))

            # Take care of eventual multipliers
            self.migration_multipliers[migration_type] = params.get(f"x_{prefix}_Migration", 1)

        # Look for parameters
        self.migration_model = MigrationModel[params.get("Migration_Model", MigrationModel.NO_MIGRATION.value)]
        self.migration_pattern = MigrationPattern[
            params.get("Migration_Pattern")] if "Migration_Pattern" in params else None

add_migration_from_file(migration_type, file_path, multiplier=1)

Add migration info from a file.

Parameters:

Name Type Description Default
migration_type MigrationTypes

Type of migration

required
file_path str

Path to file

required
multiplier float

Multiplier

1
Source code in emodpy/emod_file.py
def add_migration_from_file(self, migration_type: MigrationType, file_path: str, multiplier: float = 1):
    """
    Add migration info from a file.

    Args:
        migration_type (MigrationTypes): Type of migration
        file_path (str): Path to file
        multiplier (float): Multiplier
    """
    self.enable_migration()
    asset = Asset(absolute_path=file_path, relative_path=self.relative_path)
    if asset.extension != "bin":
        raise Exception("Please add the binary (.bin) path for the `add_migration_from_file` function!")
    self.migration_files[migration_type] = asset
    self.migration_multipliers[migration_type] = multiplier

enable_migration()

Enables migration and sets the pattern if defined. If there are no other parameters, it also sets Enable_Migration_Heterogeneity to 0.

Source code in emodpy/emod_file.py
def enable_migration(self):
    """
    Enables migration and sets the pattern if defined. If there are no other parameters, it also sets
    *Enable_Migration_Heterogeneity* to 0.
    """
    self.migration_model = MigrationModel.FIXED_RATE_MIGRATION
    if not self.migration_pattern:
        self.migration_pattern = MigrationPattern.RANDOM_WALK_DIFFUSION
    if not self.migration_other_params:
        self.migration_other_params["Enable_Migration_Heterogeneity"] = 0

gather_assets()

Gather assets for Migration files. Called by EMODTask.

Source code in emodpy/emod_file.py
def gather_assets(self):
    """
    Gather assets for Migration files. Called by EMODTask.
    """
    for asset in self.migration_files.values():
        if asset.persisted:
            continue
        self.add_asset(asset, fail_on_duplicate=False)
        self.add_asset(Asset(absolute_path=asset.absolute_path + ".json", relative_path=self.relative_path),
                       fail_on_duplicate=False)

    return super().gather_assets()

merge_with(mf, left_precedence=True)

Merge migration file with other Migration file.

Parameters:

Name Type Description Default
mf MigrationFiles

Other migration file to merge with.

required
left_precedence bool

Does the current object have precedence or the other object?

True
Source code in emodpy/emod_file.py
def merge_with(self, mf: 'MigrationFiles', left_precedence: bool = True) -> None:
    """
    Merge migration file with other Migration file.

    Args:
        mf (MigrationFiles): Other migration file to merge with.
        left_precedence (bool): Does the current object have precedence or the other object?
    """
    if not left_precedence:
        self.migration_files.update(mf.migration_files)
        self.migration_other_params.update(mf.migration_other_params)
        self.migration_multipliers.update(mf.migration_multipliers)

    else:
        for migration_type in set(mf.migration_files.keys()).difference(self.migration_files.keys()):
            self.migration_files[migration_type] = mf.migration_files[migration_type]

        for migration_param in set(mf.migration_other_params.keys()).difference(self.migration_other_params.keys()):
            self.migration_other_params[migration_param] = mf.migration_other_params[migration_param]

        for migration_multiplier in set(mf.migration_multipliers.keys()).difference(
                self.migration_multipliers.keys()):
            self.migration_multipliers[migration_multiplier] = mf.migration_multipliers[migration_multiplier]

    self.migration_pattern = mf.migration_pattern
    self.migration_model = mf.migration_model

read_config_file(config_path, asset_path)

Try to recreate the migration based on a given config file and an asset path. Args: config_path: path to the config. asset_path: path containing the assets.

Source code in emodpy/emod_file.py
def read_config_file(self, config_path, asset_path):
    """
    Try to recreate the migration based on a given config file and an asset path.
    Args:
        config_path: path to the config.
        asset_path: path containing the assets.
    """
    config = json.load(open(config_path))
    params = config["parameters"]

    # Look for files
    for migration_type in MigrationType:
        prefix = migration_type.value.title()
        file_path = params.get(f"{prefix}_Migration_Filename", None)
        if file_path:
            self.add_migration_from_file(migration_type, os.path.join(asset_path, file_path))

        # Take care of eventual multipliers
        self.migration_multipliers[migration_type] = params.get(f"x_{prefix}_Migration", 1)

    # Look for parameters
    self.migration_model = MigrationModel[params.get("Migration_Model", MigrationModel.NO_MIGRATION.value)]
    self.migration_pattern = MigrationPattern[
        params.get("Migration_Pattern")] if "Migration_Pattern" in params else None

set_all_persisted()

Set all migration assets as persisted.

Source code in emodpy/emod_file.py
def set_all_persisted(self):
    """
    Set all migration assets as persisted.
    """
    for asset in self.migration_files.values():
        asset.persisted = True
    super().set_all_persisted()

set_task_config(task)

Update the task with the migration configuration.

Parameters:

Name Type Description Default
task EMODTask

Task to update

required
Source code in emodpy/emod_file.py
def set_task_config(self, task: 'EMODTask'):
    """
    Update the task with the migration configuration.

    Args:
        task (EMODTask): Task to update
    """
    # Set the migration  model if present
    if self.migration_model:
        task.set_parameter("Migration_Model", self.migration_model.value)

    # Set the migration pattern if present
    if self.migration_pattern:
        task.set_parameter("Migration_Pattern", self.migration_pattern.value)

    # Set the extra parameters
    for parameter in self.migration_other_params:
        task.set_parameter(parameter, self.migration_other_params[parameter])

    # Enable or disable migrations depending on the available files
    for migration_type in MigrationType:
        prefix = migration_type.value.title()
        if migration_type in self.migration_files:
            task.set_parameter(f"Enable_{prefix}_Migration", 1)

            migration_file = self.migration_files[migration_type]
            task.set_parameter(f"{prefix}_Migration_Filename",
                               os.path.join(migration_file.relative_path, migration_file.filename))

            migration_multiplier = self.migration_multipliers.get(migration_type, 1)
            task.set_parameter(f"x_{prefix}_Migration", migration_multiplier)

        else:
            task.set_parameter(f"Enable_{prefix}_Migration", 0)

update_migration_pattern(migration_pattern, **kwargs)

Update migration pattern.

Parameters:

Name Type Description Default
migration_pattern MigrationPattern

Migration Pattern to use

required
**kwargs Any

Additional migration parameters supplied as keyword arguments (for example Enable_Migration_Heterogeneity=1).

{}
Source code in emodpy/emod_file.py
def update_migration_pattern(self, migration_pattern: MigrationPattern, **kwargs: Any) -> None:
    """
    Update migration pattern.

    Args:
        migration_pattern (MigrationPattern): Migration Pattern to use
        **kwargs (Any): Additional migration parameters supplied as keyword
            arguments (for example `Enable_Migration_Heterogeneity=1`).
    """
    self.enable_migration()
    self.migration_pattern = migration_pattern
    for param, value in kwargs.items():
        self.migration_other_params[param] = value