Skip to content

Instantly share code, notes, and snippets.

@ZGainsforth
Last active August 24, 2022 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZGainsforth/dac3c020ec7d29062d6043a49da0c823 to your computer and use it in GitHub Desktop.
Save ZGainsforth/dac3c020ec7d29062d6043a49da0c823 to your computer and use it in GitHub Desktop.
Fityk script file to fit three peaks in an EDS spectrum and output areas. Does each peak independently. Does not include edge jumps.
# Fityk script. Fityk version: 1.3.1. Created: Fri Aug 19 12:09:17 2022
set verbosity = -1 #the rest of the file is not shown
set autoplot = 0
reset
# ------------ settings ------------
set box_constraints = 1
set default_sigma = sqrt
set domain_percent = 30
set epsilon = 1e-012
set fit_replot = 0
set fitting_method = levenberg_marquardt
set ftol_rel = 0
set function_cutoff = 0
set guess_uses_weights = 1
set height_correction = 1
set lm_lambda_down_factor = 10
set lm_lambda_start = 0.001
set lm_lambda_up_factor = 10
set lm_max_lambda = 1e+015
set lm_stop_rel_change = 1e-007
set log_output = 0
set logfile = ''
set max_fitting_time = 0
set max_wssr_evaluations = 1000
set nm_convergence = 0.0001
set nm_distribution = bound
set nm_move_all = 0
set nm_move_factor = 1
set numeric_format = '%g'
set on_error = stop
set pseudo_random_seed = 0
set refresh_period = 4
set width_correction = 1
set xtol_rel = 0
# ------------ datasets ------------
@0 < '/Volumes/ParticleBase/Europa in a can/20220730 - TitanX - EIAC - J2-313 Grid A10/008 - Stack Area 1 zoomin/Bruker Quants/Carbon.txt' text
@+ < '/Volumes/ParticleBase/Europa in a can/20220730 - TitanX - EIAC - J2-313 Grid A10/008 - Stack Area 1 zoomin/Bruker Quants/Carbon.txt' text
@+ < '/Volumes/ParticleBase/Europa in a can/20220730 - TitanX - EIAC - J2-313 Grid A10/008 - Stack Area 1 zoomin/Bruker Quants/Carbon.txt' text
use @0
# Name this dataset.
title = 'C-K'
# Set fitting range.
A = x > 0.150 and x < 0.374
# ------------ variables and functions ------------
$CK_height = ~100.0
$CK_center = ~0.266
$CK_hwhm = ~0.0325895018656
$BkgCK_a0 = ~63.4978126002
$BkgCK_a1 = ~37.6863402513
%CK = Gaussian($CK_height, $CK_center, $CK_hwhm)
%BkgCK = Linear($BkgCK_a0, $BkgCK_a1)
# ------------ models ------------
@0: F = %CK + %BkgCK
plot [-1.6183:2.643] [0.521:19800]
use @0
set autoplot = 1
set verbosity = 0
fit @0
use @1
title = 'O-K'
A = x > 0.374 and x < 0.640
# ------------ variables and functions ------------
$OK_height = ~100.0
$OK_center = ~0.5
$OK_hwhm = ~0.0325895018656
$BkgOK_a0 = ~63.4978126002
$BkgOK_a1 = ~37.6863402513
%OK = Gaussian($OK_height, $OK_center, $OK_hwhm)
%BkgOK = Linear($BkgOK_a0, $BkgOK_a1)
# ------------ models ------------
@1: F = %OK + %BkgOK
plot [-1.6183:2.643] [0.521:19800]
use @1
set autoplot = 1
set verbosity = 0
fit @1
use @2
title = 'Fe-L'
A = x > 0.630 and x < 0.850
# ------------ variables and functions ------------
$FeL_height = ~100.0
$FeL_center = ~0.7
$FeL_hwhm = ~0.0325895018656
$BkgFeL_a0 = ~63.4978126002
$BkgFeL_a1 = ~37.6863402513
%FeL = Gaussian($FeL_height, $FeL_center, $FeL_hwhm)
%BkgFeL = Linear($BkgFeL_a0, $BkgFeL_a1)
# ------------ models ------------
@2: F = %FeL + %BkgFeL
plot [-1.6183:2.643] [0.521:19800]
use @2
set autoplot = 1
set verbosity = 0
fit @2
plot [0:1] [:max(y)]
use @0
info peaks
use @1
info peaks
use @2
info peaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment