Dear all, as I got no reply, I did embark on this little automation quest by myself, as announced. I used AutoHotkey to write a script that operates on Artemis by sending keystrokes and mousecommands. I will attach the the code to the end of this mail so anyone interested can take a peek. I basically wrote it for myself so some parts might not be clear or smartly designed but it does it's job of automatically starting fit after fit while varying the start/guess/set parameters. It is somewhat commented so anyone with a real interest in this should be able to get it to work, otherwise just ask me for help. Subsequently I used MS PowerShell to grab the relevant parameters from the log-files of the fits. I won't attach that script, but if anyone is interested in it: just ask. Attention, wall-of-text/code below! Felix Contents of "artemis_fitting.ahk": ; This is what comments look like ; 3D Parameter Scan ; Artemis Main Window: ; Using IDs for buttons and text-fields and windows would be much better than using mouse-positioning. ; The IDs would make the whole thing independent from the resolution. ; GDS Window: ; Change Parameters ; Window unique ID: 0x30a38 ; fields in GDS table don't have unique classes so mouse-positioning will have to be used after all.... ; this means there will be a calibration step before running the fitting loop ; Log Window: ; Save Log File ^j:: { CoordMode, Mouse , Screen ; MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl ; MouseGetPos, MouseXPosition, MouseYPosition, ArtemisMainWindowUID, ArtemisMainWindowClassNN ; MsgBox Mouse Cursor x-position: %MouseXPosition%`n ; , Mouse Cursor y-position: %MouseYPosition%`n ; , Window unique ID: %ArtemisMainWindowUID%`n ; , Window Class: %ArtemisMainWindowClassNN% ; 0. calibration ;MsgBox Calibration. Position the cursor over Artemis main window's entry field for Fit-Name and press return. MsgBox Calibration: Name MouseGetPos, Edit1XP, Edit1YP, ArtemisMainWindowUID ;MsgBox ArtemisMainWindowUID is %ArtemisMainWindowUID% ;MsgBox Calibration. Position the cursor over Artemis main window's fit description entry field. MsgBox Calibration: Fit description MouseGetPos, FDXP, FDYP ;MsgBox Calibration. Position the cursor over the Fit Button of Artemis' main window. MsgBox Calibration: Fit MouseGetPos, FitXP, FitYP ;MsgBox Calibration. Position the cursor over the "Show log" button of the main window. MsgBox Calibration: Show log MouseGetPos, slogX, slogY ; A - pick the two fields that containt the guess-value for FixedParameter1 and FixedParameter2 ;MsgBox Calibration. Position the mouse cursor over the input field for FixedParameter1 and press Return. MsgBox Calibration: Parameter1 MouseGetPos, FixPar1MXP, FixPar1MYP ;MsgBox Position the mouse cursor over the input field for FixedParameter2 and press Return. MsgBox Calibration: Parameter2 MouseGetPos, FixPar2MXP, FixPar2MYP, GDSWindowUID ; B - enter the desired minimum, maximum and step-size for each of the FixedParamteres ; for now just fixed ; minimum = 0.002, ; maxmimum = 0.012 and ; step width = 0.001 MinPar1=0.002000 MinPar2=0.002000 MaxPar1=0.012000 MaxPar2=0.012000 StepSize=0.00100 CurPar1=%MinPar1% CurPar2=%MinPar2% ;MsgBox Calibration(finally last step though). Place mouse cursor over Log-window's Save button. MsgBox Calibration: Save (Log-Window) MouseGetPos, SaveX, SaveY, LogID ;MsgBox Calibration: Plot Window ;MouseGetPos, PX, PY, PID LV1=1 LV2=1 TFC=0 Loop , 11 { CurPar2:=MinPar2 LV1:=LV1+1 Loop, 11 { LV2:=LV2+1 TFC:=TFC+1 ; block below is what should be executed in each run of the loop, let's build the loop { ; 1. Go to GDS Window ; WinActivate [, WinTitle, WinText, ExcludeTitle, ExcludeText] WinActivate , ahk_id %GDSWindowUID% WinWaitActive , ahk_id %GDSWindowUID% ; 2. Set the two fixed parameters as desired !! THIS NEEDS TO BE VARIED FROM ITERATION TO ITERATION ; should work (i.e. be varied/changed) MouseMove, FixPar1MXP, FixPar1MYP, 0 ;Sleep 500 MouseClick ;Sleep 500 MouseClick ;MsgBox Just to make sure: CurPar1=%CurPar1% Sleep 100 SendInput %CurPar1% Sleep 100 MouseMove, FixPar2MXP, FixPar2MYP, 0 ;Sleep 500 MouseClick ;Sleep 500 MouseClick ;MsgBox Just to make sure: CurPar2=%CurPar2% Sleep 100 SendInput %CurPar2% Sleep 100 ; 3. Go to Artemis Main Window WinActivate , ahk_id %ArtemisMainWindowUID% WinWaitActive , ahk_id %ArtemisMainWindowUID% ; 3. Enter the fit name !! THIS NEEDS TO BE VARIED FROM ITERATION TO ITERATION ; should be fine now MouseMove, Edit1XP, Edit1YP, 0 MouseClick MouseClick SendInput ^{a} {BS}{BS}{BS}Fit %TFC% ; 4. Enter the fit description !! THIS NEEDS TO BE VARIED FROM ITERATION TO ITERATION ;should be fine MouseMove, FDXP, FDYP, 0 MouseClick MouseClick SendInput ^{Home} {Ctrl down} +{End} {Ctrl up} {BS}{BS}{BS}{BS}{BS}{BS}{BS}Parameter1: %CurPar1% {Enter}Parameter2: %CurPar2% ; 5. Press "Fit" Button MouseMove, FitXP, FitYP, 0 MouseClick ; 6. wait (how long?), oh, possibly until the log window becomes active ; This one is a serious issue ; The fitting does not seem to be completely finished when the plot window pops up... ; actually, until the plot window pops up ;WinWaitActive , ahk_id %PID% ;MsgBox 6 ; This is really annoying, these windows keep changing names. ; I will just add a timer here as well and maybe improve/fix it later ; no, this timer is what causes the issues I think. ; simply have to include picking the plot window at the beginning Sleep 5000 ; 7. Go to log window (if necessary) WinActivate , ahk_id %ArtemisMainWindowUID% WinWaitActive , ahk_id %ArtemisMainWindowUID% ;MsgBox 7 MouseMove, slogX, slogY, 0 MouseClick MouseClick ;Sleep 300 ; 8. Save the log file ; THERE SEEMS TO BE A PROBLEM WITH SAVING THE LOGFILES. ; I COULD PLAY AROUND WITH LONGER SLEEP TIME WinActivate , ahk_id %LogID% WinWaitActive , ahk_id %LogID% ;MsgBox 8 MouseMove, SaveX, SaveY, 0 MouseClick ; WinWaitActive , ahk_id 0x3028a ID doesn't work as this one changes, so just wait some time Sleep 1000 SendInput ^{a} {BS}{BS}{BS}Fit %TFC% Sleep 1000 SendInput {Enter} Sleep 500 CurPar2:=CurPar2+StepSize } ; target #1: PtCoN NP bC } CurPar1:=CurPar1+StepSize } Sleep 1000 MsgBox A total of %TFC% fits have been performed. Return } On 16/06/2017 18:59, Felix E. Feiten wrote:
I am very sorry, in the second paragraph the sequence describing what I want to do could have been clearer:
I want to 1. start a fit with certain parameters, 2. save the log file, 3. change one parameter. This should be repeated many (120 for now) times.
Felix
On 16/06/2017 18:39, Felix E. Feiten wrote:
Dear Ifeffit mailing-list,
first of all sorry for writing another mail to the list in such a short time span, I hope people will not get sick of me too quickly.
I want to do many fits for the same data with varying start-parameters. More specifically, I am doing fits to EXAFS data of the Pt L3 edge of PtCo(X) nanoparticles and want to vary sigma^2 for each of the two paths (Pt-Pt and Pt-Co) that I fit. I want to 1. start a fit with certain parameters, 2. save the log file, 3. change one parameter many (120 for now) times.
If there is no functionality to do this in Artemis I'll have to resort to using some external script that abuses Artemis. In that case I will report on how it went. But obviously, it would be much more comfortable if Artemis had something like this implemented.
Any way to start a fit from the windows command line (I'm using Windows 10) would also be very helpful as that would probably allow me to do the scripting in PowerShell relatively easily.
With kind regards,
Felix
_______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit Unsubscribe: http://millenia.cars.aps.anl.gov/mailman/options/ifeffit