diff --git a/pysurfex/binary_input.py b/pysurfex/binary_input.py index e9a6d79..40acafd 100644 --- a/pysurfex/binary_input.py +++ b/pysurfex/binary_input.py @@ -49,7 +49,6 @@ def __init__(self, data): def archive_files(self): """Archive files.""" for output_file, target in self.data.items(): - logging.info("%s -> %s", output_file, target) command = "mv" if isinstance(target, dict): @@ -95,7 +94,6 @@ def __init__(self, data): def prepare_input(self): """Prepare input.""" for target, input_file in self.data.items(): - logging.info("%s -> %s", target, input_file) logging.debug(os.path.realpath(target)) command = None diff --git a/pysurfex/cli.py b/pysurfex/cli.py index 646a2e3..b4c1185 100644 --- a/pysurfex/cli.py +++ b/pysurfex/cli.py @@ -139,7 +139,6 @@ def run_first_guess_for_oi(**kwargs): cache = Cache(3600) f_g = None for var in variables: - inputfile = kwargs.get("inputfile") fileformat = kwargs.get("inputformat") logging.debug("inputfile: %s", inputfile) @@ -417,7 +416,6 @@ def run_masterodb(**kwargs): if output is not None: exists = os.path.exists(output) if not exists or force: - if binary is None: my_batch = None diff --git a/pysurfex/cmd_parsing.py b/pysurfex/cmd_parsing.py index f2d4d91..fbbd967 100644 --- a/pysurfex/cmd_parsing.py +++ b/pysurfex/cmd_parsing.py @@ -851,13 +851,15 @@ def parse_args_masterodb(argv): nargs="?", help="Full path of MASTERODB binary", ) - parser.add_argument("--no-consistency", dest="no_consistency", - action="store_true", required=False + parser.add_argument( + "--no-consistency", dest="no_consistency", action="store_true", required=False ) parser.add_argument( - "--assemble", type=str, required=False, + "--assemble", + type=str, + required=False, help="Path to file containing list of namelist blocks", - default=None + default=None, ) if len(argv) == 0: @@ -993,13 +995,15 @@ def parse_args_surfex_binary(argv, mode): help="JSON file with archive output", ) parser.add_argument("binary", type=str, help="Command to run") - parser.add_argument("--no-consistency", dest="no_consistency", - action="store_true", required=False + parser.add_argument( + "--no-consistency", dest="no_consistency", action="store_true", required=False ) parser.add_argument( - "--assemble", type=str, required=False, + "--assemble", + type=str, + required=False, help="Path to file containing list of namelist blocks", - default=None + default=None, ) if len(argv) == 0: @@ -2228,7 +2232,6 @@ def variable_parser(needles, argv, parser): kwargs = {} for needle in needles: - argv = argv_string[start_indices[needle] : end_indices[needle]].split() opt = parser.parse_args(argv) vargs = {} diff --git a/pysurfex/file.py b/pysurfex/file.py index 539ae55..ab7bdcc 100644 --- a/pysurfex/file.py +++ b/pysurfex/file.py @@ -1323,7 +1323,6 @@ def read(self, variable, times): tstep = 0 col = 0 for line in self.file.read().splitlines(): - words = line.split() if len(words) > 0: for i, word in enumerate(words): diff --git a/pysurfex/forcing.py b/pysurfex/forcing.py index 433b6f1..f4da216 100644 --- a/pysurfex/forcing.py +++ b/pysurfex/forcing.py @@ -567,7 +567,6 @@ def run_time_loop(options, var_objs, att_objs): # Loop output time steps this_time = options["start"] while this_time <= options["stop"]: - # Write for each time step logging.info( "Creating forcing for: %s time_step: %s", @@ -639,7 +638,6 @@ def set_input_object( # All objects with converters, find converter dict entry conf_dict = {} if forcingformat != "constant": - # Non-height dependent variables if ref_height is None: if "converter" in conf[sfx_var][forcingformat]: @@ -694,7 +692,6 @@ def set_input_object( obj = ConstantValue(geo, sfx_var, const_dict) else: - # Construct the converter converter = Converter( selected_converter, first_base_time, defs, conf_dict, forcingformat @@ -892,7 +889,6 @@ def set_forcing_config(**kwargs): atts = ["ZS", "ZREF", "UREF"] att_objs = [] for att_var in atts: - # Override with command line options for a given variable ref_height = None cformat = fileformat @@ -947,7 +943,6 @@ def set_forcing_config(**kwargs): var_objs = [] # Search in config file for parameters to override for sfx_var in variables: - ref_height = None cformat = fileformat if sfx_var == "TA": diff --git a/pysurfex/geo.py b/pysurfex/geo.py index 08397c8..3647cff 100644 --- a/pysurfex/geo.py +++ b/pysurfex/geo.py @@ -653,7 +653,6 @@ def __init__(self, from_json, recreate=False): and "ncols" and "nrows" in domain_dict["nam_ign"] ): - self.clambert = domain_dict["nam_ign"]["clambert"] npoints = domain_dict["nam_ign"]["npoints"] self.x_x = domain_dict["nam_ign"]["xx"] @@ -811,7 +810,6 @@ def ign_mask(pxall, pyall, xxx, yyy, recreate): for i, pxall_val in enumerate(pxall): for pyall_val in pyall: - count = count + 1 for k, xval in enumerate(xxx): if xval == pxall_val and yyy[k] == pyall_val: @@ -933,7 +931,6 @@ def set_domain(settings, domain, hm_mode=False): if isinstance(settings, dict): if domain in settings: if hm_mode: - ezone = 11 if "EZONE" in settings[domain]: ezone = settings[domain]["EZONE"] diff --git a/pysurfex/input_methods.py b/pysurfex/input_methods.py index 12dea3c..d4f78cb 100644 --- a/pysurfex/input_methods.py +++ b/pysurfex/input_methods.py @@ -33,7 +33,6 @@ def get_datasources(obs_time, settings): """ datasources = [] for obs_set in settings: - kwargs = {} kwargs.update({"label": obs_set}) diff --git a/pysurfex/namelist.py b/pysurfex/namelist.py index 7bf2f6d..d7a35d9 100644 --- a/pysurfex/namelist.py +++ b/pysurfex/namelist.py @@ -119,7 +119,6 @@ def namelist_blocks(self): # Program specific settings if self.program == "pgd": - input_blocks += ["pgd", "pgd_cover", "pgd_zs"] eco_sg = self.config.get_setting("SURFEX#COVER#SG") if eco_sg: @@ -377,7 +376,6 @@ def concistency(self, nml): # Program specific settings if self.program == "pgd": - problems = self.check_nml_setting( problems, nml, @@ -407,7 +405,6 @@ def concistency(self, nml): self.config.get_setting("SURFEX#TILES#TOWN"), ) if self.config.get_setting("SURFEX#TOWN#LTOWN_TO_ROCK"): - if self.config.get_setting("SURFEX#TILES#TOWN") != "NONE": logging.warning( "WARNING: TOWN is not NONE and you want LTOWN_TO_ROCK. " diff --git a/pysurfex/namelist_legacy.py b/pysurfex/namelist_legacy.py index a6f139a..4ad2468 100644 --- a/pysurfex/namelist_legacy.py +++ b/pysurfex/namelist_legacy.py @@ -1443,7 +1443,6 @@ def set_pgd_namelist(self, merged_dict): self.config.get_setting("SURFEX#TILES#TOWN"), ) if self.config.get_setting("SURFEX#TOWN#LTOWN_TO_ROCK"): - if self.config.get_setting("SURFEX#TILES#TOWN") != "NONE": logging.warning( "WARNING: TOWN is not NONE and you want LTOWN_TO_ROCK. " @@ -1908,7 +1907,6 @@ def prepare_offline_perturbation(self, merged_dict): merged_dict["NAM_VAR"].update({"NIVAR": 0}) merged_dict["NAM_IO_VARASSIM"].update({"LPRT": False}) if self.config.get_setting("SURFEX#ASSIM#SCHEMES#ISBA") == "EKF": - merged_dict = self.merge_json_namelist_file( merged_dict, self.input_path + "/offline_assim_pert.json" ) @@ -1941,7 +1939,6 @@ def prepare_offline_perturbation(self, merged_dict): merged_dict = self.sub(merged_dict, "NAM_VAR", "NVAR", nvar) if self.config.get_setting("SURFEX#ASSIM#SCHEMES#ISBA") == "ENKF": - merged_dict = self.merge_json_namelist_file( merged_dict, self.input_path + "/offline_assim_pert.json" ) diff --git a/pysurfex/netcdf.py b/pysurfex/netcdf.py index c5fb157..a0fa0d0 100644 --- a/pysurfex/netcdf.py +++ b/pysurfex/netcdf.py @@ -848,7 +848,6 @@ def oi2soda(dtg, t2m=None, rh2m=None, s_d=None, s_m=None, output=None): """ def check_input_to_soda_dimensions(my_nx, my_ny, nx1, ny1): - if my_nx < 0: my_nx = nx1 if my_ny < 0: diff --git a/pysurfex/platform_deps.py b/pysurfex/platform_deps.py index 7f60435..3284014 100644 --- a/pysurfex/platform_deps.py +++ b/pysurfex/platform_deps.py @@ -288,7 +288,6 @@ def parse_setting( """ # Check on arguments if isinstance(setting, str): - if basedtg is not None: if isinstance(basedtg, str): basedtg = as_datetime(basedtg) diff --git a/pysurfex/pseudoobs.py b/pysurfex/pseudoobs.py index 68a3bcf..26fde55 100644 --- a/pysurfex/pseudoobs.py +++ b/pysurfex/pseudoobs.py @@ -171,7 +171,6 @@ def snow_pseudo_obs_cryoclim( providers = [] logging.debug("p_fg_snow_depth.shape[0]=%s", p_fg_snow_depth.shape[0]) for i in range(0, p_fg_snow_depth.shape[0]): - p_snow_fg = p_fg_snow_depth[i] logging.debug("%s %s %s %s", i, p_snow_fg, res_lons[i], res_lats[i]) if not np.isnan(p_snow_fg): @@ -319,7 +318,6 @@ def sm_obs_sentinel( lafs = [] providers = [] for i in range(0, p_fg_sm.shape[0]): - p_sm_fg = p_fg_sm[i] if not np.isnan(p_sm_fg): # Check if in grid diff --git a/pysurfex/run.py b/pysurfex/run.py index d453e29..699ad6b 100644 --- a/pysurfex/run.py +++ b/pysurfex/run.py @@ -293,7 +293,6 @@ def __init__( if self.prepfile.input_file is not None and os.path.abspath( self.prepfile.filename ) != os.path.abspath(self.prepfile.input_file): - logging.info("Input PREP file is: %s", self.prepfile.input_file) remove_existing_file(self.prepfile.input_file, self.prepfile.filename) os.symlink(self.prepfile.input_file, self.prepfile.filename) diff --git a/pysurfex/titan.py b/pysurfex/titan.py index 864e293..9fc5099 100644 --- a/pysurfex/titan.py +++ b/pysurfex/titan.py @@ -1052,7 +1052,6 @@ def __init__(self, blacklist): blacklist_stid = {} if "lons" in blacklist and "lats" in blacklist: for i in range(0, len(blacklist["lons"])): - if len(blacklist["lons"]) != len(blacklist["lats"]): raise RuntimeError( "Blacklist must have the same length for both lons and lats" @@ -1092,7 +1091,6 @@ def test(self, dataset, mask, code=100): flags = dataset.flags for i, lon_val in enumerate(dataset.lons): if i in mask: - lon = Observation.format_lon(lon_val) lat = Observation.format_lat(dataset.lats[i]) stid = dataset.stids[i] @@ -1342,7 +1340,6 @@ def define_quality_control(test_list, settings, an_time, domain_geo=None, blackl tests.append(Buddy(**kwargs)) elif qct.lower() == "climatology": - if test_options is not None: opts = ["minval", "maxval", "offset"] for opt in opts: @@ -1351,7 +1348,6 @@ def define_quality_control(test_list, settings, an_time, domain_geo=None, blackl tests.append(Climatology(an_time, **kwargs)) elif qct.lower() == "sct": - if test_options is not None: opts = [ "num_min", @@ -1687,7 +1683,6 @@ def perform_tests(self): mask = [] findex = 0 for obs_set in self.datasources: - if obs_set.label == "": raise RuntimeError( "Observations set for quality control are " @@ -2003,7 +1998,6 @@ def merge_json_qc_data_sets(an_time, filenames, qc_flag=None, skip_flags=None): index_pos = {} data = {} for filename in filenames: - if os.path.exists(filename): with open(filename, mode="r", encoding="utf-8") as file_handler: data1 = json.load(file_handler) diff --git a/tests/smoke/test_cli_fg_titan_oi_obsmon.py b/tests/smoke/test_cli_fg_titan_oi_obsmon.py index b2f36bf..ecf6798 100644 --- a/tests/smoke/test_cli_fg_titan_oi_obsmon.py +++ b/tests/smoke/test_cli_fg_titan_oi_obsmon.py @@ -583,7 +583,6 @@ def _qc_gridpp_obsmon( def obsmon_test(var, qc_fname, first_guess_file, analysis_file, db_file): - translation = { "t2m": "air_temperature_2m", "rh2m": "relative_humidity_2m", diff --git a/tests/smoke/test_cli_misc.py b/tests/smoke/test_cli_misc.py index cf436ff..de4682f 100644 --- a/tests/smoke/test_cli_misc.py +++ b/tests/smoke/test_cli_misc.py @@ -65,7 +65,6 @@ def test_cli_set_geo_from_obs_set(obsset_fname, tmp_path_factory): def test_cryoclim_pseudoobs(tmp_path_factory, data_cryoclim_nc_file, firstguess4gridpp): - out_fname = f"{tmp_path_factory.getbasetemp().as_posix()}/output_cryoclim.json" argv = [ "-step", @@ -86,7 +85,6 @@ def test_cryoclim_pseudoobs(tmp_path_factory, data_cryoclim_nc_file, firstguess4 def test_cryoclim_pseudoobs_iv( tmp_path_factory, data_cryoclim_nc_file, firstguess4gridpp ): - out_fname = f"{tmp_path_factory.getbasetemp().as_posix()}/output_cryoclim2.json" argv = [ "-step", @@ -109,7 +107,6 @@ def test_cryoclim_pseudoobs_iv( def test_cryoclim_pseudoobs_iv_slope_glacier_mask_netcdf( tmp_path_factory, data_cryoclim_nc_file, firstguess4gridpp, data_surfex_pgd_nc_file ): - out_fname = f"{tmp_path_factory.getbasetemp().as_posix()}/output_cryoclim4.json" argv = [ "-step", @@ -204,7 +201,6 @@ def data_sentinel_nc_file(tmp_path_factory): def test_sentinel(tmp_path_factory, data_sentinel_nc_file, firstguess4gridpp): - out_fname = f"{tmp_path_factory.getbasetemp().as_posix()}/output_sentinel.json" argv = [ "-step", diff --git a/tests/smoke/test_cli_run_binary.py b/tests/smoke/test_cli_run_binary.py index 7cec0c0..98fe9f0 100644 --- a/tests/smoke/test_cli_run_binary.py +++ b/tests/smoke/test_cli_run_binary.py @@ -165,7 +165,6 @@ def test_run_prep( tmp_path_factory, input_binary_data_file, ): - # PREP pgd = tmp_path_factory.getbasetemp() / "PGD_input.nc" @@ -209,7 +208,6 @@ def test_run_prep_old( conf_proj_2x3_file, tmp_path_factory, ): - # PREP wrk = tmp_path_factory.getbasetemp() / "nam_old" wrk.mkdir(exist_ok=True) diff --git a/tests/unit/test_binary_input_data.py b/tests/unit/test_binary_input_data.py index 108c010..0543cdb 100644 --- a/tests/unit/test_binary_input_data.py +++ b/tests/unit/test_binary_input_data.py @@ -100,7 +100,6 @@ def working_directory(path): def test_json_output(tmp_path_factory): - target = tmp_path_factory.getbasetemp() / "target_output_file" target2 = tmp_path_factory.getbasetemp() / "target_output_file2" destination = tmp_path_factory.getbasetemp() / "destination_output_file" @@ -266,7 +265,6 @@ def test_new_binary_input( input_binary_data_file, input_binary_data_file_single, ): - system_paths = { "first_guess_dir": "/fg", "ecoclimap_sg": "/ecoclimap", diff --git a/tests/unit/test_cryoclim.py b/tests/unit/test_cryoclim.py index 06b63c8..e634605 100644 --- a/tests/unit/test_cryoclim.py +++ b/tests/unit/test_cryoclim.py @@ -18,7 +18,6 @@ def test_read_cryo_nc(data_cryoclim_nc_file): def test_get_cryo_obs_set(tmp_path_factory, data_cryoclim_nc_file, conf_proj_2x3): - validtime = as_datetime("202303010600") fg_geo = conf_proj_2x3 @@ -43,7 +42,6 @@ def test_get_cryo_obs_set(tmp_path_factory, data_cryoclim_nc_file, conf_proj_2x3 def test_get_cryo_obs_set_varname(data_cryoclim_nc_file, conf_proj_2x3): - validtime = as_datetime("202303010600") fg_geo = conf_proj_2x3 diff --git a/tests/unit/test_ekf.py b/tests/unit/test_ekf.py index 2125f90..1712892 100644 --- a/tests/unit/test_ekf.py +++ b/tests/unit/test_ekf.py @@ -12,7 +12,6 @@ @pytest.mark.usefixtures("_mockers") def test_ekf_fa(surfex_fa_file): - var_dict = { "filepattern": surfex_fa_file, "varname": "SFX.T2M", diff --git a/tests/unit/test_grib.py b/tests/unit/test_grib.py index 640939b..87a4dcc 100644 --- a/tests/unit/test_grib.py +++ b/tests/unit/test_grib.py @@ -115,7 +115,6 @@ def test_grib2_from_converter(converter_config, conf_proj_domain): @pytest.mark.usefixtures("_mockers") def test_read_rotated_ll_grib1(converter_config, rotated_ll_t2m_grib1): - converter_conf = converter_config["t2m"]["grib1"]["converter"] var = get_var(1, converter_conf) grib_file = Grib(rotated_ll_t2m_grib1) @@ -127,7 +126,6 @@ def test_read_rotated_ll_grib1(converter_config, rotated_ll_t2m_grib1): @pytest.mark.usefixtures("_mockers") def test_read_rotated_ll_grib2(converter_config, rotated_ll_t1_grib2): - converter_conf = converter_config["t1"]["grib2"]["converter"] var = get_var(2, converter_conf) grib_file = Grib(rotated_ll_t1_grib2) @@ -139,7 +137,6 @@ def test_read_rotated_ll_grib2(converter_config, rotated_ll_t1_grib2): @pytest.mark.usefixtures("_mockers") def test_read_regular_ll_grib1(converter_config, regular_ll_t2m_grib1): - converter_conf = converter_config["t2m"]["grib1"]["converter"] var = get_var(1, converter_conf) @@ -152,7 +149,6 @@ def test_read_regular_ll_grib1(converter_config, regular_ll_t2m_grib1): @pytest.mark.usefixtures("_mockers") def test_read_regular_ll_grib2(converter_config, regular_ll_t1_grib2): - converter_conf = converter_config["t1"]["grib2"]["converter"] var = get_var(2, converter_conf) diff --git a/tests/unit/test_titan.py b/tests/unit/test_titan.py index 74ca545..82d7c6d 100644 --- a/tests/unit/test_titan.py +++ b/tests/unit/test_titan.py @@ -18,7 +18,6 @@ def obs_set(an_time): - obs_set = { "0": { "varname": "airTemperatureAt2M", diff --git a/tests/unit/test_variable.py b/tests/unit/test_variable.py index db5059a..3690fad 100644 --- a/tests/unit/test_variable.py +++ b/tests/unit/test_variable.py @@ -274,7 +274,6 @@ def test_open_new_file_fail(fixture): def test_variable_grib1(rotated_ll_t2m_grib1): - var_dict = { "filepattern": rotated_ll_t2m_grib1, "parameter": 11, @@ -294,7 +293,6 @@ def test_variable_grib1(rotated_ll_t2m_grib1): def test_variable_grib2(rotated_ll_t1_grib2): - var_dict = { "filepattern": rotated_ll_t1_grib2, "discipline": 0, @@ -318,7 +316,6 @@ def test_variable_grib2(rotated_ll_t1_grib2): @pytest.mark.usefixtures("_mockers") def test_variable_surfex_fa(surfex_fa_file): - var_dict = { "filepattern": surfex_fa_file, "varname": "SFX.T2M", @@ -336,7 +333,6 @@ def test_variable_surfex_fa(surfex_fa_file): @pytest.mark.usefixtures("_mockers") def test_variable_surfex_fa_sfx(surfex_fa_file_sfx): - var_dict = { "filepattern": surfex_fa_file_sfx, "varname": "SFX.T2M",