4Misc_Startr4Platformr@9VersionCheck xHH@Rg(HHdh xHH@Rg(HHdh x HH@Rg(HHdh ^Graph*,WDashSettings#  ! 6Normal@ Monaco<HHHH$$4 4 4 4 4 4 Vhome"xd4Macintosh HD:Users:kaikin:Documents:Igor Pro Docs:Misc experiments:Zach GOMECH Igor tool: Macintosh HDBDZach GOMECH Igor tool cuMisc experimentsN/:Users:kaikin:Documents:Igor Pro Docs:Misc experiments:Zach GOMECH Igor tool/,Zach GOMECH Igor tool Macintosh HDKUsers/kaikin/Documents/Igor Pro Docs/Misc experiments/Zach GOMECH Igor tool/ fRecentWindows2Curve Fitting.ihfGOMECH_PanelIgor Reference.ihf 4Misc_EndrXOPState_Start`rHDF5-64tting.ihfGOMECH_PanelIgorGIS64nce.ihfPeakFunctions2-64or tool4XOPState_Endr\ •//GOMECH_Analysis(CO_Plume, HONO_Plume, 0, "Plot") •//GOMECH_Analysis(CO_Plume, O3_Plume, 1, "Plot") •//GOMECH_Analysis(CO_Plume, MA_Plume, 1, "Plot") •//GOMECH_Analysis(CO_Plume, jHONO_Plume, 3, "Plot") •GOMECH_Panel() !Jp0'ko#ݞHONO_Plume????~jt@Zd;O?rh|Ͽ/$@~jt?Zd;@h|?5+َ @333333@bX9/$?E@Dl)@+4@@(\'@ClL7A`$@M @bX9+@zG1@Hz7@Q1@n 9@v/D@/ݴK@ G@'1J@'1*N@)\@@EA@w/Q@5^I U@U@ +U@QZ@%C[@(\ Y@?5^Ig@Q@nu@zG@~j@33333@vì@x&o@ r@/$D@Dl;@K@Qx@ +ָ@(\B@ףp=@CKB@Vױ@`"@Hz@9vg@B`"G@+nf@ @Զ@X9b@%cG@L7A@{GA@ *@X96@B`bU@ffffF@%#e@|?5^|@K7@Q@bX9Զ@/$t@Ҙ@L7A`@NbX@y&1V@ij@L@;O@5^Il}@Q@Zd;ߏ@L7A@/d;@|?ɷ@v@\@m$@ 2@/݄S@d;OS@E=߹@Zdú@'18@MR@ˡE3T@/$&@u]@5^I@V@v @{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p0N#o#ݞO3_Plume????(\P@-O@OnbP@ʡQ@rhTQ@&1Q@!rhQ@V-Q@DlQ@ rhaQ@nQ@eQ@Q%R@L7A`eS@sh|R@/E@ClD@K7)E@v/E@S㥛$E@)\8E@K7YE@oQE@\(|E@sh|D@x&D@sh|D@(\EF@ rhF@SUG@ʡG@ rhF@-E@ rE@"E@SD@ E@33333SF@HzGE@{GE@33333cE@D@/$F@&1 E@I +D@zGD@zGC@SKB@$CA@%Ck@@= ףp]?@K=@x&q<@x&=@Qe=@sh|?=@oa<@Q=@+7<@J +6:@l8@/;@&1|:@|?5~7@(\6@Q^4@T㥛3@?5^I3@{G3@ˡE3@h|?4@X9v4@(\4@= ףp=5@V-r5@sh|5@Mb4@%C4@rh5@MbX8@w/9@|?5^z:@)\;@-G?@Zd;I@bX9M@T㥛L@w/J@R@npQ@㥛 O@xN@QuI@~jN@SKR@PnQ@nbR@)\K@SK@+پJ@~jtG@DlK@Hz?R@V-R@|?5FR@Zd;O]Q@*R// Platform=Macintosh, IGORVersion=8.050, architecture=Intel, systemTextEncoding="MacRoman", historyTextEncoding="UTF-8", procwinTextEncoding="UTF-8", recreationTextEncoding="UTF-8", build=37401 #pragma TextEncoding = "UTF-8" Silent 101 // use | as bitwise or -- not comment. DefaultFont "Arial" MoveWindow/P 403,200,1499,745 MoveWindow/C 2,645,654,826 GOMECH_Panel() KillStrings/Z root:gWMSetNextTextFilesTextEncoding Window GOMECH_Panel() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(592,45,1050,326) as "GOMECH_Panel" SetDrawLayer UserBack SetDrawEnv fsize= 10,fstyle= 2,textrgb= (65535,0,0) DrawText 40,80,"e.g. Carbon Monoxide, Methane, etc." SetDrawEnv fsize= 10,fstyle= 2,textrgb= (65535,0,0) DrawText 39,191,"Initial guess of plume center of short-lived compound relative to the width of the \rlong-lived compound. This value is usually 0 for compounds with plume centers aligned\rwith the tracer or 1-3 for unaligned compounds. Guessing 0.5 can help if you are unsure. " PopupMenu popupLL,pos={39.00,46.00},size={183.00,23.00},title="Long-lived species:" PopupMenu popupLL,fSize=12 PopupMenu popupLL,mode=1,popvalue="_none_",value= #"\"_none_;\"+SortList(WaveList(\"*\", \";\", \"\"))" PopupMenu popupSL,pos={40.00,94.00},size={183.00,23.00},title="Long-lived species:" PopupMenu popupSL,fSize=12 PopupMenu popupSL,mode=1,popvalue="_none_",value= #"\"_none_;\"+SortList(WaveList(\"*\", \";\", \"\"))" SetVariable setvarPlumeCenter,pos={40.00,133.00},size={134.00,18.00},title="Plume Center:" SetVariable setvarPlumeCenter,fSize=12,value= _NUM:0.5 CheckBox checkPlot,pos={40.00,206.00},size={73.00,16.00},title="Make Plot" CheckBox checkPlot,fSize=12,value= 0 GroupBox group0,pos={20.00,17.00},size={420.00,217.00} Button button0,pos={201.00,249.00},size={50.00,20.00},proc=ButtonProcCalcPlume,title="Do It" EndMacro `$#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. //Below are functions for the GOMECH analysis tool. This tool is intended //for use in analyses of crosswind heterogeneity studies. The tool uses a //GOMECH fit to produce plume width and center metrics of a short-lived //compound relative to a long-lived tracer. GOMECH is explained in detail //in the accompanied manuscript. //Questions and comments can be directed to ZacharyCJDecker@gmail.com //ZCJD: v.01 created Oct 07 2021 Function GOMECH_Analysis(wLL, wSL, vCenter_Guess, sPlot) //wLL: Wave containing long-lived observation (e.g. carbon monoxide, methane, etc.) //wSL: Wave containing a short-lived observation //vCenter_Guess Va variable containing the initial guess of the plume center of the short-lived // compound relative to the width of the long-lived compound. This value is usually 0 for // compounds with plume centers aligned with the tracer or 1-3 for unaligned compounds. // Guessing 0.5 can help if you are unsure. //sPlot A string to indicate wheter you want the results plotted ("Plot"), or not (anything else). Wave wLL, wSL Variable vCenter_Guess String sPlot SetDatafolder Root: Variable AllPoints = numpnts(wLL) String wLL_Loc = GetWavesDataFolder(WLL, 2) String wSL_Loc = GetWavesDataFolder(wSL, 2) String wLL_Name = nameofwave(wLL) String WSL_Name = nameofwave(wSL) NewDataFolder/O/S Root:GOMECH NewDataFolder/O/S $(WSL_Name) String Local_wSL_Name =WSL_Name+"_Orig" String Local_wLL_Name =wLL_Name+"_Orig" Duplicate/O $wSL_Loc, $Local_wSL_Name Duplicate/O $wLL_Loc, $Local_wLL_Name wave PL_WSL = $Local_wSL_Name wave PL_WLL = $Local_wLL_Name //***Fit*** //Fitting parameters are as follows //k0 = Width of SL, k1 = Width of LL, K2 = Center shift, K3 = Maximum of LL, K4 = Maximum of SL //k0 is guessed as 1 by default (width equivalent to LL. //Calculate wave maxes to constrain the k3 and k4 variables. Variable vSL_Max = wavemax(PL_wSL) Variable vLL_Max = wavemax(PL_wLL) //Create variable guesses. Make/D/N=5/O W_coef_All W_coef_All = {1,1,vCenter_Guess,vLL_Max, vSL_Max} //Constraints: Width of Sl must be between 0-3. Plume center shift must be between 0-3.5. Make/O/T/N=4 T_Constraints T_Constraints[0] = {"K0 > 0","K0 < 3","K2 > 0","K2 < 3.5"} //Perform fit. Hold k1, k3, and k4. FuncFit/H="01011"/Q GOMECH W_coef_All PL_wSL /X=PL_wLL /D /C=T_Constraints //***Make Gaussian*** //Create a gaussian wave for a visual. Wave W_Sigma Create_Gaussian_From_Fit(W_coef_All[0], W_coef_All[2], "GOMECH_Gaus_" + WSL_Name) wave wGaus_LL = Standard_Gaussian wave wGaus_SL = $("GOMECH_Gaus_" + WSL_Name) //***Calculate Error bounds from the fit*** //Calculate_Residual(W_coef_All, PL_wSL, PL_wLL) //Create upperbound and lowerbound gaussian from fit errors Create_Gaussian_From_Fit((W_coef_All[0]+W_Sigma[0]), (W_coef_All[2]+W_Sigma[2]), "GOMECH_Gaus_" + WSL_Name + "_PErr") Create_Gaussian_From_Fit((W_coef_All[0]-W_Sigma[0]), (W_coef_All[2]-W_Sigma[2]), "GOMECH_Gaus_" + WSL_Name + "_MErr") wave wGaussian = $("GOMECH_Gaus_" + WSL_Name) wave wGaussian_PErr = $("GOMECH_Gaus_" + WSL_Name + "_PErr") wave wGaussian_MErr = $("GOMECH_Gaus_" + WSL_Name + "_MErr") //*** Plot *** Make/d/o/n=2 One_2_One = {0, vSL_Max} SetScale/P x 0,vLL_Max,"", One_2_One If(cmpstr(sPlot, "Plot") == 0) Display /W=(144,98,774.857,382.571) $Local_wSL_Name vs $Local_wLL_Name AppendToGraph One_2_One,$("fit_"+Local_WSL_Name) AppendToGraph/L=Gaussian/B=x_Gaussian wGaus_LL vs $"Gaussian_xwave" AppendToGraph/L=Gaussian/B=x_Gaussian $("GOMECH_Gaus_"+wSL_Name+"_PErr"),$("GOMECH_Gaus_"+wSL_Name+"_MErr") vs $"Gaussian_xwave" AppendToGraph/L=Gaussian/B=x_Gaussian $("GOMECH_Gaus_"+wSL_Name) vs $"Gaussian_xwave" ModifyGraph width=504,height={Aspect,0.4} ModifyGraph mode($Local_wSL_Name)=3,mode($("GOMECH_Gaus_"+WSL_Name+"_PErr"))=7 ModifyGraph marker($Local_wSL_Name)=19 ModifyGraph rgb($Local_wSL_Name)=(52428,52428,52428),rgb(One_2_One)=(0,0,0),rgb($"Standard_Gaussian")=(0,0,0) ModifyGraph rgb($("GOMECH_Gaus_"+wSL_Name+"_PErr"))=(65535,49151,49151),rgb($("GOMECH_Gaus_"+wSL_Name+"_MErr"))=(65535,49151,49151) ModifyGraph msize($Local_wSL_Name)=2 ModifyGraph hbFill($("GOMECH_Gaus_"+wSL_Name+"_PErr"))=8 ModifyGraph toMode($("GOMECH_Gaus_"+wSL_Name+"_PErr"))=1 ModifyGraph fSize=14 ModifyGraph fStyle=1 ModifyGraph highTrip(left)=1000 ModifyGraph notation(left)=1 ModifyGraph lblPosMode(left)=1,lblPosMode(bottom)=1,lblPosMode(Gaussian)=3,lblPosMode(x_Gaussian)=1 ModifyGraph lblPos(left)=41,lblPos(bottom)=38,lblPos(Gaussian)=60 ModifyGraph freePos(Gaussian)={0,x_Gaussian} ModifyGraph freePos(x_Gaussian)={0,Gaussian} ModifyGraph axisEnab(bottom)={0,0.5} ModifyGraph axisEnab(x_Gaussian)={0.7,1} Label left "Short-lived Measurement" Label bottom "Long-lived Measurement" Label Gaussian "Short- and Long-lived\rMeasurement" Label x_Gaussian "Plume Width Ratio\r(w\\BSL\\M/w\\BLL\\M)" SetAxis/A/N=1 left SetAxis/A/N=1 bottom SetAxis/E=1 x_Gaussian 0,3 Wave w_Coef_all Variable Width = w_Coef_all[0] Variable Center = w_Coef_all[2] TextBox/C/F=0/B=1/N=text0/X=69.39/Y=-3.40 "\\Z12GOMECH Fitting Results\rw\B\Z12SL\M\Z12/w\B\Z12LL\M\Z12: "+num2str(Width)+"\rb\B\Z12SL\M\Z12/w\B\Z12LL\M\Z12: "+num2str(Center) Endif SetDataFolder Root: End Function Create_Gaussian_From_Fit(vWidth, vOffset, sNewWaveName) //Creates a guassian shape using the fitting results //vWidth: Variable containing the gaussian width. //vOffset: Variable containing the gaussian offset, or center. //sNewWaveName: A string containing the name of the gaussian to be created. Variable vWidth, vOffset String sNewWaveName //Arbitrary basis chosen for resolution only. Make/d/o/n=1000 Gaussian_xwave = (p)/250 Variable Num_Of_Points = numpnts(Gaussian_xwave) Variable LL_x_Max = Gaussian_xwave[Num_Of_Points-1] Make/d/o/n=(Num_Of_Points) $sNewWaveName Wave wGaussian = $sNewWaveName Make/d/o/n=(Num_Of_Points) Standard_Gaussian = exp(-(Gaussian_xwave[p])^2/(1)^2) wGaussian = exp(-(Gaussian_xwave[p]-vOffset)^2/(vWidth)^2) End // GOMECH Fitting Function Function GOMECH(w,x) : FitFunc Wave w Variable x //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog. //CurveFitDialog/ Equation: //CurveFitDialog/ f(x) = AX*ACO^-(wCO^2/wX^2)*x^(wCO^2/wX^2)*exp((2*b/wX^2)*SQRT(ln(x^-wCO^2)-ln(ACO^-wCO^2)))*exp(-(1/wX^2)*b^2) //CurveFitDialog/ End of Equation //CurveFitDialog/ Independent Variables 1 //CurveFitDialog/ x //CurveFitDialog/ Coefficients 5 //CurveFitDialog/ w[0] = wX //CurveFitDialog/ w[1] = wCO //CurveFitDialog/ w[2] = b //CurveFitDialog/ w[3] = ACO //CurveFitDialog/ w[4] = AX return w[4]*w[3]^-(w[1]^2/w[0]^2)*x^(w[1]^2/w[0]^2)*exp((2*w[2]/w[0]^2)*SQRT(ln(x^-w[1]^2)-ln(w[3]^-w[1]^2)))*exp(-(1/w[0]^2)*w[2]^2) End // Ken Aikin: Code to read panel and run the main function Function ButtonProcCalcPlume(ctrlName) : ButtonControl String ctrlName string LLstr, SLstr, plotStr variable plumeCntr, plotFlag ControlInfo/W=GOMECH_Panel popupLL LLstr = S_value if (cmpstr(LLstr, "_none_")==0) DoAlert 0, "Choose a long-lived species" Abort endif wave LLwave = $LLstr ControlInfo/W=GOMECH_Panel popupSL SLstr = S_value if (cmpstr(SLstr, "_none_")==0) DoAlert 0, "Choose a short-lived species" Abort endif wave SLwave = $SLstr ControlInfo/W=GOMECH_Panel setvarPlumeCenter plumeCntr = V_value ControlInfo/W=GOMECH_Panel checkPlot plotFlag = V_value if (plotFlag) plotStr = "Plot" else plotStr = "" endif GOMECH_Analysis(LLwave, SLwave, plumeCntr, plotStr) End Window GOMECH_Panel() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(602,73,1060,354) as "GOMECH_Panel" SetDrawLayer UserBack SetDrawEnv fsize= 10,fstyle= 2,textrgb= (65535,0,0) DrawText 40,80,"e.g. Carbon Monoxide, Methane, etc." SetDrawEnv fsize= 10,fstyle= 2,textrgb= (65535,0,0) DrawText 39,191,"Initial guess of plume center of short-lived compound relative to the width of the \rlong-lived compound. This value is usually 0 for compounds with plume centers aligned\rwith the tracer or 1-3 for unaligned compounds. Guessing 0.5 can help if you are unsure. " PopupMenu popupLL,pos={39.00,46.00},size={183.00,23.00},title="Long-lived species:" PopupMenu popupLL,fSize=12 PopupMenu popupLL,mode=1,popvalue="_none_",value= #"\"_none_;\"+SortList(WaveList(\"*\", \";\", \"\"))" PopupMenu popupSL,pos={40.00,94.00},size={183.00,23.00},title="Long-lived species:" PopupMenu popupSL,fSize=12 PopupMenu popupSL,mode=1,popvalue="_none_",value= #"\"_none_;\"+SortList(WaveList(\"*\", \";\", \"\"))" SetVariable setvarPlumeCenter,pos={40.00,133.00},size={134.00,18.00},title="Plume Center:" SetVariable setvarPlumeCenter,fSize=12,value= _NUM:0.5 CheckBox checkPlot,pos={40.00,206.00},size={73.00,16.00},title="Make Plot" CheckBox checkPlot,fSize=12,value= 0 GroupBox group0,pos={20.00,17.00},size={420.00,217.00} Button button0,pos={201.00,249.00},size={50.00,20.00},proc=ButtonProcCalcPlume,title="Do It" EndMacro