function uly_star_init, cmp, WAVERANGE=lamrange, VELSCALE=velscale, QUIET=quiet
compile_opt idl2
on_error, 2
init_data = *cmp.init_data
if n_elements(*init_data.lsf_file) ne 0 then begin
lsf = *init_data.lsf_file
endif
if size(init_data.file, /TYPE) eq 8 then begin
file_in = uly_spect_logrebin(init_data.file, velscale, WAVERANGE=lamrange)
endif else begin
if size(init_data.file, /TYPE) eq 7 then begin
if file_test(init_data.file) ne 1 then begin
message, 'Error, file does not exist', /INFO
return, 0
endif
file_in = uly_spect_read(init_data.file, lamrange[0], lamrange[1], $
VELSCALE=velscale, QUIET=quiet)
endif
endelse
if uly_spect_get(file_in) ne 1 then begin
if size(init_data.file, /TYPE) eq 7 then $
message, 'Could not read the file ('+init_data.file+')', /INFO $
else $
message, 'Invalid input structure', /INFO
return, 0
endif
cmp.eval_fun = 'STAR'
if n_elements(lsf) gt 0 then begin
uly_spect_lsfconvol, lsf, file_in
endif
cmp.eval_data = ptr_new(*file_in.data)
cmp.npix = (size(*file_in.data,/DIM))[0]
cmp.start = double(file_in.start)
cmp.step = double(file_in.step)
cmp.sampling = fix(file_in.sampling)
if n_elements(*file_in.goodpix) gt 0 then begin
cmp.mask = ptr_new(bytarr(cmp.npix))
(*cmp.mask)[*file_in.goodpix] = 1
endif
uly_spect_free, file_in
return, cmp
end
function uly_star, file_in, $
LSF=lsf_file, $
NAME=name, $
WL=lim_weight
compile_opt idl2
on_error, 2
if n_elements(file_in) gt 1 then $
return, [uly_star(file_in[0],LSF=lsf_file,NAME=name,WL=lim_weight), $
uly_star(file_in[1:*],LSF=lsf_file,NAME=name,WL=lim_weight)]
if size(file_in, /TYPE) eq 0 then begin
print, 'Usage: ULY_STAR, <filename|spect>, ...'
mess = 'Error, no filename or spect was given'
message, mess, /INFO
return, 0
endif else if size(file_in, /TYPE) eq 7 then begin
if file_test(file_in) ne 1 then begin
print, 'Usage: ULY_STAR, <filename|spect>, ...'
mess = 'Error, file does not exist'
if file_in ne '' then mess += ' ('+file_in+')'
message, mess, /INFO
return, 0
endif
endif else if size(file_in, /TYPE) eq 8 then begin
if uly_spect_get(file_in) ne 1 then begin
print, 'Usage: ULY_STAR, <filename|spect>, ...'
message, 'Invalid input structure', /INFO
return, 0
endif
endif
namec = uly_cmp_name(name)
s_wl = size(lim_weight)
if s_wl[0] gt 0 then if not s_wl[0] eq 2 then $
message, 'The weight limits have to be of the type arr(2)'
lw = (n_elements(lim_weight) eq 0) ? (machar(/DOUBLE)).xmax*[0,1] : double(lim_weight)
if size(file_in, /TYPE) eq 7 then descr = 'file:' + file_in + ' ' $
else descr = 'spect'
if n_elements(lsf_file) eq 1 then descr += 'lsf:' + lsf_file
init_data = {file:file_in, lsf_file:ptr_new(lsf_file)}
return, {name:namec, $
descr:descr, $
init_fun:'uly_star_init', $
init_data:ptr_new(init_data), $
eval_fun:'', $
eval_data:ptr_new(), $
para:ptr_new(/ALLO), $
start:0d, $
step:0d, $
npix: 0l, $
sampling:-1s, $
mask:ptr_new(), $
weight:0d, $
e_weight:0d, $
l_weight:0d, $
lim_weig:lw $
}
end
Part of