From 92369710e7563633abe4c26c910a42317c25bbc3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 17:17:23 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/biomass/huc12_map.py | 4 +--- scripts/cligen/daily_clifile_editor.py | 2 +- scripts/cligen/exercise.py | 2 +- scripts/cligen/qc_summarize.py | 2 +- scripts/climatechange/figure2.py | 4 +--- scripts/dynamic_tillage/map_myhucs.py | 2 +- scripts/dynamic_tillage/nass_comparison.py | 8 ++------ scripts/dynamic_tillage/workflow.py | 4 +--- scripts/gridorder/huc12_map.py | 2 +- scripts/import/create_website_mask.py | 4 +--- scripts/import/flowpath2prj.py | 6 +++--- scripts/plots/yearly_avg_summary.py | 2 +- scripts/switchgrass/modify_for_switchgrass.py | 2 +- scripts/tillage/residue_plot.py | 3 +-- scripts/ucs/huc12_map.py | 2 +- 15 files changed, 18 insertions(+), 31 deletions(-) diff --git a/scripts/biomass/huc12_map.py b/scripts/biomass/huc12_map.py index e6942573..1b599f85 100644 --- a/scripts/biomass/huc12_map.py +++ b/scripts/biomass/huc12_map.py @@ -24,9 +24,7 @@ def main(): nologo=True, subtitle="1 Jan 2014 thru 31 Dec 2014", caption="Daily Erosion Project", - title=( - "Harvest Index 0.8 Change in 2014 Soil Delivery " "from Baseline" - ), + title=("Harvest Index 0.8 Change in 2014 Soil Delivery from Baseline"), ) cursor.execute( diff --git a/scripts/cligen/daily_clifile_editor.py b/scripts/cligen/daily_clifile_editor.py index 5213fcf9..d58eb181 100644 --- a/scripts/cligen/daily_clifile_editor.py +++ b/scripts/cligen/daily_clifile_editor.py @@ -412,7 +412,7 @@ def _cb_lp(args): def bpstr(ts, accum): """Make a string representation of this breakpoint and accumulation""" # Need four decimals for accurate reproduction - return f"{ts.hour:02.0f}.{(ts.minute / 60. * 10000.):04.0f} {accum:.2f}" + return f"{ts.hour:02.0f}.{(ts.minute / 60.0 * 10000.0):04.0f} {accum:.2f}" def compute_breakpoint(ar, accumThreshold=2.0, intensityThreshold=1.0): diff --git a/scripts/cligen/exercise.py b/scripts/cligen/exercise.py index b20c8a7e..d2516bdc 100644 --- a/scripts/cligen/exercise.py +++ b/scripts/cligen/exercise.py @@ -767,7 +767,7 @@ def edit(bpdata): pos2 = o.find("12\t6\t2015") out = open("/i/0/cli/095x041/094.86x040.84.cli", "w") newdata = ( - "11\t6\t2015\t%(points)s\t25.0\t20.0\t269\t4.2\t0\t20.0\n" "%(bp)s\n" + "11\t6\t2015\t%(points)s\t25.0\t20.0\t269\t4.2\t0\t20.0\n%(bp)s\n" ) % dict(points=len(bpdata), bp=("\n".join(bpdata))) out.write(o[:pos1] + newdata + o[pos2:]) out.close() diff --git a/scripts/cligen/qc_summarize.py b/scripts/cligen/qc_summarize.py index 016fdc03..fd26de94 100644 --- a/scripts/cligen/qc_summarize.py +++ b/scripts/cligen/qc_summarize.py @@ -222,7 +222,7 @@ def do_qc(fn, df, year): df2 = df.loc[slice(datetime.date(year, 1, 1), datetime.date(year, 1, 31))][ ["diff_precip", "pcpn_in", "iemre_precip", "stage4_precip"] ].sort_values(by="diff_precip") - print(" --- Daily values for month " "") + print(" --- Daily values for month ") print(df2) diff --git a/scripts/climatechange/figure2.py b/scripts/climatechange/figure2.py index 5af95725..cc973218 100644 --- a/scripts/climatechange/figure2.py +++ b/scripts/climatechange/figure2.py @@ -47,9 +47,7 @@ def main(): """Go Main Go.""" - title = ( - "Change in Hillslope Soil Loss\n" "by -/+ 14 Day Precipitation Shift" - ) + title = "Change in Hillslope Soil Loss\nby -/+ 14 Day Precipitation Shift" (fig, ax) = figure_axes( logo="dep", title=title, diff --git a/scripts/dynamic_tillage/map_myhucs.py b/scripts/dynamic_tillage/map_myhucs.py index eb152983..cf4bdb29 100644 --- a/scripts/dynamic_tillage/map_myhucs.py +++ b/scripts/dynamic_tillage/map_myhucs.py @@ -42,7 +42,7 @@ def main(): logo="dep", title="HUC12s Selected for Erosion Sensitivity Test", subtitle=( - f"{len(hucdf.index)} HUC12s selected over " f"{len(mlras)} MLRAs" + f"{len(hucdf.index)} HUC12s selected over {len(mlras)} MLRAs" ), nocaption=True, ) diff --git a/scripts/dynamic_tillage/nass_comparison.py b/scripts/dynamic_tillage/nass_comparison.py index 93dba186..85de750a 100644 --- a/scripts/dynamic_tillage/nass_comparison.py +++ b/scripts/dynamic_tillage/nass_comparison.py @@ -381,10 +381,7 @@ def plot_accum( def plot_v2(ax2, crop, year, district, state): """Plot v2.""" v2df = pd.read_csv( - ( - f"plotsv2/{crop}_{year}_{district if state is None else state}" - ".csv" - ), + (f"plotsv2/{crop}_{year}_{district if state is None else state}.csv"), parse_dates=["valid"], ) v2df["valid"] = v2df["valid"].dt.date @@ -474,8 +471,7 @@ def main( fig = figure( logo="dep", title=( - f"{year} DEP Dynamic Tillage {crop.capitalize()} " - "Planting Progress" + f"{year} DEP Dynamic Tillage {crop.capitalize()} Planting Progress" ), subtitle=f"Comparison with USDA NASS Weekly Progress for {title}", figsize=(10.24, 7.68), diff --git a/scripts/dynamic_tillage/workflow.py b/scripts/dynamic_tillage/workflow.py index 4e2b8f0d..b1629dcc 100644 --- a/scripts/dynamic_tillage/workflow.py +++ b/scripts/dynamic_tillage/workflow.py @@ -108,9 +108,7 @@ def edit_rotfile(year, huc12, row): thisdt = dates.pop(0) if thisdt is None: thisdt = row["plant"] - lines[i] = ( - f"{thisdt:%-m %-d} {yearindex} " f"{' '.join(tokens[3:])}\n" - ) + lines[i] = f"{thisdt:%-m %-d} {yearindex} {' '.join(tokens[3:])}\n" with open(rotfn, "w", encoding="ascii") as fh: fh.write("".join(lines)) diff --git a/scripts/gridorder/huc12_map.py b/scripts/gridorder/huc12_map.py index 529e2735..b7239c90 100644 --- a/scripts/gridorder/huc12_map.py +++ b/scripts/gridorder/huc12_map.py @@ -21,7 +21,7 @@ axisbg="white", nologo=True, subtitle="1 Jan 2007 thru 31 Dec 2016", - title=("Grid Order %s minus Grid Order %s " "Soil Delivery") + title=("Grid Order %s minus Grid Order %s Soil Delivery") % (titles2[scenario1], titles2[scenario2]), ) diff --git a/scripts/import/create_website_mask.py b/scripts/import/create_website_mask.py index b0efdf84..367d6aed 100644 --- a/scripts/import/create_website_mask.py +++ b/scripts/import/create_website_mask.py @@ -48,9 +48,7 @@ def main(): fig.savefig("depdomain.png") with open("depdomain.wld", "w", encoding="utf-8") as fp: - fp.write( - "2000.\n" "0.0\n" "0.0\n" "-2000.\n" f"{ulx:.2f}\n" f"{uly:.2f}\n" - ) + fp.write(f"2000.\n0.0\n0.0\n-2000.\n{ulx:.2f}\n{uly:.2f}\n") # Now make white color transparent subprocess.call( [ diff --git a/scripts/import/flowpath2prj.py b/scripts/import/flowpath2prj.py index db8276b7..3d4b6a9d 100644 --- a/scripts/import/flowpath2prj.py +++ b/scripts/import/flowpath2prj.py @@ -136,15 +136,15 @@ def do_rotation(scenario, zone, rotfn, landuse: str, management): # Created with scripts/import/flowpath2prj.py # Version = 98.7 -Name = {data['name']} +Name = {data["name"]} Description {{ }} Color = 0 255 0 LandUse = 1 -InitialConditions = {data['initcond']} +InitialConditions = {data["initcond"]} Operations {{ -{data['yearly']} +{data["yearly"]} }} """ ) diff --git a/scripts/plots/yearly_avg_summary.py b/scripts/plots/yearly_avg_summary.py index 99f9c793..a1618466 100644 --- a/scripts/plots/yearly_avg_summary.py +++ b/scripts/plots/yearly_avg_summary.py @@ -119,7 +119,7 @@ def main(argv): f""" WITH data as ( SELECT huc_12, extract(year from valid) as yr, - sum({v.replace('_metric', '')}) as d from results_by_huc12 + sum({v.replace("_metric", "")}) as d from results_by_huc12 WHERE scenario = %s and valid >= %s and valid <= %s GROUP by huc_12, yr), diff --git a/scripts/switchgrass/modify_for_switchgrass.py b/scripts/switchgrass/modify_for_switchgrass.py index 997507a4..7fd7bc7c 100644 --- a/scripts/switchgrass/modify_for_switchgrass.py +++ b/scripts/switchgrass/modify_for_switchgrass.py @@ -54,7 +54,7 @@ def main(argv): and line.find('File = "IDEP2/') > 0 ): lines[i] = ( - " File = " '"IDEP2/CSCAP/SWITCHGRASS.rot"\n' + ' File = "IDEP2/CSCAP/SWITCHGRASS.rot"\n' ) fp = open(newfn, "w") fp.write("".join(lines)) diff --git a/scripts/tillage/residue_plot.py b/scripts/tillage/residue_plot.py index 4d1dbcb7..9a9e7d97 100644 --- a/scripts/tillage/residue_plot.py +++ b/scripts/tillage/residue_plot.py @@ -126,8 +126,7 @@ def main(): ] fig, ax = figure_axes( title=( - "2017-2022 Distribution of Residue " - "Cover Estimate after Given Crop" + "2017-2022 Distribution of Residue Cover Estimate after Given Crop" ), logo="dep", figsize=(8, 6), diff --git a/scripts/ucs/huc12_map.py b/scripts/ucs/huc12_map.py index 42b89e70..7662b646 100644 --- a/scripts/ucs/huc12_map.py +++ b/scripts/ucs/huc12_map.py @@ -23,7 +23,7 @@ axisbg="white", nologo=True, subtitle="1 Jan 2008 thru 31 Dec 2015", - title=("UCS %s Year %s Scenario Change in Soil Delivery " "from Baseline") + title=("UCS %s Year %s Scenario Change in Soil Delivery from Baseline") % (titles2[scenario], nt.get(scenario, "")), )