Skip to content

Instantly share code, notes, and snippets.

View ipashchenko's full-sized avatar

Ilya ipashchenko

  • LPI ASC
View GitHub Profile
import joblib
import os
cachedir = 'cache'
if not os.path.isdir(cachedir): os.mkdir(cachedir)
mem = joblib.Memory(cachedir=cachedir, verbose=True)
@mem.cache
def my_long_function(i):
return i + i
@ipashchenko
ipashchenko / reformat_txt.py
Last active August 29, 2015 14:22
reformat weird txt-files with pulses
import sys
import numpy as np
def reformat_txt(inname, outname):
"""
Function that converts txt-file with dyn. spectra in format:
https://www.dropbox.com/sh/l6kr87oxsxpg367/AACbXZNX4KU1KNEYWjphKbhoa/FRB010724/ascii_files?dl=0
#ch0 t1 value
import numpy as np
import scipy.ndimage as ndimage
# The array you gave above
data = np.array(
[
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@ipashchenko
ipashchenko / grid_dm_search_info.py
Last active August 29, 2015 14:22
parameters of grid DM search for FRB
def delta_dm_max(nu_max, nu_min, dt):
"""
Return difference in DM that corresponds to arrival time shift between
highest and lowest frequency channels equals to time resolution.
:param nu_max:
Frequency of highest frequency channel [MHz].
:param nu_min:
Frequency of lowest frequency channel [MHz].
:param dt:
@ipashchenko
ipashchenko / discrete_emcee_hack.py
Last active August 29, 2015 14:21
discrete parameters sampling with ``emcee`` using @lfloeer's hack
import emcee
import numpy as np
from scipy import stats
try:
import matplotlib.pyplot as plt
except:
plt = None
vround = np.vectorize(round)
@ipashchenko
ipashchenko / infer_num_trials_binomial.py
Last active August 29, 2015 14:21
Bayesian estimation of number of trials in a Binomial distribution
import numpy as np
from scipy import stats
try:
import matplotlib.pyplot as plt
except:
plt = None
def posterior_trials(n_max, data, alpha, beta, delta=0.005):
"""
@ipashchenko
ipashchenko / geom_vs_poisson.py
Last active May 11, 2020 11:16
Model selection via Bayes factor estimation with ``emcee`` (see http://stronginference.com/bayes-factors-pymc.html for ``pymc`` version of model probabilities calculation)
import numpy as np
from scipy import stats
from emcee import PTSampler, EnsembleSampler
try:
import matplotlib.pyplot as plt
except:
plt = None
def lnlike_geom(p, y):
from numpy.fft import fft, ifft, fft2, ifft2, fftshift
import numpy as np
def fft_convolve2d(x,y):
""" 2D convolution, using FFT"""
fr = fft2(x)
fr2 = fft2(np.flipud(np.fliplr(y)))
m,n = fr.shape
cc = np.real(ifft2(fr*fr2))
cc = np.roll(cc, -m/2+1,axis=0)
diff -r 96a023de3ddf make/sun/font/Makefile
--- a/make/sun/font/Makefile Wed Jun 06 18:39:46 2012 -0700
+++ b/make/sun/font/Makefile Fri Jun 08 12:52:01 2012 +0900
@@ -128,7 +128,7 @@
ifeq ($(USING_SYSTEM_FT_LIB), false)
FREETYPE_LIB = $(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX).6
endif
- OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype
+ OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype -lfontconfig
endif
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Solarized Dark" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="14" />
<option name="EDITOR_FONT_NAME" value="Consolas" />
<colors>
<option name="ADDED_LINES_COLOR" value="" />
<option name="ANNOTATIONS_COLOR" value="2b36" />
<option name="ANNOTATIONS_MERGED_COLOR" value="" />
<option name="CARET_COLOR" value="dc322f" />