def plot_bandpass_set(setname):
    """Plot the given set of bandpasses."""

    rc("font", family="serif")

    bandpass_meta = registry.get_loaders_metadata(Bandpass)

    fig = plt.figure(figsize=(9, 3))
    ax = plt.axes()

    nbands = 0
    for m in bandpass_meta:
        if m['filterset'] != setname:
            continue
        b = get_bandpass(m['name'])
        ax.plot(b.wave, b.trans, label=m['name'])
        nbands += 1

    ax.set_xlabel("Wavelength ($\\AA$)")
    ax.set_ylabel("Transmission")

    ncol = 1 + (nbands-1) // 9  # 9 labels per column
    ax.legend(loc='upper right', frameon=False, fontsize='small',
              ncol=ncol)

    # Looks like each legend column takes up about 0.125 of the figure.
    # Make room for the legend.
    xmin, xmax = ax.get_xlim()
    xmax += ncol * 0.125 * (xmax - xmin)
    ax.set_xlim(xmin, xmax)
    plt.tight_layout()
    plt.show()
Пример #2
0
def plot_bandpass_set(setname):
    """Plot the given set of bandpasses."""

    rc("font", family="serif")

    bandpass_meta = registry.get_loaders_metadata(Bandpass)

    fig = plt.figure(figsize=(9, 3))
    ax = plt.axes()

    nbands = 0
    for m in bandpass_meta:
        if m['filterset'] != setname:
            continue
        b = get_bandpass(m['name'])
        ax.plot(b.wave, b.trans, label=m['name'])
        nbands += 1

    ax.set_xlabel("Wavelength ($\\AA$)")
    ax.set_ylabel("Transmission")

    ncol = 1 + (nbands - 1) // 9  # 9 labels per column
    ax.legend(loc='upper right', frameon=False, fontsize='small', ncol=ncol)

    # Looks like each legend column takes up about 0.125 of the figure.
    # Make room for the legend.
    xmin, xmax = ax.get_xlim()
    xmax += ncol * 0.125 * (xmax - xmin)
    ax.set_xlim(xmin, xmax)
    plt.tight_layout()
    plt.show()
Пример #3
0
sphinx documentation via the automodule directive."""

import string

from astropy.extern import six
from sncosmo import registry, MagSystem

lines = [
    '', '  '.join([10 * '=', 60 * '=', 35 * '=', 15 * '=']),
    '{0:10}  {1:60}  {2:35}  {3:15}'.format('Name', 'Description', 'Subclass',
                                            'Spectrum Source')
]
lines.append(lines[1])

urlnums = {}
for m in registry.get_loaders_metadata(MagSystem):

    urllink = ''
    description = ''

    if 'description' in m:
        description = m['description']

    if 'url' in m:
        url = m['url']
        if url not in urlnums:
            if len(urlnums) == 0:
                urlnums[url] = 0
            else:
                urlnums[url] = max(urlnums.values()) + 1
        urllink = '`{0}`_'.format(string.ascii_letters[urlnums[url]])
Пример #4
0
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import Grid
from sncosmo import registry
from sncosmo import Bandpass, get_bandpass


bandpass_meta = registry.get_loaders_metadata(Bandpass)
filtersets = []
for m in bandpass_meta:
    if m['filterset'] not in filtersets: filtersets.append(m['filterset'])

fig = plt.figure(figsize=(9., 3. * len(filtersets)))
grid = Grid(fig, rect=111, nrows_ncols=(len(filtersets), 1),
            axes_pad=0.25, label_mode='L')

for ax, filterset in zip(grid, filtersets):

    for m in bandpass_meta:
        if m['filterset'] != filterset: continue
        b = get_bandpass(m['name'])
        ax.plot(b.wave, b.trans, label=m['name'])
    ax.set_xlabel('Angstroms')
    ax.set_ylabel('Transmission')
    ax.legend(loc='upper right')

xmin, xmax = ax.get_xlim()
ax.set_xlim(right=(xmax + 1000.))  # make room for legend
plt.tight_layout()
plt.show()
Пример #5
0
"""Generate a restructured text document that describes built-in bandpasses
and save it to this module's docstring for the purpose of including in
sphinx documentation via the automodule directive."""

import string

from astropy.extern import six
from sncosmo import registry, Bandpass, get_bandpass

bandpass_meta = registry.get_loaders_metadata(Bandpass)
table_delim = "  ".join([11 * '=', 80 * '=', 14 * '=', 8 * '=', 12 * '='])
table_colnames = ("{0:11}  {1:80}  {2:14}  {3:8}  {4:12}".format(
    'Name', 'Description', 'Reference', 'Data URL', 'Retrieved'))
urlnums = {}


def bandpass_table(setname):
    """Return a string containing a rst table of bandpasses in the set."""

    lines = [table_delim, table_colnames, table_delim]
    allrefs = []

    for m in bandpass_meta:
        if m['filterset'] != setname:
            continue

        reflink = ''
        urllink = ''
        retrieved = ''

        if 'reference' in m:
sphinx documentation via the automodule directive."""

import string

from astropy.extern import six
from sncosmo import registry, MagSystem


lines = ['',
         '  '.join([10*'=', 60*'=', 35*'=', 15*'=']),
         '{0:10}  {1:60}  {2:35}  {3:15}'
         .format('Name', 'Description', 'Subclass', 'Spectrum Source')]
lines.append(lines[1])

urlnums = {}
for m in registry.get_loaders_metadata(MagSystem):

    urllink = ''
    description = ''

    if 'description' in m:
        description = m['description']

    if 'url' in m:
        url = m['url']
        if url not in urlnums:
            if len(urlnums) == 0:
                urlnums[url] = 0
            else:
                urlnums[url] = max(urlnums.values()) + 1
        urllink = '`{0}`_'.format(string.ascii_letters[urlnums[url]])
from astropy.extern import six
from sncosmo import registry, Source


lines = [
    '',
    '  '.join([20*'=', 7*'=', 10*'=', 27*'=', 14*'=', 7*'=', 7*'=']),
    '{0:20}  {1:7}  {2:10}  {3:27}  {4:14}  {5:7}  {6:50}'.format(
        'Name', 'Version', 'Type', 'Subclass', 'Reference', 'Website', 'Notes')
    ]
lines.append(lines[1])

urlnums = {}
allnotes = []
allrefs = []
for m in registry.get_loaders_metadata(Source):

    reflink = ''
    urllink = ''
    notelink = ''

    if 'note' in m:
        if m['note'] not in allnotes:
            allnotes.append(m['note'])
        notenum = allnotes.index(m['note'])
        notelink = '[{0}]_'.format(notenum + 1)

    if 'reference' in m:
        reflink = '[{0}]_'.format(m['reference'][0])
        if m['reference'] not in allrefs:
            allrefs.append(m['reference'])