Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

DOCUMENTATION.markdown 4.53 KB
Newer Older
Qusai Al Shidi's avatar
Qusai Al Shidi committed
1
# Module [swmfpy](#swmfpy)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

A collection of tools to read, write, visualize with the
Space Weather Modeling Framework (SWMF)



    
## Sub-modules

* [swmfpy.io](#swmfpy.io)
* [swmfpy.paramin](#swmfpy.paramin)






    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
20
# Module [swmfpy.io](#swmfpy.io)
21
22
23
24
25
26
27
28
29
30
31
32

Input/Output tools for SWMF





    
## Functions


    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
33
### Function [swmfpy.io.coarse_filtering](#swmfpy.io.coarse_filtering)
34
35
36
37
38
39
40
41
42
43


    
> `def coarse_filtering(data, coarseness=3)`


Applies coarse filtering to a pandas.DataFrame


    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
44
### Function [swmfpy.io.read_gm_log](#swmfpy.io.read_gm_log)
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



    
> `def read_gm_log(filename, colnames=None, index_by_time=True)`


Make a pandas.DataFrame out of the Dst indeces outputted
from the GM model log.


###### Args

**`filename`** : `str`
:   The filename as a string.


colnames (list(str)): Supply the name of the columns
**`index_by_time`** : `bool`
:   Change the index to a time index



###### Returns

`pandas.DataFrame` of `the` `log` `file`
:    

###### Examples

##### To plot AL and Dst get the log files
geo = swmfpy.read_gm_log("run/GM/IO2/geoindex_e20140215-100500.log")
dst = swmfpy.read_gm_log("run/GM/IO2/log_e20140215-100500.log")
##### Then plot using pandas features
dst["dst_sm"].plot.line()
geo["AL"].plot.line()


    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
84
### Function [swmfpy.io.read_omni_csv](#swmfpy.io.read_omni_csv)
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
113
114
115
116
117
118
119
120
121
122
123



    
> `def read_omni_csv(filename, filtering=False, **kwargs)`


Take an OMNI csv file from cdaweb.sci.gsfc.nasa.gov
and turn it into a pandas.DataFrame.


###### Args

**`fnames`**
:   dict with filenames from omni .lst files. The keys must be:
    density, temperature, magnetic_field, velocity


**`filtering`**
:   default=False Remove points where the value
                  is >sigma (default: sigma=3) from mean.


**`Returns`** : `pandas.DataFrame` `object` `with` `solar` `wind` `data`
:    


Make sure to download the csv files with cdaweb.sci.gsfc.nasa.gov
the header seperated into a json file for safety.

This only tested with OMNI data specifically.

Other Args:
    coarseness: default=3, Number of standard deviations above which to
                remove if filtering=True.
    clean: default=True, Clean the omni data of bad data points


    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
124
### Function [swmfpy.io.read_wdc_ae](#swmfpy.io.read_wdc_ae)
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154



    
> `def read_wdc_ae(wdc_filename)`


Read an auroral electrojet (AE) indeces from Kyoto's World Data Center
   text file into a dictionary of lists.


###### Args

**`wdc_filename`** : `str`
:   Filename of wdc data from
                    <http://wdc.kugi.kyoto-u.ac.jp/>



###### Returns

**`dict`**
:   {"time" (datetime.datetime): list of datetime objects
                                   corresponding to time in UT.
       "AL", "AE", "AO", "AU" (int): Auroral indeces.
      }



    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
155
### Function [swmfpy.io.write_imf_input](#swmfpy.io.write_imf_input)
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189



    
> `def write_imf_input(data, outfilename='IMF.dat', enable_rb=True, **kwargs)`


Writes the pandas.DataFrame into an input file
that SWMF can read as input IMF (IMF.dat).


###### Args

**`data`**
:   pandas.DataFrame object with solar wind data


**`outfilename`**
:   The output file name for ballistic solar wind data.                 (default: "IMF.dat")


**`enable_rb`**
:   Enables solar wind input for the radiation belt model.                 (default: True)


Other paramaters:
    gse: (default=False)
        Use GSE coordinate system for the file instead of GSM default.





    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
190
# Module [swmfpy.paramin](#swmfpy.paramin)
191
192
193
194
195
196
197
198
199
200
201
202

Tools to manipulate or create SWMF param.in files





    
## Functions


    
Qusai Al Shidi's avatar
Qusai Al Shidi committed
203
### Function [swmfpy.paramin.replace](#swmfpy.paramin.replace)
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251



    
> `def replace(input_file, replace, output_file='PARAM.in')`


Replace values for the parameters in a PARAM.in file.

Note, if you have repeat commands this will replace all the repeats.


###### Args

**`input_file`** :&ensp;`str`
:   String of PARAM.in file name.


**[`replace()`](#swmfpy.paramin.replace)** :&ensp;`dict`
:   Dictionary of strs with format
                replace = {"#COMMAND": ["value", "comments", ...]}
                This is case sensitive.


**`output_file`** :&ensp;`str`
:   (default "PARAM.in") The output file to write to.
                   A value of None will not output a file.



###### Returns

A list of lines of the PARAM.in file that would be outputted.

###### Examples

```
change["#SOLARWINDFILE"] = [["T", "UseSolarWindFile"],
                            ["new_imf.dat", "NameSolarWindFile"]]
##### This will overwrite PARAM.in
swmfpy.paramin.replace("PARAM.in.template", change)
```




-----
Generated by *pdoc* 0.7.5 (<https://pdoc3.github.io>).