Difference between revisions of "Minimalistic SimFit example"
Jump to navigation
Jump to search
m (Kuehnel moved page Isis:simfit:example to Minimalistic SimFit example without leaving a redirect) |
Thalhammer (talk | contribs) m |
||
Line 80: | Line 80: | ||
</pre> | </pre> | ||
− | < | + | <pre> |
#!/bin/bash | #!/bin/bash | ||
# | # | ||
Line 94: | Line 94: | ||
COMMAND="mpiexec isis-script simpi_fitpars.sl 0" | COMMAND="mpiexec isis-script simpi_fitpars.sl 0" | ||
/usr/bin/nice -n +15 ${COMMAND} | /usr/bin/nice -n +15 ${COMMAND} | ||
− | </ | + | </pre> |
− | < | + | <pre> |
#!/bin/bash | #!/bin/bash | ||
# | # | ||
Line 110: | Line 110: | ||
COMMAND="mpiexec isis-script simpi_fitpars.sl 1" | COMMAND="mpiexec isis-script simpi_fitpars.sl 1" | ||
/usr/bin/nice -n +15 ${COMMAND} | /usr/bin/nice -n +15 ${COMMAND} | ||
− | </ | + | </pre> |
− | < | + | <pre> |
#!/bin/bash | #!/bin/bash | ||
# | # | ||
Line 126: | Line 126: | ||
COMMAND="mpiexec isis-script simpi_fitpars.sl 2" | COMMAND="mpiexec isis-script simpi_fitpars.sl 2" | ||
/usr/bin/nice -n +15 ${COMMAND} | /usr/bin/nice -n +15 ${COMMAND} | ||
− | </ | + | </pre> |
− | < | + | <pre> |
require("isisscripts"); | require("isisscripts"); | ||
_traceback=1; | _traceback=1; | ||
Line 164: | Line 164: | ||
time,strjoin(__argv," "),nint(elaptime),time_array(elaptime)[-1]+1, | time,strjoin(__argv," "),nint(elaptime),time_array(elaptime)[-1]+1, | ||
["sec","min","h","d","y"][length(time_array(elaptime))-1] ); | ["sec","min","h","d","y"][length(time_array(elaptime))-1] ); | ||
− | </ | + | </pre> |
Latest revision as of 11:19, 13 September 2018
The aim of this example is to demonstrate the functionality of the SimFit routines with a minimalistic Example.
require("isisscripts"); % Define Data Minimum_Stat_Err = 1e-20; seed_random(1); variable N = 30; variable bin_lo = [1:2:#N+1][[:-2]]; variable bin_hi = [1:2:#N+1][[1:]]; variable data1 = struct{ bin_lo = bin_lo, bin_hi = bin_hi, value = (30+5*sin(2*PI*bin_lo) + grand(N)-0.5) * (bin_hi-bin_lo), err = (9e-1*[1.:1.:#N]) * (bin_hi-bin_lo) }; variable data2 = struct{ bin_lo = bin_lo, bin_hi = bin_hi, value = (35+10*sin(2*PI*bin_lo) + grand(N)-0.5) * (bin_hi-bin_lo), err = (10e-1*[1.:1.:#N]) * (bin_hi-bin_lo) }; variable data3 = struct{ bin_lo = bin_lo, bin_hi = bin_hi, value = (35+10*sin(2*PI*bin_lo) + grand(N)-0.5) * (bin_hi-bin_lo), err = (10e-1*[1.:1.:#N]) * (bin_hi-bin_lo) }; fancy_plot_unit("A"); % Nur zum plotten, falls Daten kein Spektrum sind! % % Initialize sim fit variable sfit = simultaneous_fit(); % Add data () = sfit.add_data(data1); () = sfit.add_data([data2,data3]); % Set fit function sfit.fit_fun("sinwave2(%)"); % Define global Parameter: Tie parameter sinwave2(%).c of all groups to % that of group 1 sfit.set_global("sinwave2(%).b"); sfit.set_global("sinwave2(%).c"); sfit.set_par("sinwave2(%).d",1,0,0,1e6); % load Parameter: variable file_org = "simpi"; variable file_new = "simpi_new"; variable file; if( wherefirst(__argv == "org") != NULL ){ file = file_org; } else{ file = file_new; } vmessage("\n Loading %s.par & %s.model.",file,file); load_par(file+".par"); sfit.load_model(file+".model"); define save_newpar(){ vmessage("\n SAVING %s.par & %s.model.\n",file_new,file_new); save_par(file_new+".par"); %sfit.save_model(file_new+".model"); }; if( wherefirst(__argv == "run") != NULL ){ variable runjob = sfit.fit_pars_run_job("simpi_0000.job", ["simpi_0001.job", "simpi_0002.job"], "simpi_fitpars/*.fits", &save_newpar; agree,maxiter=3,wait=10); }
#!/bin/bash # #PBS -S /bin/bash -V #PBS -l nodes=2 #PBS -l arch=x86_64 #PBS -l walltime=00:01:00 #PBS -N simpi_fitpars_0000 #PBS -o /home/falkner/Public/simpi_fitpars/simpi_fitpars/simpi_fitpars_0000.out #PBS -e /home/falkner/Public/simpi_fitpars/simpi_fitpars/simpi_fitpars_0000.err cd /home/falkner/Public/simpi_fitpars COMMAND="mpiexec isis-script simpi_fitpars.sl 0" /usr/bin/nice -n +15 ${COMMAND}
#!/bin/bash # #PBS -S /bin/bash -V #PBS -l nodes=2 #PBS -l arch=x86_64 #PBS -l walltime=00:01:00 #PBS -N simpi_fitpars_0001 #PBS -o /home/falkner/Public/simpi_fitpars/simpi_fitpars/simpi_fitpars_0001.out #PBS -e /home/falkner/Public/simpi_fitpars/simpi_fitpars/simpi_fitpars_0001.err cd /home/falkner/Public/simpi_fitpars COMMAND="mpiexec isis-script simpi_fitpars.sl 1" /usr/bin/nice -n +15 ${COMMAND}
#!/bin/bash # #PBS -S /bin/bash -V #PBS -l nodes=2 #PBS -l arch=x86_64 #PBS -l walltime=00:01:00 #PBS -N simpi_fitpars_0002 #PBS -o /home/falkner/Public/simpi_fitpars/simpi_fitpars/simpi_fitpars_0002.out #PBS -e /home/falkner/Public/simpi_fitpars/simpi_fitpars/simpi_fitpars_0002.err cd /home/falkner/Public/simpi_fitpars COMMAND="mpiexec isis-script simpi_fitpars.sl 2" /usr/bin/nice -n +15 ${COMMAND}
require("isisscripts"); _traceback=1; % TIME LOG tic;vmessage("%s : Calling: '%s'",time,strjoin(__argv," ")); %%% initialize the simultaneous fit, adding the %%% %%% data and defining/loading the model here %%% ()=evalfile ("simpi.sl"); % get command line arguments (last argument has to be the group index!) variable grp = atoi(__argv[-1]); %%% set the directory for the output fits-files here %%% %%% make sure that this directory exists! %%% variable parpath = "/home/falkner/Public/simpi_fitpars/simpi_fitpars"; % check on existence of parpath if (access(parpath, F_OK) != 0) { vmessage("error: directory %s does not exist, aborting...", parpath); exit; } % calculate uncertainties %%% replace 'simfit' by the name of your simultaneous-fit-structure %%% variable fpars = sfit.mpi_fit_pars( grp ; dir=parpath, basefilename = sprintf("simpi_fitpars_%04d", grp) ); % TIME LOG variable elaptime = toc; vmessage("%s : Finished '%s' after %d s < %d %s", time,strjoin(__argv," "),nint(elaptime),time_array(elaptime)[-1]+1, ["sec","min","h","d","y"][length(time_array(elaptime))-1] );