Skip to content

Instantly share code, notes, and snippets.

View andycasey's full-sized avatar

Andy Casey andycasey

View GitHub Profile
@andycasey
andycasey / di_cook.py
Created January 15, 2023 00:54
SDSS DR17 subset for Di Cook
from astropy.table import Table
data = Table.read("/uufs/chpc.utah.edu/common/home/sdss50/dr17/apogee/spectro/aspcap/dr17/synspec_rev1/allStar-dr17-synspec_rev1.fits")
column_names = data.dtype.names
ignore = ["TIII_FE"]
available_elements = [ea for ea in column_names if f"{ea}_FLAG" in column_names and ea not in ignore]
keep = (
@andycasey
andycasey / find_apogee_for_froe.py
Created November 11, 2022 14:50
APOGEE 2D frames for FROE
# /uufs/chpc.utah.edu/common/home/sdss43/dr17/apogee/spectro/redux/dr17/exposures/apogee-n/57282
# or
# https://dr17.sdss.org/sas/dr17/apogee/spectro/redux/dr17/exposures/apogee-n/57282/
from glob import glob
from astropy.io import fits
# Just use the middle chip for now
paths = glob("ap2D-b-*.fits")
# TODO: Library.get(X) should resolve to Library.get(id=X)
# Make & (Document.date > (datetime.now() - timedelta(days=365.25 * 5)) work
# Make document.year > 2017 work
# Make Document.in_(library) and Library.contains(document) work using docs() function
# Remove default behaviour of .limit(10)
# Document.full() should be searchable, and Document.full == '' SHOULD NOT WORK
"""
Give me:
- highly cited people;
import pendulum
from datetime import datetime
from airflow import DAG
from airflow.models import DagRun
from airflow.sensors.external_task import ExternalTaskSensor
from airflow.operators.dummy import DummyOperator
def get_most_recent_dag_run(dag_id):
dag_runs = DagRun.find(dag_id=dag_id)
import numpy as np
from astroquery.gaia import Gaia
import matplotlib.pyplot as plt
import astropy.coordinates as coord
import gala.dynamics as gd
import gala.potential as gp
from astropy import units as u
np.random.seed(42)
import numpy as np
import matplotlib.pyplot as plt
import pystan as stan
model = stan.StanModel(model_code="""
data {
real parallax;
real parallax_error;
}
import numpy as np
from astroquery.gaia import Gaia
import matplotlib.pyplot as plt
def astrometry_covariance_matrix(source):
"""
Construct a covariance matrix for a 5-parameter astrometric solution
measured by Gaia for a single source.
import numpy as np
from scipy.spatial import Delaunay
training_set_labels = #.... from somewhere else
test_set_labels = np.atleast_2d(test_set_labels)
# construct convex hull of the training set using all labels
hull = Delaunay(training_set_labels)
wget https://data.sdss.org/sas/dr14/apogee/spectro/redux/r8/stars/l31c/l31c.2/cannon/allStarCannon-l31c.2.fits
wget https://data.sdss.org/sas/dr14/apogee/spectro/redux/r8/stars/l31c/l31c.2/allStar-l31c.2.fits
# Script to monitor and restart wireless access point when needed
maxPloss=10 #Maximum percent packet loss before a restart
restart_networking() {
# Add any commands need to get network back up and running
/etc/init.d/networking restart
#only needed if your running a wireless ap