Skip to content

Instantly share code, notes, and snippets.

View ipashchenko's full-sized avatar

Ilya ipashchenko

  • LPI ASC
View GitHub Profile
@ipashchenko
ipashchenko / get_sim_results.py
Created July 4, 2018 15:51
Getting simulation results
import pandas as pd
import numpy as np
# Reading file with circular elliptic cores
df = pd.read_csv("df_result_cg.csv")
df["dr_ratio"] = df["dr_obs"]/df["dr_true"]
df["phi_app"] = np.arctan(np.tan(df["fi"])/np.sin(df["theta"]))
# These are optional!
# This chooses only sources with models with equal number of components
@ipashchenko
ipashchenko / mojave_vlba_counts.py
Last active December 19, 2018 17:00
Counts of sources from MOJAVE beamed LF (See Cara&Lister 2008)
import numpy as np
from scipy.integrate import quad
from astropy.cosmology import LambdaCDM
# cm in pc
pc = 3.086 * 1E+18
def beta(Gamma):
"""
@ipashchenko
ipashchenko / fit_george_mcmc.py
Last active February 23, 2018 12:10
Full Bayes on RQ+WN with george and emcee
import numpy as np
import george
import emcee
import pickle
from functools import partial
import scipy.optimize as op
import matplotlib.pyplot as plt
from tqdm import tqdm
@ipashchenko
ipashchenko / fit_with_celerite.py
Last active February 22, 2018 20:35
Trying celerite
import pickle
import numpy as np
from scipy.optimize import minimize
import celerite
from celerite import terms
import emcee
import matplotlib.pyplot as plt
# Ilya: We only need x, y, yerr 1D arrays. Substitute your's
with open("0716+714_umrao_lc.pkl", "rb") as fo:
@ipashchenko
ipashchenko / quick_fit.py
Last active February 23, 2018 15:00
Empirical Bayes with RQ+WN kernel
import numpy as np
import george
import pickle
from functools import partial
import scipy.optimize as op
import matplotlib.pyplot as plt
def is_embraced(curve, means, widths):
"""
@ipashchenko
ipashchenko / fit_pymc3.py
Last active February 20, 2018 16:48
robust GP
import pickle
import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt
def fit_robustly(t, y, yerr, draws=500, chains=None, njobs=4, tune=500,
n_new=None, t_new=None, show_traceplot=False,
show_fitted_GP=True, file_fig=None, progressbar=True):
"""
@ipashchenko
ipashchenko / build-gcc-offload-nvptx.sh
Created January 2, 2018 01:00 — forked from kristerw/build-gcc-offload-nvptx.sh
Build GCC with support for offloading to NVIDIA GPUs
#!/bin/sh
#
# Build GCC with support for offloading to NVIDIA GPUs.
#
work_dir=$HOME/offload/wrk
install_dir=$HOME/offload/install
# Location of the installed CUDA toolkit
@ipashchenko
ipashchenko / timeseries_cnn.py
Created November 23, 2017 09:20 — forked from jkleint/timeseries_cnn.py
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
#!/usr/bin/env python
"""
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
"""
from __future__ import print_function, division
import numpy as np
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten
from keras.models import Sequential
import matplotlib.pyplot as plt
import numpy as np
import seaborn
from keras.layers import Input, Dense, merge, ELU, Dropout
from keras.models import Model
from keras.regularizers import l2
from keras import backend as K
from keras.optimizers import rmsprop, adam
import numpy as np
from scipy.stats import gaussian_kde
def get_cdf_of_difference(data_1, data_2, diff_value=0):
data_1 = np.asarray(data_1)
data_2 = np.asarray(data_2)
kde_1 = gaussian_kde(data_1)
data_1.sort()
data_2.sort()