|
7 | 7 | "source": [ |
8 | 8 | "# Cross-Sections\n", |
9 | 9 | "\n", |
10 | | - "This section demonstrates how to extract cross-sections from an unstructured grid using UXarray, which allows the analysis and visualization across slices of grids.\n" |
| 10 | + "This section demonstrates how to extract cross-sections from an unstructured grid using UXarray, which allows the analysis and visualization across slices of grids. Cross-sections can be performed directly on a `ux.Grid` object or on a `ux.UxDataArray`\n" |
11 | 11 | ] |
12 | 12 | }, |
13 | 13 | { |
14 | 14 | "cell_type": "code", |
15 | 15 | "execution_count": null, |
16 | 16 | "id": "b35ba4a2c30750e4", |
17 | | - "metadata": { |
18 | | - "ExecuteTime": { |
19 | | - "start_time": "2024-10-14T16:39:35.957687Z" |
20 | | - }, |
21 | | - "jupyter": { |
22 | | - "is_executing": true |
23 | | - } |
24 | | - }, |
| 17 | + "metadata": {}, |
25 | 18 | "outputs": [], |
26 | 19 | "source": [ |
27 | 20 | "import uxarray as ux\n", |
|
33 | 26 | "projection = ccrs.Robinson()" |
34 | 27 | ] |
35 | 28 | }, |
36 | | - { |
37 | | - "cell_type": "markdown", |
38 | | - "id": "395a3db7-495c-4cff-b733-06bbe522a604", |
39 | | - "metadata": {}, |
40 | | - "source": [ |
41 | | - "## Data" |
42 | | - ] |
43 | | - }, |
44 | 29 | { |
45 | 30 | "cell_type": "code", |
46 | 31 | "execution_count": null, |
47 | 32 | "id": "b4160275c09fe6b0", |
48 | | - "metadata": { |
49 | | - "ExecuteTime": { |
50 | | - "end_time": "2024-10-09T17:50:51.217211Z", |
51 | | - "start_time": "2024-10-09T17:50:50.540946Z" |
52 | | - } |
53 | | - }, |
| 33 | + "metadata": {}, |
54 | 34 | "outputs": [], |
55 | 35 | "source": [ |
56 | 36 | "base_path = \"../../test/meshfiles/ugrid/outCSne30/\"\n", |
|
66 | 46 | ")" |
67 | 47 | ] |
68 | 48 | }, |
69 | | - { |
70 | | - "cell_type": "code", |
71 | | - "execution_count": null, |
72 | | - "id": "c844a3b5-ef71-41c8-a0ae-02ea937801d6", |
73 | | - "metadata": {}, |
74 | | - "outputs": [], |
75 | | - "source": [ |
76 | | - "uxds.uxgrid.normalize_cartesian_coordinates()" |
77 | | - ] |
78 | | - }, |
79 | 49 | { |
80 | 50 | "cell_type": "markdown", |
81 | 51 | "id": "a7a40958-0a4d-47e4-9e38-31925261a892", |
82 | 52 | "metadata": {}, |
83 | 53 | "source": [ |
84 | 54 | "## Constant Latitude\n", |
85 | 55 | "\n", |
86 | | - "Cross-sections along constant latitude lines can be obtained using the ``.cross_section.constant_latitude`` method, available for both ``ux.Grid`` and ``ux.DataArray`` objects. This functionality allows users to extract and analyze slices of data at specified latitudes, providing insights into variations along horizontal sections of the grid.\n" |
| 56 | + "Cross-sections along constant latitude lines can be obtained by using the ``.cross_section.constant_latitude(lat)`` method. The sliced grid will be made up of the faces that contain at least one edge that intersects with a line of constant latitude.\n" |
87 | 57 | ] |
88 | 58 | }, |
89 | 59 | { |
90 | 60 | "cell_type": "markdown", |
91 | 61 | "id": "2fbe9f6e5bb59a17", |
92 | 62 | "metadata": {}, |
93 | 63 | "source": [ |
94 | | - "For example, we can obtain a cross-section at 30 degrees latitude by doing the following:" |
| 64 | + "For example, we can obtain a cross-section at 0 degrees latitude by doing the following:" |
95 | 65 | ] |
96 | 66 | }, |
97 | 67 | { |
98 | 68 | "cell_type": "code", |
99 | 69 | "execution_count": null, |
100 | 70 | "id": "3775daa1-2f1d-4738-bab5-2b69ebd689d9", |
101 | | - "metadata": { |
102 | | - "ExecuteTime": { |
103 | | - "end_time": "2024-10-09T17:50:53.093314Z", |
104 | | - "start_time": "2024-10-09T17:50:53.077719Z" |
105 | | - } |
106 | | - }, |
| 71 | + "metadata": {}, |
107 | 72 | "outputs": [], |
108 | 73 | "source": [ |
109 | 74 | "lat = 0\n", |
|
167 | 132 | "## Constant Longitude\n", |
168 | 133 | "\n", |
169 | 134 | "\n", |
170 | | - "\n", |
171 | | - "Cross-sections along constant longitude lines can be obtained using the ``.cross_section.constant_longitude`` method, available for both ``ux.Grid`` and ``ux.DataArray`` objects. \n" |
| 135 | + "Cross-sections along constant longitude lines can be obtained using the ``.cross_section.constant_longitude(lon)`` method. The sliced grid will be made up of the faces that contain at least one edge that intersects with a line of constant longitude.\n" |
172 | 136 | ] |
173 | 137 | }, |
174 | 138 | { |
|
205 | 169 | ")" |
206 | 170 | ] |
207 | 171 | }, |
| 172 | + { |
| 173 | + "cell_type": "markdown", |
| 174 | + "id": "5044b8680d514fdc", |
| 175 | + "metadata": {}, |
| 176 | + "source": [ |
| 177 | + "## Constant Latitude Interval\n", |
| 178 | + "\n", |
| 179 | + "Cross-sections between two lines of latitudes can be obtained using the ``.cross_section.constant_lats_interval(lats)`` method. The sliced grid will contain faces that are strictly between the latitude interval." |
| 180 | + ] |
| 181 | + }, |
| 182 | + { |
| 183 | + "cell_type": "code", |
| 184 | + "execution_count": null, |
| 185 | + "id": "fc84e47efe2edf96", |
| 186 | + "metadata": {}, |
| 187 | + "outputs": [], |
| 188 | + "source": [ |
| 189 | + "lats = [-20, 20]\n", |
| 190 | + "\n", |
| 191 | + "uxda_constant_lat_interval = uxds[\"psi\"].cross_section.constant_latitude_interval(lats)" |
| 192 | + ] |
| 193 | + }, |
| 194 | + { |
| 195 | + "cell_type": "code", |
| 196 | + "execution_count": null, |
| 197 | + "id": "60232626ba6c74ad", |
| 198 | + "metadata": {}, |
| 199 | + "outputs": [], |
| 200 | + "source": [ |
| 201 | + "(\n", |
| 202 | + " uxda_constant_lat_interval.plot(\n", |
| 203 | + " rasterize=False,\n", |
| 204 | + " backend=\"bokeh\",\n", |
| 205 | + " cmap=\"inferno\",\n", |
| 206 | + " projection=projection,\n", |
| 207 | + " global_extent=True,\n", |
| 208 | + " coastline=True,\n", |
| 209 | + " title=f\"Cross Section between {lats[0]} and {lats[1]} degrees latitude\",\n", |
| 210 | + " periodic_elements=\"split\",\n", |
| 211 | + " )\n", |
| 212 | + " * gf.grid(projection=projection)\n", |
| 213 | + ")" |
| 214 | + ] |
| 215 | + }, |
| 216 | + { |
| 217 | + "cell_type": "markdown", |
| 218 | + "id": "4afa3d891a80c597", |
| 219 | + "metadata": {}, |
| 220 | + "source": [ |
| 221 | + "## Constant Longitude Interval\n", |
| 222 | + "\n", |
| 223 | + "Cross-sections between two lines of longitude can be obtained using the ``.cross_section.constant_lons_interval(lons)`` method. The sliced grid will contain faces that are strictly between the longitude interval.\n" |
| 224 | + ] |
| 225 | + }, |
| 226 | + { |
| 227 | + "cell_type": "code", |
| 228 | + "execution_count": null, |
| 229 | + "id": "b183d15838aaf6bb", |
| 230 | + "metadata": {}, |
| 231 | + "outputs": [], |
| 232 | + "source": [ |
| 233 | + "lons = [-25, 25]\n", |
| 234 | + "\n", |
| 235 | + "uxda_constant_lon_interval = uxds[\"psi\"].cross_section.constant_longitude_interval(lats)" |
| 236 | + ] |
| 237 | + }, |
| 238 | + { |
| 239 | + "cell_type": "code", |
| 240 | + "execution_count": null, |
| 241 | + "id": "22793d56701504ce", |
| 242 | + "metadata": {}, |
| 243 | + "outputs": [], |
| 244 | + "source": [ |
| 245 | + "(\n", |
| 246 | + " uxda_constant_lon_interval.plot(\n", |
| 247 | + " rasterize=False,\n", |
| 248 | + " backend=\"bokeh\",\n", |
| 249 | + " cmap=\"inferno\",\n", |
| 250 | + " projection=projection,\n", |
| 251 | + " global_extent=True,\n", |
| 252 | + " coastline=True,\n", |
| 253 | + " title=f\"Cross Section between {lons[0]} and {lons[1]} degrees longitude\",\n", |
| 254 | + " periodic_elements=\"split\",\n", |
| 255 | + " )\n", |
| 256 | + " * gf.grid(projection=projection)\n", |
| 257 | + ")" |
| 258 | + ] |
| 259 | + }, |
208 | 260 | { |
209 | 261 | "cell_type": "markdown", |
210 | 262 | "id": "54d9eff1-67f1-4691-a3b0-1ee0c874c98f", |
|
219 | 271 | "metadata": {}, |
220 | 272 | "source": [ |
221 | 273 | "```{warning}\n", |
222 | | - "Arbitrary great circle arc cross sections are not yet supported.\n", |
| 274 | + "Arbitrary great circle arc cross sections are not yet implemented.\n", |
223 | 275 | "```" |
224 | 276 | ] |
225 | 277 | } |
|
240 | 292 | "name": "python", |
241 | 293 | "nbconvert_exporter": "python", |
242 | 294 | "pygments_lexer": "ipython3", |
243 | | - "version": "3.11.8" |
| 295 | + "version": "3.12.3" |
244 | 296 | } |
245 | 297 | }, |
246 | 298 | "nbformat": 4, |
|
0 commit comments