Skip to content

Instantly share code, notes, and snippets.

View e-koch's full-sized avatar

Eric Koch e-koch

View GitHub Profile
@e-koch
e-koch / reproject_align_celestialnorth.py
Created October 3, 2025 19:16
reproject_align_celestialnorth
# Example using the mosaicking helper functions in reproject to produce a new WCS
# aligned with North, then reproject the input data to the new header.
from astropy.io import fits
from astropy.wcs import WCS
from reproject import reproject_adaptive
from reproject.mosaicking import find_optimal_celestial_wcs
@e-koch
e-koch / radial_noise_estimator.py
Created June 28, 2024 11:06
Estimate radially varying noise levels in an image
from astropy.io import fits
from astropy.stats import sigma_clip, mad_std
# Sigma-clipped rms estimator
# std_clipped = lambda x: sigma_clip(x).std()
std_clipped = lambda x: mad_std(sigma_clip(x), ignore_nan=True)
# radial profile function from turbustat. It's not actually a power spectrum (poor naming choice)
### Accounting for the beam in 2D fitting ###
# Trying to fit a 2D Gaussian while convolving with the telescope beam.
# NOTES: - currently fails if units are used.
# - Example regions I'm using is not fit by this snippet.
import warnings
import numpy as np
import matplotlib.pyplot as plt
from spectral_cube import SpectralCube, Projection
@e-koch
e-koch / DustContinuumCalc.ipynb
Created April 18, 2016 22:22 — forked from low-sky/DustContinuumCalc.ipynb
Dust Continuum Calculator
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
'''
Save massive FITS files.
I keep another version in https://github.com/e-koch/ewky_scripts, but the gist
avoids you having to download a bunch of other stuff.
'''
from astropy.io import fits
import numpy as np
@e-koch
e-koch / move_dir_to_vos.py
Last active August 29, 2015 14:23
Moves a directory and its contents to VOS piecewise -- Useful for massive datasets
'''
Creates a list of all files within a directory, then copies each over to
VOS.
Run getCert before this script.
Call sequence:
1 - folder -- str
2 - Root of the vos file -- str
3 - Number of tries before giving up. -- int