# Path: sncosmo/bandpasses.py
# def get_bandpass(name, *args):
#     """Get a Bandpass from the registry by name."""
#     if isinstance(name, Bandpass):
#         return name
#     if len(args) == 0:
#         return _BANDPASSES.retrieve(name)
#     else:
#         interp = _BANDPASS_INTERPOLATORS.retrieve(name)
#         return interp.at(*args)
# 
# Path: sncosmo/utils.py
# def dict_to_array(d):
#     """Convert a dictionary of lists (or single values) to a structured
#     numpy.ndarray."""
# 
#     # Convert all lists/values to 1-d arrays, in order to let numpy
#     # figure out the necessary size of the string arrays.
#     new_d = OrderedDict()
#     for key in d:
#         new_d[key] = np.atleast_1d(d[key])
# 
#     # Determine dtype of output array.
#     dtype = [(key, arr.dtype)
#              for key, arr in new_d.items()]
# 
#     # Initialize ndarray and then fill it.
#     col_len = max([len(v) for v in new_d.values()])
#     result = np.empty(col_len, dtype=dtype)
#     for key in new_d:
#         result[key] = new_d[key]
# 
#     return result


import json
import math
import os
import numpy as np
from collections import OrderedDict
from astropy import wcs
from astropy.io import fits
from astropy.table import Table
from .bandpasses import get_bandpass
from .utils import dict_to_array
    from astropy.utils.data import get_pkg_data_filename
    from astropy.utils.data import get_pkg_data_filename
        photometry files. Default is to try to read all files in directory.

    Returns
    -------
    t : astropy `~astropy.table.Table`
        Table of data. Metadata (as an `OrderedDict`) can be accessed via
        the ``t.meta`` attribute. For example: ``t.meta['key']``. The key
        is case-sensitive.

    Examples
    --------

    Read an ascii format file that includes metadata (``StringIO``
    behaves like a file object):

    >>> from io import StringIO
    >>> f = StringIO('''
    ... @id 1
    ... @RA 36.0
    ... @description good
    ... time band flux fluxerr zp zpsys
    ... 50000. g 1. 0.1 25. ab
    ... 50000.1 r 2. 0.1 25. ab
    ... ''')
    >>> t = read_lc(f, format='ascii')
    >>> print(t)
      time  band flux fluxerr  zp  zpsys
    ------- ---- ---- ------- ---- -----
    50000.0    g  1.0     0.1 25.0    ab
    50000.1    r  2.0     0.1 25.0    ab

# Path: sncosmo/bandpasses.py
# def get_bandpass(name, *args):
#     """Get a Bandpass from the registry by name."""
#     if isinstance(name, Bandpass):
#         return name
#     if len(args) == 0:
#         return _BANDPASSES.retrieve(name)
#     else:
#         interp = _BANDPASS_INTERPOLATORS.retrieve(name)
#         return interp.at(*args)
# 
# Path: sncosmo/utils.py
# def dict_to_array(d):
#     """Convert a dictionary of lists (or single values) to a structured
#     numpy.ndarray."""
# 
#     # Convert all lists/values to 1-d arrays, in order to let numpy
#     # figure out the necessary size of the string arrays.
#     new_d = OrderedDict()
#     for key in d:
#         new_d[key] = np.atleast_1d(d[key])
# 
#     # Determine dtype of output array.
#     dtype = [(key, arr.dtype)
#              for key, arr in new_d.items()]
# 
#     # Initialize ndarray and then fill it.
#     col_len = max([len(v) for v in new_d.values()])
#     result = np.empty(col_len, dtype=dtype)
#     for key in new_d:
#         result[key] = new_d[key]
# 
#     return result


# Path: sncosmo/io.py
import json
import math
import os
import numpy as np
from collections import OrderedDict
from astropy import wcs
from astropy.io import fits
from astropy.table import Table
from .bandpasses import get_bandpass
from .utils import dict_to_array
    from astropy.utils.data import get_pkg_data_filename
    from astropy.utils.data import get_pkg_data_filename

        photometry files. Default is to try to read all files in directory.

    Returns
    -------
    t : astropy `~astropy.table.Table`
        Table of data. Metadata (as an `OrderedDict`) can be accessed via
        the ``t.meta`` attribute. For example: ``t.meta['key']``. The key
        is case-sensitive.

    Examples
    --------

    Read an ascii format file that includes metadata (``StringIO``
    behaves like a file object):

    >>> from io import StringIO
    >>> f = StringIO('''
    ... @id 1
    ... @RA 36.0
    ... @description good
    ... time band flux fluxerr zp zpsys
    ... 50000. g 1. 0.1 25. ab
    ... 50000.1 r 2. 0.1 25. ab
    ... ''')
    >>> t = read_lc(f, format='ascii')
    >>> print(t)
      time  band flux fluxerr  zp  zpsys
    ------- ---- ---- ------- ---- -----
    50000.0    g  1.0     0.1 25.0    ab
    50000.1    r  2.0     0.1 25.0    ab

    >>> t.meta