#pragma rtGlobals=1 // Use modern global access method. Menu "SHG Single" "Load Plot smooth single SHG File...", LoadAndGraphXYa("", "") End Menu "Normalization" " Divide by GaAs Spectrum", LogRatio("","") End Menu "Average by Cursor " " Average wave by Cursor", CursorMath() End Function CursorMath() variable xx xx = WaveAverageBetweenCursors() print " Average = " , xx End Function LoadAndGraphXYa(fileName, pathName) String fileName // Name of file to load or "" to get dialog String pathName // Name of path or "" to get dialog // Load the waves and set the globals LoadWave/G/A/E=1/D/O/P=$pathName fileName if (V_flag==0) // No waves loaded. Perhaps user canceled. return -1 endif Display // Create a new graph String sxw, syw, szw Variable index=0 Variable tt, dtt tt = 1/(1/3508.61 + 1/803.506) //3508.61 is theoritical value of poly peak..so tt is theory poly SFG peak dtt = tt-652.3 // 652.3 is practical value of sfg poly peak taken from poly spectrum do // Now append waves to graph sxw=StringFromList(index, S_waveNames) // Next name if (strlen(sxw) == 0) // No more? break // break out of loop endif syw=StringFromList(index+1, S_waveNames)// Next name Wave xw = $sxw // Create wave references. Wave yw = $syw SetScale d 0, 0, "", xw // Set x wave's units SetScale d 0, 0, "", yw // Set y wave's units String newName = NameOfWave(yw) + "_out" // Compute output wave name Duplicate/O yw, $newName // Create output wave Wave wOut = $newName // Create wave reference for output wave //wOut += 1 AppendToTable wOut AppendToGraph yw vs xw xw = xw + dtt xw = 10^7/xw -10^7/803.506 // Smooth/M=20 5, yw;DelayUpdate Label left "SFG Intensity(a.u) " Label bottom "IR Wavelength (cm-1)" WMMedianXYIM#MedianXY(xw,yw,20,"medianWave",threshold=10);DelayUpdate String newName1 = NameOfWave(yw) + "_medianWave" // Compute output wave name Duplicate/O medianWave, $newName1 // Create output wave Wave wOutsmooth = $newName1 // Create wave reference for output wave AppendToTable wOutsmooth Display wOutsmooth vs wave0;Delayupdate Label left "SFG Intensity(a.u) " Label bottom "IR Wavelength (cm-1)" index += 2 while (1) // Unconditionally loop back up to “do” // Annotate graph Textbox/A=LT "File: " + S_fileName return 0 // Signifies success. End //Function DoNormalization(Tn) /Wave Tn //Duplicate Tn, $newName End // WavesAverage(baseName, destName) // Produces a new wave, each point of which contains the average of the // corresponding points of a number of source waves. // All waves whose name starts with the specified base name are source waves. // This function assumes that all waves that start with the base name have // the same number of points and that there is at least one such wave. // Returns full path to destination wave as a string. Function/S WavesAverage(baseName, destName) String baseName // name for source wave String destName // name for destination wave String wn // contains the name of a particular wave String wl // contains a list of wave names Variable index=0 //Prompt wn, "Enter First wave : " // Set prompt for Firsr wave //Prompt wl, "Enter Second wave: " // Set prompt for second wave //DoPrompt "Enter two waves name", wn, wl //if (V_Flag) //return -1 // User canceled //endif // get list of waves whose names start with baseName wl = WaveList(baseName+"*", ";", "") // Make destination wave based on the first source wave wn = StringFromList(0, wl) Duplicate/O $wn, $destName WAVE dest = $destName // create wave reference for destination dest = 0 do wn = StringFromList(index, wl) // get next wave if (strlen(wn) == 0) // no more names in list? break // break out of loop endif WAVE source = $wn // create wave reference for source dest += source // add source to dest index += 1 while (1) // do unconditional loop dest /= index // divide by number of waves return GetWavesDataFolder(dest,2)// string is full path to wave End Function/S LogRatio(swa, swb) String swa // contains the name of a particular wave String swb // contains a list of wave names String swc // Name of the x column swa = "wave1" swb = "wave2" swc = "wave0" Prompt swa, "Enter First wave : " // Set prompt for Firsr wave Prompt swb, "Enter Second wave: " // Set prompt for second wave Prompt swc, "Enter x column" DoPrompt "Enter two waves name and x column", swa, swb, swc //Wave wa =CsrWaveRef(A) Wave wa =$swa Wave wb =$swb Wave wc=$swc String destName = NameOfWave(wa) + "/" + NameOfWave(wb) destName = CleanupName(destName,1) // obey name length limitation Duplicate/O wa, $destName WAVE dest = $destName dest =wa / wb AppendToTable dest Display dest vs wc //return GetWavesDataFolder(dest,2) // string is full path to wave End Function/S CursorAWave() WAVE/Z w = CsrWaveRef(A) if (WaveExists(w)==0) return "" endif //return wave(w) End End Function WaveAverageBetweenCursors() WAVE/Z w = CsrWaveRef(A) if (!WaveExists(w)) // Cursor is not on any wave. return NaN endif Variable xA = xcsr(A) Variable xB = xcsr(B) Variable avg = mean(w, xA, xB) return avg End