-
Notifications
You must be signed in to change notification settings - Fork 5
PlottingTools.jl
This module contains a bunch of functions and recipes for convenience to plot results from tmm_optics, fit_tmm_optics and three_omega. It can also serve for solutions from fit_curve_model.
This is an optional module that exports functions for convenience, otherwise, you can use your own. All the recipes are based on RecipesBase.jl so you need to load Plots.jl when using any of the functions as below. To install Plots
, type:
julia> ]
pkg> add Plots
Plots.jl has different backends for plotting. By default, uses GR.jl, which is installed with Plots
. Another alternative is PyPlot.jl, which is a wrapper around Matplotlib library. You can install it by typing:
julia> ]
pkg> add PyPlot
If you don't feel like using the PlottingTools.jl, you can load the plotting library you desire, and use it instead. Check the visualization ecosystem available in Julia here.
The options to plot the results from tmm_optics
are more numerous given the number of results obtained from running this method.
Plot the spectrum of reflectance, transmittance, or/and absorbance as a function of the wavelength.
plot(Spectrum1D(), λ, S; s=(640,480))
gui()
where λ
is the wavelength range, and S
is the array of spectra.
Plot the spectrum of reflectance, transmittance, or/and absorbance as a function of the angle of incidence.
plot(SpectrumAngle1D(), θ, S, s=(640,480))
gui()
where θ
is the array of angles of incidence, and S
is the array of spectra.
When you calculate the spectra for both parameters, you can use this recipe to plot the spectra (reflectance, transmittance, and absorbance) for λ and θ.
plot(Spectrum2D(), λ, θ, S; num_levels=80, s=(640,480))
gui()
where num_levels
is an optional parameter for the number of levels in the contour plot.
Plot the electromagnetic field distribution (EMF) for depth and λ, at a given angle of incidence θ. In this case, you have to select yourself which angle of incidence you choose, passing the correct emf array:
plot(EMF2D(), λ, ℓ, emf; num_levels=80, s=(640,480))
gui()
where ℓ
is the depth of the multilayer that takes into account the h
parameter, and emf
is the selected field distribution for plotting.
Plot the electromagnetic field distribution (EMF) for depth and θ, at a given λ. In this case, you have to select yourself which wavelength you choose, passing the correct emf array:
plot(EMFAngle2D(), θ, ℓ, emf; num_levels=80, s=(640,480))
gui()
Plot the indices of refraction at a certain wavelength (default to λ0) and angle of incidence (default to θ[1]) of a multilayer structure computed from tmm_optics
.
plot(RIprofile(), solution;
plotemf=false, wave=:b, λ=[solution.Misc.λ0],
θ=[solution.Beam.θ[1]], s=(640,480))
If the EMF was also calculated, you can pass plotemf=true
, then a second plot shows the EMF overlapping the profile of indices of refraction across the multilayer. This is useful to see the field distribution inside the structure. Here, you can pass the optional parameter wave=:p
for p/TM-wave, or wave=:s
for the s/TE-wave of the EMF to overlap. By default wave=:b
, plots both types of polarisation.
Plots the photonic dispersion of a binary perfect photonic crystal, using the indices of refraction and the thicknesses of the two different layers of the structure. For this type of plot there exist several recipes depending on the dimension of the Bloch wavevector.
1D option
This is used when you computed the photonic dispersion using a range of wavelengths and one angle of incidence.
plot(PBGDispersion1D(), solution.Bloch; kpart=:real, wave=:p, s=(640,480))
plot(PBGDispersion1Dimre(), solution.Bloch; wave=:p, s=(640,480))
plot(PBGDispersion1Dalt(), solution.Bloch; kpart=:real, s=(640,480))
2D option
This is used when you computed the photonic dispersion using a range of wavelengths and a range of angles of incidence.
plot(PBGDispersion2D(), solution.Bloch; wave=:p, s=(640,480), num_levels=90)
plot(PBGDispersion2Dalt(), solution.Bloch; s=(640,480), num_levels=90)
These plots also draw the light line and the range to mid-range ratio as described here.
The results from any of these fitting procedures can be plotted using the following recipe:
plot(FitSpectrum(), solution.Beam.λ, solution.spectrumExp, solution.spectrumFit)
If you used the SpaceSolutionEMA
function you can also get the map of the objective function as follow:
plot(SpaceSolution(),
solution.od, solution.p, solution.solSpace,
xaxis=("Optical thickness [nm]"), yaxis=("Porosity"))
The results from three_omega
are quite simple and the recipe to plot them can be invoked as follow:
plot(TOMPlot(), solution; s=(640,480))
where solution
is a structure returned by three_omega
, and s
is an optional parameter for the size of the figure.