Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OPOSSUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
phelix
rust
OPOSSUM
Commits
a420a5d8
Commit
a420a5d8
authored
1 year ago
by
Udo Eisenbarth
Browse files
Options
Downloads
Patches
Plain Diff
Update documentation
parent
1166f2c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/beam_combine_test.rs
+5
-2
5 additions, 2 deletions
examples/beam_combine_test.rs
src/nodes/node_beam_splitter.rs
+3
-3
3 additions, 3 deletions
src/nodes/node_beam_splitter.rs
src/optic_scenery.rs
+1
-6
1 addition, 6 deletions
src/optic_scenery.rs
src/spectrum.rs
+17
-4
17 additions, 4 deletions
src/spectrum.rs
with
26 additions
and
15 deletions
examples/beam_combine_test.rs
+
5
−
2
View file @
a420a5d8
...
...
@@ -27,8 +27,11 @@ fn main() -> Result<(), OpossumError> {
})),
);
let
i_bs
=
scenery
.add_element
(
"Beam splitter"
,
BeamSplitter
::
new
(
0.5
));
let
filter_spectrum
=
Spectrum
::
from_csv
(
"NE03B.csv"
)
?
;
let
i_f
=
scenery
.add_element
(
"Filter"
,
IdealFilter
::
new
(
FilterType
::
Spectrum
(
filter_spectrum
))
?
);
let
filter_spectrum
=
Spectrum
::
from_csv
(
"NE03B.csv"
)
?
;
let
i_f
=
scenery
.add_element
(
"Filter"
,
IdealFilter
::
new
(
FilterType
::
Spectrum
(
filter_spectrum
))
?
,
);
let
i_d1
=
scenery
.add_element
(
"Detector 1"
,
Detector
::
default
());
scenery
.connect_nodes
(
i_s1
,
"out1"
,
i_bs
,
"input1"
)
?
;
...
...
This diff is collapsed.
Click to expand it.
src/nodes/node_beam_splitter.rs
+
3
−
3
View file @
a420a5d8
...
...
@@ -6,7 +6,7 @@ use crate::{
lightdata
::{
DataEnergy
,
LightData
},
optic_node
::{
Dottable
,
LightResult
,
Optical
},
optic_ports
::
OpticPorts
,
spectrum
::{
unify
_spectr
um
,
Spectrum
},
spectrum
::{
merge
_spectr
a
,
Spectrum
},
};
type
Result
<
T
>
=
std
::
result
::
Result
<
T
,
OpossumError
>
;
...
...
@@ -67,8 +67,8 @@ impl BeamSplitter {
_
=>
return
Err
(
OpossumError
::
Analysis
(
"expected DataEnergy value"
.into
())),
}
}
let
out1_spec
=
unify
_spectr
um
(
out1_1_spectrum
,
out2_2_spectrum
);
let
out2_spec
=
unify
_spectr
um
(
out1_2_spectrum
,
out2_1_spectrum
);
let
out1_spec
=
merge
_spectr
a
(
out1_1_spectrum
,
out2_2_spectrum
);
let
out2_spec
=
merge
_spectr
a
(
out1_2_spectrum
,
out2_1_spectrum
);
let
mut
out1_data
:
Option
<
LightData
>
=
None
;
let
mut
out2_data
:
Option
<
LightData
>
=
None
;
if
let
Some
(
out1_spec
)
=
out1_spec
{
...
...
This diff is collapsed.
Click to expand it.
src/optic_scenery.rs
+
1
−
6
View file @
a420a5d8
...
...
@@ -210,12 +210,7 @@ impl OpticScenery {
})
.collect
::
<
HashMap
<
String
,
Option
<
LightData
>>>
()
}
fn
set_outgoing_edge_data
(
&
mut
self
,
idx
:
NodeIndex
,
port
:
String
,
data
:
Option
<
LightData
>
,
)
{
fn
set_outgoing_edge_data
(
&
mut
self
,
idx
:
NodeIndex
,
port
:
String
,
data
:
Option
<
LightData
>
)
{
let
edges
=
self
.g
.edges_directed
(
idx
,
petgraph
::
Direction
::
Outgoing
);
let
edge_ref
=
edges
.into_iter
()
...
...
This diff is collapsed.
Click to expand it.
src/spectrum.rs
+
17
−
4
View file @
a420a5d8
...
...
@@ -38,7 +38,7 @@ impl Spectrum {
}
if
range
.start
>=
range
.end
{
return
Err
(
OpossumError
::
Spectrum
(
"wavelength range must be in ascending order"
.into
(),
"wavelength range must be in ascending order
and not empty
"
.into
(),
));
}
if
range
.start
<=
Length
::
zero
()
||
range
.end
<=
Length
::
zero
()
{
...
...
@@ -316,6 +316,13 @@ impl Spectrum {
.map
(|
d
|
(
d
.0
-
d
.1
)
.clamp
(
0.0
,
f64
::
abs
(
d
.0
-
d
.1
)))
.collect
();
}
/// Generate a plot of this [`Spectrum`].
///
/// Generate a x/y spectrum plot as SVG graphics with the given filename. This function is meant mainly for debugging purposes.
///
/// # Panics
///
/// ???
pub
fn
to_plot
(
&
self
,
filename
:
&
str
)
{
let
root
=
SVGBackend
::
new
(
filename
,
(
800
,
600
))
.into_drawing_area
();
root
.fill
(
&
WHITE
)
.unwrap
();
...
...
@@ -326,7 +333,7 @@ impl Spectrum {
.margin
(
5
)
.x_label_area_size
(
40
)
.y_label_area_size
(
40
)
.build_cartesian_2d
(
x_left
*
1.0E9
..
x_right
*
1.0E9
,
0.0
..
y_top
*
1E-9
)
.build_cartesian_2d
(
x_left
*
1.0E9
..
x_right
*
1.0E9
,
0.0
..
y_top
*
1E-9
)
.unwrap
();
chart
...
...
@@ -341,7 +348,7 @@ impl Spectrum {
self
.lambdas
.iter
()
.zip
(
self
.data
.iter
())
.map
(|
x
|
(
*
x
.0
*
1.0E9
,
*
x
.1
*
1E-9
)),
// y values are displayed in 1/nm
.map
(|
x
|
(
*
x
.0
*
1.0E9
,
*
x
.1
*
1E-9
)),
// y values are displayed in 1/nm
&
RED
,
))
.unwrap
();
...
...
@@ -449,7 +456,13 @@ pub fn create_nd_glass_spectrum(energy: f64) -> Spectrum {
.unwrap
();
s
}
pub
fn
unify_spectrum
(
s1
:
Option
<
Spectrum
>
,
s2
:
Option
<
Spectrum
>
)
->
Option
<
Spectrum
>
{
/// Helper function for adding two spectra.
///
/// This function allows for adding two (maybe non-existing = None) spectra with different bandwidth.
/// The resulting spectum is created such that both spectra are contained. The resolution corresponds
/// to the highest (average) resolution of both spectra. If one spectrum is `None` the other spectrum is
/// returned respectively. If both spectra a `None` then also `None`is returned.
pub
fn
merge_spectra
(
s1
:
Option
<
Spectrum
>
,
s2
:
Option
<
Spectrum
>
)
->
Option
<
Spectrum
>
{
if
s1
.is_none
()
&&
s2
.is_none
()
{
None
}
else
if
s1
.is_some
()
&&
s2
.is_none
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment