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
View continuous arccosine notes
TODO: copy from my codes and add a test:
http://comments.gmane.org/gmane.comp.python.scientific.devel/17439
@FilipDominec
FilipDominec / Lagrangian points - force plot
Created Jan 25, 2015
there are 5 points in the Sun-Earth system where gravitational and centrifugal forces cancel
View Lagrangian points - force plot
#!/usr/bin/env python
#coding:utf8
import numpy as np
#Mearth, Msun = 5.97e24, 1.98e30 ## <-- these are realistic
Mearth, Msun = 1.97e29, 1.98e30 ## <-- unrealistic, but better for visualisation
earth_sun_dist = 149e9
Xsun = - earth_sun_dist * (Mearth/Msun) ## Sun center distance to the center-of-mass
Xearth = earth_sun_dist * (1 - Mearth/Msun) ## Earth center distance to the center-of-mass
kappa = 6.67e-11 ## Gravitational constant
View Plot Kramers-Kronig relations
#!/usr/bin/env python
#-*- coding: utf-8 -*-
## Import common moduli
import matplotlib, sys, os, time, re
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import c, hbar, pi
matplotlib.rc('text', usetex=True)
matplotlib.rc('font', size=10)
@FilipDominec
FilipDominec / Testing Padé approximants
Last active Aug 29, 2015
- or, how eˣ can be approximated by fractions having small degrees of numerator/denominator
View Testing Padé approximants
#!/usr/bin/env python
#-*- coding: utf-8 -*-
## Import common moduli
from __future__ import division
import matplotlib, sys, os, time
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import c, hbar, pi
@FilipDominec
FilipDominec / FFT of frequency-modulated sinewave
Created Feb 18, 2015
How does the spectrum of a frequency modulated wave differ from the well known amplitude-modulated one?
View FFT of frequency-modulated sinewave
#!/usr/bin/env python
#-*- 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
## Use LaTeX
@FilipDominec
FilipDominec / Mayavi scripting
Created Feb 20, 2015
Instantly display a vector VTK file in Mayavi
View Mayavi scripting
#!/usr/bin/env python2.7
#-*- coding: utf-8 -*-
import os,sys
import numpy as np
try: from enthought.mayavi import mlab
except: from mayavi import mlab
mlab.options.offscreen = True ## XXX
def symmetric_colors(lut_manager):
@FilipDominec
FilipDominec / Square root of a matrix
Created Feb 20, 2015
Most scalar functions can be generalized to square matrices, which requires to apply the function to the eigenvalues
View Square root of a matrix
#!/usr/bin/env python
#coding:utf8
import numpy as np
import scipy.linalg as la
size = 3
A = np.random.random([size, size])
print "\n== Random square matrix can be subject to virtually any function =="
View useful_functions.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
## . S C SM
## F1 PREAMB Import UseLatex StartFig
## F2 GET Load1D Gen1D Get2D
## F3
## F4
## F5 PLOT Plot1D Contours
## F6
View rule30_order_and_chaos.py
#!/usr/bin/env python
# -*- coding: utf -*-
S = "-"*70 + u"█" + "-"*80
for x in range(100):
print S
Q = "-"
for l in range(1, len(S)-1):
a, b, c = S[l-1]==u"█", S[l]==u"█", S[l+1]==u"█"
if (a and not b and not c) or (not a and b and not c) or (not a and not b and c) or (not a and b and c):
Q = Q+u"█"
View annotate_picture_by_name.sh
#!/bin/bash
for n in $*; do
q=${n};
#q=${n%.png};
mogrify -gravity southeast -density 300 -font Arial -pointsize 12 -annotate 0 ${q} $n
done