Adding wave to Z wave in image plot
sousavelosa.filipe
Hello all,
I have several image plots from time resolved spectrospy. The X and Y axis are time and wavelength and Z is absorption change with time. Besides the original data I need to add to the Z data, after some processing in Igor Pro, another spectrum with different spectral range. I could do this outside Igor but it's added work that seems unnecessary since we can add waves easily in Igor.
In short, I need to know if it's possible to add to the Z data, in a image plot, a single wave like using Wave Arithmetic panel?
Thanks in advance,
Filipe Velosa
As long as the waves have the same dimensions:
image1 += image2[p][q]
DisplayHelpTopic "Multidimensional Wave Assignment"
August 27, 2021 at 12:02 pm - Permalink
Yes, It is possible.
If the spectrum to be added has the same dimensions with the original data, things is quite simple, you can just do it as johnweeks's method.
If the waves have different dimensions(different dimension range,different size,different sample intervals), things become a little complicated. You can try the following codes to see whether or not it can meet your needs.
wave w1 //the original image
wave w2 //the image to be added
Variable flag //0:create new wave, named by w_tmp; 1:overwrite w1
Variable x0,dx,nx,y0,dy,ny
[x0,dx,nx]=GetWavesRangeMax(w1,w2,0)
[y0,dy,ny]=GetWavesRangeMax(w1,w2,1)
Make/O/N=(nx,ny) w_tmp
SetScale/P x,x0,dx,w_tmp
SetScale/P y,y0,dy,w_tmp
w_tmp=GetInterp2dValue(w1,x,y)+GetInterp2dValue(w2,x,y)
if(0==flag)
return w_tmp
else
Duplicate/O w_tmp w1
Killwaves/Z w_tmp
return w1
endif
End
Function [Variable v0,Variable d,Variable n]GetWavesRangeMax(wave w1,wave w2,Variable dim)
Variable vmin1,d1,vmax1,vmin2,d2,vmax2
[vmin1,d1,vmax1]=GetScaleInfo(w1,dim)
[vmin2,d2,vmax2]=GetScaleInfo(w2,dim)
v0=min(vmin1,vmin2)
d=min(d1,d2)
n=floor((max(vmax1,vmax2)-v0)/d)+1
End
Function [Variable v0,Variable d,Variable v1] GetScaleInfo(wave w,variable dim)
v0=dimoffset(w,dim)
d=dimdelta(w,dim)
v1=v0+(dimsize(w,dim)-1)*d
End
Function GetInterp2dValue(w,x,y) //if (x,y) is out scale index range, return 0
wave w //else,return interpolated value
variable x,y
Variable v0=interp2d(w,x,y)
if(2==numtype(v0))
return 0
endif
return v0
end
August 28, 2021 at 12:43 am - Permalink