2626 "execution_count" : null ,
2727 "metadata" : {},
2828 "outputs" : [],
29- "source" : " from pathlib import Path\n\n import matplotlib.pyplot as plt\n import numpy as np\n import uxarray as ux\n\n import parcels\n import parcels.tutorial\n from parcels.convert import fesom_to_ugrid"
29+ "source" : [
30+ " from pathlib import Path\n " ,
31+ " \n " ,
32+ " import matplotlib.pyplot as plt\n " ,
33+ " import numpy as np\n " ,
34+ " import uxarray as ux\n " ,
35+ " \n " ,
36+ " import parcels\n " ,
37+ " import parcels.tutorial\n " ,
38+ " from parcels.convert import fesom_to_ugrid"
39+ ]
3040 },
3141 {
3242 "cell_type" : " markdown" ,
4656 "outputs" : [],
4757 "source" : [
4858 " for name in [\n " ,
49- " \" FESOM_periodic_channel/fesom_channel\" , # grid description\n " ,
59+ " \" FESOM_periodic_channel/fesom_channel\" , # grid description\n " ,
5060 " \" FESOM_periodic_channel/u.fesom_channel\" , # zonal velocity (face-registered)\n " ,
5161 " \" FESOM_periodic_channel/v.fesom_channel\" , # meridional velocity (face-registered)\n " ,
5262 " \" FESOM_periodic_channel/w.fesom_channel\" , # vertical velocity (node-registered)\n " ,
5363 " ]:\n " ,
5464 " parcels.tutorial.open_dataset(name)\n " ,
5565 " \n " ,
5666 " from parcels._datasets.remote import _DATA_HOME\n " ,
67+ " \n " ,
5768 " data_dir = Path(_DATA_HOME) / \" data\" / \" FESOM_periodic_channel\"\n " ,
5869 " \n " ,
5970 " grid_path = str(data_dir / \" fesom_channel.nc\" )\n " ,
8899 "metadata" : {},
89100 "outputs" : [],
90101 "source" : [
91- " ds = ux.open_mfdataset(grid_path, data_paths).rename_vars({\" u\" : \" U\" , \" v\" : \" V\" , \" w\" : \" W\" })\n " ,
102+ " ds = ux.open_mfdataset(grid_path, data_paths).rename_vars(\n " ,
103+ " {\" u\" : \" U\" , \" v\" : \" V\" , \" w\" : \" W\" }\n " ,
104+ " )\n " ,
92105 " ds"
93106 ]
94107 },
158171 "execution_count" : null ,
159172 "metadata" : {},
160173 "outputs" : [],
161- "source" : " lon_grid, lat_grid = np.meshgrid(\n np.linspace(0.5, 4.0, 10),\n np.linspace(3.0, 15.0, 4),\n )\n lon = lon_grid.ravel()\n lat = lat_grid.ravel()\n z = np.full(lon.size, 50.0) # release at 50 m depth\n\n pset = parcels.ParticleSet(\n fieldset=fieldset, pclass=parcels.Particle, lon=lon, lat=lat, z=z,\n )\n\n output_file = parcels.ParticleFile(\" output-fesom.parquet\" , outputdt=np.timedelta64(1, \" h\" ))\n\n pset.execute(\n [parcels.kernels.AdvectionRK4],\n runtime=np.timedelta64(2, \" D\" ),\n dt=np.timedelta64(5, \" m\" ),\n output_file=output_file,\n verbose_progress=False,\n )"
174+ "source" : [
175+ " lon_grid, lat_grid = np.meshgrid(\n " ,
176+ " np.linspace(0.5, 4.0, 10),\n " ,
177+ " np.linspace(3.0, 15.0, 4),\n " ,
178+ " )\n " ,
179+ " lon = lon_grid.ravel()\n " ,
180+ " lat = lat_grid.ravel()\n " ,
181+ " z = np.full(lon.size, 50.0) # release at 50 m depth\n " ,
182+ " \n " ,
183+ " pset = parcels.ParticleSet(\n " ,
184+ " fieldset=fieldset,\n " ,
185+ " pclass=parcels.Particle,\n " ,
186+ " lon=lon,\n " ,
187+ " lat=lat,\n " ,
188+ " z=z,\n " ,
189+ " )\n " ,
190+ " \n " ,
191+ " output_file = parcels.ParticleFile(\n " ,
192+ " \" output-fesom.parquet\" , outputdt=np.timedelta64(1, \" h\" )\n " ,
193+ " )\n " ,
194+ " \n " ,
195+ " pset.execute(\n " ,
196+ " [parcels.kernels.AdvectionRK4],\n " ,
197+ " runtime=np.timedelta64(2, \" D\" ),\n " ,
198+ " dt=np.timedelta64(5, \" m\" ),\n " ,
199+ " output_file=output_file,\n " ,
200+ " verbose_progress=False,\n " ,
201+ " )"
202+ ]
162203 },
163204 {
164205 "cell_type" : " markdown" ,
170211 "execution_count" : null ,
171212 "metadata" : {},
172213 "outputs" : [],
173- "source" : " df = parcels.read_particlefile(\" output-fesom.parquet\" )\n\n fig, ax = plt.subplots(figsize=(10, 5))\n ax.scatter(lon, lat, facecolors=\" none\" , edgecolors=\" k\" , s=60, label=\" release\" )\n sc = ax.scatter(df[\" lon\" ], df[\" lat\" ], c=df[\" time\" ].dt.total_seconds(), s=8, cmap=\" viridis\" )\n fig.colorbar(sc, ax=ax, label=\" time since release [s]\" )\n ax.set_xlabel(\" Longitude [deg E]\" )\n ax.set_ylabel(\" Latitude [deg N]\" )\n ax.legend(loc=\" upper right\" )\n plt.show()"
214+ "source" : [
215+ " df = parcels.read_particlefile(\" output-fesom.parquet\" )\n " ,
216+ " \n " ,
217+ " fig, ax = plt.subplots(figsize=(10, 5))\n " ,
218+ " ax.scatter(lon, lat, facecolors=\" none\" , edgecolors=\" k\" , s=60, label=\" release\" )\n " ,
219+ " sc = ax.scatter(\n " ,
220+ " df[\" lon\" ], df[\" lat\" ], c=df[\" time\" ].dt.total_seconds(), s=8, cmap=\" viridis\"\n " ,
221+ " )\n " ,
222+ " fig.colorbar(sc, ax=ax, label=\" time since release [s]\" )\n " ,
223+ " ax.set_xlabel(\" Longitude [deg E]\" )\n " ,
224+ " ax.set_ylabel(\" Latitude [deg N]\" )\n " ,
225+ " ax.legend(loc=\" upper right\" )\n " ,
226+ " plt.show()"
227+ ]
174228 },
175229 {
176230 "cell_type" : " markdown" ,
201255 },
202256 "nbformat" : 4 ,
203257 "nbformat_minor" : 4
204- }
258+ }
0 commit comments