import numpy as np
import proplot as pplt
from matplotlib import pyplot as plt
import cartopy.geodesic
def add_ticks(ax, labelpad=None):
"""
Only works for major ticks on the left and bottom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interp_orbit(ix, snap_list, npts=51, rtol=1e-5): | |
ns = len(snap_list) - 1 | |
ts = np.array([si.t for si in snap_list.values()]) | |
t_list = np.empty((ns, npts)) | |
xv_list = np.empty((len(ix), ns, npts, 6)) | |
for i, si in enumerate(snap_list.values()): | |
print(i, end=',', flush=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import json | |
for file in sys.argv[1:]: | |
print('# file: %s' % file) | |
print('# vi: filetype=python') | |
print('') | |
code = json.load(open(file)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CubicSplineExtrap(CubicSpline): | |
def __init__(self, x, y, bc_type='not-a-knot', extrapolate='linear'): | |
""" | |
Linearly extrapolate outside the range | |
extrapolate: False, float, 'const', 'linear', 'cubic', or a 2-tuple of them | |
Example | |
------- | |
from scipy.interpolate import PchipInterpolator, CubicSpline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create env and install dependency | |
conda create -n agama python=3.8 numpy gsl glpk eigen cvxopt | |
conda activate agama | |
# download files | |
cd $HOME/src | |
wget https://github.com/GalacticDynamics-Oxford/Agama/archive/master.zip -O agama.zip | |
wget https://github.com/GalacticDynamics-Oxford/unsio/archive/master.zip -O unsio.zip | |
wget https://github.com/cvxopt/cvxopt/archive/master.zip -O cvxopt.zip | |
unzip agama.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Add exponentiated variance (EV) acquisition function to skopt. | |
Author: | |
Zhaozhou Li (lizz.astro@gmail.com) | |
""" | |
import numpy as np | |
import warnings | |
import skopt.acquisition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
author: | |
Zhaozhou Li (lizz.astro@gmail.com) | |
history: | |
This code is taken from my project mw_mass3. | |
""" | |
import numpy as np | |
from scipy.interpolate import CubicSpline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python IO for nemo snapshot | |
Author: syrte (lizz.astro@gmail.com) | |
Example: | |
file = '../data/N1e6_d0.22_g0.16_0.00_f0.00.snap' | |
snap = open_nemo(file, file_meta=False) | |
print(snap.History.data, end='\n\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def null_decorator(*args, **kwargs): | |
"A decorator that does nothing." | |
if len(args) == 1 and len(kwargs) == 0 and callable(args[0]): | |
return args[0] | |
else: | |
return null_decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from libc.string cimport memcpy | |
from numpy cimport ndarray | |
from cython_gsl cimport * | |
cdef struct gsl_spline_t: | |
gsl_interp_t *interp | |
double *x | |
double *y |