Skip to content

Commit 16d9920

Browse files
authored
Apply formatting changes from black v23 (#325)
1 parent 18d87c8 commit 16d9920

39 files changed

+38
-131
lines changed

examples/advection_correction.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def advection_correction(R, T=5, t=1):
102102
np.arange(R[0].shape[1], dtype=float), np.arange(R[0].shape[0], dtype=float)
103103
)
104104
for i in range(t, T + t, t):
105-
106105
pos1 = (y - i / T * V[1], x - i / T * V[0])
107106
R1 = map_coordinates(R[0], pos1, order=1)
108107

examples/anvil_nowcast.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
refobs_field, metadata = utils.to_rainrate(refobs_field[-1], metadata)
124124
refobs_field[refobs_field < 0.5] = 0.0
125125

126+
126127
###############################################################################
127128
# Plot the extrapolation, S-PROG and ANVIL nowcasts.
128129
# --------------------------------------------------

examples/blended_forecast.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@
194194
leadtimes_min = [30, 60, 90, 120, 150, 180]
195195
n_leadtimes = len(leadtimes_min)
196196
for n, leadtime in enumerate(leadtimes_min):
197-
198197
# Nowcast with blending into NWP
199198
plt.subplot(n_leadtimes, 2, n * 2 + 1)
200199
plot_precip_field(

examples/data_transformations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
# Test data transformations
7171
# -------------------------
7272

73+
7374
# Define method to visualize the data distribution with boxplots and plot the
7475
# corresponding skewness
7576
def plot_distribution(data, labels, skw):
76-
7777
N = len(data)
7878
fig, ax1 = plt.subplots()
7979
ax2 = ax1.twinx()

examples/my_first_nowcast.ipynb

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"outputs": [],
4848
"source": [
49-
"# These libraries are needed for the pygrib library in Colab. \n",
49+
"# These libraries are needed for the pygrib library in Colab.\n",
5050
"# Note that is needed if you install pygrib using pip.\n",
5151
"# If you use conda, the libraries will be installed automatically.\n",
5252
"! apt-get install libeccodes-dev libproj-dev\n",
@@ -68,7 +68,7 @@
6868
"source": [
6969
"# Uninstall existing shapely\n",
7070
"# We will re-install shapely in the next step by ignoring the binary\n",
71-
"# wheels to make it compatible with other modules that depend on \n",
71+
"# wheels to make it compatible with other modules that depend on\n",
7272
"# GEOS, such as Cartopy (used here).\n",
7373
"!pip uninstall --yes shapely"
7474
]
@@ -83,7 +83,7 @@
8383
},
8484
"outputs": [],
8585
"source": [
86-
"# To install cartopy in Colab using pip, we need to install the library \n",
86+
"# To install cartopy in Colab using pip, we need to install the library\n",
8787
"# dependencies first.\n",
8888
"\n",
8989
"!apt-get install -qq libgdal-dev libgeos-dev\n",
@@ -170,9 +170,9 @@
170170
},
171171
"outputs": [],
172172
"source": [
173-
"# If the configuration file is placed in one of the default locations \n",
174-
"# (https://pysteps.readthedocs.io/en/latest/user_guide/set_pystepsrc.html#configuration-file-lookup) \n",
175-
"# it will be loaded automatically when pysteps is imported. \n",
173+
"# If the configuration file is placed in one of the default locations\n",
174+
"# (https://pysteps.readthedocs.io/en/latest/user_guide/set_pystepsrc.html#configuration-file-lookup)\n",
175+
"# it will be loaded automatically when pysteps is imported.\n",
176176
"config_file_path = create_default_pystepsrc(\"pysteps_data\")"
177177
]
178178
},
@@ -198,6 +198,7 @@
198198
"source": [
199199
"# Import pysteps and load the new configuration file\n",
200200
"import pysteps\n",
201+
"\n",
201202
"_ = pysteps.load_config_file(config_file_path, verbose=True)"
202203
]
203204
},
@@ -224,7 +225,8 @@
224225
"source": [
225226
"# The default parameters are stored in pysteps.rcparams.\n",
226227
"from pprint import pprint\n",
227-
"pprint(pysteps.rcparams.data_sources['mrms'])"
228+
"\n",
229+
"pprint(pysteps.rcparams.data_sources[\"mrms\"])"
228230
]
229231
},
230232
{
@@ -272,7 +274,9 @@
272274
"start_time = time.time()\n",
273275
"\n",
274276
"# Import the data\n",
275-
"precipitation, metadata, timestep = load_dataset('mrms',frames=35) # precipitation in mm/h\n",
277+
"precipitation, metadata, timestep = load_dataset(\n",
278+
" \"mrms\", frames=35\n",
279+
") # precipitation in mm/h\n",
276280
"\n",
277281
"end_time = time.time()\n",
278282
"\n",
@@ -330,7 +334,7 @@
330334
},
331335
"outputs": [],
332336
"source": [
333-
"timestep # In minutes"
337+
"timestep # In minutes"
334338
]
335339
},
336340
{
@@ -450,25 +454,25 @@
450454
"\n",
451455
"# Let's define some plotting default parameters for the next plots\n",
452456
"# Note: This is not strictly needed.\n",
453-
"plt.rc('figure', figsize=(4,4))\n",
454-
"plt.rc('figure', dpi=100)\n",
455-
"plt.rc('font', size=14) # controls default text sizes\n",
456-
"plt.rc('axes', titlesize=14) # fontsize of the axes title\n",
457-
"plt.rc('axes', labelsize=14) # fontsize of the x and y labels\n",
458-
"plt.rc('xtick', labelsize=14) # fontsize of the tick labels\n",
459-
"plt.rc('ytick', labelsize=14) # fontsize of the tick labels\n",
457+
"plt.rc(\"figure\", figsize=(4, 4))\n",
458+
"plt.rc(\"figure\", dpi=100)\n",
459+
"plt.rc(\"font\", size=14) # controls default text sizes\n",
460+
"plt.rc(\"axes\", titlesize=14) # fontsize of the axes title\n",
461+
"plt.rc(\"axes\", labelsize=14) # fontsize of the x and y labels\n",
462+
"plt.rc(\"xtick\", labelsize=14) # fontsize of the tick labels\n",
463+
"plt.rc(\"ytick\", labelsize=14) # fontsize of the tick labels\n",
460464
"\n",
461465
"# Let's use the last available composite for nowcasting from the \"training\" data (train_precip[-1])\n",
462466
"# Also, we will discard any invalid value.\n",
463467
"valid_precip_values = train_precip[-1][~np.isnan(train_precip[-1])]\n",
464468
"\n",
465469
"# Plot the histogram\n",
466-
"bins= np.concatenate( ([-0.01,0.01], np.linspace(1,40,39)))\n",
467-
"plt.hist(valid_precip_values,bins=bins,log=True, edgecolor='black')\n",
468-
"plt.autoscale(tight=True, axis='x')\n",
470+
"bins = np.concatenate(([-0.01, 0.01], np.linspace(1, 40, 39)))\n",
471+
"plt.hist(valid_precip_values, bins=bins, log=True, edgecolor=\"black\")\n",
472+
"plt.autoscale(tight=True, axis=\"x\")\n",
469473
"plt.xlabel(\"Rainfall intensity [mm/h]\")\n",
470474
"plt.ylabel(\"Counts\")\n",
471-
"plt.title('Precipitation rain rate histogram in mm/h units')\n",
475+
"plt.title(\"Precipitation rain rate histogram in mm/h units\")\n",
472476
"plt.show()"
473477
]
474478
},
@@ -507,11 +511,11 @@
507511
"source": [
508512
"from pysteps.utils import transformation\n",
509513
"\n",
510-
"# Log-transform the data to dBR. \n",
514+
"# Log-transform the data to dBR.\n",
511515
"# The threshold of 0.1 mm/h sets the fill value to -15 dBR.\n",
512-
"train_precip_dbr, metadata_dbr = transformation.dB_transform(train_precip, metadata, \n",
513-
" threshold=0.1, \n",
514-
" zerovalue=-15.0)"
516+
"train_precip_dbr, metadata_dbr = transformation.dB_transform(\n",
517+
" train_precip, metadata, threshold=0.1, zerovalue=-15.0\n",
518+
")"
515519
]
516520
},
517521
{
@@ -554,7 +558,7 @@
554558
"\n",
555559
"# We will only use one composite to fit the function to speed up things.\n",
556560
"# First, remove the no precip areas.\"\n",
557-
"precip_to_fit = valid_precip_dbr[valid_precip_dbr > -15] \n",
561+
"precip_to_fit = valid_precip_dbr[valid_precip_dbr > -15]\n",
558562
"\n",
559563
"fit_params = scipy.stats.lognorm.fit(precip_to_fit)\n",
560564
"\n",
@@ -617,7 +621,7 @@
617621
"plt.title(\"Estimated motion field with the Lukas-Kanade algorithm\")\n",
618622
"\n",
619623
"# Plot the last rainfall field in the \"training\" data.\n",
620-
"# Remember to use the mm/h precipitation data since plot_precip_field assumes \n",
624+
"# Remember to use the mm/h precipitation data since plot_precip_field assumes\n",
621625
"# mm/h by default. You can change this behavior using the \"units\" keyword.\n",
622626
"plot_precip_field(train_precip[-1], geodata=metadata, axis=\"off\")\n",
623627
"\n",
@@ -662,7 +666,7 @@
662666
"\n",
663667
"last_observation[~np.isfinite(last_observation)] = metadata[\"zerovalue\"]\n",
664668
"\n",
665-
"# We set the number of leadtimes (the length of the forecast horizon) to the \n",
669+
"# We set the number of leadtimes (the length of the forecast horizon) to the\n",
666670
"# length of the observed/verification preipitation data. In this way, we'll get\n",
667671
"# a forecast that covers these time intervals.\n",
668672
"n_leadtimes = observed_precip.shape[0]\n",
@@ -746,7 +750,7 @@
746750
" 64,\n",
747751
"] # In grid points.\n",
748752
"\n",
749-
"scales_in_km = np.array(scales)*4\n",
753+
"scales_in_km = np.array(scales) * 4\n",
750754
"\n",
751755
"# Set the threshold\n",
752756
"thr = 1.0 # in mm/h\n",
@@ -764,13 +768,13 @@
764768
"\n",
765769
"# Now plot it\n",
766770
"plt.figure()\n",
767-
"x = np.arange(1, n_leadtimes+1) * timestep\n",
771+
"x = np.arange(1, n_leadtimes + 1) * timestep\n",
768772
"plt.plot(x, score, lw=2.0)\n",
769773
"plt.xlabel(\"Lead time [min]\")\n",
770774
"plt.ylabel(\"FSS ( > 1.0 mm/h ) \")\n",
771775
"plt.title(\"Fractions Skill Score\")\n",
772776
"plt.legend(\n",
773-
" scales_in_km, \n",
777+
" scales_in_km,\n",
774778
" title=\"Scale [km]\",\n",
775779
" loc=\"center left\",\n",
776780
" bbox_to_anchor=(1.01, 0.5),\n",

examples/optical_flow_methods_convergence.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
# The "precipitation region" includes the precipitation pattern plus a margin of
117117
# approximately 20 grid points.
118118

119+
119120
################################################################################
120121
# Let's create a function to construct different motion fields.
121122
def create_motion_field(input_precip, motion_type):

examples/plot_linear_blending.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@
210210
leadtimes_min = [30, 60, 80, 100, 120]
211211
n_leadtimes = len(leadtimes_min)
212212
for n, leadtime in enumerate(leadtimes_min):
213-
214213
# Extrapolation
215214
plt.subplot(n_leadtimes, 4, n * 4 + 1)
216215
plot_precip_field(

examples/rainfarm_downscale.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
# half or double the estimated slope.
9090
alpha = None
9191
for n in range(num_realizations):
92-
9392
# Spectral slope estimated from the upscaled field
9493
precip_hr, alpha = rainfarm.downscale(
9594
precip_lr, ds_factor=scale_factor, alpha=alpha, return_alpha=True

pysteps/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def config_fname():
9494

9595
file_name = None
9696
for file_name in _fconfig_candidates_generator():
97-
9897
if file_name is not None:
9998
if os.path.exists(file_name):
10099
st_mode = os.stat(file_name).st_mode

pysteps/blending/linear_blending.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def forecast(
4141
saliency=False,
4242
nowcast_kwargs=None,
4343
):
44-
4544
"""Generate a forecast by linearly or saliency-based blending of nowcasts with NWP data
4645
4746
Parameters

0 commit comments

Comments
 (0)