-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ProjectTorreyPines/add_tool
Make translator between grid subset names and indices
- Loading branch information
Showing
5 changed files
with
200 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,163 +1,163 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Plotting examples using GGDUtils\n", | ||
" \n", | ||
" For running this notebook, you need to install package IJulia in your home environment (that is messy, but that is the only way I know right now). So in your terminal:\n", | ||
" ```\n", | ||
" % julia\n", | ||
" julia > ]\n", | ||
" (@v1.9 pkg) pkg> add IJulia\n", | ||
" ```\n", | ||
"\n", | ||
" After this, Julia kernel would appear in your jupyter notebooks as an option. This also works for julia notebooks directly opened on VSCode. Select the Julia kernel to run this notebook." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"using Pkg\n", | ||
"Pkg.activate(\"./\")\n", | ||
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/IMASDD.jl.git\")\n", | ||
"Pkg.develop(path=\"../\")\n", | ||
"Pkg.add(\"Plots\")\n", | ||
"Pkg.add(\"LaTeXStrings\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"using IMASDD\n", | ||
"using GGDUtils\n", | ||
"using Plots\n", | ||
"using LaTeXStrings" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dd = IMASDD.json2imas(\"../samples/time_dep_edge_profiles_last_step_only.json\")\n", | ||
"grid_ggd = dd.edge_profiles.grid_ggd[1]\n", | ||
"space = grid_ggd.space[1]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plotting grid and subsets" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Choose backend\n", | ||
"gr() # Fast and can save pdf\n", | ||
"# plotlyjs() # Use for interactive plot, can only save png\n", | ||
"\n", | ||
"plot(space) # Simply plot the grid described in space, all common arguments to plot can be given here\n", | ||
"\n", | ||
"# You can overlay any subset by giving a second argument\n", | ||
"# Labels \n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 6), markercolor=:chocolate1)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 7), linecolor=:red, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 8), linecolor=:darkred, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 9), linecolor=:limegreen, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 10), linecolor=:darkgreen, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 11), linecolor=:cyan, linewidth=2)\n", | ||
"# plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 12), linecolor=:teal, linewidth=1)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 13), linecolor=:royalblue1, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 14), linecolor=:navyblue, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 15), linecolor=:fuchsia, linewidth=2, linestyle=:dash)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 16), linecolor=:purple4, linewidth=2, linestyle=:dash)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 101), markershape=:rect, markercolor=:royalblue1)\n", | ||
"# plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 102), markershape=:rect, markercolor=:maroon)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 103), markershape=:diamond, markercolor=:fuchsia)\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 104), markershape=:diamond, markercolor=:purple4)\n", | ||
"\n", | ||
"# Legend is supressed unless asked for specifically\n", | ||
"plot!(legend=true)\n", | ||
"# Default labels are subset.identifier.name but can be changed by providing a label argument\n", | ||
"\n", | ||
"# It is recommended to add atleast 10 pt margin to the left to accomodate the y-axis label\n", | ||
"plot!(left_margin=10Plots.pt)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plotting 2D quantities as heatmaps" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Choose backend\n", | ||
"gr() # Fast and can save pdf\n", | ||
"# plotlyjs() # Use for interactive plot, can only save png\n", | ||
"\n", | ||
"n_e = GGDUtils.get_prop_with_grid_subset_index(dd.edge_profiles.ggd[1].electrons.density, 5)\n", | ||
"plot(dd.edge_profiles.grid_ggd, n_e, colorbar_title=\"Electrons density / \" * L\"m^{-3}\",\n", | ||
" left_margin=10Plots.pt)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### You can overlap any grid on top of a quantity" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Choose backend\n", | ||
"gr() # Fast and can save pdf\n", | ||
"# plotlyjs() # Use for interactive plot, can only save png\n", | ||
"\n", | ||
"plot(dd.edge_profiles.grid_ggd, n_e) # Note default label in colorbar\n", | ||
"plot!(space, GGDUtils.get_grid_subset_with_index(grid_ggd, 16), linecolor=:red,\n", | ||
" linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true,\n", | ||
" left_margin=10Plots.pt)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Julia 1.9.4", | ||
"language": "julia", | ||
"name": "julia-1.9" | ||
}, | ||
"language_info": { | ||
"file_extension": ".jl", | ||
"mimetype": "application/julia", | ||
"name": "julia", | ||
"version": "1.9.4" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Plotting examples using GGDUtils\n", | ||
" \n", | ||
" For running this notebook, you need to install package IJulia in your home environment (that is messy, but that is the only way I know right now). So in your terminal:\n", | ||
" ```\n", | ||
" % julia\n", | ||
" julia > ]\n", | ||
" (@v1.9 pkg) pkg> add IJulia\n", | ||
" ```\n", | ||
"\n", | ||
" After this, Julia kernel would appear in your jupyter notebooks as an option. This also works for julia notebooks directly opened on VSCode. Select the Julia kernel to run this notebook." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"using Pkg\n", | ||
"Pkg.activate(\"./\")\n", | ||
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/IMASDD.jl.git\")\n", | ||
"Pkg.develop(path=\"../\")\n", | ||
"Pkg.add(\"Plots\")\n", | ||
"Pkg.add(\"LaTeXStrings\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"using IMASDD\n", | ||
"using GGDUtils\n", | ||
"using Plots\n", | ||
"using LaTeXStrings" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dd = IMASDD.json2imas(\"../samples/time_dep_edge_profiles_last_step_only.json\")\n", | ||
"grid_ggd = dd.edge_profiles.grid_ggd[1]\n", | ||
"space = grid_ggd.space[1]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plotting grid and subsets" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Choose backend\n", | ||
"gr() # Fast and can save pdf\n", | ||
"# plotlyjs() # Use for interactive plot, can only save png\n", | ||
"\n", | ||
"plot(space) # Simply plot the grid described in space, all common arguments to plot can be given here\n", | ||
"\n", | ||
"# You can overlay any subset by giving a second argument\n", | ||
"# Labels \n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"x_points\"), markercolor=:chocolate1)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"core_cut\"), linecolor=:red, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 8), linecolor=:darkred, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 9), linecolor=:limegreen, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 10), linecolor=:darkgreen, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 11), linecolor=:cyan, linewidth=2)\n", | ||
"# plot!(space, GGDUtils.get_grid_subset(grid_ggd, 12), linecolor=:teal, linewidth=1)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 13), linecolor=:royalblue1, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 14), linecolor=:navyblue, linewidth=2)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 15), linecolor=:fuchsia, linewidth=2, linestyle=:dash)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:purple4, linewidth=2, linestyle=:dash)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 101), markershape=:rect, markercolor=:royalblue1)\n", | ||
"# plot!(space, GGDUtils.get_grid_subset(grid_ggd, 102), markershape=:rect, markercolor=:maroon)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 103), markershape=:diamond, markercolor=:fuchsia)\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 104), markershape=:diamond, markercolor=:purple4)\n", | ||
"\n", | ||
"# Legend is supressed unless asked for specifically\n", | ||
"plot!(legend=true)\n", | ||
"# Default labels are subset.identifier.name but can be changed by providing a label argument\n", | ||
"\n", | ||
"# It is recommended to add atleast 10 pt margin to the left to accomodate the y-axis label\n", | ||
"plot!(left_margin=10Plots.pt)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plotting 2D quantities as heatmaps" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Choose backend\n", | ||
"gr() # Fast and can save pdf\n", | ||
"# plotlyjs() # Use for interactive plot, can only save png\n", | ||
"\n", | ||
"n_e = GGDUtils.get_prop_with_grid_subset_index(dd.edge_profiles.ggd[1].electrons.density, 5)\n", | ||
"plot(dd.edge_profiles.grid_ggd, n_e, colorbar_title=\"Electrons density / \" * L\"m^{-3}\",\n", | ||
" left_margin=10Plots.pt)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### You can overlap any grid on top of a quantity" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Choose backend\n", | ||
"gr() # Fast and can save pdf\n", | ||
"# plotlyjs() # Use for interactive plot, can only save png\n", | ||
"\n", | ||
"plot(dd.edge_profiles.grid_ggd, n_e) # Note default label in colorbar\n", | ||
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:red,\n", | ||
" linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true,\n", | ||
" left_margin=10Plots.pt)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Julia 1.9.4", | ||
"language": "julia", | ||
"name": "julia-1.10" | ||
}, | ||
"language_info": { | ||
"file_extension": ".jl", | ||
"mimetype": "application/julia", | ||
"name": "julia", | ||
"version": "1.9.4" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.