<commit_before>#-*- coding:utf-8 -*-
#
# Author: <NAME> <<EMAIL>>
# Author: <NAME> <<EMAIL>>
# Written: 2011/03/29
#
# <License info will go here...>
#
"""Test function for plotting an AIA FITS image."""

import os
import datetime
import pyfits
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as colors
from matplotlib.patches import Circle
from sunpy import Sun
import sunpy.dev.cm

AIA_SAMPLE_IMAGE = 'sample-data/AIA20110319_105400_0171.fits'

def plot_fits(filepath=None):
    '''Plots an AIA image.'''

    if filepath is None:
        filepath = os.path.join(os.path.dirname(__file__), AIA_SAMPLE_IMAGE)

    # Load fits file
    fits = pyfits.open(filepath)
    header = fits[0].header
    data = fits[0].data

    # Get useful header information
    date  = header['date-obs']
    fitsDatetime = datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%f")
    instr = header['instrume']
    rSun  = header['r_sun']
    wavelength = header['wavelnth']
    
    centerX = header['crpix1']
    centerY = header['crpix1']
    scaleX = header['cdelt1']
    scaleY = header['cdelt2']
    
    # Create a figure and add title and axes
    fig = plt.figure()
    
    ax = fig.add_subplot(111)
    ax.set_title(instr + ' ' + date)
    ax.set_xlabel('X-postion (arcseconds)')
    ax.set_ylabel('Y-postion (arcseconds)')
    
    # Draw circle at solar limb
    circ = Circle([0, 0], radius=Sun.radius(fitsDatetime), fill=False, color='white')
    ax.add_artist(circ)
        
    # Determine extent
    xmin = -(centerX - 1) * scaleX
    xmax = (centerX - 1) * scaleX
    ymin = -(centerY - 1) * scaleY
    ymax = (centerY - 1) * scaleY
    
    extent = [xmin, xmax, ymin, ymax]
    
    # Draw image
    cm = sunpy.dev.cm.log_adaptive(data)
    imgplot = plt.imshow(data, cmap=cm, origin='lower', extent=extent)

    plt.colorbar()
    
    # Show figure
    plt.show()<commit_msg>Set vmin to 10 when generating cmap for better results<commit_after>#-*- coding:utf-8 -*-
#
# Author: <NAME> <<EMAIL>>
# Author: <NAME> <<EMAIL>>
# Written: 2011/03/29
#
# <License info will go here...>
#
"""Test function for plotting an AIA FITS image."""

import os
import datetime
import pyfits
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as colors
from matplotlib.patches import Circle
from sunpy import Sun
import sunpy.dev.cm

AIA_SAMPLE_IMAGE = 'sample-data/AIA20110319_105400_0171.fits'

def plot_fits(filepath=None):
    '''Plots an AIA image.'''

    if filepath is None:
        filepath = os.path.join(os.path.dirname(__file__), AIA_SAMPLE_IMAGE)

    # Load fits file
    fits = pyfits.open(filepath)
    header = fits[0].header
    data = fits[0].data

    # Get useful header information
    date  = header['date-obs']
    fitsDatetime = datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%f")
    instr = header['instrume']
    rSun  = header['r_sun']
    wavelength = header['wavelnth']
    
    centerX = header['crpix1']
    centerY = header['crpix1']
    scaleX = header['cdelt1']
    scaleY = header['cdelt2']
    
    # Create a figure and add title and axes
    fig = plt.figure()
    
    ax = fig.add_subplot(111)
    ax.set_title(instr + ' ' + date)
    ax.set_xlabel('X-postion (arcseconds)')
    ax.set_ylabel('Y-postion (arcseconds)')
    
    # Draw circle at solar limb
    circ = Circle([0, 0], radius=Sun.radius(fitsDatetime), fill=False, color='white')
    ax.add_artist(circ)
        
    # Determine extent
    xmin = -(centerX - 1) * scaleX
    xmax = (centerX - 1) * scaleX
    ymin = -(centerY - 1) * scaleY
    ymax = (centerY - 1) * scaleY
    
    extent = [xmin, xmax, ymin, ymax]
    
    # Draw image
    cm = sunpy.dev.cm.log_adaptive(data, vmin=10)
    imgplot = plt.imshow(data, cmap=cm, origin='lower', extent=extent)

    plt.colorbar()
    
    # Show figure
    plt.show()
{'fraction_non_alphanumeric': 0.13711340206185568, 'fraction_numerical': 0.02268041237113402, 'mean_word_length': 3.013443640124095, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5359063', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1390, 'n_words': 337}