Skip to content

Instantly share code, notes, and snippets.

View mileslucas's full-sized avatar

Miles Lucas mileslucas

  • Institute for Astronomy
  • Hilo, Hawaii
  • 14:51 (UTC -10:00)
View GitHub Profile
from collections import OrderedDict
import multiprocessing
from pathlib import Path
import shutil
from typing import Union, Optional
from astropy.io import fits
import click
import pandas
from tqdm.auto import tqdm
@mileslucas
mileslucas / pupil.py
Last active October 31, 2023 20:45
SCExAO pupil simulator
"""
Simulate the SCExAO pupil
"""
from argparse import ArgumentParser
import hcipy as hp
import numpy as np
from astropy.io import fits
__all__ = ["generate_pupil"]
@mileslucas
mileslucas / quickselect.jl
Last active May 3, 2023 06:34
quickselect scripts using ds9 interfaces
using Glob
using SAOImageDS9
function quickselect(glob_str; logscale=true)
# parse out the directory, if any
directory, globstr = splitdir(glob_str)
filelist = collect(glob(globstr, directory))
N = length(filelist)
@info "Selecting through $N files"
# connect to ds9 and set up
from astropy.io import fits
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation
import astropy.units as u
subaru_loc = EarthLocation(lat=19.825504 * u.deg, lon=-155.4760187 * u.deg)
def get_pa_from_header(filename):
with fits.open(filename) as hdul:
from astropy.io import fits
import numpy as np
from vampires_dpp.constants import SUBARU_LOC, PUPIL_OFFSET
import vampires_dpp.mueller_matrices as mm
def mueller_matrix_miles(filename):
header = fits.getheader(filename)
bs_ord = header["U_CAMERA"] == 1
@mileslucas
mileslucas / reproject.py
Created April 9, 2020 02:39
Simple Image Reprojection
from reproject import reproject_interp
from astropy.io import fits
from glob import glob
import numpy as np
# get the header for the file we want to reproject to
hdr = fits.getheader("NEP5281_r_0_new.fits")
# get the filenames as a list for each filter
rfiles = glob("*r*_new.fits")
ifiles = glob("*i*_new.fits")
@mileslucas
mileslucas / README.md
Created March 20, 2020 03:02
Multiple Badge CI

Badges

Linux Mac OS X Windows

@mileslucas
mileslucas / save_the_kernel__save_the_world.py
Created December 16, 2018 22:07
3 parameter ARD kernel Tensorflow for Gaussian Process marginal likelihood optimization
import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
tfk = tfp.positive_semidefinite_kernels
from Starfish.emulator import PCAGrid
class InputTransformedKernel(tfk.PositiveSemidefiniteKernel):