swmfpy.web.html 8.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module swmfpy.web</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="swmfpy.html"><font color="#ffffff">swmfpy</font></a>.web</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/qusai/Documents/Code/swmfpy/swmfpy/web.py">/home/qusai/Documents/Code/swmfpy/swmfpy/web.py</a></font></td></tr></table>
    <p><tt>Tools&nbsp;to&nbsp;retrieve&nbsp;and&nbsp;send&nbsp;data&nbsp;on&nbsp;the&nbsp;web.<br>
&nbsp;<br>
SWMF&nbsp;Web&nbsp;Tools<br>
==============<br>
&nbsp;<br>
Here&nbsp;are&nbsp;a&nbsp;collection&nbsp;of&nbsp;tools&nbsp;to&nbsp;work&nbsp;with&nbsp;data&nbsp;on&nbsp;the&nbsp;internet.&nbsp;Thus,<br>
this&nbsp;module&nbsp;mostly&nbsp;requires&nbsp;an&nbsp;internet&nbsp;connection.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="datetime.html">datetime</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-download_magnetogram_adapt"><strong>download_magnetogram_adapt</strong></a>(time, map_type<font color="#909090">='fixed'</font>, **kwargs)</dt><dd><tt>This&nbsp;routine&nbsp;downloads&nbsp;GONG&nbsp;ADAPT&nbsp;magnetograms.<br>
&nbsp;<br>
Downloads&nbsp;ADAPT&nbsp;magnetograms&nbsp;from&nbsp;<a href="ftp://gong2.nso.edu/adapt/maps/gong/">ftp://gong2.nso.edu/adapt/maps/gong/</a><br>
to&nbsp;a&nbsp;local&nbsp;directory.&nbsp;It&nbsp;will&nbsp;download&nbsp;all&nbsp;maps&nbsp;with&nbsp;the&nbsp;regex&nbsp;file<br>
pattern:&nbsp;adapt4[0,1]3*yyyymmddhh<br>
&nbsp;<br>
Args:<br>
&nbsp;&nbsp;&nbsp;&nbsp;time&nbsp;(datetime.datetime):&nbsp;Time&nbsp;in&nbsp;which&nbsp;you&nbsp;want&nbsp;the&nbsp;magnetogram.<br>
&nbsp;&nbsp;&nbsp;&nbsp;map_type&nbsp;(str):&nbsp;(default:&nbsp;'fixed')<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Choose&nbsp;either&nbsp;'fixed'&nbsp;or&nbsp;'central'&nbsp;for<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;map&nbsp;type&nbsp;you&nbsp;want.<br>
&nbsp;&nbsp;&nbsp;&nbsp;**kwargs:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;download_dir&nbsp;(str):&nbsp;(default&nbsp;is&nbsp;current&nbsp;dir)&nbsp;Relative&nbsp;directory<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where&nbsp;you&nbsp;want&nbsp;the&nbsp;maps&nbsp;to&nbsp;be&nbsp;downloaded.<br>
&nbsp;<br>
Returns:<br>
&nbsp;&nbsp;&nbsp;&nbsp;str:&nbsp;First&nbsp;unzipped&nbsp;filename&nbsp;found.<br>
&nbsp;<br>
Raises:<br>
&nbsp;&nbsp;&nbsp;&nbsp;NotADirectoryError:&nbsp;If&nbsp;the&nbsp;adapt&nbsp;maps&nbsp;directory<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is&nbsp;not&nbsp;found&nbsp;on&nbsp;the&nbsp;server.<br>
&nbsp;&nbsp;&nbsp;&nbsp;ValueError:&nbsp;If&nbsp;map_type&nbsp;is&nbsp;not&nbsp;recognized.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(i.e.&nbsp;not&nbsp;'fixed'&nbsp;or&nbsp;'central')<br>
&nbsp;&nbsp;&nbsp;&nbsp;FileNotFoundError:&nbsp;If&nbsp;maps&nbsp;were&nbsp;not&nbsp;found.<br>
&nbsp;<br>
Examples:<br>
&nbsp;&nbsp;&nbsp;&nbsp;```python<br>
&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;datetime&nbsp;as&nbsp;dt<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Use&nbsp;datetime&nbsp;objects&nbsp;for&nbsp;the&nbsp;time<br>
&nbsp;&nbsp;&nbsp;&nbsp;time_flare&nbsp;=&nbsp;dt.datetime(2018,&nbsp;2,&nbsp;12,&nbsp;hour=10)<br>
&nbsp;&nbsp;&nbsp;&nbsp;swmfpy.web.<a href="#-download_magnetogram_adapt">download_magnetogram_adapt</a>(time=time_flare,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map_type='central',<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;download_dir='./mymaps/')<br>
&nbsp;&nbsp;&nbsp;&nbsp;```</tt></dd></dl>
 <dl><dt><a name="-get_omni_data"><strong>get_omni_data</strong></a>(time_from, time_to, **kwargs)</dt><dd><tt>Retrieve&nbsp;omni&nbsp;solar&nbsp;wind&nbsp;data&nbsp;over&nbsp;http.<br>
&nbsp;<br>
This&nbsp;will&nbsp;download&nbsp;omni&nbsp;data&nbsp;from&nbsp;https://spdf.gsfc.nasa.gov/pub/data/omni<br>
and&nbsp;put&nbsp;it&nbsp;into&nbsp;a&nbsp;dictionary.&nbsp;If&nbsp;your&nbsp;data&nbsp;is&nbsp;large,&nbsp;then&nbsp;make&nbsp;a&nbsp;csv&nbsp;and<br>
use&nbsp;swmfpy.io.read_omni_data().<br>
&nbsp;<br>
Args:<br>
&nbsp;&nbsp;&nbsp;&nbsp;time_from&nbsp;(datetime.datetime):&nbsp;The&nbsp;start&nbsp;time&nbsp;of&nbsp;the&nbsp;solar&nbsp;wind<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;that&nbsp;you&nbsp;want&nbsp;to&nbsp;receive.<br>
&nbsp;&nbsp;&nbsp;&nbsp;time_to&nbsp;(datetime.datetime):&nbsp;The&nbsp;end&nbsp;time&nbsp;of&nbsp;the&nbsp;solar&nbsp;wind&nbsp;data<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;you&nbsp;want&nbsp;to&nbsp;receive.<br>
&nbsp;<br>
Returns:<br>
&nbsp;&nbsp;&nbsp;&nbsp;dict:&nbsp;This&nbsp;will&nbsp;be&nbsp;a&nbsp;list&nbsp;of&nbsp;*all*&nbsp;columns<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;available&nbsp;in&nbsp;the&nbsp;omni&nbsp;data&nbsp;set.<br>
&nbsp;<br>
Examples:<br>
&nbsp;&nbsp;&nbsp;&nbsp;```python<br>
&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;datetime<br>
&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;swmfpy.web<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;storm_start&nbsp;=&nbsp;datetime.datetime(year=2000,&nbsp;month=1,&nbsp;day=1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;storm_end&nbsp;=&nbsp;datetime.datetime(year=2000,&nbsp;month=2,&nbsp;day=15)<br>
&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;=&nbsp;swmfpy.web.<a href="#-get_omni_data">get_omni_data</a>(time_from=storm_start,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time_to=storm_end)<br>
&nbsp;&nbsp;&nbsp;&nbsp;```</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__author__</strong> = 'Qusai Al Shidi'<br>
<strong>__email__</strong> = 'qusai@umich.edu'</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Qusai&nbsp;Al&nbsp;Shidi</td></tr></table>
</body></html>