Skip to content

Instantly share code, notes, and snippets.

View granttremblay's full-sized avatar
🌳

Grant Tremblay granttremblay

🌳
View GitHub Profile
Sync my Atom settings across devices.
@granttremblay
granttremblay / mask_alma_maps.py
Last active August 4, 2017 15:35
NaN masking ALMA maps
#!/usr/bin/env python
import numpy as np
from astropy.io import fits
files = ['HE0433_mom0.fits', 'HE0433_mom1.fits', 'HE0433_mom2.fits']
outnames = ['mom0_masked.fits', 'mom1_masked.fits', 'mom2_masked.fits']
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@granttremblay
granttremblay / flip_osiris_axes.py
Last active August 14, 2017 17:23
Flip Keck/OSIRIS IFU Cube axes from (Lambda, RA, Declination) to (RA, Declination, Lambda)
#!/usr/bin/env python
"""
flip_osiris_axes.py: Convert a Keck/OSIRIS IFU datacube from axes of
(Lambda, RA, Dec) to (RA, Dec, Lambda) so that it can be read by, e.g.,
QFitsView.
OSIRIS, for a frankly mystifying reason, (related to FITS FORTRAN axes
orders, I think), defaults to axes of (Lambda, RA, Dec.). This script
converts the cube to (Ra, Dec, Lambda), which requires both a reorder of the
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def fusemusealma(muse_moment_fits, alma_moment_fits):
'''
Open MUSE and ALMA HDUs, pick up their WCSs,
drop needless ALMA WCS axes, reproject
ALMA to MUSE, then output new HDUs.
'''
museHDU = fits.open(get_pkg_data_filename(muse_moment_fits))
almaHDU = fits.open(get_pkg_data_filename(alma_moment_fits))
w_alma = WCS(almaHDU[0])
import os
import glob
import warnings
from astropy.io import fits
from astropy.wcs import WCS
from astroquery.ned import Ned
import os
import glob
import argparse
import warnings
from astropy.io import fits
from astropy.wcs import WCS
@granttremblay
granttremblay / gist:daa05be7734d587d60c49d46815d4712
Created December 27, 2017 21:11
Explicitly select colors in a matplotlib.style color pallete. DUMB.
# Yes, this is the dumb way you have to select mpl.style (like 'ggplot') colors:
color_number = 2
color_choice = list(plt.rcParams['axes.prop_cycle'])[color_number]['color']
def fusemusealma(muse_moment_fits, alma_moment_fits):
'''
Open MUSE and ALMA HDUs, pick up their WCSs,
drop needless ALMA WCS axes, reproject
ALMA to MUSE, then output new HDUs.
'''
museHDU = fits.open(get_pkg_data_filename(muse_moment_fits))
almaHDU = fits.open(get_pkg_data_filename(alma_moment_fits))