Skip to content

Instantly share code, notes, and snippets.

View dpshelio's full-sized avatar
🌴
On vacation

David Pérez-Suárez dpshelio

🌴
On vacation
View GitHub Profile
@dpshelio
dpshelio / rebin_std.pro
Created March 7, 2014 14:17
This IDL function generates the standard deviation of a 2D array when it's compressed by an integer factor.
function rebin_stddev, image, new_xsize, new_ysize, image_small = image_small
;+
; rebin_stddev
; It just works for making the image smaller by a integer factor (as rebin)
;
;-
dimensions = size(image, /dimensions)
number_of_pixels_combined = total(dimensions / float([new_xsize, new_ysize]))
; Rebin image to a smaller dimenssion
image_small = rebin(image, new_xsize, new_ysize)
@dpshelio
dpshelio / fix_eitfiles.py
Created May 20, 2014 13:37
This gist contain the script used to update the fits files that are giving problems in SunPy
import os
import glob
from astropy.io import fits
import sunpy.data.test
from sunpy.net import vso
from sunpy.image.rescale import resample as sunpy_image_resample
"""
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
from astropy.wcs import WCS
from astropy.io import fits
from wcsaxes import WCSAxes
import sunpy.map
from sunpy.net import vso
@dpshelio
dpshelio / idl.startup
Last active August 29, 2015 14:13
SSW from bash
device, true_color = 24
device, decomposed = 0
device, retain = 2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dpshelio
dpshelio / pixel.py
Created July 27, 2015 09:48
Problem when wcsaxes is on, the plot uses pixel coordinates on the image, no degrees or arcsecs.
import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np
from skimage.measure import find_contours
import sunpy.map
xsub = 400 * u.arcsec + 75 * ([-1, 1] * u.arcsec)
ysub = 300 * u.arcsec + 50 * ([-1, 1] * u.arcsec)
map01 = sunpy.map.Map('./hmi.m_45s.2010.08.10_12_01_30_TAI.magnetogram.fits').submap(xsub, ysub)
@dpshelio
dpshelio / diffrot.py
Last active August 29, 2015 14:27 — forked from Cadair/gist:5893586
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
@dpshelio
dpshelio / sparks.py
Created November 17, 2011 08:51 — forked from stefanv/sparks.py
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE:
@dpshelio
dpshelio / smart_plot.pro
Created August 29, 2012 11:35
Access to HFC using IDL
;set time range:
timerange = ['2001-04-15','2001-04-16']
cmd_url = hio_form_hfc_query(timerange=timerange,listname='VIEW_AR_HQI')
smart_ars = decode_votable(ssw_hio_query(cmd_url,/verb),/quiet)
; we should have the url on the database, but it seems it's not there (I'm taking note for that!!)
; but we can work around this way:
mdimags=mdi_time2file(timerange[0],timerange[1],/stanford)
lab = where(smart_ars[0].filename eq ssw_strsplit(mdimags,'/',/tail),num)
sock_copy,mdimags[lab],local_file=filename
@dpshelio
dpshelio / cshrc_ssw_local
Last active October 11, 2015 02:28
My Solarsoft configuration files
# SSW path
setenv SSW $HOME/ssw/ssw_local
# SSW instrument list
setenv SSW_INSTR "gen eit hessi secchi stereo"
# Set IDL paths; where you have all your wonderful creations that you will use more than once
setenv IDL_PATH "~/Work/IDL:+~/Superlib"
# set IDL startup options; Do you have any preferred options in IDL that you want them to load at the beginning?