@@ -21,6 +21,32 @@ function expand_range(start::Float64, stop::Float64)::Tuple{Float64,Float64}
21
21
end
22
22
23
23
24
+ """ gets comment from spectrum"""
25
+ function get_comment (spectrum:: SpmSpectrum ):: String
26
+ comment = " "
27
+
28
+ # Nanonis files have these numbered comment lines
29
+ for i in 1 : 99
30
+ comment_key = (i < 10 ) ? " Comment0$(i) " : " Comment$(i) "
31
+ if haskey (spectrum. header, comment_key)
32
+ if i > 1
33
+ comment *= " \n "
34
+ end
35
+ comment *= utf8ify (spectrum. header[comment_key])
36
+ else
37
+ break
38
+ end
39
+ end
40
+
41
+ # GXSM has a special comment field
42
+ if haskey (spectrum. header, " GXSM-Main-Comment" )
43
+ comment *= utf8ify (spectrum. header[" GXSM-Main-Comment" ])
44
+ end
45
+
46
+ return comment
47
+ end
48
+
49
+
24
50
""" Get the units for channel and channel2"""
25
51
function get_channel_units (griditem:: SpmGridItem , spectrum:: SpmSpectrum ):: Tuple{String,String}
26
52
units = map ((griditem. channel_name, griditem. channel2_name)) do c
@@ -554,19 +580,6 @@ function parse_spectrum!(griditems::Dict{String, SpmGridItem}, virtual_copies_di
554
580
end
555
581
end
556
582
557
- comment = " "
558
- for i in 1 : 99
559
- comment_key = (i < 10 ) ? " Comment0$(i) " : " Comment$(i) "
560
- if haskey (spectrum. header, comment_key)
561
- if i > 1
562
- comment *= " \n "
563
- end
564
- comment *= utf8ify (spectrum. header[comment_key])
565
- else
566
- break
567
- end
568
- end
569
-
570
583
if haskey (griditems, id)
571
584
griditem = griditems[id]
572
585
# still update a few fields (the files may have changed) - but most of these fields should stay unchanged
@@ -581,7 +594,7 @@ function parse_spectrum!(griditems::Dict{String, SpmGridItem}, virtual_copies_di
581
594
griditem. z_feedback_setpoint = z_feedback_setpoint
582
595
griditem. z_feedback_setpoint_unit = z_feedback_setpoint_unit
583
596
griditem. z = spectrum. position[3 ]
584
- griditem. comment = comment
597
+ griditem. comment = get_comment (spectrum)
585
598
griditem. status = 0
586
599
else
587
600
# get the respective image channel (depending on whether the feedback was on or not)
@@ -592,7 +605,7 @@ function parse_spectrum!(griditems::Dict{String, SpmGridItem}, virtual_copies_di
592
605
center= spectrum. position .* 1e9 , scan_direction= 2 ,
593
606
bias= spectrum. bias, z_feedback= spectrum. z_feedback,
594
607
z_feedback_setpoint= z_feedback_setpoint, z_feedback_setpoint_unit= z_feedback_setpoint_unit, z= spectrum. position[3 ],
595
- comment= comment
608
+ comment= get_comment (spectrum)
596
609
)
597
610
if only_new
598
611
push! (griditems_new, id)
@@ -618,7 +631,7 @@ function parse_spectrum!(griditems::Dict{String, SpmGridItem}, virtual_copies_di
618
631
virtual_copy. z_feedback_setpoint = z_feedback_setpoint
619
632
virtual_copy. z_feedback_setpoint_unit = z_feedback_setpoint_unit
620
633
virtual_copy. z = spectrum. position[3 ]
621
- virtual_copy. comment = comment
634
+ virtual_copy. comment = get_comment (spectrum)
622
635
virtual_copy. status = 0
623
636
624
637
t = Threads. @spawn create_spectrum! (virtual_copy, spectrum, dir_cache= dir_cache, use_existing= use_existing)
0 commit comments