Skip to content

Instantly share code, notes, and snippets.

View Cadair's full-sized avatar

Stuart Mumford Cadair

View GitHub Profile
@Cadair
Cadair / gen_rotate.py
Created August 7, 2012 16:30
Propose rotate function
# -*- coding: utf-8 -*-
"""
:Created on: Tue Aug 7 16:44:50 2012
:author: Stuart Mumford
This is a wrapper for a general rotate method, it will rotate and rescale the
image around an arbitary point and then if requested shift the point to the centre.
"""
@Cadair
Cadair / streamlines.py
Created August 14, 2012 14:53
Simple streamline generators
def fieldlines(self,v1,v2,seeds,dS=1):
""" Simple Euler fieldline integrator
v1,v2 - y and x vectors
seeds - array of coordinate (array indexes) pairs
dS [optional] - step size
"""
from scipy import ndimage
field = []
#Get extent of domain
@Cadair
Cadair / IDL_rotate.pro
Created September 17, 2012 13:37
IDL bicubic rotation
read_sdo, "aia.lev1.193A_2012-06-10T13:00:07.84Z.image_lev1.fits",header,data
rotated_cubic = rot(data,90,cubic=-0.5)
save, data, rotated_cubic
@Cadair
Cadair / IDL_vs_sunpy.py
Created September 17, 2012 13:38
Comparision of IDL and SunPy bicubic rotation
# -*- coding: utf-8 -*-
"""
:Created on: Fri Sep 14 15:03:51 2012
:author: Stuart Mumford
Test Sunpy.map.rotate() against idl rot()
"""
import numpy as np
@Cadair
Cadair / scipy_vs_sunpy.py
Created September 17, 2012 13:40
Bicubic vs Spline interpolation
# -*- coding: utf-8 -*-
"""
:Created on: Fri Sep 14 15:03:51 2012
:author: Stuart Mumford
Test scipy's spline rotation against sunpy's bicubic rotation.
"""
import numpy as np
@Cadair
Cadair / massive_fits.py
Created November 13, 2012 15:35
Save a massive FITS file
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 13 15:05:36 2012
@author: stuart
Problem from SunPy mailing list. Save a MASSIVE array to a fits file
"""
import numpy as np
import numpy.lib as nplib
Report
======
6627 statements analysed.
Messages by category
--------------------
+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
@Cadair
Cadair / more_pylint
Last active December 14, 2015 00:09
Using sunpy/tools/pylint/pylintrc and ignorning gui and tests. staging is previous run and namesapce_cleanup is new.
************* Module sunpy.sun.position
I0011: 7,0: Locally disabling E1101
I0011: 7,0: Locally disabling E1121
R0914: 26,0:position: Too many local variables (22/15)
************* Module sunpy.sun.constants
I0011: 93,0: Locally disabling E0611
C0301: 4,0: Line too long (88/80)
C0301: 5,0: Line too long (83/80)
C0301: 12,0: Line too long (86/80)
C0301: 18,0: Line too long (91/80)
@Cadair
Cadair / gist:5775070
Last active December 18, 2015 11:20
comp map
def add_map(self, input_, zorder=None, alpha=1, levels=False):
"""Adds a map to the CompositeMap
Parameters
----------
input_ : {sunpy.map, string}
Map instance or filepath to map to be added
zorder : int
The index to use when determining where the map should lie along
the z-axis; maps with higher z-orders appear above maps with lower
@Cadair
Cadair / gist:5893586
Last active March 15, 2017 09:20
How to compensate for differential rotation in the default sunpy image. This is based upon a combination of pr/452 and pr/482 my branch for which can be found here: https://github.com/Cadair/sunpy/tree/map_refactor_diff_rot
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 21:31:58 2013
@author: stuart
"""
import numpy as np
from datetime import timedelta