This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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:]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
""" | |
Program accepts two parameters: image1 image2 | |
Both files have to have the same dimension. Any format accepted by scipy is possible. | |
They may be grayscale or RGB, in the latter case the R+G+B value is taken. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
try: | |
with open('num.txt') as ff: | |
num = int(ff.read())+1 | |
except FileNotFoundError: | |
num=1 | |
numstr = '{:02d}'.format(num) | |
print(numstr) | |
with open('num.txt', 'w') as ff: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#plotstyle = "basis" | |
plotstyle = "amplitude" | |
decimatex = 1 | |
ncomponents = 6 | |
a = ys[:, ::decimatex] | |
xs = xs[:, ::decimatex] | |
U, s, V = np.linalg.svd(a, full_matrices=False) | |
if plotstyle=="basis": | |
for x, y, label in zip(xs[:ncomponents], V[:ncomponents], range(ncomponents)): |