예제 #1
0
 def test_progress_png(self, client, capsys):
     """
     Tests if progress bars are disabled when running `download_png()`.
     """
     msg = "\rFiles Downloaded:"
     client = HelioviewerClient()
     client.download_png('2012/07/16 10:08:00',
                         2.4,
                         "[SDO,AIA,AIA,171,1,100]",
                         x0=0,
                         y0=0,
                         width=1024,
                         height=1024,
                         progress=False)
     _, err = capsys.readouterr()
     assert msg not in err
     client.download_png('2012/07/16 10:08:00',
                         2.4,
                         "[SDO,AIA,AIA,171,1,100]",
                         x0=0,
                         y0=0,
                         width=1024,
                         height=1024)
     _, err = capsys.readouterr()
     assert msg in err
예제 #2
0
	year, month, day = get_date()

	timelist = build_timelist(year, month, day)
	hv = HelioviewerClient()  
	#file = hv.download_png('2015/01/01', 6, "[SDO,AIA,AIA,304,1,100],[SDO,AIA,AIA,193,1,50],[SOHO,LASCO,C2,white-light,1,100],[SOHO,LASCO,C3,white-light,1,100]", x0=0, y0=0, width=900, height=900)  
	minutes = []
	for minute in xrange(0, 60, 12):
		minutes.append(minute)

	for time in timelist:
		filenum = timelist.index(time) + 1
		total = len(timelist)
		print("DOWNLOADING: " + str(time) + " --- " + str(filenum) + "/" + str(total))
		file = hv.download_png(time, 6, 
		                       "[SDO,AIA,AIA,193,1,100],"\
		                       "[SOHO,LASCO,C2,white-light,1,100]",
		                       directory="./downloaded", 
		                       x0=0, y0=0, width=2000, height=2000, watermark=False ) 
	
	i = 0
	for f in sorted(glob.glob("downloaded/*.png")):
		os.rename(f, "downloaded/" + str(i) + ".png")
		i = i + 1

	outname = "LASCO_" + str(year) + str(month) + str(day) + ".mp4"
	subprocess.call('ffmpeg -r 24 -i downloaded/%01d.png -vcodec libx264 -filter "minterpolate=mi_mode=blend" -b:v 4M -pix_fmt yuv420p  -y ' + outname, shell = True)


	backup = "archived/" + str(year) + str(month) + str(day)
	subprocess.call("mkdir -p " + backup + " && mv downloaded/*.png " + backup, shell = True) 
예제 #3
0
from sunpy.net.helioviewer import HelioviewerClient
from matplotlib.image import imread
import matplotlib.pyplot as plt
from matplotlib import patches

hv = HelioviewerClient()

DAT = input('Date yyyy/m/d: ')
#IMRES = input('Image Resolution in arcseconds/pixel: ')
SRCID = input('Data Source ID: ')
#VIS = input('Visibility: ')
#OP = input('Opacity: ')
XFOC = input('Specify x-coord: ')
YFOC = input('Specify y-coord: ')

##include image size in a function, make dict for source ids, make optional args for composite images

IN = [SRCID, XFOC, YFOC]
FLIN = list(map(float, IN))

imgfile = hv.download_png(DAT,
                          6.0, [FLIN[0], 1.0, 100.0],
                          x0=FLIN[1],
                          y0=FLIN[2],
                          width=512,
                          height=512)

im = imread(imgfile)
plt.imshow(im)
plt.show()
예제 #4
0
    'stereocor1', 'sdoaia304', 'sdoaia193', 'sdoaia211', 'sdoaia4500',
    'trace1550', 'trace195', 'stereohi1', 'yohkohsxtwh', 'irissji2796',
    'sdoaia1600', 'sohoeit195'
]

print('List of available color maps: ')
pprint.pprint(cmap_list)
color = None
while color not in cmap_list:
    color = input('Select a color map to display: ')

cmap = plt.get_cmap(color)

imgfile = hv.download_png(date,
                          6.0, [SRCID, 5.0, 100.0],
                          x0=0,
                          y0=0,
                          width=512,
                          height=512)

##Section 3 -- PNG image downloaded from Helioviewer is processed using Pillow. The image is first converted to a JPG file, then split into RGB components. From these component files, a FITS image is compiled that sunpy.maps can readily use for plotting.

im = Image.open(imgfile)
imRGB = im.convert('RGB')
imRGB.save('im.jpg')
image = Image.open('im.jpg')
xsize, ysize = image.size
r, g, b = image.split()
r_data = np.array(r.getdata())
g_data = np.array(g.getdata())
b_data = np.array(b.getdata())
예제 #5
0
from sunpy.net.helioviewer import HelioviewerClient
hv = HelioviewerClient()
hv.download_png("2099/01/01", 6,
                 "[SDO,AIA,AIA,304,1,100],[SDO,AIA,AIA,193,1,50],"+
                 "[SOHO,LASCO,C2,white-light,1,100]",
                 x0=0, y0=0, width=768, height=768)
예제 #6
0
def download_images(c1, c2, craft, c1_hvr, c2_hvr, cme_root):
    """Download the COR1 and COR2 fits files for the frame nearest tm, to get
    coords and do distance calc. Download several pngs around the event.
    """
    # Open up a VSO client and a Helioviewer Client
    vsoclient = vso.VSOClient()
    hv = HelioviewerClient()
    # Loop over the events, make event directory, download closest fits file
    # and several pngs.
    for i in range(len(c1)):
        print 'length of c1'
        print len(c1)
        print i
        cme_dir = cme_root + r'\cme_' + '{0:02d}'.format(i + 1)
        if not os.path.exists(cme_dir):
            os.makedirs(cme_dir)
        #######################################################################
        # Search for COR1 data in +/- 30min window around event tm1
        dt = pd.Timedelta(30, 'm')
        tl = [(c1['tm'][i] - dt).isoformat(), (c1['tm'][i] + dt).isoformat()]
        # Query VSO to find what files available
        qr = vsoclient.query(vso.attrs.Time(tl[0], tl[1]),
                             vso.attrs.Instrument('cor1'),
                             vso.attrs.Source(craft))
        # Take out values that are not 0deg polarised
        q = 0
        while q <= len(qr) - 1:
            tpe = qr[q]['info'].split(';')[3].strip()
            if tpe == '0deg.':
                q = q + 1
            else:
                qr.pop(q)
        # Find closest mathced in time
        # Get datetimes of the query resutls
        times = np.array([pd.to_datetime(x['time']['start']) for x in qr])
        # Remove querys before the closest match
        q = 0
        while q < np.argmin(np.abs(times - c1['tm'][i])):
            qr.pop(0)
            q = q + 1
        # Remove querys after the closest match
        while len(qr) > 1:
            qr.pop(1)
        # Download best matched file
        vsoclient.get(qr, path=cme_dir + r"\{file}").wait()
        for t in times:
            hv.download_png(t.isoformat(),
                            7.5,
                            c1_hvr,
                            x0=0,
                            y0=0,
                            width=1024,
                            height=1024,
                            directory=cme_dir,
                            watermark=True)
        ###################################################################
        # Search for COR2 data around tm2
        dt = pd.Timedelta(90, 'm')
        tl = [(c2['tm'][i] - dt).isoformat(), (c2['tm'][i] + dt).isoformat()]
        qr = vsoclient.query(vso.attrs.Time(tl[0], tl[1]),
                             vso.attrs.Instrument('cor2'),
                             vso.attrs.Source(craft))
        # Take out values not 2048x2048 double exposures
        q = 0
        while q <= len(qr) - 1:
            tpe = qr[q]['info'].split(';')[2].strip()
            sze = qr[q]['info'].split(';')[-1].strip()
            if tpe == 'DOUBLE' and sze == '2048x2048':
                q = q + 1
            else:
                qr.pop(q)
        # Find closest mathced in time
        # Get datetimes of the query resutls
        times = np.array([pd.to_datetime(x['time']['start']) for x in qr])
        # Remove querys before the closest match
        q = 0
        while q < np.argmin(np.abs(times - c2['tm'][i])):
            qr.pop(0)
            q = q + 1
        # Remove querys after the closest match
        while len(qr) > 1:
            qr.pop(1)
        # Download best matched file
        vsoclient.get(qr, path=cme_dir + r"\{file}").wait()
        # Use the query times to download helioviewer PNGS
        for t in times:
            hv.download_png(t.isoformat(),
                            14.7,
                            c2_hvr,
                            x0=0,
                            y0=0,
                            width=2048,
                            height=2048,
                            directory=cme_dir,
                            watermark=True)
        ###################################################################
        # Now use the fits files to work out the mid point distance and
        # update the arrays
        c1_file = glob.glob(cme_dir + r'\*c1*.fts')
        rb, rm = calc_radial_distance(c1_file, cme_root)
        c1['rb'][i] = rb
        c1['rm'][i] = rm
        # Repeat for COR2
        c2_file = glob.glob(cme_dir + r'\*c2*.fts')
        rb, rm = calc_radial_distance(c2_file, cme_root)
        c2['rb'][i] = rb
        c2['rm'][i] = rm
    return c1, c2
예제 #7
0
from sunpy.net.helioviewer import HelioviewerClient
hv = HelioviewerClient()
hv.download_png("2099/01/01",
                6,
                "[SDO,AIA,AIA,304,1,100],[SDO,AIA,AIA,193,1,50]," +
                "[SOHO,LASCO,C2,white-light,1,100]",
                x0=0,
                y0=0,
                width=768,
                height=768)