Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focused on getting my research done, and sometimes, the rp2daq project

Filip Dominec FilipDominec

🎯
Focused on getting my research done, and sometimes, the rp2daq project
View GitHub Profile
@FilipDominec
FilipDominec / wrong_charset_detection.py
Created Jun 28, 2022
Searches for such charset conversion, which would generate a wrong encoded string from a known correct one
View wrong_charset_detection.py
#!/usr/bin/python3
#-*- coding: utf-8 -*-
# Searches for such charset conversion, which would generate a wrong encoded string from a known correct one
# Public domain, written by Filip Dominec 2022
# EXAMPLES:
#wrong, correct = "╪ konstrukЯnб ¤eчenб", "ě konstrukční řešení"
#wrong, correct = "sloučeninovĂ˝ch", "sloučeninových"
@FilipDominec
FilipDominec / Abbreviate Journal Names in Bibtex Database.py
Last active Jun 7, 2022
Using the translation table from the Jabref program, finds and replaces all scientific journal names to their standardized abbreviated form. First argument is the file to be processed; outputs safely to 'abbreviated.bib'
View Abbreviate Journal Names in Bibtex Database.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# Supporting Python 3
import sys, os, re
try: bibtexdb = open(sys.argv[1]).read()
except: print("Error: specify the file to be processed!")
if not os.path.isfile('journalList.txt'):
@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 / hamiltonian1D_eigenstates.py
Last active Sep 6, 2019
Playground for visualisation of the Schrödinger equation solutions in one dimension
View hamiltonian1D_eigenstates.py
#!/usr/bin/python3
import matplotlib.pyplot as plt
import numpy as np
import numpy.linalg as la
width, n= 1., 500 ## width of the 1D quantum system, and number of points
nplot = 10 ## number of quantum states to plot
h = 1e-4 ## our definition of "Planck constant" determines the density of states
psiscale = .01 ## for plotting only: approximate matching of probability and potential scales
@FilipDominec
FilipDominec / owon_wave.py
Last active Jun 1, 2019 — forked from aniline/owon_wave.py
Make a wave file from owon oscilloscope wave dump. It just does one channel. Not tested with numerous other combinations. Note that slow "running-wave" records fail to be properly saved due to Owon firmware bug.
View owon_wave.py
#!/usr/bin/env python
#
# Makes a wav file out of owon oscilloscope waveform save file.
# Tested with SDS6062 only.
#
# Used:
# http://bikealive.nl/owon-bin-file-format.html and
# http://bikealive.nl/tl_files/EmbeddedSystems/Test_Measurement/owon/OWON%20Oscilloscope%20PC%20Guidance%20Manual.pdf
#
@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 -