Esempio n. 1
0
def download(date):
    date = parse(date)
    # Loop through wavelengths
    for w, wlen in enumerate(wlens):
        data_dir = '/whatever/'
        fits_dir = os.path.join(data_dir, '{}/{:%Y/%m/%d}/'.format(wlen, date))
        searchname = os.path.join(fits_dir, '*{:%H:%M}*fits'.format(date))
        countfiles = glob.glob(searchname)
        if countfiles == 1:
            f = open('runfile_{}'.format(w), 'w')
            f.write("python getdata.py {} {} {}".format(date, wlen, fits_dir))
            f.close()
        # Download data if not enough found
        subprocess.call("qsub runfile_{}".format(w))

    running = True
    iterations = 0
    while running:
        if subprocess.check_output('qstat') != '':
            running = False
        elif iterations > 7200:
            
        sleep(1)
        iterations += 1
    
    return
Esempio n. 2
0
from matplotlib import use
use('agg')
import sys
from os.path import join, expanduser
CThome = expanduser(join('~', 'CoronaTemps'))
sys.path.append(CThome)
from temperature import TemperatureMap as TMap
from matplotlib import pyplot as plt
from sunpy.time import parse_time as parse

dates = ['2014-12-15 12:00', '2014-12-15 12:30', '2014-12-15 14:00']

completed = False
while completed == False:
    try:
        for date in dates:
            thismap = TMap(date,
                           data_dir=join(CThome, 'data'),
                           maps_dir=CThome,
                           verbose=True)
            thismap.save()
            #thismap = thismap.submap([-1200, -200], [-500, 500], units='data')
            fig = plt.figure(figsize=(32, 24))
            thismap.plot()
            plt.colorbar()
            plt.savefig('t_{:%Y-%m-%d_%H-%M-%S}'.format(parse(thismap.date)))
            plt.close()
        completed = True
    except:
        print 'Failed - restarting'
def p95(data):
    return np.percentile(data, 95)


def p5(data):
    return np.percentile(data, 5)

fastdata = join('/fastdata', 'sm1ajl', 'thesis')

parameter = 'mean'
functions = {'mean': np.nanmean, 'max': np.nanmax, 'min': np.nanmin, 
             '95th %-ile': p95, '5th %-ile': p5}
savedir = join(fastdata, 'plots', 'chapter6', 'all_classes', '{}'.format(parameter.replace(' ', '_')))

start = parse('2011-02-01')
end = parse('2011-04-01')

client = hek.HEKClient()
flares = client.query(hek.attrs.Time(start, end),
                      hek.attrs.EventType('FL'))

flares = [fl for fl in flares if (fl['ar_noaanum'] > 11137 and 
                                  fl['ar_noaanum'] < 11184)]
ar_rad = 75
ar_temps_fltime = []
ar_temps_1 = []
ar_temps_10 = []
ar_temps_30 = []
fl_classes = []
#           'n 6.02-6.08']
if parameter == 'all':
    pars = allpars[:8]
else:
    pars = [parameter]

savedir = "/fastdata/sm1ajl/thesis/plots/chapter6/x_class/temperature/{}/".format(parameter.replace(' ', '_').replace('.', '_'))
print exists(savedir)
if density:
    savedir = savedir.replace('temperature', 'density_{}'.format(density))
if not exists(savedir):
    os.makedirs(savedir)

#flarefiles = glob.glob('/imaps/sspfs/archive/sdo/aia/flares/*/*.dat')
#print len(flarefiles)
start = parse('2010-07-14')
end = parse('2011-09-19')

client = hek.HEKClient()
allflares = client.query(hek.attrs.Time(start, end),
                         hek.attrs.EventType('FL'))
allflares = [fl for fl in allflares if (fl['fl_goescls'] != "" and fl['fl_goescls'][0] == 'X')]
print len(allflares)

ar_rad = 75
ar_temps_fltime = []
ar_temps_1 = []
ar_temps_10 = []
ar_temps_30 = []
fl_classes = []
if parameter == 'all':
    pars = allpars[:8]
else:
    pars = [parameter]

home = expanduser('~')
savedir = join(home, "tempplots/{}/".format(parameter.replace(' ', '_').replace('.', '_')))
if density:
    savedir = savedir.replace('tempplots', 'densplots_{}'.format(density))
if not exists(savedir):
    os.makedirs(savedir)
data_root = '/imaps/sspfs/archive/sdo/aia/drew_ar11166/'

ar_rad = 75

starttime = parse('2011-03-05')
endtime = parse('2011-03-13')
timerange = tr(starttime, endtime)

# Get Carrington coords of active region
client = hek.HEKClient()
ars = client.query(hek.attrs.Time(starttime, endtime),
                hek.attrs.EventType('AR'),
                hek.attrs.AR.NOAANum == 11166)
coords = ars[0]['hgc_x'], ars[0]['hgc_y']
print coords

# Define times for maps
delta = dt.timedelta(minutes=2)
ntimes = int(timerange.seconds()/delta.total_seconds())
alltimes = [time.start() for time in timerange.split(ntimes)]
Esempio n. 6
0
from matplotlib import use
use('agg')
import sys
from os.path import join, expanduser
CThome = expanduser(join('~', 'CoronaTemps'))
sys.path.append(CThome)
from temperature import TemperatureMap as TMap
from matplotlib import pyplot as plt
from sunpy.time import parse_time as parse

dates = ['2014-12-15 12:00', '2014-12-15 12:30', '2014-12-15 14:00']

completed = False
while completed == False:
    try:
        for date in dates:
            thismap = TMap(date, data_dir=join(CThome, 'data'), maps_dir=CThome, verbose=True)
            thismap.save()
            #thismap = thismap.submap([-1200, -200], [-500, 500], units='data')
            fig = plt.figure(figsize=(32, 24))
            thismap.plot()
            plt.colorbar()
            plt.savefig('t_{:%Y-%m-%d_%H-%M-%S}'.format(parse(thismap.date)))
            plt.close()
        completed = True
    except:
        print 'Failed - restarting'