Skip to content

Instantly share code, notes, and snippets.

Avatar

Filip Dominec FilipDominec

View GitHub Profile
@FilipDominec
FilipDominec / convert_rwd8_to_txt.py
Created Feb 25, 2022
Convert binary .RWD8 format from Avaspec spectrometers into a text file and graphical plots
View convert_rwd8_to_txt.py
#!/usr/bin/python3
#-*- coding: utf-8 -*-
## Import common moduli
import sys
import matplotlib.pyplot as plt
import numpy as np
import struct
"""
@FilipDominec
FilipDominec / numpy2tkinter.py
Last active Dec 3, 2021
Easy plotting from 2D numpy array, supporting colormaps, embossing, (un)zooming etc. Depends on TkInter + numpy only.
View numpy2tkinter.py
#!/usr/bin/python3
#-*- coding: utf-8 -*-
# License: This code is released as public domain.
import time
import numpy as np
import tkinter as tk
X_SIZE, Y_SIZE = 200, 200
@FilipDominec
FilipDominec / encoding_detection_for_html.py
Created Oct 19, 2021
Helps to fix diacritics mess in legacy websites. Uses the chardet module to detect character encoding; accepts multiple files to print a table
View encoding_detection_for_html.py
#!/usr/bin/python3
#-*- coding: utf-8 -*-
import chardet, pathlib, sys
known_enc = {'Win':'Windows-1250', 'ISO':'ISO-8859-2', '1250':'Windows-1250', 'utf':'utf8' }
for fn in sys.argv[1:]:
found_enc = chardet.detect(pathlib.Path(fn).read_bytes())['encoding']
if found_enc[:3] in known_enc.keys():
found_enc = known_enc[found_enc[:3]]
print(f'{fn:20s} auto-detected encoding {found_enc:14s}', end='')
View journalList.txt
"Meteor" Forschungsergebnisse = "Meteor" Forschungsergeb.
2D Materials = 2D Mater.
3D Printing and Additive Manufacturing = 3D Print. Addit. Manuf.
AACN Clinical Issues = AACN Clin. Issues
AACN Clinical Issues in Critical Care Nursing = AACN Clin. Issues Crit. Care Nurs.
AADE Editors Journal = AADE Ed. J.
AANA Journal = AANA J.
AANNT Journal = AANNT J.
AAOHN Journal = AAOHN J.
AAPG Bulletin = AAPG Bull.
@FilipDominec
FilipDominec / multifit.py
Last active Feb 28, 2019
Loads ASCII-exported spectra from Princeton spectrometer, exports "worm plot" of spectral position and intensity of the peak
View multifit.py
#!/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 Jan 1, 2019
Parses one or more XLS files, each containing arbitrary number of sheets, and filters all rows for a pattern
View labbook_xls_filter.py
#!/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 Dec 14, 2018
File splitter based on (multiple) keyword searches (must be at line start!). Keeps 1st line as header.
View file_splitter_by_search.py
#!/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 / RPSDF.py
Created Jul 27, 2018
Evaluate the cathodoluminescence statistical features using Radial Power Spectral Density
View RPSDF.py
#!/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 / calibration_curve.dat
Last active Sep 22, 2017
How to calibrate an UV spectrometer if you have separate UVB, UVA and visible sources
View calibration_curve.dat
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
View cathodoluminescence_contours.py
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')