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 / 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 / plot_test_diffrot.py
Created August 22, 2012 22:39
comparing diff_rot values obtained from SSW and from sunpy. The IDL program calculate the variation for 20 days (every 0.2 d) for different latitudes (from -90 to 90). Plot_test_diffrot.py reads these values and copares them with the ones obtained by Jos
import matplotlib.pyplot as plt
import numpy as np
from diff_rot import *
# Reading idl files
modes = ['allen','howard','sidereal','synodic']
days = np.arange(0,20,.2)
i = 0
fig = plt.figure()
for mode in modes:
@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?
@dpshelio
dpshelio / git_steps_to_separate_pr
Created October 10, 2012 20:00
How to separate the pull request into two different ones
# From the master branch I create one to test Steve pull request
git checkout -b steve
# I fetch all that ehsteve has in his branch
git remote add
git fetch -v ehsteve
# Merge Steve pull request with master
git pull ehsteve master
# Run the tests
py.test sunpy
#!!! 3 of them fails!
@dpshelio
dpshelio / cc_lamb2disk.pro
Created November 7, 2012 18:19
Chain code contours from Lambert to disk projection
function cc_lamb2disk,eit_map,s_ch
;+
; CC_LAMB2DISK
; It converts the chain code of ch structures produced by CHARM from Lambert maps to disk
; INPUTS: eit_map -> the map used for the detection (normally EIT or AIA)
; s_ch -> the structure saved from CHARM
; OUTPUT: new_s_ch -> the same structure than s_ch with the CC updated for all the CHs
; EXAMPLE: CHARM_DETECTION
; updated_s_ch = cc_lamb2disk(euv_map,s_ch)
; ; if I want to plot the new ones
git remote add keith https://github.com/khughitt/sunpy.git
git fetch keith
git checkout keith/master
git checkout -b keithmaster
#modify a file
git commit -am "testing update of a pulling request"
git push main keithmaster
and pull request from github to khughitt/sunpy master
@dpshelio
dpshelio / error.log
Created August 1, 2013 14:14
Astropy import error from a web application.
/usr/local/lib/python2.7/dist-packages/astropy/config/configuration.py:432: ConfigurationMissingWarning: Configuration defaults will be used, and configuration cannot be saved due to OSError:Could not find unix home directory to search for astropy config dir
warn(ConfigurationMissingWarning(msg))
/usr/local/lib/python2.7/dist-packages/astropy/logger.py:490: RuntimeWarning: log file '' could not be opened for writing: Could not find unix home directory to search for astropy config dir
'{1}'.format(log_file_path, unicode(e)), RuntimeWarning)
Traceback (most recent call last):
File "testastropy.py", line 2, in <module>
import astropy
File "/usr/local/lib/python2.7/dist-packages/astropy/__init__.py", line 153, in <module>
config.configuration.update_default_config(__package__, config_dir)
File "/usr/local/lib/python2.7/dist-packages/astropy/config/configuration.py", line 688, in update_default_config
@dpshelio
dpshelio / impex_calls.py
Last active December 22, 2015 06:49 — forked from anonymous/impex_calls.py
How to use IMPEx (FMI) from python2.7 with suds
from suds.client import Client
import random
import astropy.constants as const
import numpy as np
url = 'http://impex-fp7.fmi.fi/impex/IMPExServer.php?wsdl'
client = Client(url)
print client #Shows all the methods available and their inputs
# getDataPointValue_spacecraft example
result = client.service.getDataPointValue_spacecraft(ResourceID="impex://FMI/HWA/HYB/venus/run01_nominal_with_cx/O+_ave_hybstate", Spacecraft_name="VenusExpress", StartTime="2007-01-11T00:00:00", StopTime="2007-01-21T00:00:00", Sampling="600")
@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)