Skip to content

Instantly share code, notes, and snippets.

@wtbarnes
wtbarnes / make_potential_field.py
Last active May 22, 2017 19:15
Create a potential field extrapolation using a synthesized magnetogram with the solarbextrapolation package.
import numpy as np
from solarbextrapolation.example_data_generator import generate_example_data,dummyDataToMap
from solarbextrapolation.extrapolators import PotentialExtrapolator
import astropy.units as u
# create synthetic magnetogram, simple dipole
# 300x300 box, we will resample to 100x100
arr_grid_shape = [ 300, 300]
xrange = u.Quantity([ -150.0, 150.0 ] * u.arcsec)
yrange = u.Quantity([ -150.0, 150.0 ] * u.arcsec)
@wtbarnes
wtbarnes / make_json_instrument_data.py
Last active April 7, 2017 06:13
Make instrument data files for the synthesizAR package. This is just a stopgap until there is a better way of producing these from SunPy. Ideally, we would not want to hardcode these and store them in the repo.
"""
Format instrument files into JSON.
This uses a part of SunPy that has thus far only been implemented on a PR so will not work
using either the latest release or master.
"""
import json
import os
import glob
@wtbarnes
wtbarnes / pandas_example.ipynb
Last active May 10, 2017 15:26
Example of how to manipulate some simple tabular data with Pandas. This notebook stacks multiple CSV files into a single dataframe, selecting only two columns out of each of the individual files. Information from the file name is then used as a third and fourth parameter in the combined dataframe.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
  • Update RELEASE.md (major releases only)

  • Update the version for build numbers on Appveyor (major releases only)

  • Run the tests (on both Python 2 and Python 3):

python setup.py test
  • Update version number in setup.py (in both branches) [don't commit yet]
  • Build the source distribution:
@wtbarnes
wtbarnes / metaclass_factory_example.py
Last active August 9, 2017 07:10
Example of how to implement a factory with a metaclass in Python
class CarFactory(type):
def __call__(cls,*args,**kwargs):
if args[0]=='van':
return Van(*args,**kwargs)
elif args[0]=='truck':
return Truck(*args,**kwargs)
else:
return type.__call__(cls,*args,**kwargs)
class BaseCar(object):
@wtbarnes
wtbarnes / file_rename.sh
Created August 17, 2017 21:09
Shell script for renaming a large number of files
#!/bin/bash
species=$1
alpha=$2
rootdir="/data/datadrive2/EBTEL-2fluid_runs/${species}_heating_runs/alpha${alpha}/"
cd $rootdir"config/"
echo "About to begin config files"
sleep 5
@wtbarnes
wtbarnes / fiasco_tutorial.ipynb
Last active October 31, 2017 07:23
Tutorial for parsing CHIANTI atomic data, building it into an HDF5 file, and accessing it
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wtbarnes
wtbarnes / movie2plot.ipynb
Last active September 20, 2017 06:35
Notebook for converting movie (mpeg, wav, etc.) to plots in matplotlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wtbarnes
wtbarnes / globus_personal_endpoint_guide.md
Last active May 7, 2018 22:50
Guide to setting up Globus Personal Endpoint

Globus Personal Endpoint Guide

This gist gives somewhat detailed instructions for setting up your Linux machine as a Globus endpoint. The Globus docs are a bit sparse and not that up-to-date. Additionally, they do not show how to configure the Globus endpoint as a service. For at least the first part of the guide, I'll be following the command line section in this guide.

Throughout this guide, I'll assume we're working on Ubuntu 14.04 (may work on slightly earlier/later releases or other Linux flavors) with a some user named user and that you've already created a Globus account at globus.org.

NOTE: At the time of writing, all of the Globus tools are Python 2 only!

@wtbarnes
wtbarnes / pandoc.template.latex
Created October 16, 2017 19:49
Nice template for generating TeX from pandoc documents
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
%Import necessary packages
\usepackage{graphicx}
\usepackage{amssymb,amsmath}
\usepackage{multicol}
\usepackage[numbers,sort]{natbib}
\usepackage{mathptmx}
\usepackage{titling}
\usepackage[font=footnotesize,margin=0in]{caption}
\usepackage[utf8]{inputenc} %force unicode in bibtex