Skip to content

Commit 34ebde8

Browse files
committed
Update pre-commit hooks and associated style changes
1 parent d7a5b0e commit 34ebde8

File tree

7 files changed

+2615
-2512
lines changed

7 files changed

+2615
-2512
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ repos:
2727
- id: trailing-whitespace
2828

2929
- repo: https://github.com/pre-commit/mirrors-prettier
30-
rev: "v4.0.0-alpha.8"
30+
rev: "v3.1.0"
3131
hooks:
3232
- id: prettier
3333
types_or: [yaml, markdown, html, css, scss, javascript, json]
3434
args: [--prose-wrap=always]
3535

3636
- repo: https://github.com/astral-sh/ruff-pre-commit
37-
rev: "v0.11.8"
37+
rev: "v0.11.9"
3838
hooks:
3939
- id: ruff
4040
args: ["--fix", "--show-fixes"]

CODE_OF_CONDUCT.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## 1. Our Commitment
44

5-
We are dedicated to fostering a respectful environment for everyone contributing to this project. We expect all participants to treat each other with respect, professionalism, and kindness.
5+
We are dedicated to fostering a respectful environment for everyone contributing
6+
to this project. We expect all participants to treat each other with respect,
7+
professionalism, and kindness.
68

79
## 2. Expected Behavior
810

@@ -21,15 +23,20 @@ The following behaviors will not be tolerated:
2123
- Sharing inappropriate content.
2224

2325
## 4. Reporting Violations
24-
If you experience or witness any behavior that violates this Code of Conduct, please report it by contacting the project maintainers. All reports will be reviewed confidentially.
26+
27+
If you experience or witness any behavior that violates this Code of Conduct,
28+
please report it by contacting the project maintainers. All reports will be
29+
reviewed confidentially.
2530

2631
## 5. Enforcement
27-
Violations of this Code of Conduct may result in actions such as warnings, temporary bans, or permanent exclusion from participation at the discretion of the maintainers.
32+
33+
Violations of this Code of Conduct may result in actions such as warnings,
34+
temporary bans, or permanent exclusion from participation at the discretion of
35+
the maintainers.
2836

2937
## Contact Info
30-
31-
Organization: National Snow and Ice Data Center¹
32-
Website: <https://nsidc.org/>
33-
Date last modified: 01-22-2025
38+
39+
Email: <[email protected]> Organization: National Snow and Ice Data Center¹
40+
Website: <https://nsidc.org/> Date last modified: 01-22-2025
3441

3542
¹Work performed under NASA contract 80GSFC23CA035.

docs/iceflow-example.ipynb

Lines changed: 412 additions & 396 deletions
Large diffs are not rendered by default.

docs/iceflow-with-icepyx.ipynb

Lines changed: 2108 additions & 2067 deletions
Large diffs are not rendered by default.

notebooks/iceflow-example.ipynb

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,26 @@
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
36+
"from __future__ import annotations\n",
37+
"\n",
38+
"import datetime as dt\n",
39+
"from pathlib import Path\n",
40+
"\n",
41+
"import matplotlib.pyplot as plt\n",
42+
"\n",
3643
"from nsidc.iceflow import (\n",
37-
" find_iceflow_data,\n",
38-
" download_iceflow_results,\n",
39-
" read_iceflow_datafiles,\n",
40-
" DatasetSearchParameters,\n",
4144
" BoundingBox,\n",
45+
" DatasetSearchParameters,\n",
4246
" ILATM1BDataset,\n",
47+
" download_iceflow_results,\n",
48+
" find_iceflow_data,\n",
49+
" read_iceflow_datafiles,\n",
4350
")\n",
44-
"from pathlib import Path\n",
45-
"import datetime as dt\n",
46-
"import matplotlib.pyplot as plt\n",
51+
"\n",
4752
"# note: use `inline` to save the resulting image as an embedded png (nice for sharing). \\\n",
4853
"# Use `widget` to obtain interactive controls to explore the data in depth!\n",
4954
"%matplotlib inline\n",
50-
"# %matplotlib widget\n"
55+
"# %matplotlib widget"
5156
]
5257
},
5358
{
@@ -73,8 +78,13 @@
7378
"# Define the dataset that we want to search for.\n",
7479
"atm1b_v1_dataset = ILATM1BDataset(version=\"1\")\n",
7580
"\n",
76-
"# Define a bounding box for our area of interest. \n",
77-
"BBOX = BoundingBox(lower_left_lon=-103.125559, lower_left_lat=-75.180563, upper_right_lon=-102.677327, upper_right_lat=-74.798063)\n",
81+
"# Define a bounding box for our area of interest.\n",
82+
"BBOX = BoundingBox(\n",
83+
" lower_left_lon=-103.125559,\n",
84+
" lower_left_lat=-75.180563,\n",
85+
" upper_right_lon=-102.677327,\n",
86+
" upper_right_lat=-74.798063,\n",
87+
")\n",
7888
"\n",
7989
"# We will define a short date range in 2009 to search for data.\n",
8090
"date_range = (dt.date(2009, 11, 1), dt.date(2009, 12, 31))"
@@ -202,7 +212,9 @@
202212
"outputs": [],
203213
"source": [
204214
"for variable in [\"latitude\", \"longitude\", \"elevation\"]:\n",
205-
" print(f\"Max difference in {variable}: {abs(itrf2014_df[variable] - iceflow_df[variable]).max()}\")"
215+
" print(\n",
216+
" f\"Max difference in {variable}: {abs(itrf2014_df[variable] - iceflow_df[variable]).max()}\"\n",
217+
" )"
206218
]
207219
},
208220
{
@@ -257,7 +269,9 @@
257269
"outputs": [],
258270
"source": [
259271
"for variable in [\"latitude\", \"longitude\", \"elevation\"]:\n",
260-
" print(f\"Max difference in {variable}: {abs(itrf2014_epoch_2019_7_df[variable] - iceflow_df[variable]).max()}\")"
272+
" print(\n",
273+
" f\"Max difference in {variable}: {abs(itrf2014_epoch_2019_7_df[variable] - iceflow_df[variable]).max()}\"\n",
274+
" )"
261275
]
262276
},
263277
{
@@ -277,7 +291,9 @@
277291
"metadata": {},
278292
"outputs": [],
279293
"source": [
280-
"filter_condition = (iceflow_df.reset_index().index > 50) & ( iceflow_df.reset_index().index < 60)\n",
294+
"filter_condition = (iceflow_df.reset_index().index > 50) & (\n",
295+
" iceflow_df.reset_index().index < 60\n",
296+
")\n",
281297
"sampled_iceflow_df = iceflow_df[filter_condition]\n",
282298
"sampled_itrf2014_df = itrf2014_df[filter_condition]\n",
283299
"sampled_itrf2014_epoch_2019_7_df = itrf2014_epoch_2019_7_df[filter_condition]"

notebooks/iceflow-with-icepyx.ipynb

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
"outputs": [],
5050
"source": [
5151
"# Imports\n",
52-
"from pathlib import Path\n",
52+
"from __future__ import annotations\n",
53+
"\n",
5354
"import datetime as dt\n",
55+
"from pathlib import Path\n",
5456
"\n",
5557
"import dask.dataframe as dd\n",
5658
"import icepyx as ipx\n",
@@ -60,12 +62,12 @@
6062
"import xarray as xr\n",
6163
"\n",
6264
"from nsidc.iceflow import (\n",
63-
" make_iceflow_parquet,\n",
64-
" DatasetSearchParameters,\n",
6565
" BoundingBox,\n",
66-
" find_iceflow_data,\n",
66+
" DatasetSearchParameters,\n",
67+
" IceflowDataFrame,\n",
6768
" download_iceflow_results,\n",
68-
" IceflowDataFrame\n",
69+
" find_iceflow_data,\n",
70+
" make_iceflow_parquet,\n",
6971
")"
7072
]
7173
},
@@ -90,8 +92,8 @@
9092
"source": [
9193
"# Constants\n",
9294
"\n",
93-
"# All of our data will be downloaded to this location. \n",
94-
"OUTPUT_DIR = Path(\"./downloaded-data/\")\n",
95+
"# All of our data will be downloaded to this location.\n",
96+
"OUTPUT_DIR = Path(\"./downloaded-data/\")\n",
9597
"\n",
9698
"# ICESat2 data products use ITRF2014 (e.g., see https://nsidc.org/data/atl06/versions/6):\n",
9799
"# > WGS 84 ellipsoid, ITRF2014 reference frame\n",
@@ -100,7 +102,12 @@
100102
"ICESAT2_ITRF = \"ITRF2014\"\n",
101103
"\n",
102104
"# This bounding box covers an area near Sermeq Kujalleq (Jakobshavn Isbrae)\n",
103-
"BBOX = BoundingBox(lower_left_lon=-49.149, lower_left_lat=69.186, upper_right_lon=-48.949, upper_right_lat=69.238)\n",
105+
"BBOX = BoundingBox(\n",
106+
" lower_left_lon=-49.149,\n",
107+
" lower_left_lat=69.186,\n",
108+
" upper_right_lon=-48.949,\n",
109+
" upper_right_lat=69.238,\n",
110+
")\n",
104111
"\n",
105112
"# Range of dates we want to evaluate\n",
106113
"DATE_RANGE = (dt.date(2007, 1, 1), dt.date(2024, 10, 28))"
@@ -195,7 +202,7 @@
195202
"source": [
196203
"iceflow_df = dd.read_parquet(parquet_path)\n",
197204
"\n",
198-
"# Ensure that our index is set as a datetime object \n",
205+
"# Ensure that our index is set as a datetime object\n",
199206
"iceflow_df = iceflow_df.reset_index()\n",
200207
"iceflow_df[\"utc_datetime\"] = dd.to_datetime(iceflow_df[\"utc_datetime\"])\n",
201208
"iceflow_df = iceflow_df.set_index(\"utc_datetime\")\n",
@@ -290,7 +297,7 @@
290297
" reader.vars.append(var_list=[\"h_li\", \"latitude\", \"longitude\"])\n",
291298
" ds = reader.load()\n",
292299
" datasets.append(ds)\n",
293-
" except:\n",
300+
" except Exception:\n",
294301
" print(f\"{file=} contains an error and will not be read\")\n",
295302
" continue\n",
296303
"\n",
@@ -364,8 +371,8 @@
364371
"# Drop rows where lat, lon, or elev are missing.\n",
365372
"df = df.dropna(subset=[\"latitude\", \"longitude\", \"elevation\"], how=\"any\")\n",
366373
"df = df.set_index(\"utc_datetime\")\n",
367-
"# Cast the df as an IceflowDataFrame. \n",
368-
"# The `atl06_df` can now be used with e.g., `iceflow`'s ITRF conversion function \n",
374+
"# Cast the df as an IceflowDataFrame.\n",
375+
"# The `atl06_df` can now be used with e.g., `iceflow`'s ITRF conversion function\n",
369376
"# to perform plate motion model adjustments if desired.\n",
370377
"atl06_df = IceflowDataFrame(df)\n",
371378
"atl06_df.head()"
@@ -434,11 +441,13 @@
434441
"\n",
435442
"iceflow_df_sampled = iceflow_df_sampled[iceflow_df_sampled.elevation > 0]\n",
436443
"\n",
437-
"iceflow_avg = iceflow_df_sampled.resample(\"W\").agg({\n",
438-
" \"elevation\": \"mean\",\n",
439-
" \"dataset\": lambda x: \", \".join(x.astype(\"str\").unique()), \n",
440-
"})\n",
441-
"iceflow_avg = iceflow_avg.replace([np.inf, -np.inf], np.nan) \n",
444+
"iceflow_avg = iceflow_df_sampled.resample(\"W\").agg(\n",
445+
" {\n",
446+
" \"elevation\": \"mean\",\n",
447+
" \"dataset\": lambda x: \", \".join(x.astype(\"str\").unique()),\n",
448+
" }\n",
449+
")\n",
450+
"iceflow_avg = iceflow_avg.replace([np.inf, -np.inf], np.nan)\n",
442451
"iceflow_avg = iceflow_avg.dropna(how=\"any\")\n",
443452
"iceflow_avg = iceflow_avg.compute()\n",
444453
"\n",
@@ -479,9 +488,23 @@
479488
"for dataset, marker in iceflow_marker_map.items():\n",
480489
" subset = iceflow_avg[iceflow_avg.dataset == dataset]\n",
481490
" if subset.elevation.any():\n",
482-
" plt.scatter(subset.index, subset.elevation, marker=marker, label=dataset, linestyle=\"\", color=\"black\")\n",
491+
" plt.scatter(\n",
492+
" subset.index,\n",
493+
" subset.elevation,\n",
494+
" marker=marker,\n",
495+
" label=dataset,\n",
496+
" linestyle=\"\",\n",
497+
" color=\"black\",\n",
498+
" )\n",
483499
"\n",
484-
"plt.scatter(atl06_avg_df.index, atl06_avg_df.elevation, color=\"black\", marker=\"*\", label=\"ATL06v6\", linestyle=\"\")\n",
500+
"plt.scatter(\n",
501+
" atl06_avg_df.index,\n",
502+
" atl06_avg_df.elevation,\n",
503+
" color=\"black\",\n",
504+
" marker=\"*\",\n",
505+
" label=\"ATL06v6\",\n",
506+
" linestyle=\"\",\n",
507+
")\n",
485508
"\n",
486509
"plt.xlabel(\"Date\")\n",
487510
"plt.ylabel(\"Elevation\")\n",

src/nsidc/iceflow/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@
3838

3939

4040
__all__ = [
41-
"__version__",
42-
"make_iceflow_parquet",
43-
"download_iceflow_results",
44-
"find_iceflow_data",
45-
"read_iceflow_datafiles",
46-
"transform_itrf",
47-
"DatasetSearchParameters",
48-
"BoundingBox",
4941
"ALL_DATASETS",
5042
"BLATM1BDataset",
43+
"BoundingBox",
44+
"DatasetSearchParameters",
5145
"GLAH06Dataset",
5246
"ILATM1BDataset",
5347
"ILVIS2Dataset",
5448
"IceflowDataFrame",
49+
"__version__",
50+
"download_iceflow_results",
51+
"find_iceflow_data",
52+
"make_iceflow_parquet",
53+
"read_iceflow_datafiles",
54+
"transform_itrf",
5555
]

0 commit comments

Comments
 (0)