Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Releasing v.0.2.1 #33

Merged
merged 15 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
examples/Project.toml
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
OMAS = "91cfaa06-6526-4804-8666-b540b3feef2f"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SOLPS2IMAS = "09becab6-0636-4c23-a92a-2b3723265c31"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
11 changes: 0 additions & 11 deletions examples/Project.toml

This file was deleted.

60 changes: 23 additions & 37 deletions examples/plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
"using Pkg\n",
"Pkg.activate(\"./\")\n",
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/OMAS.jl.git\")\n",
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/SOLPS2IMAS.jl.git\", rev=\"dev\")\n",
"Pkg.add(path=\"../\")\n",
"Pkg.add(PackageSpec(name=\"GR\", version=\"0.72.9\"))\n",
"Pkg.pin(\"GR\")\n",
"Pkg.develop(path=\"../\")\n",
"Pkg.add(\"Plots\")\n",
"Pkg.add(\"LaTeXStrings\")"
]
Expand All @@ -39,7 +36,7 @@
"metadata": {},
"outputs": [],
"source": [
"using SOLPS2IMAS\n",
"using OMAS\n",
"using GGDUtils\n",
"using Plots\n",
"using LaTeXStrings"
Expand All @@ -51,14 +48,9 @@
"metadata": {},
"outputs": [],
"source": [
"b2gmtry = \"../samples/b2fgmtry\"\n",
"b2output = \"../samples/b2time_red.nc\"\n",
"gsdesc = \"../samples/gridspacedesc.yml\"\n",
"b2mn = \"../samples/b2mn.dat\"\n",
"dd = solps2imas(b2gmtry, b2output, gsdesc, b2mn)\n",
"dd = OMAS.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]\n",
"dd.edge_profiles.ggd[1].electrons.density[5].grid_subset_index = 5 # This is a bug in SOLPS2IMAS to be fixed"
"space = grid_ggd.space[1]"
]
},
{
Expand All @@ -82,21 +74,21 @@
"\n",
"# You can overlay any subset by giving a second argument\n",
"# Labels \n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 6), markercolor=:chocolate1)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 7), linecolor=:red, linewidth=2)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 8), linecolor=:darkred, linewidth=2)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 9), linecolor=:limegreen, linewidth=2)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 10), linecolor=:darkgreen, linewidth=2)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 11), linecolor=:cyan, linewidth=2)\n",
"# plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 12), linecolor=:teal, linewidth=1)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 13), linecolor=:royalblue1, linewidth=2)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 14), linecolor=:navyblue, linewidth=2)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 15), linecolor=:fuchsia, linewidth=2, linestyle=:dash)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 16), linecolor=:purple4, linewidth=2, linestyle=:dash)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 101), markershape=:rect, markercolor=:royalblue1)\n",
"# plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 102), markershape=:rect, markercolor=:maroon)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 103), markershape=:diamond, markercolor=:fuchsia)\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 104), markershape=:diamond, markercolor=:purple4)\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",
Expand All @@ -120,7 +112,8 @@
"gr() # Fast and can save pdf\n",
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(dd.edge_profiles.grid_ggd, dd.edge_profiles.ggd[1].electrons.density[5], colorbar_title=\"Electrons density / \" * L\"m^{-3}\")"
"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}\")"
]
},
{
Expand All @@ -140,16 +133,9 @@
"gr() # Fast and can save pdf\n",
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(dd.edge_profiles.grid_ggd, dd.edge_profiles.ggd[1].electrons.density[5]) # Note default label in colorbar\n",
"plot!(space, SOLPS2IMAS.get_grid_subset_with_index(grid_ggd, 16), linecolor=:red, linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true)"
"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, linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
222 changes: 222 additions & 0 deletions examples/plotting_interferometer.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Plotting interferometer 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/OMAS.jl.git\")\n",
"Pkg.develop(path=\"../\")\n",
"Pkg.add(\"Plots\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using OMAS\n",
"using GGDUtils\n",
"using Plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load the interferometer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ids = OMAS.json2imas(\"$(@__DIR__)/../samples/time_dep_edge_profiles_with_interferometer.json\")\n",
"grid_ggd = ids.edge_profiles.grid_ggd[1]\n",
"space = grid_ggd.space[1]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plotting the interferometer geometry on top of SOLPS mesh"
]
},
{
"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)\n",
"plot!(ids.interferometer) # Default plot_type is :los \n",
"plot!(legend=true)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can provide custom lengthand thickness of mirror to be plotted and linewidth of the laser beams"
]
},
{
"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)\n",
"plot!(ids.interferometer, mirror_length=0.7, linewidth=4, mirror_thickness=0.2)\n",
"plot!(legend=true)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or you can choose to omit the mirror"
]
},
{
"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)\n",
"plot!(ids.interferometer, mirror=false)\n",
"plot!(legend=true)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can plot a single channel as well. You can override the in-built channel name for the label."
]
},
{
"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)\n",
"plot!(ids.interferometer.channel[1], label=\"Channel 1\")\n",
"plot!(legend=true)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plotting interferometer data vs time\n",
"\n",
" * Use plot_type=:n_e for integrated electron density data\n",
" * Use plot_type=:n_e_average for averaged electron density data\n"
]
},
{
"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(ids.interferometer, plot_type=:n_e)"
]
},
{
"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(ids.interferometer, plot_type=:n_e_average)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again, to plot an individual channel, just provide the channel with correct plot_type"
]
},
{
"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(ids.interferometer.channel[1], plot_type=:n_e_average)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.9.2",
"language": "julia",
"name": "julia-1.9"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.2"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
6 changes: 2 additions & 4 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/edge_profiles.h5
/b2time.nc
/b2mn.dat
/b2fgmtry
/time_dep_edge_profiles_last_step_only.json
/time_dep_edge_profiles_with_interferometer.json
12 changes: 0 additions & 12 deletions samples/b2fgmtry.dvc

This file was deleted.

12 changes: 0 additions & 12 deletions samples/b2mn.dat.dvc

This file was deleted.

13 changes: 0 additions & 13 deletions samples/b2time.nc.dvc

This file was deleted.

Binary file removed samples/b2time_red.nc
Binary file not shown.
Loading