{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Loading of data\n", "\n", "The most convinient way of working with EMC3 data is from netcdf files.\n", "This way all metadata and all available fields are known, and are loaded into memory as needed.\n", "\n", "Netcdf files are also beneficial for sharing simulation results, as they contain metadata and are thus easy to use. While xemc3 only exists for python, netcdf library implementation are present in most languages, so you can easily do your analysis in your preferred language." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import xemc3\n", "\n", "import xarray as xr\n", "import numpy as np\n", "\n", "# Matplotlib setup\n", "import setup_plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%time\n", "\n", "ds = xr.open_dataset(\"../../example-data/emc3_example.nc\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Checking the present data\n", "\n", "xarray is nicely integrated in jupyter notebook and many IDEs, so it is easy to check what quantities are included as well as units and so on.\n", "\n", "Note that for this view the data does not need to recide in memory, which is especially beneficial for high-resolution grids or large parameter scans." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Quantities can be accessed either by the `[]` operator like `[\"nZ3\"]` or by `.nZ3`. Note that assigning new quantities is only possible with the `[]` notation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds.nZ3" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds.nZ3.isel(r=-2).plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds.emc3.plot_rz(\"nZ3\", phi=np.pi / 5)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" } }, "nbformat": 4, "nbformat_minor": 4 }