Skip to content

Instantly share code, notes, and snippets.

@wtbarnes
wtbarnes / kill-processes.py
Created January 9, 2022 20:30
Python script for grepping and killing particularly processes
import subprocess
import click
@click.command()
@click.option('--filters', type=str, default=[], multiple=True)
@click.option('--dry-run', is_flag=True, default=False, help='If set, do not kill anything.')
def cli(filters, dry_run):
cmd = 'ps aux'
for f in filters:
cmd += f' | grep {f}'
@wtbarnes
wtbarnes / glue-config.py
Created January 9, 2022 18:24
Glue config for exporting coordinates to ASDF files
"""
Glue environment customization
"""
from glue.config import data_exporter
from astropy.coordinates import SkyCoord
import sunpy.coordinates # This registers the needed coordinate frames
import asdf
@wtbarnes
wtbarnes / the-astrophysical-journal-numbered.csl
Created January 2, 2022 03:06
Citation style file for The Astrophysical Journal, but using numbered citations. Useful for proposals where you need to conserve space.
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-GB">
<info>
<title>The Astrophysical Journal (numbered)</title>
<id>http://www.zotero.org/styles/the-astrophysical-journal-numbered</id>
<link href="http://www.zotero.org/styles/the-astrophysical-journal" rel="self"/>
<link href="http://www.zotero.org/styles/nature" rel="template"/>
<link href="http://aas.org/journals/authors/common_instruct#references" rel="documentation"/>
<author>
<name>Chris Lowder</name>
@wtbarnes
wtbarnes / aia-cube.py
Created October 27, 2021 23:23
NDCube subclasses for working with stacked and aligned AIA data
"""
Utilities for working with aligned AIA data cubes
"""
import copy
from os import uname
import warnings
import astropy.time
import astropy.wcs
import astropy.units as u
@wtbarnes
wtbarnes / prep_pipeline.py
Last active November 22, 2021 18:59
Pipelining script for producing aligned AIA datacubes.
"""
Process images from level 1 FITS to level 1.5 aligned cutouts in Zarr
"""
import copy
import glob
import logging
import os
import traceback
import sunpy
@wtbarnes
wtbarnes / tai-time-tests.ipynb
Created August 18, 2021 16:39
Differences between astropy time and anytim2tai
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wtbarnes
wtbarnes / hk12-sunkit-dem.py
Last active August 10, 2021 17:54
`sunkit-dem` implementation of the regularized DEM inversion method of Hannah and Kontar (2012)
"""
Hannah-Kontar (2012) DEM model definition
"""
import sys
import numpy as np
import astropy.units as u
from sunkit_dem import GenericModel
# Clone this repo and replace path below: https://github.com/ianan/demreg
@wtbarnes
wtbarnes / extrapolators.py
Created July 28, 2021 13:43
Code for computing potential magnetic field extrapolations using the method of Schmidt (1964) as described by Sakurai (1981). Includes helper functions for reprojecting a magnetogram into a Cartesian plane
"""
Field extrapolation methods for computing 3D vector magnetic fields from LOS magnetograms
"""
import numpy as np
from scipy.interpolate import griddata
import astropy.units as u
import numba
from astropy.utils.console import ProgressBar
from synthesizAR.util import SpatialPair
@wtbarnes
wtbarnes / mgn-rgb-example.py
Created July 20, 2021 18:25
Example script for creating composite RGB images from MGN-filtered AIA observations
"""
Create a composite RGB image using MGN-processed images from SDO/AIA 211, 193, and 171
"""
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.visualization import make_lupton_rgb,ImageNormalize
import numpy as np
import matplotlib.pyplot as plt
from sunpy.net import Fido, attrs as a
from sunpy.map import Map
@wtbarnes
wtbarnes / synthesizar-demo.ipynb
Last active June 25, 2021 15:33
Demo of forward modeling optically-thin coronal emission using the synthesizAR package
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.