Skip to content

Instantly share code, notes, and snippets.

View FilipDominec's full-sized avatar
🎯
Basically always busy, that's OK

Filip Dominec FilipDominec

🎯
Basically always busy, that's OK
View GitHub Profile
@FilipDominec
FilipDominec / multifit.py
Last active February 28, 2019 15:26
Loads ASCII-exported spectra from Princeton spectrometer, exports "worm plot" of spectral position and intensity of the peak
#!/usr/bin/python3
#-*- coding: utf-8 -*-
"""
Batch fitting of multiple spectra - evaluation of spectroscopic response of InGaN/GaN quantum-well sensors to the
presence of surface charges induced by gases or liquids.
Invocation:
./multifit.py <filename>.dat
where
@FilipDominec
FilipDominec / labbook_xls_filter.py
Created January 1, 2019 22:25
Parses one or more XLS files, each containing arbitrary number of sheets, and filters all rows for a pattern
#!/usr/bin/python3
#-*- coding: utf-8 -*-
"""
Parses one or more XLS files, each containing arbitrary number of sheets, and filters all rows for a
pattern as determined by filter_lines=... below. Prints matching names.
Typical invocation
python3 ./xlsfilter.py *201{6,7,8}.{1,2}.xlsx | vi -
@FilipDominec
FilipDominec / file_splitter_by_search.py
Created December 14, 2018 10:00
File splitter based on (multiple) keyword searches (must be at line start!). Keeps 1st line as header.
#!/usr/bin/python3
#-*- coding: utf-8 -*-
import re, sys
with open(sys.argv[1]) as inputf:
c = 1
ls = inputf.readlines()
fromline = 1
for splitter in sys.argv[2:]:
@FilipDominec
FilipDominec / matplotlib-dual_axis-nice_numbers.py
Last active November 4, 2018 11:20
Functional dependence of right y-axis on the left one in Matplotlib: how to get nice numbers on both axes
#!/usr/bin/python3
#-*- coding: utf-8 -*-
import numpy as np
import scipy.constants as sc
import matplotlib.pyplot as plt
import matplotlib
@FilipDominec
FilipDominec / RPSDF.py
Created July 27, 2018 18:21
Evaluate the cathodoluminescence statistical features using Radial Power Spectral Density
#!/usr/bin/python3
#-*- coding: utf-8 -*-
## Import common moduli
import matplotlib, sys, os, time
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import c, hbar, pi
from scipy.misc import imread
@FilipDominec
FilipDominec / F-P-resonance-filter
Last active October 20, 2017 10:07
Filter Fabry-Pérot resonance from luminescence spectra shown in Plotcommander
fw=int(len(xs[0])/30) # filter width
fl=int(len(xs[0])/20) # filter limit: minimum position of the Fabry-Pérot peak in correlation function
skippoints = 0 # sometimes the first point is some header
def nGaN(energies):
## returns index of refraction in GaN according to [Tisch et al., JAP 89 (2001)]
eV = [1.503, 1.655, 1.918, 2.300, 2.668, 2.757, 2.872, 3.006, 3.136, 3.229, 3.315, 3.395, 3.422]
n = [2.359+0.08, 2.366+0.04, 2.383+0.02, 2.419, 2.470, 2.486, 2.511, 2.549, 2.596, 2.643, 2.711-.01, 2.818-.045, 2.893-.100]
return np.interp(energies, eV, n)
@FilipDominec
FilipDominec / calibration_curve.dat
Last active September 22, 2017 17:04
How to calibrate an UV spectrometer if you have separate UVB, UVA and visible sources
3.003903829999999857e+02 1.640232643851876337e-01
3.006813710000000128e+02 1.663268589412743859e-01
3.009723399999999742e+02 1.676764695268916916e-01
3.012632909999999811e+02 1.669212216194967402e-01
3.015542229999999790e+02 1.670782231063905887e-01
3.018451360000000250e+02 1.743939035195906928e-01
3.021360310000000027e+02 1.665717034735433866e-01
3.024269070000000283e+02 1.757442043184819225e-01
3.027177649999999858e+02 1.777328050331506148e-01
3.030086029999999937e+02 1.730466534811957724e-01
matplotlib.rc('font', size=12)
ys = np.array(ys)[:, :1024]
ys /= 5782000/.1517*0.02301 # np.max(ys) # fixed normalization for all samples
x = np.poly1d([4.64708212e-15, -1.65806129e-05, 5.20397778e-01, 3.53568373e+02])(range(1024))
for yy in ys:
yy[:] = np.convolve(yy, 2**(-np.linspace(-2,2,15)**2),mode='same')
@FilipDominec
FilipDominec / explore-object-tree.py
Created September 21, 2017 11:13
Recursively prints all attributes, lists, dicts etc. of a given object - here used for analysis of a parsed OPJ file
#!/usr/bin/python3
#-*- coding: utf-8 -*-
import liborigin
opj = liborigin.parseOriginFile('../test.opj')
coloured = True
if coloured:
normal = "\033[1;0m"
bold = "\033[1;1m"
@FilipDominec
FilipDominec / filter_outliers.py
Last active September 6, 2017 13:25
Clean up two-column ASCII file from "hot pixels" that differ by more than 3σ from their neighbours
#!/usr/bin/python3
#-*- coding: utf-8 -*-
"""
Do you have some "outlier" noise in your experimental data, e.g. due to "hot pixels" in spectrometer?
Run
python3 rm_outliers.py my_file.dat
and the new "my_file.dat_corrected.dat" will be free of these errors.