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 some_task(catalog, ...): | |
... | |
data, changed = catalog.load_url(url, path) | |
# If the data is not changed, and we are updating... we're done | |
if not changed and catalog.args.update: | |
return | |
# Continue processing, update data blah blah blah |
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 label_line(ax, line, label, color='0.5', fs=14, halign='left'): | |
"""Add an annotation to the given line with appropriate placement and rotation. | |
Based on code from: | |
[How to rotate matplotlib annotation to match a line?] | |
(http://stackoverflow.com/a/18800233/230468) | |
User: [Adam](http://stackoverflow.com/users/321772/adam) | |
Arguments | |
--------- |
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 | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots(figsize=[10, 6]) | |
ax.set(xscale='log', yscale='log') | |
ax.axis('off') | |
DURATION = 20.0 | |
CADENCE = 0.1 |
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
#!/bin/bash | |
# Detect which `ls` flavor is in use | |
if ls --color > /dev/null 2>&1; then # GNU `ls` | |
colorflag="--color" | |
else # OS X `ls` | |
colorflag="-G" | |
fi | |
# List all files colorized in long format |
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 sys | |
import os | |
import numpy as np | |
import scipy as sp | |
import scipy.stats | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
# Silence annoying numpy errors |
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
# Initialize Auto-Reloading Magic | |
%reload_ext autoreload | |
%autoreload 2 | |
import os | |
import sys | |
from importlib import reload | |
import astropy as ap | |
import numpy as np |
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
EVOLVE_ACCRETION_FLAG = True | |
def main(): | |
mbhb, sets = run_init() | |
# ... do some check and logging and whatever ... | |
if EVOLVE_ACCRETION_FLAG: |
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 | |
import scipy as sp | |
import scipy.stats | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots(figsize=[8, 5]) | |
ax.set_xscale('log') | |
# Construct a log-normal distribution | |
dist = sp.stats.lognorm(1) |
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 | |
import scipy as sp | |
import scipy.stats | |
import matplotlib.pyplot as plt | |
NUM = 100 | |
xx = np.random.uniform(-1.0, 1.0, NUM) | |
plt.hist(xx) |
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 | |
import scipy as sp | |
import scipy.stats | |
import matplotlib.pyplot as plt | |
def sf_rad(mm, aa, bb): | |
rs = aa + bb * (np.log10(mm) - 10.0) | |
return np.power(10.0, rs) |
OlderNewer