diff --git a/scripts/archive_output.py b/scripts/archive_output.py index 5e9120a..bdc7f76 100644 --- a/scripts/archive_output.py +++ b/scripts/archive_output.py @@ -22,12 +22,12 @@ with open(args.hash_file, "r") as file: hash = file.read().strip() - outfile = config["basegrid"]["outfile"] + request_name = config["zonda"]["request_name"] hashed_destination_dir = os.path.join(args.destination, hash) os.makedirs(hashed_destination_dir, exist_ok=True) - zip_filepath = os.path.join(args.workspace, f"zonda_output_{outfile}.zip") + zip_filepath = os.path.join(args.workspace, f"zonda_output_{request_name}.zip") try: shutil.move(zip_filepath, hashed_destination_dir) except FileNotFoundError: diff --git a/scripts/report.py b/scripts/report.py index 4c6a2b7..d2c070d 100644 --- a/scripts/report.py +++ b/scripts/report.py @@ -93,13 +93,13 @@ def get_issue(self, issue_id): output_url = f"https://data.iac.ethz.ch/zonda/{hash}" if args.success: - outfile = config["basegrid"]["outfile"] + request_name = config["zonda"]["request_name"] comment = ( f"Your data is ready for up to 7 days under this [link]({output_url}).\n\n" f"You can also download it using the following commands:\n" f"```bash\n" - f"wget {output_url}/zonda_output_{outfile}.zip\n" - f"unzip zonda_output_{outfile}.zip -d zonda_output_{outfile}\n" + f"wget {output_url}/zonda_output_{request_name}.zip\n" + f"unzip zonda_output_{request_name}.zip -d zonda_output_{request_name}\n" f"```" f"{config_collapsible}" ) diff --git a/src/processing/grid_manager.py b/src/processing/grid_manager.py index 7246b49..bf5b5e6 100644 --- a/src/processing/grid_manager.py +++ b/src/processing/grid_manager.py @@ -20,10 +20,10 @@ def __init__( self, config, workspace_path, self.use_apptainer = use_apptainer self.zonda_config = self.config["zonda"] - self.basegrid_config = self.config["basegrid"] + self.globals_config = self.config["globals"] self.domains_config = self.config["domains"] - self.outfile = self.basegrid_config["outfile"] + self.request_name = self.zonda_config["request_name"] n_domains = len(self.domains_config) @@ -97,9 +97,6 @@ def write_icon_gridgen_namelist(self, nesting_group, input_grid_name=None, loggi maxit = 2000 beta_spring = 0.9 - # TODO v2.0: Move the Zonda parameters on the frontend to the top and add keep_basegrid_files and outfile there. - # Maybe rename outfile to request_name. - # Create the ICON gridgen namelist content namelist = [] @@ -113,29 +110,29 @@ def write_icon_gridgen_namelist(self, nesting_group, input_grid_name=None, loggi namelist.append(f" filename = \"/input_grid/{input_grid_name}\" ") else: # Base grid settings - namelist.append(f" basegrid%grid_root = {self.basegrid_config['grid_root']}") - namelist.append(f" basegrid%grid_level = {self.basegrid_config['grid_level']-1}") # Subtract 1 because initial_refinement is always on - namelist.append(f" basegrid%icopole_lon = {self.basegrid_config['icopole_lon']}") - namelist.append(f" basegrid%icopole_lat = {self.basegrid_config['icopole_lat']}") - namelist.append(f" basegrid%icorotation = {self.basegrid_config['icorotation']}") + namelist.append(f" basegrid%grid_root = {self.globals_config['grid_root']}") + namelist.append(f" basegrid%grid_level = {self.globals_config['grid_level']-1}") # Subtract 1 because initial_refinement is always on + namelist.append(f" basegrid%icopole_lon = {self.globals_config['icopole_lon']}") + namelist.append(f" basegrid%icopole_lat = {self.globals_config['icopole_lat']}") + namelist.append(f" basegrid%icorotation = {self.globals_config['icorotation']}") namelist.append("") # Tuning parameters namelist.append(f" lspring_dynamics = {convert_to_fortran_bool(lspring_dynamics)}") namelist.append(f" maxit = {maxit}") namelist.append(f" beta_spring = {beta_spring}") - namelist.append(f" bdy_indexing_depth = {self.basegrid_config.get('bdy_indexing_depth', 14)}") + namelist.append(f" bdy_indexing_depth = {self.globals_config.get('bdy_indexing_depth', 14)}") namelist.append("") # Set centre and subcentre - namelist.append(f" centre = {self.basegrid_config.get('centre', 78)}") - namelist.append(f" subcentre = {self.basegrid_config.get('subcentre', 255)}") + namelist.append(f" centre = {self.globals_config.get('centre', 78)}") + namelist.append(f" subcentre = {self.globals_config.get('subcentre', 255)}") namelist.append("") if start_from_input_grid: lwrite_parent = (primary_domain_id == 1) - namelist.append(f" dom(1)%outfile = \"{self.outfile}\" ") + namelist.append(f" dom(1)%outfile = \"{self.request_name}\" ") namelist.append(f" dom(1)%lwrite_parent = {convert_to_fortran_bool(lwrite_parent)}") namelist.append("") @@ -147,7 +144,7 @@ def write_icon_gridgen_namelist(self, nesting_group, input_grid_name=None, loggi local_domain_id = domain_id - primary_domain_id + 1 - namelist.append(f" dom({local_domain_id})%outfile = \"{self.outfile}\" ") + namelist.append(f" dom({local_domain_id})%outfile = \"{self.request_name}\" ") namelist.append(f" dom({local_domain_id})%lwrite_parent = {convert_to_fortran_bool(lwrite_parent)}") namelist.append(f" dom({local_domain_id})%region_type = {icontools_config['region_type']}") namelist.append(f" dom({local_domain_id})%number_of_grid_used = {icontools_config.get('number_of_grid_used', 0)}") @@ -272,7 +269,7 @@ def generate_icon_grids(self, nesting_group, logging_indentation_level=0): domain_idx = domain_id - 1 self.grid_dirs[domain_idx] = icontools_dir - self.grid_filenames[domain_idx] = f"{self.outfile}_{domain_label(domain_id)}.nc" + self.grid_filenames[domain_idx] = f"{self.request_name}_{domain_label(domain_id)}.nc" case "input_grid": input_grid_path = self.get_input_grid_path(primary_domain_id, logging_indentation_level=logging_indentation_level+1) @@ -291,7 +288,7 @@ def generate_icon_grids(self, nesting_group, logging_indentation_level=0): f"An input grid was provided for domain {primary_domain_id} at \"{input_grid_path}\" " f"and the generation of additional nests was not requested, thus the grid " f"generation step is skipped for domain {primary_domain_id}! " - f"For this reason the \"basegrid\" and \"icontools_tag\" entries in the JSON " + f"For this reason the \"globals\" and \"icontools_tag\" entries in the JSON " f"config are ignored." ) # Input grid plus generated nests @@ -312,9 +309,9 @@ def generate_icon_grids(self, nesting_group, logging_indentation_level=0): domain_idx = domain_id - 1 self.grid_dirs[domain_idx] = icontools_dir - self.grid_filenames[domain_idx] = f"{self.outfile}_{domain_label(domain_id)}.nc" + self.grid_filenames[domain_idx] = f"{self.request_name}_{domain_label(domain_id)}.nc" - current_local_grid_filestem = f"{self.outfile}_{domain_label(local_domain_id)}" + current_local_grid_filestem = f"{self.request_name}_{domain_label(local_domain_id)}" # Rename grid files output from ICON Tools, because the domain label refers to the local_domain_id os.rename( os.path.join(self.grid_dirs[domain_idx], current_local_grid_filestem + ".nc"), @@ -350,8 +347,8 @@ def generate_latlon_grids(self, nesting_group, output_data_dir, logging_indentat hwidth_lat = icontools_config["hwidth_lat"] hwidth_lon = icontools_config["hwidth_lon"] - n = self.basegrid_config["grid_root"] - k = self.basegrid_config["grid_level"] - 1 + domain_id # Subtract 1 from grid_level because initial_refinement is always on + n = self.globals_config["grid_root"] + k = self.globals_config["grid_level"] - 1 + domain_id # Subtract 1 from grid_level because initial_refinement is always on grid_spacing = compute_resolution_from_rnbk(n, k) output_data_domain_dir = os.path.join(output_data_dir, domain_label(domain_id)) diff --git a/src/processing/output_manager.py b/src/processing/output_manager.py index f45d00d..5d33377 100644 --- a/src/processing/output_manager.py +++ b/src/processing/output_manager.py @@ -21,7 +21,7 @@ def __init__( self, config, workspace_path, config_filename, zonda_log_filename, self.config_filename = config_filename self.zonda_log_filename = zonda_log_filename - self.outfile = self.config["basegrid"]["outfile"] + self.request_name = self.config["zonda"]["request_name"] self.domains_config = self.config["domains"] self.visualizations_dirname = visualizations_dirname @@ -31,7 +31,7 @@ def __init__( self, config, workspace_path, config_filename, zonda_log_filename, self.logs_dir = os.path.join(self.output_dir, logs_dirname) self.namelists_dir = os.path.join(self.output_dir, namelists_dirname) - self.zip_filepath = os.path.join(self.workspace_path, f"{zip_file_prefix}{self.outfile}.zip") + self.zip_filepath = os.path.join(self.workspace_path, f"{zip_file_prefix}{self.request_name}.zip") os.makedirs(self.output_dir, exist_ok=True) os.makedirs(self.data_dir, exist_ok=True) @@ -114,10 +114,10 @@ def move_extpar_output(self, extpar_manager, domain_ids, logging_indentation_lev extpar_dir = extpar_manager.extpar_dirs[domain_idx] data_domain_dir = os.path.join(self.data_dir, current_domain_label) - self.move_files(os.path.join(extpar_dir, "external_parameter.nc"), data_domain_dir, prefix=f"{self.outfile}_{current_domain_label}_", logging_indentation_level=logging_indentation_level+1) + self.move_files(os.path.join(extpar_dir, "external_parameter.nc"), data_domain_dir, prefix=f"{self.request_name}_{current_domain_label}_", logging_indentation_level=logging_indentation_level+1) visualizations_dir = os.path.join(data_domain_dir, self.visualizations_dirname) - self.move_files(os.path.join(extpar_dir, "*.png"), visualizations_dir, prefix=f"{self.outfile}_{current_domain_label}_", logging_indentation_level=logging_indentation_level+1) + self.move_files(os.path.join(extpar_dir, "*.png"), visualizations_dir, prefix=f"{self.request_name}_{current_domain_label}_", logging_indentation_level=logging_indentation_level+1) logs_domain_dir = os.path.join(self.logs_dir, current_domain_label) self.move_files(os.path.join(extpar_dir, "*.log"), logs_domain_dir, logging_indentation_level=logging_indentation_level+1) diff --git a/src/processing/process_request.py b/src/processing/process_request.py index d0fe486..0f5ba95 100644 --- a/src/processing/process_request.py +++ b/src/processing/process_request.py @@ -65,7 +65,7 @@ def main(config_path, workspace_path, extpar_raw_data_path, zonda_log_filename, # Keeping the base grid only makes sense when icontools is the grid source of the first domain if nesting_group_idx == 0 and primary_grid_source == "icontools": - keep_basegrid_files = config["basegrid"].get("keep_basegrid_files", False) + keep_basegrid_files = config["globals"].get("keep_basegrid_files", False) else: keep_basegrid_files = False # No basegrid files if the grid is provided by the user or it's not the first domain