Skip to content

Commit

Permalink
read comment from netcdf spm files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexriss committed Jan 16, 2024
1 parent 4a2a7f9 commit 12c9dd2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/image_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ function is_image_channel_name_fwd(name)
end


"""get comment from spm image"""
function get_comment(im_spm::SpmImage)::String
comment = ""
if haskey(im_spm.header, "Comment")
comment = utf8ify(im_spm.header["Comment"])
elseif haskey(im_spm.header, "comment")
comment = utf8ify(im_spm.header["comment"])
end
return comment
end


"""saves all colorbars as pngs in the cache directory.
Returns a dictionary that associates each colorscheme name with a png file"""
function save_colorbars(dict_colorschemes::OrderedDict{String,ColorScheme}, dir_data::String, width::Int=512, height::Int=20)::OrderedDict{String,String}
Expand Down Expand Up @@ -419,13 +431,13 @@ function parse_image!(griditems::Dict{String, SpmGridItem}, virtual_copies_dict:
griditem.z_feedback_setpoint = im_spm.z_feedback_setpoint
griditem.z_feedback_setpoint_unit = im_spm.z_feedback_setpoint_unit
griditem.z = im_spm.z
griditem.comment = haskey(im_spm.header, "Comment") ? utf8ify(im_spm.header["Comment"]) : ""
griditem.comment = get_comment(im_spm)
griditem.status = 0
else
# get the respective image channel (depending on whether the feedback was on or not)
channel_name = default_channel_name(im_spm)
length(datafiles) > 1 && (filename_original = channel_names_files[id][channel_name])
comment = haskey(im_spm.header, "Comment") ? utf8ify(im_spm.header["Comment"]) : ""
comment = get_comment(im_spm)
griditems[id] = SpmGridItem(
id=id, type=SpmGridImage, filename_original=filename_original, created=created, last_modified=last_modified, recorded=im_spm.start_time,
channel_name=channel_name, scansize=im_spm.scansize, scansize_unit=im_spm.scansize_unit,
Expand Down Expand Up @@ -469,7 +481,7 @@ function parse_image!(griditems::Dict{String, SpmGridItem}, virtual_copies_dict:
virtual_copy.z_feedback_setpoint = im_spm.z_feedback_setpoint
virtual_copy.z_feedback_setpoint_unit = im_spm.z_feedback_setpoint_unit
virtual_copy.z = im_spm.z
virtual_copy.comment = haskey(im_spm.header, "Comment") ? utf8ify(im_spm.header["Comment"]) : ""
virtual_copy.comment = get_comment(im_spm)
virtual_copy.status = 0

t = Threads.@spawn create_image!(virtual_copy, im_spm, resize_to=resize_to, dir_cache=dir_cache, use_existing=use_existing)
Expand Down

0 comments on commit 12c9dd2

Please sign in to comment.