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

Glasscat tests #152

Merged
merged 16 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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 src/GlassCat/GlassCat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if !isfile(AGFGLASSCAT_PATH)
end
include("data/jl/AGFGlassCat.jl") # this needs to be literal for intellisense to work
include("data/jl/CARGILLE.jl")
export CARGILLE

# include functionality for managing runtime (dynamic) glass cats: MIL_GLASSES and MODEL_GLASSES
include("runtime.jl")
Expand Down
167 changes: 0 additions & 167 deletions src/GlassCat/GlassTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,170 +338,3 @@ function info(io::IO, glass::Glass)
end

info(g::AbstractGlass) = info(stdout, g)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the docstring function being permanently deleted or did you just move it somewhere? Even though we're not using it much now it seems to be functioning ok. Other people might find it useful for making tools to analyze glasses. Is it necessary to remove it?

Copy link
Collaborator Author

@alfredclwong alfredclwong Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took it out because it seemed like duplicate code (I can't remember where from), it was unused, and it was lowering our test coverage.


Just had a look and it seems to be essentially the same as info() above but without the padding. We should really have a third function to handle the data extraction such that info() and docstring() only need to handle the string formatting.

The other thing that confused me was that we weren't even using docstring() to generate the docstrings for GlassCat - we had an abbreviated version seen in generate.jl > glassinfo_to_docstring. This is essentially a triple duplicate - what do you think we should keep?

Copy link
Collaborator

@friggog friggog Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a look and it seems to be essentially the same as info() above but without the padding

This is basically what it did - just printed the same stuff as info with correct formatting for documentation generation - I don't see much need for it if we don't have glass docs any more.

I think glass catalog jl files get written with short form information for tooltips in VS Code, this function was used specifically for long form information for use in generation of the documentation website

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrianGun you can have the final say - if you want to keep the code then feel free to git revert d3197a2

function docstring(io::IO, glass::Glass)
D = glass.dispform

println(io, "**ID**$(glass.ID)\n")

if (D == -2)
println(io, "**Dispersion formula**Cauchy (-2)\n")
elseif (D == -1)
println(io, "**Dispersion formula**Fitted for model/MIL glass\n")
else
println(io, "**Dispersion formula**$(DISPFORM_NAMES[D]) ($D)\n")
end
println(io, "**Dispersion formula coefficients**\n")
println(io, "|Coefficient|Value|")
println(io, "|:----------|-----|")
if (D == -2) # Cauchy
println(io, "|A |$(glass.C1)|")
println(io, "|B |$(glass.C2)|")
println(io, "|C |$(glass.C3)|")
println(io, "|D |$(glass.C4)|")
println(io, "|E |$(glass.C5)|")
println(io, "|F |$(glass.C6)|")
elseif (D == -1)
println(io, "|C₀|$(glass.C1)|")
println(io, "|C₁|$(glass.C2)|")
println(io, "|C₂|$(glass.C3)|")
println(io, "|C₃|$(glass.C4)|")
elseif (D == 1) # Schott
println(io, "|a₀|$(glass.C1)|")
println(io, "|a₁|$(glass.C2)|")
println(io, "|a₂|$(glass.C3)|")
println(io, "|a₃|$(glass.C4)|")
println(io, "|a₄|$(glass.C5)|")
println(io, "|a₅|$(glass.C6)|")
elseif (D == 2) # Sellmeier1
println(io, "|K₁|$(glass.C1)|")
println(io, "|L₁|$(glass.C2)|")
println(io, "|K₂|$(glass.C3)|")
println(io, "|L₂|$(glass.C4)|")
println(io, "|K₃|$(glass.C5)|")
println(io, "|L₃|$(glass.C6)|")
elseif (D == 3) # Herzberger
println(io, "|A |$(glass.C1)|")
println(io, "|B |$(glass.C2)|")
println(io, "|C |$(glass.C3)|")
println(io, "|D |$(glass.C4)|")
println(io, "|E |$(glass.C5)|")
println(io, "|F |$(glass.C6)|")
elseif (D == 4) # Sellmeier2
println(io, "|A |$(glass.C1)|")
println(io, "|B₁|$(glass.C2)|")
println(io, "|λ₁|$(glass.C3)|")
println(io, "|B₂|$(glass.C4)|")
println(io, "|λ₂|$(glass.C5)|")
elseif (D == 5) # Conrady
println(io, "|n₀|$(glass.C1)|")
println(io, "|A |$(glass.C2)|")
println(io, "|B |$(glass.C3)|")
elseif (D == 6) # Sellmeier3
println(io, "|K₁|$(glass.C1)|")
println(io, "|L₁|$(glass.C2)|")
println(io, "|K₂|$(glass.C3)|")
println(io, "|L₂|$(glass.C4)|")
println(io, "|K₃|$(glass.C5)|")
println(io, "|L₃|$(glass.C6)|")
println(io, "|K₄|$(glass.C7)|")
println(io, "|L₄|$(glass.C8)|")
elseif (D == 7) || (D == 8) # HandbookOfOptics1/2
println(io, "|A |$(glass.C1)|")
println(io, "|B |$(glass.C2)|")
println(io, "|C |$(glass.C3)|")
println(io, "|D |$(glass.C4)|")
elseif (D == 9) # Sellmeier4
println(io, "|A |$(glass.C1)|")
println(io, "|B |$(glass.C2)|")
println(io, "|C |$(glass.C3)|")
println(io, "|D |$(glass.C4)|")
println(io, "|E |$(glass.C5)|")
elseif (D == 10) || (D == 12) # Extended1/2
println(io, "|a₀|$(glass.C1)|")
println(io, "|a₁|$(glass.C2)|")
println(io, "|a₂|$(glass.C3)|")
println(io, "|a₃|$(glass.C4)|")
println(io, "|a₄|$(glass.C5)|")
println(io, "|a₅|$(glass.C6)|")
println(io, "|a₆|$(glass.C7)|")
println(io, "|a₇|$(glass.C8)|")
elseif (D == 11) # Sellmeier5
println(io, "|K₁|$(glass.C1)|")
println(io, "|L₁|$(glass.C2)|")
println(io, "|K₂|$(glass.C3)|")
println(io, "|L₂|$(glass.C4)|")
println(io, "|K₃|$(glass.C5)|")
println(io, "|L₃|$(glass.C6)|")
println(io, "|K₄|$(glass.C7)|")
println(io, "|L₄|$(glass.C8)|")
println(io, "|K₅|$(glass.C9)|")
println(io, "|L₅|$(glass.C10)|")
elseif (D == 13) # Extended3
println(io, "|a₀|$(glass.C1)|")
println(io, "|a₁|$(glass.C2)|")
println(io, "|a₂|$(glass.C3)|")
println(io, "|a₃|$(glass.C4)|")
println(io, "|a₄|$(glass.C5)|")
println(io, "|a₅|$(glass.C6)|")
println(io, "|a₆|$(glass.C7)|")
println(io, "|a₇|$(glass.C8)|")
println(io, "|a₈|$(glass.C9)|")
else
println(io, " INVALID DISPERSION FORMULA!!\n")
end
println(io)

println(io, "**Valid wavelengths**$(glass.λmin)μm to $(glass.λmax)μm\n")
println(io, "**Reference temperature**$(glass.temp)°C\n")

if !isnan(glass.D₀) && (glass.D₀ != 0 || glass.D₁ != 0 || glass.D₂ != 0 || glass.E₀ != 0 || glass.E₁ != 0)
println(io, "**Thermal ΔRI coefficients**\n")
println(io, "|Coefficient |Value |")
println(io, "|:---------------------------|-----------|")
println(io, "|D₀ |$(glass.D₀)|")
println(io, "|D₁ |$(glass.D₁)|")
println(io, "|D₂ |$(glass.D₂)|")
println(io, "|E₀ |$(glass.E₀)|")
println(io, "|E₁ |$(glass.E₁)|")
println(io, "|λₜₖ |$(glass.λₜₖ)|")
println(io)
end

println(io, "**TCE (÷1e-6)**$(glass.TCE)\n")
println(io, "**Ignore thermal expansion**$(glass.ignore_thermal_exp == 1)\n")

println(io, "**Density (p)**$(glass.p)g/m³\n")
println(io, "**ΔPgF**$(glass.ΔPgF)\n")

println(io, "**RI at sodium D-Line (587nm)**$(glass.Nd)\n")
println(io, "**Abbe Number**$(glass.Vd)\n")

println(io, "**Cost relative to N_BK7**$(glass.relcost == -1 ? "?" : glass.relcost)\n")

if glass.CR != -1 || glass.FR != -1 || glass.SR != -1 || glass.AR != -1 || glass.PR != -1
println(io, "**Environmental resistance**\n")
println(io, "|Environment |Resistance |")
println(io, "|:-------------|----------------------------------|")
println(io, "|Climate (CR) |$(glass.CR == -1 ? "?" : glass.CR)|")
println(io, "|Stain (FR) |$(glass.FR == -1 ? "?" : glass.FR)|")
println(io, "|Acid (SR) |$(glass.SR == -1 ? "?" : glass.SR)|")
println(io, "|Alkaline (AR) |$(glass.AR == -1 ? "?" : glass.AR)|")
println(io, "|Phosphate (PR)|$(glass.PR == -1 ? "?" : glass.PR)|")
println(io)
end

println(io, "**Status**$(STATUS[glass.status + 1]) ($(glass.status))\n")
println(io, "**Melt frequency**$(glass.meltfreq == -1 ? "?" : glass.meltfreq)\n")
println(io, "**Exclude substitution**$(glass.exclude_sub == 1)\n")

if glass.transmission !== nothing
println(io, "**Transmission data**\n")
println(io, "|Wavelength|Transmission|Thickness|")
println(io, "|----------|------------|---------|")
for i in 1:(glass.transmissionN)
λ, t, τ = glass.transmission[i]
println(io, "|$(λ)μm|$t|$(τ)mm|")
end
end
end
Loading