Skip to content

Commit

Permalink
Merge pull request #16 from ProjectTorreyPines/dev
Browse files Browse the repository at this point in the history
Releasing v0.1.0
  • Loading branch information
anchal-physics authored Oct 4, 2023
2 parents eb2c8a8 + 797fc9b commit 47a30de
Show file tree
Hide file tree
Showing 20 changed files with 1,085 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
align_assignment = true
align_conditional = true
align_matrix = true
align_pair_arrow = true
align_struct_field = true
always_for_in = true
always_use_return = true
annotate_untyped_fields_with_any = false
conditional_to_if = true
for_in_replacement = ""
format_docstrings = true
import_to_using = true
indent = 4
indent_submodule = true
join_lines_based_on_source = true
long_to_short_function_def = true
margin = 88
normalize_line_endings = "unix"
pipe_to_function_call = true
remove_extra_newlines = true
separate_kwargs_with_semicolon = true
surround_whereop_typeparameters = true
trailing_comma = true
whitespace_in_kwargs = false
whitespace_ops_in_indices = false
whitespace_typedefs = true
yas_style_nesting = true
3 changes: 3 additions & 0 deletions .dvc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/config.local
/tmp
/cache
Empty file added .dvc/config
Empty file.
3 changes: 3 additions & 0 deletions .dvcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add patterns of files dvc should ignore, which could improve
# the performance. Learn more at
# https://dvc.org/doc/user-guide/dvcignore
36 changes: 36 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Format Check

on:
push:
branches: ["master", "dev", "format"]
pull_request:
branches: ["master", "dev"]
jobs:
check:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.9.3]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
14 changes: 14 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "GGDUtils"
uuid = "b7b5e640-9b39-4803-84eb-376048795def"
authors = ["Anchal Gupta <[email protected]>"]
version = "0.1.0"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
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"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# GGDUtils

![Format Check](https://github.com/ProjectTorreyPines/GGDUtils.jl/actions/workflows/format_check.yml/badge.svg)

Package holding utilities for Generalized Grid Description (GGD) objects in IMAS datastructure. Primary goals are interpolation and core profile extrapolation.
11 changes: 11 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "GGDUtils_examples"
authors = ["Anchal Gupta <[email protected]>"]
version = "0.1.0"

[deps]
GGDUtils = "b7b5e640-9b39-4803-84eb-376048795def"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
OMAS = "91cfaa06-6526-4804-8666-b540b3feef2f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SOLPS2IMAS = "09becab6-0636-4c23-a92a-2b3723265c31"
171 changes: 171 additions & 0 deletions examples/plotting.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{
"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/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.add(\"Plots\")\n",
"Pkg.add(\"LaTeXStrings\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using SOLPS2IMAS\n",
"using GGDUtils\n",
"using Plots\n",
"using LaTeXStrings"
]
},
{
"cell_type": "code",
"execution_count": null,
"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",
"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"
]
},
{
"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, 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",
"\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"
]
},
{
"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",
"plot(dd.edge_profiles.grid_ggd, dd.edge_profiles.ggd[1].electrons.density[5], colorbar_title=\"Electrons density / \" * L\"m^{-3}\")"
]
},
{
"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, 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)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}
4 changes: 4 additions & 0 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/edge_profiles.h5
/b2time.nc
/b2mn.dat
/b2fgmtry
12 changes: 12 additions & 0 deletions samples/b2fgmtry.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
md5: bcf05d7d7b6d91ef1025c0dc018c4bbf
frozen: true
deps:
- path: ITER_Lore_2296_00000/baserun/b2fgmtry
repo:
url: [email protected]:ProjectTorreyPines/SOLPSTestSamples.git
rev_lock: df499f1275428ec06175c48dc4af6ecbd5ec6117
outs:
- md5: 6589953daeef49b21744d159af970cbb
size: 2908856
hash: md5
path: b2fgmtry
12 changes: 12 additions & 0 deletions samples/b2mn.dat.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
md5: c0c920771883f03bc0abe98425b38d5e
frozen: true
deps:
- path: ITER_Lore_2296_00000/run_time_dep_EIRENE_jdl_to_ss_cont_sine2_2d_output/b2mn.dat
repo:
url: [email protected]:ProjectTorreyPines/SOLPSTestSamples.git
rev_lock: df499f1275428ec06175c48dc4af6ecbd5ec6117
outs:
- md5: 1af9d167996ea1a420f49e0d89c98e6d
size: 13925
hash: md5
path: b2mn.dat
13 changes: 13 additions & 0 deletions samples/b2time.nc.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
md5: b94876ee58c5d62734d4ee32c28bb0da
frozen: true
deps:
- path:
ITER_Lore_2296_00000/run_time_dep_EIRENE_jdl_to_ss_cont_sine2_2d_output/b2time.nc
repo:
url: [email protected]:ProjectTorreyPines/SOLPSTestSamples.git
rev_lock: df499f1275428ec06175c48dc4af6ecbd5ec6117
outs:
- md5: 778b3bb62b82f493c785373d872f6a1f
size: 13630424
hash: md5
path: b2time.nc
Binary file added samples/b2time_red.nc
Binary file not shown.
12 changes: 12 additions & 0 deletions samples/edge_profiles.h5.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
md5: 583339f63b0b4d2aa3f7f7a659a5b07c
frozen: true
deps:
- path: ITER_Lore_2296_00000/IMAS/edge_profiles.h5
repo:
url: [email protected]:ProjectTorreyPines/SOLPSTestSamples.git
rev_lock: df499f1275428ec06175c48dc4af6ecbd5ec6117
outs:
- md5: c3d60ce69e9d3a9b9ec621e9276858e0
size: 168176600
hash: md5
path: edge_profiles.h5
Loading

0 comments on commit 47a30de

Please sign in to comment.