tilupy.models.shaltop.initsimus

Attributes

README_PARAM_MATCH

Dictionary of correspondence between parameters in read_me file and param file.

SHALTOP_LAW_ID

Dictionary of correspondence between the name of rheological laws and the corresponding ID in SHALTOP.

Functions

raster_to_shaltop_txtfile(→ dict)

Convert a raster file to a Shaltop ASCII text format.

write_params_file(→ None)

Write a dictionary of parameters to a text file.

write_simu(→ None)

Prepares the input files required for a SHALTOP simulation and saves them in a dedicated folder.

write_job_files(→ None)

Write job/conf files for slurm jobs. The conf contains all the commands

make_simus(→ None)

Write shaltop initial file for simple slope test case

Module Contents

Attributes

tilupy.models.shaltop.initsimus.README_PARAM_MATCH

Dictionary of correspondence between parameters in read_me file and param file.

tilupy.models.shaltop.initsimus.SHALTOP_LAW_ID

Dictionary of correspondence between the name of rheological laws and the corresponding ID in SHALTOP.

Correspondence :

  • No_Friction = 1

  • Coulomb = 1

  • Coulomb_muI = 7

  • Voellmy = 8

  • Bingham = 6

  • Herschel_Bulkley = 61

Functions

tilupy.models.shaltop.initsimus.raster_to_shaltop_txtfile(file_in: str, file_out: str, folder_out: str = None) dict

Convert a raster file to a Shaltop ASCII text format.

Reads a raster (formats readable by tilupy.raster.read_raster()) and saves it as a ASCII text file with values flattened column-wise and rows flipped vertically.

Parameters:
  • file_in (str) – Path to the input raster file.

  • file_out (str) – Name of the output ASCII text file.

  • folder_out (str, optional) – Directory where the output file will be saved. If None, file_out is used as-is, by default None.

Returns:

Dictionary containing grid metadata:

  • ’x0’: X coordinate of the first column.

  • ’y0’: Y coordinate of the first row.

  • ’dx’: Grid spacing along X.

  • ’dy’: Grid spacing along Y.

  • ’nx’: Number of columns.

  • ’ny’: Number of rows.

Return type:

dict

tilupy.models.shaltop.initsimus.write_params_file(params: dict, directory: str = None, file_name: str = 'params.txt') None

Write a dictionary of parameters to a text file.

Each key-value pair in the dictionary is written on a separate line.

Parameters:
  • params (dict) – Dictionary of parameter names and values. Values can be int, float, or str.

  • directory (str, optional) – Directory where the parameter file will be written. Default is the current working directory.

  • file_name (str, optional) – Name of the parameter file. Default is “params.txt”.

tilupy.models.shaltop.initsimus.write_simu(raster_topo: str, raster_mass: str, tmax: float, dt_im: float, rheology_type: str, rheology_params: dict, folder_out: str = None) None

Prepares the input files required for a SHALTOP simulation and saves them in a dedicated folder.

Parameters:
  • raster_topo (str) – Name of the ASCII topography file.

  • raster_mass (str) – Name of the ASCII initial mass file.

  • tmax (float) – Maximum simulation time.

  • dt_im (float) – Output image interval (in time steps).

  • rheology_type (str) – Rheology to use for the simulation.

  • rheology_params (dict) –

    Necessary parameters for the rheology. For instance:

    • delta1

    • ksi

    • tau_density

    etc.

  • folder_out (str, optional) – Output folder where simulation inputs will be saved.

Raises:

ValueError – If the rheology is wrong.

tilupy.models.shaltop.initsimus.write_job_files(dirs: list[str], param_files: list[str], file_job: str, job_name: str, max_time_hours: int = 24, ncores_per_node: int = 6, partitions: str = 'cpuall,data,datanew', shaltop_file: str = 'shaltop', folder_conf_in_job: str = None, replace_path: list = None, number_conf_file: bool = True) None

Write job/conf files for slurm jobs. The conf contains all the commands needed to run each simulation (one command per simulation).

Parameters:
  • dirs (list[str]) – list of paths where simus will be run.

  • param_files (list[str]) – list of shaltop parameter files.

  • file_job (str) – name of job file called by sbatch.

  • job_name (str) – name of conf file used by file_job.

  • max_time_hours (int, optional) – Maximum job duration in hours before stop. The default is 24.

  • ncores_per_node (int, optional) – Number of cores per nodes. Used to know the number of nodes required for the job. The default is 6.

  • partitions (str, optional) – Names of partitions on which jobs can be launched. The default is “cpuall,data,datanew”.

  • shaltop_file (str, optional) – Bash command used to call shaltop. Can be a path. The default is “shaltop”.

  • folder_conf_in_job (str, optional) – Folder where the conf file is located. The default is the folder path of file_job.

  • replace_path (list, optional) – replace replace_path[0] by replace_path[1] for every path in dir. This is used if simulations are prepared and run on two different machines (e.g. laptop and cluster). The default is None.

  • number_conf_file (bool, optional) – If True, add a number in front of each line of the conf file. Required to identify slurm jobs. The default is True.

tilupy.models.shaltop.initsimus.make_simus(law: str, rheol_params: dict, folder_data: str, folder_out: str, readme_file: str) None

Write shaltop initial file for simple slope test case

Reads topography and initial mass files in ASCII format, writes them in Shaltop-compatible format, prepares simulation parameters based on a README file and user-provided values, and generates a shell script to run the simulations.

Parameters:
  • law (str) – Name of the rheological law to use (must match a key in SHALTOP_LAW_ID).

  • rheol_params (dict of list) – Dictionary of rheology parameters. Each key corresponds to a parameter name and its value is a list of parameter values to simulate.

  • folder_data (str) – Path to the folder containing input data files “topo.asc” and “mass.asc”.

  • folder_out (str) – Path to the folder where output simulation folders and Shaltop files will be created.

  • readme_file (str) – Path to the README file containing simulation parameters and metadata.