Skip to content

Commit cac9b82

Browse files
committed
Wrap-up pre-commit lint steps
1 parent e757e49 commit cac9b82

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

_toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
- file: core/pandas
4141
- file: core/data-formats
4242
- file: core/xarray
43-
sections:
44-
- file: core/xarray/xarray-nc-cf
43+
sections:
44+
- file: core/xarray/xarray-nc-cf

core/xarray/xarray-nc-cf.ipynb

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"source": [
121121
"# Use pandas to create an array of datetimes\n",
122122
"import pandas as pd\n",
123+
"\n",
123124
"times = pd.date_range('2018-01-01', periods=5)\n",
124125
"times"
125126
]
@@ -219,6 +220,7 @@
219220
"outputs": [],
220221
"source": [
221222
"from datetime import timedelta\n",
223+
"\n",
222224
"temp.sel(time='2018-01-07', method='nearest', tolerance=timedelta(days=2))"
223225
]
224226
},
@@ -251,7 +253,9 @@
251253
"metadata": {},
252254
"outputs": [],
253255
"source": [
254-
"temp.sel(time=slice('2018-01-01', '2018-01-03'), lon=slice(-110, -70), lat=slice(25, 45))"
256+
"temp.sel(\n",
257+
" time=slice('2018-01-01', '2018-01-03'), lon=slice(-110, -70), lat=slice(25, 45)\n",
258+
")"
255259
]
256260
},
257261
{
@@ -289,7 +293,7 @@
289293
"outputs": [],
290294
"source": [
291295
"# This *doesn't* work however:\n",
292-
"#temp.loc[-110:-70, 25:45,'2018-01-01':'2018-01-03']"
296+
"# temp.loc[-110:-70, 25:45,'2018-01-01':'2018-01-03']"
293297
]
294298
},
295299
{
@@ -494,6 +498,7 @@
494498
"outputs": [],
495499
"source": [
496500
"from cftime import date2num\n",
501+
"\n",
497502
"time_units = 'hours since {:%Y-%m-%d 00:00}'.format(times[0])\n",
498503
"time_vals = date2num(times, time_units)\n",
499504
"time_vals"
@@ -519,12 +524,15 @@
519524
"metadata": {},
520525
"outputs": [],
521526
"source": [
522-
"ds = xr.Dataset({'temperature': (['time', 'z', 'y', 'x'], temps, {'units':'Kelvin'})},\n",
523-
" coords={'x_dist': (['x'], x, {'units':'km'}),\n",
524-
" 'y_dist': (['y'], y, {'units':'km'}),\n",
525-
" 'pressure': (['z'], press, {'units':'hPa'}),\n",
526-
" 'forecast_time': (['time'], times)\n",
527-
" })\n",
527+
"ds = xr.Dataset(\n",
528+
" {'temperature': (['time', 'z', 'y', 'x'], temps, {'units': 'Kelvin'})},\n",
529+
" coords={\n",
530+
" 'x_dist': (['x'], x, {'units': 'km'}),\n",
531+
" 'y_dist': (['y'], y, {'units': 'km'}),\n",
532+
" 'pressure': (['z'], press, {'units': 'hPa'}),\n",
533+
" 'forecast_time': (['time'], times),\n",
534+
" },\n",
535+
")\n",
528536
"ds"
529537
]
530538
},
@@ -635,11 +643,11 @@
635643
"metadata": {},
636644
"outputs": [],
637645
"source": [
638-
"ds.x.attrs['axis'] = 'X' # Optional\n",
646+
"ds.x.attrs['axis'] = 'X' # Optional\n",
639647
"ds.x.attrs['standard_name'] = 'projection_x_coordinate'\n",
640648
"ds.x.attrs['long_name'] = 'x-coordinate in projected coordinate system'\n",
641649
"\n",
642-
"ds.y.attrs['axis'] = 'Y' # Optional\n",
650+
"ds.y.attrs['axis'] = 'Y' # Optional\n",
643651
"ds.y.attrs['standard_name'] = 'projection_y_coordinate'\n",
644652
"ds.y.attrs['long_name'] = 'y-coordinate in projected coordinate system'"
645653
]
@@ -696,9 +704,9 @@
696704
"outputs": [],
697705
"source": [
698706
"from pyproj import Proj\n",
707+
"\n",
699708
"X, Y = np.meshgrid(x, y)\n",
700-
"lcc = Proj({'proj':'lcc', 'lon_0':-105, 'lat_0':40, 'a':6371000.,\n",
701-
" 'lat_1':25})\n",
709+
"lcc = Proj({'proj': 'lcc', 'lon_0': -105, 'lat_0': 40, 'a': 6371000.0, 'lat_1': 25})\n",
702710
"lon, lat = lcc(X * 1000, Y * 1000, inverse=True)"
703711
]
704712
},
@@ -715,8 +723,8 @@
715723
"metadata": {},
716724
"outputs": [],
717725
"source": [
718-
"ds = ds.assign_coords(lon = (['y', 'x'], lon))\n",
719-
"ds = ds.assign_coords(lat = (['y', 'x'], lat))\n",
726+
"ds = ds.assign_coords(lon=(['y', 'x'], lon))\n",
727+
"ds = ds.assign_coords(lat=(['y', 'x'], lat))\n",
720728
"ds"
721729
]
722730
},
@@ -775,9 +783,9 @@
775783
"source": [
776784
"ds['lambert_projection'] = int()\n",
777785
"ds.lambert_projection.attrs['grid_mapping_name'] = 'lambert_conformal_conic'\n",
778-
"ds.lambert_projection.attrs['standard_parallel'] = 25.\n",
779-
"ds.lambert_projection.attrs['latitude_of_projection_origin'] = 40.\n",
780-
"ds.lambert_projection.attrs['longitude_of_central_meridian'] = -105.\n",
786+
"ds.lambert_projection.attrs['standard_parallel'] = 25.0\n",
787+
"ds.lambert_projection.attrs['latitude_of_projection_origin'] = 40.0\n",
788+
"ds.lambert_projection.attrs['longitude_of_central_meridian'] = -105.0\n",
781789
"ds.lambert_projection.attrs['semi_major_axis'] = 6371000.0\n",
782790
"ds.lambert_projection"
783791
]

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ dependencies:
1010
- xarray
1111
- netcdf4
1212
- scipy
13-
- pyproj
13+
- pyproj

0 commit comments

Comments
 (0)