Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Add glass map #164

Merged
merged 21 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions src/GlassCat/GlassCat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ using Unitful
using StaticArrays
using Base: @.
import Unitful: Length, Temperature, Quantity, Units
using Unitful.DefaultSymbols
using Pkg
using ForwardDiff

include("constants.jl")

Expand Down
25 changes: 25 additions & 0 deletions src/GlassCat/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,28 @@ function plot_indices(glass::AbstractGlass; polyfit::Bool = false, fiterror::Boo

gui(p)
end


""" Draw a scatter plot of index vs dispersion (the derivative of index with respect to wavelength). Both index and dispersion are computed at wavelength λ. If showprefixglasses is true then glasses with names like F_BAK7 will be displayed. Otherwise glasses that have a leading letter prefix followed by an underscore, such as F_, will not be displayed."""
function drawglassmap(glasscatalog::Module; λ = 550nm, glassfontsize = 3, showprefixglasses = false)
wavelength = Float64(ustrip(uconvert(u"μm", λ)))
indices = Vector{Float64}(undef,0)
dispersions = Vector{Float64}(undef,0)
glassnames = Vector{String}(undef,0)

for name in names(glasscatalog)
glass = eval(:($glasscatalog.$name))
glassstring = String(name)
hasprefix = occursin("_",glassstring)
alfredclwong marked this conversation as resolved.
Show resolved Hide resolved

if typeof(glass) !== Module && index(glass,wavelength) > 0 && index(glass,wavelength) < 3 && (showprefixglasses ? true : !hasprefix)
alfredclwong marked this conversation as resolved.
Show resolved Hide resolved
f(x) = index(glass,x)
push!(indices,index(glass,wavelength))
g = x -> ForwardDiff.derivative(f, x);
push!(dispersions, -g(wavelength))
push!(glassnames,String(name))
end
end
series_annotations = Plots.series_annotations(glassnames, Plots.font(family = "Sans", pointsize = glassfontsize, color = RGB(0.0,0.0,.4)))
scatter(dispersions,indices, xaxis = "dispersion", yaxis = "index", series_annotations = series_annotations, markersize = .001, legends = :none, markershape = :none)
end