forked from alyshareinard/dimmings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_yashiro_catalog.py
36 lines (25 loc) · 1.23 KB
/
get_yashiro_catalog.py
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
import os
import pandas as pd
from datetime import datetime
def get_yashiro_catalog(data_path=os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")):
""" program to read in yashiro CME catalog """
#try downloading the data
try:
cme_file="https://cdaw.gsfc.nasa.gov/CME_list/UNIVERSAL/text_ver/univ_all.txt"
#if that doesn't work, use the local file
except:
cme_file=data_path+"/yashiro_all.txt"
print("\nReading CME data from: ", cme_file)
names=["ymd", "hour", "sep", "minute", "sep2", "sec", "PA", "width",
"lin_speed", "20speed_init", "20speed_final", "20speed_20R",
"accel", "sep3", "mass", "sep4", "ke", "sep5", "mpa"]
widths=[10, 4, 1, 2, 1, 2, 8, 8, 8, 8, 8, 6, 6, 1, 10, 1, 10, 1, 8]
cmes=pd.read_fwf(cme_file, widths=widths, header=3, names=names)#, parse_dates=[[1]])
date=[]
for i in range(len(cmes["ymd"])):
ymd=cmes["ymd"][i].split("/")
date.append(datetime(int(ymd[0]), int(ymd[1]), int(ymd[2]), cmes["hour"][i], cmes["minute"][i]))#, cmes["sec"][i]))
cmes["date"]=date
cmes["mass"]=cmes["mass"].replace("-------", "-1").replace("*******", "-1")
cmes.mass=cmes.mass.astype(float)
return cmes