Skip to content

Commit

Permalink
Replace IMASDD with IMASdd
Browse files Browse the repository at this point in the history
  • Loading branch information
eldond committed Aug 1, 2024
1 parent 79e61cc commit 3058dc0
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 147 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ version = "1.0.2"
[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
IMASDD = "06b86afa-9f21-11ec-2ef8-e51b8960cfc5"
EFIT = "cda752c5-6b03-55a3-9e33-132a441b0c17"
IMASdd = "c5a45a97-b3f9-491c-b9a7-aa88c3bc0067"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Expand All @@ -17,7 +18,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
ArgParse = "1"
ColorSchemes = "3"
IMASDD = "0.1, 1"
Interpolations = "0.15"
NearestNeighbors = "0.4"
RecipesBase = "1"
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# using Pkg
# Pkg.add("Documenter")
# Pkg.add(; url="https://github.com/ProjectTorreyPines/IMASDD.jl.git");
# Pkg.add(; url="https://github.com/ProjectTorreyPines/IMASdd.jl.git");
# Pkg.develop(PackageSpec(; path="../"));
# Pkg.instantiate()
using Documenter
Expand Down
18 changes: 9 additions & 9 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ get_types_with

Several plot recipes have been defined for easy visualization.
```@docs
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.edge_profiles__grid_ggd___space)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.edge_profiles__grid_ggd___space, ::GGDUtils.IMASDD.edge_profiles__grid_ggd___grid_subset)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.edge_profiles__grid_ggd, ::GGDUtils.IMASDD.IDSvectorElement)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::AbstractVector{<:GGDUtils.IMASDD.edge_profiles__grid_ggd}, ::GGDUtils.IMASDD.IDSvectorElement)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.interferometer)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.interferometer__channel)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.interferometer__channel___line_of_sight)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.interferometer__channel___n_e_line)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASDD.interferometer__channel___n_e_line_average)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.edge_profiles__grid_ggd___space)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.edge_profiles__grid_ggd___space, ::GGDUtils.IMASdd.edge_profiles__grid_ggd___grid_subset)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.edge_profiles__grid_ggd, ::GGDUtils.IMASdd.IDSvectorElement)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::AbstractVector{<:GGDUtils.IMASdd.edge_profiles__grid_ggd}, ::GGDUtils.IMASdd.IDSvectorElement)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.interferometer)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.interferometer__channel)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.interferometer__channel___line_of_sight)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.interferometer__channel___n_e_line)
RecipesBase.apply_recipe(::Dict{Symbol,Any}, ::GGDUtils.IMASdd.interferometer__channel___n_e_line_average)
```
6 changes: 3 additions & 3 deletions examples/plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"source": [
"using Pkg\n",
"Pkg.activate(\"./\")\n",
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/IMASDD.jl.git\")\n",
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/IMASdd.jl.git\")\n",
"Pkg.develop(path=\"../\")\n",
"Pkg.add(\"Plots\")\n",
"Pkg.add(\"LaTeXStrings\")"
Expand All @@ -36,7 +36,7 @@
"metadata": {},
"outputs": [],
"source": [
"using IMASDD\n",
"using IMASdd\n",
"using GGDUtils\n",
"using Plots\n",
"using LaTeXStrings"
Expand All @@ -48,7 +48,7 @@
"metadata": {},
"outputs": [],
"source": [
"dd = IMASDD.json2imas(\"../samples/time_dep_edge_profiles_last_step_only.json\");\n",
"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];"
]
Expand Down
6 changes: 3 additions & 3 deletions examples/plotting_interferometer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"source": [
"using Pkg\n",
"Pkg.activate(\"./\")\n",
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/IMASDD.jl.git\")\n",
"Pkg.add(url=\"[email protected]:ProjectTorreyPines/IMASdd.jl.git\")\n",
"Pkg.develop(path=\"../\")\n",
"Pkg.add(\"Plots\")"
]
Expand All @@ -35,7 +35,7 @@
"metadata": {},
"outputs": [],
"source": [
"using IMASDD\n",
"using IMASdd\n",
"using GGDUtils\n",
"using Plots"
]
Expand All @@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"ids = IMASDD.json2imas(\"$(@__DIR__)/../samples/time_dep_edge_profiles_with_interferometer.json\");\n",
"ids = IMASdd.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];"
]
Expand Down
2 changes: 1 addition & 1 deletion src/GGDUtils.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GGDUtils

using IMASDD: IMASDD
using IMASdd: IMASdd

const inv_16pi = 1.0 / (16π)

Expand Down
68 changes: 34 additions & 34 deletions src/interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export get_kdtree
export get_TPS_mats

"""
get_kdtree(space::IMASDD.edge_profiles__grid_ggd___space)
get_kdtree(space::IMASdd.edge_profiles__grid_ggd___space)
Get a KDTree for all the cells in the space for search for nearest neighbours.
"""
function get_kdtree(space::IMASDD.edge_profiles__grid_ggd___space)
function get_kdtree(space::IMASdd.edge_profiles__grid_ggd___space)
grid_nodes = space.objects_per_dimension[1].object
grid_faces = space.objects_per_dimension[3].object
grid_faces = [cell for cell grid_faces if length(cell.nodes) == 4]
Expand All @@ -25,15 +25,15 @@ end

"""
get_kdtree(
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset,
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset,
)
Get a KDTree for a subset of the space for search for nearest neighbours.
"""
function get_kdtree(
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset,
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset,
)
subset_centers = get_subset_centers(space, subset)
return KDTree([SVector{2}(sc) for sc subset_centers]; leafsize=10)
Expand Down Expand Up @@ -178,15 +178,15 @@ function interp(y::Vector{T}, x::Vector{Tuple{U, U}}) where {T <: Real, U <: Rea
return interp(y, get_TPS_mats(x))
end

function get_TPS_mats(space::IMASDD.edge_profiles__grid_ggd___space)
function get_TPS_mats(space::IMASdd.edge_profiles__grid_ggd___space)
nodes = [Tuple(node.geometry) for node space.objects_per_dimension[1].object]
return get_TPS_mats(nodes)
end

"""
interp(
prop_values::Vector{T},
space::IMASDD.edge_profiles__grid_ggd___space
space::IMASdd.edge_profiles__grid_ggd___space
) where {T <: Real}
If the whole space is provided instead of a kdtree, calculate the kdtree for whole
Expand All @@ -195,40 +195,40 @@ of the space.
"""
function interp(
prop_values::Vector{T},
space::IMASDD.edge_profiles__grid_ggd___space,
space::IMASdd.edge_profiles__grid_ggd___space,
) where {T <: Real}
return interp(prop_values, get_TPS_mats(space))
end

function get_TPS_mats(
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset,
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset,
)
return get_TPS_mats(get_subset_centers(space, subset))
end

"""
interp(
prop_values::Vector{Real},
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset
)
If a subset of the space is provided, calculate the kdtree for the subset. In this case
it is assumed that the property values are provided for each element of the subset.
"""
function interp(
prop_values::Vector{T},
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset,
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset,
) where {T <: Real}
return interp(prop_values, get_TPS_mats(space, subset))
end

"""
interp(
prop::edge_profiles__prop_on_subset,
grid_ggd::IMASDD.edge_profiles__grid_ggd,
grid_ggd::IMASdd.edge_profiles__grid_ggd,
value_field::Symbol=:values
)
Expand All @@ -242,7 +242,7 @@ get_e_field_par = interp(dd.edge_profiles.ggd[1].e_field[1], grid_ggd, :parallel
"""
function interp(
prop::edge_profiles__prop_on_subset,
grid_ggd::IMASDD.edge_profiles__grid_ggd,
grid_ggd::IMASdd.edge_profiles__grid_ggd,
value_field::Symbol=:values,
)
subset = get_grid_subset(grid_ggd, prop.grid_subset_index)
Expand All @@ -253,8 +253,8 @@ end
"""
interp(
prop_arr::AbstractVector{T},
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset,
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset,
value_field::Symbol=:values
) where {T <: edge_profiles__prop_on_subset}
Expand All @@ -267,8 +267,8 @@ get_electron_density = interp(dd.edge_profiles.ggd[1].electrons.density, space,
"""
function interp(
prop_arr::AbstractVector{T},
space::IMASDD.edge_profiles__grid_ggd___space,
subset::IMASDD.edge_profiles__grid_ggd___grid_subset,
space::IMASdd.edge_profiles__grid_ggd___space,
subset::IMASdd.edge_profiles__grid_ggd___grid_subset,
value_field::Symbol=:values,
) where {T <: edge_profiles__prop_on_subset}
prop = get_prop_with_grid_subset_index(prop_arr, subset.identifier.index)
Expand All @@ -278,7 +278,7 @@ end
"""
interp(
prop_arr::AbstractVector{T},
grid_ggd::IMASDD.edge_profiles__grid_ggd,
grid_ggd::IMASdd.edge_profiles__grid_ggd,
grid_subset_index::Int,
value_field::Symbol=:values
) where {T <: edge_profiles__prop_on_subset}
Expand All @@ -291,7 +291,7 @@ get_n_e_sep = interp(dd.edge_profiles.ggd[1].electrons.density, grid_ggd, 16)
"""
function interp(
prop_arr::AbstractVector{T},
grid_ggd::IMASDD.edge_profiles__grid_ggd,
grid_ggd::IMASdd.edge_profiles__grid_ggd,
grid_subset_index::Int,
value_field::Symbol=:values,
) where {T <: edge_profiles__prop_on_subset}
Expand All @@ -301,7 +301,7 @@ function interp(
return interp(getfield(prop, value_field), space, subset)
end

function get_TPS_mats(grid_ggd::IMASDD.edge_profiles__grid_ggd, grid_subset_index::Int)
function get_TPS_mats(grid_ggd::IMASdd.edge_profiles__grid_ggd, grid_subset_index::Int)
subset = get_grid_subset(grid_ggd, grid_subset_index)
space = grid_ggd.space[subset.element[1].object[1].space]
return get_TPS_mats(space, subset)
Expand Down Expand Up @@ -345,7 +345,7 @@ const RHO_EXT_POS = [1.0001, 1.1, 5]
const RHO_EXT_NEG = [-5, -0.0001] # I guess this would be at a PF coil or something?

"""
interp(eqt::IMASDD.equilibrium__time_slice)
interp(eqt::IMASdd.equilibrium__time_slice)
For a given equilibrium time slice, return a function that can be used to interpolate
from (r, z) space to rho (normalized toroidal flux coordinate)space.
Expand All @@ -357,7 +357,7 @@ rz2rho = interp(dd.equilibrium.time_slice[1])
rho = rz2rho.([(r, z) for r ∈ 3.0:0.01:9.0, z ∈ -5.0:0.01:5.0])
```
"""
function interp(eqt::IMASDD.equilibrium__time_slice)
function interp(eqt::IMASdd.equilibrium__time_slice)
p1 = eqt.profiles_1d
p2 = eqt.profiles_2d[1]
gq = eqt.global_quantities
Expand Down Expand Up @@ -388,7 +388,7 @@ end
"""
interp(
prop::Vector{T},
prof::IMASDD.core_profiles__profiles_1d,
prof::IMASdd.core_profiles__profiles_1d,
) where {T <: Real}
Returns an inteprolation function for the core profile property values defined on
Expand All @@ -404,7 +404,7 @@ get_n_e(1) # Returns electron density at rho = 1 (separatix)
"""
function interp(
prop::Vector{T},
prof::IMASDD.core_profiles__profiles_1d,
prof::IMASdd.core_profiles__profiles_1d,
) where {T <: Real}
rho_prof = copy(prof.grid.rho_tor_norm)
length(prop) == length(rho_prof) ||
Expand All @@ -420,7 +420,7 @@ end
"""
interp(
prop::Vector{T},
prof::IMASDD.core_profiles__profiles_1d,
prof::IMASdd.core_profiles__profiles_1d,
rz2rho::Function,
)
Expand All @@ -439,7 +439,7 @@ get_n_e(5.0, 3.5) # Returns electron density at (R, Z) = (5.0, 3.5)
"""
function interp(
prop::Vector{T},
prof::IMASDD.core_profiles__profiles_1d,
prof::IMASdd.core_profiles__profiles_1d,
rz2rho::Function,
) where {T <: Real}
itp = interp(prop, prof)
Expand All @@ -452,8 +452,8 @@ end
"""
interp(
prop::Vector{T},
prof::IMASDD.core_profiles__profiles_1d,
eqt::IMASDD.equilibrium__time_slice,
prof::IMASdd.core_profiles__profiles_1d,
eqt::IMASdd.equilibrium__time_slice,
) where {T <: Real}
Returns an inteprolation function in (R, Z) domain for the core profile property values
Expand All @@ -471,8 +471,8 @@ get_n_e(5.0, 3.5) # Returns electron density at (R, Z) = (5.0, 3.5)
"""
function interp(
prop::Vector{T},
prof::IMASDD.core_profiles__profiles_1d,
eqt::IMASDD.equilibrium__time_slice,
prof::IMASdd.core_profiles__profiles_1d,
eqt::IMASdd.equilibrium__time_slice,
) where {T <: Real}
rz2rho = interp(eqt)
return interp(prop, prof, rz2rho)
Expand Down
Loading

0 comments on commit 3058dc0

Please sign in to comment.