tilupy.models.shaltop.initsimus =============================== .. py:module:: tilupy.models.shaltop.initsimus Attributes ---------- .. autoapisummary:: tilupy.models.shaltop.initsimus.README_PARAM_MATCH tilupy.models.shaltop.initsimus.SHALTOP_LAW_ID Functions --------- .. autoapisummary:: tilupy.models.shaltop.initsimus.raster_to_shaltop_txtfile tilupy.models.shaltop.initsimus.write_params_file tilupy.models.shaltop.initsimus.write_simu tilupy.models.shaltop.initsimus.write_job_files tilupy.models.shaltop.initsimus.make_simus Module Contents --------------- Attributes ^^^^^^^^^^ .. py:data:: README_PARAM_MATCH Dictionary of correspondence between parameters in read_me file and param file. .. py:data:: 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 ^^^^^^^^^ .. py:function:: 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 :func:`tilupy.raster.read_raster`) and saves it as a ASCII text file with values flattened column-wise and rows flipped vertically. :param file_in: Path to the input raster file. :type file_in: str :param file_out: Name of the output ASCII text file. :type file_out: str :param folder_out: Directory where the output file will be saved. If None, `file_out` is used as-is, by default None. :type folder_out: str, optional :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. :rtype: dict .. py:function:: 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. :param params: Dictionary of parameter names and values. Values can be int, float, or str. :type params: dict :param directory: Directory where the parameter file will be written. Default is the current working directory. :type directory: str, optional :param file_name: Name of the parameter file. Default is "params.txt". :type file_name: str, optional .. py:function:: 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. :param raster_topo: Name of the ASCII topography file. :type raster_topo: str :param raster_mass: Name of the ASCII initial mass file. :type raster_mass: str :param tmax: Maximum simulation time. :type tmax: float :param dt_im: Output image interval (in time steps). :type dt_im: float :param rheology_type: Rheology to use for the simulation. :type rheology_type: str :param rheology_params: Necessary parameters for the rheology. For instance: - delta1 - ksi - tau_density etc. :type rheology_params: dict :param folder_out: Output folder where simulation inputs will be saved. :type folder_out: str, optional :raises ValueError: If the rheology is wrong. .. py:function:: 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). :param dirs: list of paths where simus will be run. :type dirs: list[str] :param param_files: list of shaltop parameter files. :type param_files: list[str] :param file_job: name of job file called by sbatch. :type file_job: str :param job_name: name of conf file used by file_job. :type job_name: str :param max_time_hours: Maximum job duration in hours before stop. The default is 24. :type max_time_hours: int, optional :param ncores_per_node: Number of cores per nodes. Used to know the number of nodes required for the job. The default is 6. :type ncores_per_node: int, optional :param partitions: Names of partitions on which jobs can be launched. The default is "cpuall,data,datanew". :type partitions: str, optional :param shaltop_file: Bash command used to call shaltop. Can be a path. The default is "shaltop". :type shaltop_file: str, optional :param folder_conf_in_job: Folder where the conf file is located. The default is the folder path of file_job. :type folder_conf_in_job: str, optional :param replace_path: 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. :type replace_path: list, optional :param number_conf_file: If True, add a number in front of each line of the conf file. Required to identify slurm jobs. The default is True. :type number_conf_file: bool, optional .. py:function:: 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. :param law: Name of the rheological law to use (must match a key in :data:`SHALTOP_LAW_ID`). :type law: str :param rheol_params: Dictionary of rheology parameters. Each key corresponds to a parameter name and its value is a list of parameter values to simulate. :type rheol_params: dict of list :param folder_data: Path to the folder containing input data files "topo.asc" and "mass.asc". :type folder_data: str :param folder_out: Path to the folder where output simulation folders and Shaltop files will be created. :type folder_out: str :param readme_file: Path to the README file containing simulation parameters and metadata. :type readme_file: str