Skip to content

Instantly share code, notes, and snippets.

View syrte's full-sized avatar

Zhaozhou Li syrte

View GitHub Profile
@eteq
eteq / apj_short_prop.bst
Created March 1, 2013 20:12
A modified version of the apj latex/bibtex bst file for funding/observing proposals where there is very little space.
%%This is often best used in a latex file in two-column mode. To do that, do:
%%
%%\usepackage{multicol} % before \begin{document}
%% ... document ...
%%\begin{multicols}{2}
%%\bibliography{filename}{}
%%\bibliographystyle{apj_short_prop}
%%\end{multicols}
@letmaik
letmaik / voronoi_polygons.py
Last active June 9, 2022 22:16
Creates a Voronoi diagram with cell polygons using scipy's Delaunay triangulation (scipy >= 0.9)
from __future__ import division
import collections
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay, KDTree
# an adaptation of https://stackoverflow.com/a/15783581/60982
# using ideas from https://stackoverflow.com/a/9471601/60982
@PBarmby
PBarmby / tab_trans.py
Created May 1, 2014 15:09
Transpose tables in astropy
import numpy as np
from astropy.table import Table, Column
def transpose_table(tab_before, id_col_name='ID'):
'''Returns a copy of tab_before (an astropy.Table) with rows and columns interchanged
id_col_name: name for optional ID column corresponding to
the column names of tab_before'''
# contents of the first column of the old table provide column names for the new table
# TBD: check for duplicates in new_colnames & resolve
new_colnames=tuple(tab_before[tab_before.colnames[0]])
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@tillahoffmann
tillahoffmann / weighted_kde.ipynb
Last active June 24, 2023 07:39
Weighted kernel density estimation based on `scipy.stats.gaussian_kde`.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hugke729
hugke729 / rasterize_and_save.py
Last active December 3, 2023 02:55
Simplify export of matplotlib figures when both raster and vector components are desired in output
# A function to rasterize components of a matplotlib figure while keeping
# axes, labels, etc as vector components
# https://brushingupscience.wordpress.com/2017/05/09/vector-and-raster-in-one-with-matplotlib/
from inspect import getmembers, isclass
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
def rasterize_and_save(fname, rasterize_list=None, fig=None, dpi=None,
@dshulchevskiy
dshulchevskiy / add_sublime_shortcut.py
Last active May 28, 2020 14:06
Sublime shortcut for jupyter notebook
"""
Sublime shortcuts for jupyter notebook
"""
from jupyter_core.paths import jupyter_config_dir
import os
custom_js_path = os.path.join(jupyter_config_dir(), 'custom', 'custom.js')
custom_path = os.path.join(jupyter_config_dir(), 'custom')
@bamford
bamford / sersic_lum.py
Created October 18, 2023 08:13
Luminosity of Sérsic function in annulus
from numpy import pi, exp
from scipy.special import gamma, gammaincinv, gammainc
# Normalisation constant
def b(n):
return gammaincinv(2*n, 0.5)
# Total luminosity of a 2D Sérsic profile
def sersic_total_lum(Ie, re, n):
bn = b(n)