Skip to content

Instantly share code, notes, and snippets.

View abulatek's full-sized avatar

Alyssa Bulatek abulatek

View GitHub Profile
from astropy.io import fits
from spectral_cube import OneDSpectrum
from glob import glob
def write_madcuba_ascii(fn):
# Write the ASCII header based on the FITS spectrum provided
hdul = fits.open(fn)
# Get header parts
spec_unit = f"UnitSpectral: {hdul[0].header['CUNIT1']}"
int_unit = f"UnitInten: {hdul[0].header['BUNIT']}"
@abulatek
abulatek / aspect_ratios.py
Created January 20, 2022 21:51
How to fix aspect ratios in marginal/joint plot (fixes provided by Adam Ginsburg, gist written by Alyssa Bulatek)
# I hope this is a MWE
# Generate random signal mask, using seed
numpy.random.seed(24)
signal_mask = np.random.rand(37,512,512)
import matplotlib.pyplot as plt
from astropy.visualization import simple_norm
# Generate data that we're plotting (from a cube called `signal_mask`
@abulatek
abulatek / SpectralCubeReprojectMaskExample_v3.ipynb
Last active July 2, 2021 15:59
Compiled from tutorials by Adam Ginsburg (reprojection) and Eric Koch, Adam Ginsburg, Tom Robitaille, and Erik Rosolowsky (signal masking). Example of reprojecting one spectral cube onto another, and masking the signal of one cube with the signal of another. Now with better noise estimation, more annotations, continuum subtraction, and PV projec…
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from spectral_cube import SpectralCube, StokesSpectralCube # maybe don't need StokesSpectralCube
from glue.core import Data, DataCollection
from glue.app.qt.application import GlueApplication
from glue.viewers.image.qt import ImageViewer
from glue.core.coordinates import coordinates_from_wcs
image_dir = '/orange/adamginsburg/brick_alma_linesurvey/2019.1.00092.S/imaging_results/'
image_file = image_dir + 'BrickMaser_87_spw25.residual'
cube = SpectralCube.read(image_file, format = 'casa_image')