Skip to content

Instantly share code, notes, and snippets.

View wtbarnes's full-sized avatar

Will Barnes wtbarnes

View GitHub Profile
@wtbarnes
wtbarnes / eis-aia-alignment-tests.ipynb
Created January 9, 2022 21:22
Notebooks for experimenting with EIS data in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wtbarnes
wtbarnes / detached-screens.sh
Created January 9, 2022 20:32
Useful function for doing things inside of screen commands
# Useful functions for managing things in detached screen sessions
# Starts zotero in headless mode in a screen session using xvfb
zotero_headless () {
screen -dm -S "zotero-headless" bash -c "cd $HOME/.local/Zotero_linux-x86_64; xvfb-run ./zotero"
}
# Start and stop a headless zotero session
zotero_start_stop () {
@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 June 1, 2025 12:33
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
Loading
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