#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. #pragma moduleName=normalizer #pragma version=1.1 // https://www.wavemetrics.com/user/tony //menu "Macros" // "Normalize Waves", /Q, normalizer#NormalizeWaves() //end Menu "Macros" Submenu "IR and Raman" "Normalise Spectra...", /Q, normalizer#NormalizeWaves() end end static function NormalizeWaves() dowindow /k NormPanel NewDataFolder /O root:Packages NewDataFolder /O root:Packages:Normalizer DFREF dfr=root:Packages:Normalizer make /o /n=(0,3)/T dfr:w_newList /WAVE=w_newList make /o/W/U /n=(3,5,3) dfr:w_color/WAVE=w_color w_color={{0,0,0},{65535,0,0}} MatrixTranspose w_color make /o /n=(0,3,3) dfr:w_selection /WAVE=w_selection SetDimLabel 2,1,backColors,w_selection // define plane 1 as background colors make /o /n=3 /T dfr:w_titles /wave=w_titles w_titles={"input","mm","output"} wave /T w_wavelist=ListToTextWave(wavelist("*",";","DIMS:1"), ";") killwaves /Z dfr:w_wavelist movewave w_wavelist dfr:w_wavelist make /o/n=(numpnts(w_wavelist)) dfr:w_waveselection /wave=w_waveselection string /G dfr:s_edit="" NewPanel /K=1/N=NormPanel/W=(100,100,950,560) as "Normalize" ModifyPanel /W=NormPanel fixedSize=1 ListBox listboxWaves,win=NormPanel, pos={20, 40},size={200, 350}, listwave=w_wavelist, selwave=w_waveselection, mode=9 button buttonGrabWaves win=NormPanel, pos={250,180},size={50,50},title=">", proc=normalizer#normButtons ListBox listboxOut,win=NormPanel, mode=6, selwave=w_selection, titlewave=w_titles, pos={330, 40},size={500, 350}, editstyle=1 ListBox listboxOut,win=NormPanel, colorwave=w_color, listwave=w_newList,widths={150,50,150}, fsize=16, proc=normalizer#normListBox Button buttonDoIt win=NormPanel,pos={780,410},size={50,30},title="Do It", proc=normalizer#normButtons Button buttonCancel win=NormPanel,pos={700,410},size={60,30},title="Cancel", proc=normalizer#normButtons End // rebuild list of 1D waves in current data folder static function resetWaveList() DFREF dfr=root:Packages:Normalizer wave /T w_wavelist=ListToTextWave(wavelist("*",";","DIMS:1"), ";") duplicate /o w_wavelist dfr:w_wavelist redimension /n=(numpnts(w_wavelist)) dfr:w_waveselection end // wrapper for buttons static function normButtons(ba) STRUCT WMButtonAction &ba DFREF dfr=root:Packages:Normalizer wave /T w_wavelist=dfr:w_wavelist wave w_waveselection=dfr:w_waveselection wave /T w_newList=dfr:w_newList wave w_selection=dfr:w_selection wave w_color=dfr:w_color variable i,count switch( ba.eventCode ) case 2: // mouse up if(stringmatch(ba.ctrlName, "buttonGrabWaves")) count=numpnts(w_wavelist) for (i=0;irowsinwave) // add a wave w_newList[dimsize(w_newList, 0)][]={{w_wavelist[i]},{"0"},{CleanupName(w_wavelist[i]+"_cm",0)}} w_selection[dimsize(w_selection, 0)][]={{0},{2},{2}} normSanityCheck() endif endif endfor elseif(stringmatch(ba.ctrlName, "buttonDoIt")) count=dimsize(w_newList, 0) for (i=0;i