Skip to content

Commit c095ee4

Browse files
committed
black formatting
1 parent 4b0eb4e commit c095ee4

14 files changed

+299
-247
lines changed

example_scripts/notebook_tutorials/runnable_notebooks/altimetry/altimetry_tutorial.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
},
123123
"outputs": [],
124124
"source": [
125-
"#altimetry.dataset # uncomment to print data object summary"
125+
"# altimetry.dataset # uncomment to print data object summary"
126126
]
127127
},
128128
{
@@ -163,7 +163,7 @@
163163
"# same methods can be applied. Alternatively, if you want to save the new\n",
164164
"# metrics to the original altimetry object, set 'create_new_object = False'.\n",
165165
"\n",
166-
"#stats.dataset # uncomment to print data object summary"
166+
"# stats.dataset # uncomment to print data object summary"
167167
]
168168
},
169169
{
@@ -183,7 +183,7 @@
183183
"# to basic_stats, `create_new_object` keyword arg can be set to `false` to save output to\n",
184184
"# the original altimetry object.\n",
185185
"\n",
186-
"#crps.dataset # uncomment to print data object summary"
186+
"# crps.dataset # uncomment to print data object summary"
187187
]
188188
},
189189
{

example_scripts/notebook_tutorials/runnable_notebooks/general/climatology_tutorial.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@
6060
"fn_out = None\n",
6161
"\n",
6262
"# Read in multiyear data (This example uses NEMO data from a single file.)\n",
63-
"nemo_data = coast.Gridded(fn_data=fn_nemo_dat,\n",
64-
" fn_domain=fn_nemo_dom,\n",
65-
" config=fn_nemo_config,\n",
66-
" ).dataset\n"
63+
"nemo_data = coast.Gridded(\n",
64+
" fn_data=fn_nemo_dat,\n",
65+
" fn_domain=fn_nemo_dom,\n",
66+
" config=fn_nemo_config,\n",
67+
").dataset"
6768
]
6869
},
6970
{
@@ -107,7 +108,7 @@
107108
"metadata": {},
108109
"outputs": [],
109110
"source": [
110-
"#clim_mean # uncomment to print data object summary"
111+
"# clim_mean # uncomment to print data object summary"
111112
]
112113
},
113114
{

example_scripts/notebook_tutorials/runnable_notebooks/general/eof_tutorial.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"dn_files = root + \"./example_files/\"\n",
3434
"\n",
3535
"fn_nemo_dat_t = dn_files + \"nemo_data_T_grid.nc\"\n",
36-
"fn_nemo_dom = dn_files + \"coast_example_nemo_domain.nc\"\n",
36+
"fn_nemo_dom = dn_files + \"coast_example_nemo_domain.nc\"\n",
3737
"fn_nemo_config = root + \"./config/example_nemo_grid_t.json\""
3838
]
3939
},
@@ -56,7 +56,7 @@
5656
"source": [
5757
"# Load data variables that are on the NEMO t-grid\n",
5858
"\n",
59-
"nemo_t = coast.Gridded( fn_data = fn_nemo_dat_t, fn_domain = fn_nemo_dom, config = fn_nemo_config )"
59+
"nemo_t = coast.Gridded(fn_data=fn_nemo_dat_t, fn_domain=fn_nemo_dom, config=fn_nemo_config)"
6060
]
6161
},
6262
{
@@ -84,7 +84,7 @@
8484
},
8585
"outputs": [],
8686
"source": [
87-
"eof_data = coast.compute_eofs( nemo_t.dataset.ssh )"
87+
"eof_data = coast.compute_eofs(nemo_t.dataset.ssh)"
8888
]
8989
},
9090
{
@@ -110,7 +110,7 @@
110110
},
111111
"outputs": [],
112112
"source": [
113-
"#eof_data # uncomment to print data object summary"
113+
"# eof_data # uncomment to print data object summary"
114114
]
115115
},
116116
{
@@ -164,7 +164,7 @@
164164
},
165165
"outputs": [],
166166
"source": [
167-
"eof_data.EOF.sel(mode=[1,2,3,4]).plot.pcolormesh(col='mode',col_wrap=2,x='longitude',y='latitude')"
167+
"eof_data.EOF.sel(mode=[1, 2, 3, 4]).plot.pcolormesh(col=\"mode\", col_wrap=2, x=\"longitude\", y=\"latitude\")"
168168
]
169169
},
170170
{
@@ -178,7 +178,7 @@
178178
},
179179
"outputs": [],
180180
"source": [
181-
"eof_data.temporal_proj.sel(mode=[1,2,3,4]).plot(col='mode',col_wrap=2,x='time')"
181+
"eof_data.temporal_proj.sel(mode=[1, 2, 3, 4]).plot(col=\"mode\", col_wrap=2, x=\"time\")"
182182
]
183183
},
184184
{
@@ -197,8 +197,8 @@
197197
"metadata": {},
198198
"outputs": [],
199199
"source": [
200-
"heof_data = coast.compute_hilbert_eofs( nemo_t.dataset.ssh )\n",
201-
"#heof_data # uncomment to print data object summary"
200+
"heof_data = coast.compute_hilbert_eofs(nemo_t.dataset.ssh)\n",
201+
"# heof_data # uncomment to print data object summary"
202202
]
203203
},
204204
{

example_scripts/notebook_tutorials/runnable_notebooks/general/mask_maker_tutorial.ipynb

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"# Define convenient aliases based on nemo data\n",
9696
"lon = nemo.dataset.longitude.values\n",
9797
"lat = nemo.dataset.latitude.values\n",
98-
"bathy = nemo.dataset.bathymetry.values\n"
98+
"bathy = nemo.dataset.bathymetry.values"
9999
]
100100
},
101101
{
@@ -182,9 +182,18 @@
182182
"masks_list.append(mm.region_def_nws_kattegat(lon, lat, bathy))\n",
183183
"masks_list.append(mm.region_def_nws_fsc(lon, lat, bathy))\n",
184184
"\n",
185-
"masks_names = [\"whole domain\", \"northern north sea\", \"southern north sea\", \"outer shelf\",\n",
186-
" \"norwegian trench\", \"english_channel\", \"off shelf\",\n",
187-
" \"irish sea\", \"kattegat\", \"fsc\"]"
185+
"masks_names = [\n",
186+
" \"whole domain\",\n",
187+
" \"northern north sea\",\n",
188+
" \"southern north sea\",\n",
189+
" \"outer shelf\",\n",
190+
" \"norwegian trench\",\n",
191+
" \"english_channel\",\n",
192+
" \"off shelf\",\n",
193+
" \"irish sea\",\n",
194+
" \"kattegat\",\n",
195+
" \"fsc\",\n",
196+
"]"
188197
]
189198
},
190199
{
@@ -236,7 +245,7 @@
236245
"metadata": {},
237246
"outputs": [],
238247
"source": [
239-
"mm.quick_plot(mask_xr)\n"
248+
"mm.quick_plot(mask_xr)"
240249
]
241250
},
242251
{
@@ -254,11 +263,11 @@
254263
"metadata": {},
255264
"outputs": [],
256265
"source": [
257-
"plt.subplot(2,2,1)\n",
258-
"mm.quick_plot(mask_xr.sel(dim_mask=[0,3,9]))\n",
266+
"plt.subplot(2, 2, 1)\n",
267+
"mm.quick_plot(mask_xr.sel(dim_mask=[0, 3, 9]))\n",
259268
"\n",
260-
"plt.subplot(2,2,2)\n",
261-
"mm.quick_plot(mask_xr.sel(dim_mask=[1,2,4,5,6,7,8]))\n",
269+
"plt.subplot(2, 2, 2)\n",
270+
"mm.quick_plot(mask_xr.sel(dim_mask=[1, 2, 4, 5, 6, 7, 8]))\n",
262271
"\n",
263272
"plt.tight_layout()"
264273
]
@@ -271,10 +280,10 @@
271280
"outputs": [],
272281
"source": [
273282
"# Show overlap\n",
274-
"mask_xr.mask.sum(dim='dim_mask').plot(levels=(1,2,3,4))\n",
283+
"mask_xr.mask.sum(dim=\"dim_mask\").plot(levels=(1, 2, 3, 4))\n",
275284
"\n",
276285
"# Save if required\n",
277-
"#plt.savefig('tmp.png')"
286+
"# plt.savefig('tmp.png')"
278287
]
279288
},
280289
{
@@ -296,9 +305,9 @@
296305
"source": [
297306
"# Read EN4 data into profile object\n",
298307
"fn_prof = path.join(dn_files, \"coast_example_en4_201008.nc\")\n",
299-
"fn_cfg_prof = path.join(\"config\",\"example_en4_profiles.json\")\n",
308+
"fn_cfg_prof = path.join(\"config\", \"example_en4_profiles.json\")\n",
300309
"profile = coast.Profile(config=fn_cfg_prof)\n",
301-
"profile.read_en4( fn_prof )\n"
310+
"profile.read_en4(fn_prof)"
302311
]
303312
},
304313
{
@@ -390,18 +399,21 @@
390399
"metadata": {},
391400
"outputs": [],
392401
"source": [
393-
"for count_region in range(profile_mask_means.sizes['dim_mask']): \n",
394-
" plt.plot( \n",
395-
" profile_mask_means.profile_mean_temperature.isel(dim_mask=count_region),\n",
396-
" profile_mask_means.profile_mean_depth.isel(dim_mask=count_region),\n",
397-
" label=profile_mask_means.region_names[count_region].values,\n",
398-
" marker=\".\", linestyle='none')\n",
402+
"for count_region in range(profile_mask_means.sizes[\"dim_mask\"]):\n",
403+
" plt.plot(\n",
404+
" profile_mask_means.profile_mean_temperature.isel(dim_mask=count_region),\n",
405+
" profile_mask_means.profile_mean_depth.isel(dim_mask=count_region),\n",
406+
" label=profile_mask_means.region_names[count_region].values,\n",
407+
" marker=\".\",\n",
408+
" linestyle=\"none\",\n",
409+
" )\n",
399410
"\n",
400-
"plt.ylim([10,1000])\n",
411+
"plt.ylim([10, 1000])\n",
401412
"plt.yscale(\"log\")\n",
402413
"plt.gca().invert_yaxis()\n",
403-
"plt.xlabel('temperature'); plt.ylabel('depth')\n",
404-
"plt.legend()\n"
414+
"plt.xlabel(\"temperature\")\n",
415+
"plt.ylabel(\"depth\")\n",
416+
"plt.legend()"
405417
]
406418
},
407419
{
@@ -421,8 +433,8 @@
421433
"metadata": {},
422434
"outputs": [],
423435
"source": [
424-
"# Syntax: xr.where(if <first>, then <2nd>, else <3rd>) \n",
425-
"mask_SST = xr.where( mask_xr.mask, nemo.dataset.temperature.isel(z_dim=0), np.NaN)\n",
436+
"# Syntax: xr.where(if <first>, then <2nd>, else <3rd>)\n",
437+
"mask_SST = xr.where(mask_xr.mask, nemo.dataset.temperature.isel(z_dim=0), np.NaN)\n",
426438
"\n",
427439
"# Take the mean over space for each region\n",
428440
"mask_mean_SST = mask_SST.mean(dim=\"x_dim\").mean(dim=\"y_dim\")"
@@ -448,14 +460,17 @@
448460
"source": [
449461
"# Plot timeseries per region\n",
450462
"\n",
451-
"for count_region in range(mask_mean_SST.sizes['dim_mask']):\n",
452-
" \n",
453-
" plt.plot( \n",
463+
"for count_region in range(mask_mean_SST.sizes[\"dim_mask\"]):\n",
464+
"\n",
465+
" plt.plot(\n",
454466
" mask_mean_SST.isel(dim_mask=count_region),\n",
455467
" label=mask_mean_SST.region_names[count_region].values,\n",
456-
" marker=\".\", linestyle='none')\n",
468+
" marker=\".\",\n",
469+
" linestyle=\"none\",\n",
470+
" )\n",
457471
"\n",
458-
"plt.xlabel('time'); plt.ylabel('SST')\n",
472+
"plt.xlabel(\"time\")\n",
473+
"plt.ylabel(\"SST\")\n",
459474
"plt.legend()"
460475
]
461476
},

example_scripts/notebook_tutorials/runnable_notebooks/general/polar_plotting.ipynb

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"fn_nemo_dom = dn_files + \"coast_nemo_quiver_dom.nc\"\n",
8888
"\n",
8989
"# Define output filepath (optional: None or str)\n",
90-
"fn_out = './quiver_plot.png'"
90+
"fn_out = \"./quiver_plot.png\""
9191
]
9292
},
9393
{
@@ -98,18 +98,21 @@
9898
"outputs": [],
9999
"source": [
100100
"# Read in multiyear data (This example uses NEMO data from a single file.)\n",
101-
"nemo_data_t = coast.Gridded(fn_data=fn_nemo_dat_t,\n",
102-
" fn_domain=fn_nemo_dom,\n",
103-
" config=fn_nemo_config_t,\n",
104-
" ).dataset\n",
105-
"nemo_data_u = coast.Gridded(fn_data=fn_nemo_dat_u,\n",
106-
" fn_domain=fn_nemo_dom,\n",
107-
" config=fn_nemo_config_u,\n",
108-
" ).dataset\n",
109-
"nemo_data_v = coast.Gridded(fn_data=fn_nemo_dat_v,\n",
110-
" fn_domain=fn_nemo_dom,\n",
111-
" config=fn_nemo_config_v,\n",
112-
" ).dataset"
101+
"nemo_data_t = coast.Gridded(\n",
102+
" fn_data=fn_nemo_dat_t,\n",
103+
" fn_domain=fn_nemo_dom,\n",
104+
" config=fn_nemo_config_t,\n",
105+
").dataset\n",
106+
"nemo_data_u = coast.Gridded(\n",
107+
" fn_data=fn_nemo_dat_u,\n",
108+
" fn_domain=fn_nemo_dom,\n",
109+
" config=fn_nemo_config_u,\n",
110+
").dataset\n",
111+
"nemo_data_v = coast.Gridded(\n",
112+
" fn_data=fn_nemo_dat_v,\n",
113+
" fn_domain=fn_nemo_dom,\n",
114+
" config=fn_nemo_config_v,\n",
115+
").dataset"
113116
]
114117
},
115118
{
@@ -136,7 +139,7 @@
136139
"data_v = data_v.isel(t_dim=0, z_dim=0)\n",
137140
"\n",
138141
"# Calculate speed\n",
139-
"speed = ((data_u.to_array().values[0, :, :] ** 2 + data_v.to_array().values[0, :, :] ** 2) ** 0.5)"
142+
"speed = (data_u.to_array().values[0, :, :] ** 2 + data_v.to_array().values[0, :, :] ** 2) ** 0.5"
140143
]
141144
},
142145
{
@@ -168,9 +171,8 @@
168171
"source": [
169172
"uv_velocities = [data_u.to_array().values[0, :, :], data_v.to_array().values[0, :, :]]\n",
170173
"u_new, v_new = coast._utils.plot_util.velocity_grid_to_geo(\n",
171-
" nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n",
172-
" uv_velocities,\n",
173-
" polar_stereo_cartopy_bug_fix=False)"
174+
" nemo_data_t.longitude.values, nemo_data_t.latitude.values, uv_velocities, polar_stereo_cartopy_bug_fix=False\n",
175+
")"
174176
]
175177
},
176178
{
@@ -265,22 +267,22 @@
265267
"\n",
266268
"\n",
267269
"# cs = ax[0].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n",
268-
"# ax[0].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n",
269-
"# data_u.to_array().values[0, :, :], data_v.to_array().values[0, :, :], \n",
270+
"# ax[0].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values,\n",
271+
"# data_u.to_array().values[0, :, :], data_v.to_array().values[0, :, :],\n",
270272
"# color='w', transform=data_crs, angles='xy', regrid_shape=40)\n",
271273
"\n",
272274
"# ax[1].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n",
273-
"# ax[1].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n",
274-
"# u_new, v_new, \n",
275+
"# ax[1].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values,\n",
276+
"# u_new, v_new,\n",
275277
"# color='w', transform=data_crs, angles='xy', regrid_shape=40)\n",
276278
"\n",
277279
"# ax[2].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n",
278-
"# ax[2].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n",
279-
"# u_pol, v_pol, \n",
280+
"# ax[2].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values,\n",
281+
"# u_pol, v_pol,\n",
280282
"# color='w', transform=data_crs, angles='xy', regrid_shape=40)\n",
281283
"\n",
282284
"# ax[3].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n",
283-
"# ax[3].streamplot(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n",
285+
"# ax[3].streamplot(nemo_data_t.longitude.values, nemo_data_t.latitude.values,\n",
284286
"# u_pol, v_pol, transform=data_crs, linewidth=1, density=2, color='w', zorder=101)\n",
285287
"\n",
286288
"# ax[0].set_title('1: No Correction')\n",
@@ -375,7 +377,7 @@
375377
"# cax.set_xlabel(r\"SST ($^{\\circ}$C)\")\n",
376378
"# fig.colorbar(cs2, cax=cax, orientation=\"horizontal\")\n",
377379
"\n",
378-
"# # fig.savefig(fn_out, dpi=120)\n"
380+
"# # fig.savefig(fn_out, dpi=120)"
379381
]
380382
},
381383
{

0 commit comments

Comments
 (0)