Skip to content

Instantly share code, notes, and snippets.

@dpshelio
Created August 22, 2012 22:39
Show Gist options
  • Save dpshelio/3430240 to your computer and use it in GitHub Desktop.
Save dpshelio/3430240 to your computer and use it in GitHub Desktop.
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:
filename = mode+'.csv'
data = np.genfromtxt(filename,skip_header=1,delimiter=';')
latitudes = data[:,0]
data = data[:,1:]
for ind,lat in enumerate(latitudes):
a = fig.add_subplot(len(modes),len(latitudes),i+1)
# plt.plot(days,data[ind,:])
# plt.plot(days,diff_rot(days,lat,option=mode)
pyway = diff_rot(days,lat,mode)
plt.plot(days, (data[ind,:]-pyway)*60.*60., 'r--o',label = mode)
if i%8 == 0:
a.legend(loc='lower right')
a.set_ylabel('Difference (arcsec)')
if i < 8:
a.annotate(lat,xy=(0.2,0.8),xycoords='axes fraction')
if i > 23:
a.set_xlabel('Days')
i+=1
plt.show()
pro test_diffrot
days=findgen(100)*0.2
latitude = round((findgen(8)*180./7.-90.)*1000)/1000. ;so it's round to 3 decimal place
modes = ['allen','howard','sidereal','synodic']
options = fltarr(4)
for i=0,3 do begin
options[i] = 1
openw,lun,modes[i]+'.csv',/get_lun
printf,lun,'# '+modes[i]+'/latitude days'+strjoin(string(days,format='((F4.1),:,";")'))
for lat = 0, n_elements(latitude)-1 do begin
results = diff_rot(days,latitude[lat], $
allen=options[0], $
howard=options[1], $
sidereal=options[2],$
synodic = options[3])
printf,lun,string(latitude[lat],format='(F8.4)')+';'+strjoin(string(results,format='((F23.18),:,";")'))
endfor
close,lun
options[i]=0
endfor
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment