Skip to content

Commit 3f2afdb

Browse files
committed
update notebook
1 parent 908f244 commit 3f2afdb

1 file changed

Lines changed: 44 additions & 31 deletions

File tree

docs/user-guide/cross-sections.ipynb

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@
77
"source": [
88
"# Cross-Sections\n",
99
"\n",
10+
"UXarray allows for cross‑sections to be performed along arbitrary great‑circle arcs (GCAs) and lines of constant latitude or longitude. This enables workflows such as vertical or temporal cross-section visualizations.\n",
1011
"\n",
11-
"UXarray allows for cross-sections to be performed along arbitrary great-circle arcs (GCAs) and lines of constant latitude or longitude. This enables workflows such as vertical or temporal cross-section visualizations\n"
12+
"The data variable is sampled along the cross‑section, and the result is an `xarray.DataArray` (no longer a `uxarray.UxDataArray`) since the output is detached from the original unstructured grid.\n"
1213
]
1314
},
1415
{
1516
"cell_type": "code",
16-
"execution_count": null,
1717
"id": "16db9f880115ac2b",
1818
"metadata": {},
19-
"outputs": [],
2019
"source": [
2120
"import matplotlib.pyplot as plt\n",
2221
"import numpy as np\n",
2322
"\n",
2423
"import uxarray as ux"
25-
]
24+
],
25+
"outputs": [],
26+
"execution_count": null
2627
},
2728
{
2829
"cell_type": "code",
29-
"execution_count": null,
3030
"id": "720c4a345d659fd3",
3131
"metadata": {},
32-
"outputs": [],
3332
"source": [
3433
"def set_lon_lat_xticks(ax, cross_section, n_ticks=6):\n",
3534
" \"\"\"Utility function to draw stacked lat/lon points along the sampled cross-section\"\"\"\n",
@@ -53,121 +52,135 @@
5352
" plt.tight_layout()\n",
5453
"\n",
5554
" return fig, ax"
56-
]
55+
],
56+
"outputs": [],
57+
"execution_count": null
5758
},
5859
{
5960
"cell_type": "code",
60-
"execution_count": null,
6161
"id": "2a42a1aa9249a94f",
6262
"metadata": {},
63-
"outputs": [],
6463
"source": [
6564
"grid_path = \"../../test/meshfiles/scrip/ne30pg2/grid.nc\"\n",
6665
"data_path = \"../../test/meshfiles/scrip/ne30pg2/data.nc\"\n",
6766
"\n",
6867
"uxds = ux.open_dataset(grid_path, data_path)\n",
6968
"uxds[\"RELHUM\"]"
70-
]
69+
],
70+
"outputs": [],
71+
"execution_count": null
7172
},
7273
{
7374
"cell_type": "markdown",
7475
"id": "637eaeb7670eea9b",
7576
"metadata": {},
76-
"source": "## Arbitrary Great Circle Arc (GCA)"
77+
"source": [
78+
"## Arbitrary Great Circle Arc (GCA)\n",
79+
"\n",
80+
"A cross‑section can be performed between two **arbitrary** (lon,lat) points, which will form a geodesic arc."
81+
]
7782
},
7883
{
7984
"cell_type": "code",
80-
"execution_count": null,
8185
"id": "11d2b717ba274d79",
8286
"metadata": {},
83-
"outputs": [],
8487
"source": [
8588
"start_point = (-45, -45)\n",
8689
"end_point = (45, 45)\n",
8790
"\n",
8891
"cross_section_gca = uxds[\"RELHUM\"].cross_section(\n",
8992
" start=start_point, end=end_point, steps=100\n",
9093
")"
91-
]
94+
],
95+
"outputs": [],
96+
"execution_count": null
9297
},
9398
{
9499
"cell_type": "code",
95-
"execution_count": null,
96100
"id": "cf73e86a3ddd57d9",
97101
"metadata": {},
98-
"outputs": [],
99102
"source": [
100103
"fig, ax = plt.subplots()\n",
101104
"cross_section_gca.plot(ax=ax)\n",
102105
"\n",
103106
"set_lon_lat_xticks(ax, cross_section_gca)\n",
104107
"ax.set_title(f\"Cross Section between {start_point} and {end_point}\")\n",
105108
"ax.invert_yaxis()"
106-
]
109+
],
110+
"outputs": [],
111+
"execution_count": null
107112
},
108113
{
109114
"cell_type": "markdown",
110115
"id": "c2f3ff22dc82d6ce",
111116
"metadata": {},
112-
"source": "## Constant Latitude"
117+
"source": [
118+
"## Constant Latitude\n",
119+
"\n",
120+
"A constant‐latitude cross‐section samples data along a horizontal line at a fixed latitude.\n"
121+
]
113122
},
114123
{
115124
"cell_type": "code",
116-
"execution_count": null,
117125
"id": "5a7415fa56f86071",
118126
"metadata": {},
119-
"outputs": [],
120127
"source": [
121128
"lat = 45\n",
122129
"cross_section_const_lat = uxds[\"RELHUM\"].cross_section(lat=lat, steps=100)"
123-
]
130+
],
131+
"outputs": [],
132+
"execution_count": null
124133
},
125134
{
126135
"cell_type": "code",
127-
"execution_count": null,
128136
"id": "b8cfda1b537a059e",
129137
"metadata": {},
130-
"outputs": [],
131138
"source": [
132139
"fig, ax = plt.subplots()\n",
133140
"cross_section_const_lat.plot(ax=ax)\n",
134141
"\n",
135142
"set_lon_lat_xticks(ax, cross_section_const_lat)\n",
136143
"ax.set_title(f\"Cross Section at {lat}° latitude.\")\n",
137144
"ax.invert_yaxis()"
138-
]
145+
],
146+
"outputs": [],
147+
"execution_count": null
139148
},
140149
{
141150
"cell_type": "markdown",
142151
"id": "b6ab076677f11637",
143152
"metadata": {},
144-
"source": "## Constant Longitude"
153+
"source": [
154+
"## Constant Longitude\n",
155+
"\n",
156+
"A constant‐longitude cross‐section samples data along a vertical line at a fixed longitude"
157+
]
145158
},
146159
{
147160
"cell_type": "code",
148-
"execution_count": null,
149161
"id": "add5646acb68496e",
150162
"metadata": {},
151-
"outputs": [],
152163
"source": [
153164
"lon = 0\n",
154165
"cross_section_const_lon = uxds[\"RELHUM\"].cross_section(lon=lon, steps=100)"
155-
]
166+
],
167+
"outputs": [],
168+
"execution_count": null
156169
},
157170
{
158171
"cell_type": "code",
159-
"execution_count": null,
160172
"id": "1999ff933ce37f4e",
161173
"metadata": {},
162-
"outputs": [],
163174
"source": [
164175
"fig, ax = plt.subplots()\n",
165176
"cross_section_const_lon.plot(ax=ax)\n",
166177
"\n",
167178
"set_lon_lat_xticks(ax, cross_section_const_lon)\n",
168179
"ax.set_title(f\"Cross Section at {lon}° longitude.\")\n",
169180
"ax.invert_yaxis()"
170-
]
181+
],
182+
"outputs": [],
183+
"execution_count": null
171184
}
172185
],
173186
"metadata": {

0 commit comments

Comments
 (0)