# 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
        Filename.
    format : {'ascii', 'salt2', 'snana', 'json'}, optional
        Format of file. Default is 'ascii'. 'salt2' is the new format available
        in snfit version >= 2.3.0.
    delim : str, optional
        **[ascii only]** Character used to separate entries on a line.
        Default is ' '.
    metachar : str, optional
        **[ascii only]** Metadata designator. Default is '@'.
    raw : bool, optional
        **[salt2, snana]** By default, the SALT2 and SNANA writers rename
        some metadata keys and column names in order to comply with what
        snfit and SNANA expect. Set to True to override this.
        Default is False.
    pedantic : bool, optional
        **[salt2, snana]** If True, check that output column names and header
        keys comply with expected formatting, and raise a ValueError if not.
        It is probably a good idea to set to False when raw is True.
        Default is True.
    """

    if format not in WRITERS:
        raise ValueError("Writer not defined for format {0!r}. Options: "
                         .format(format) + ", ".join(WRITERS.keys()))
    if isinstance(data, Table):
        meta = data.meta
        data = np.asarray(data)
    else:
        meta = OrderedDict()
        if not isinstance(data, np.ndarray):

# 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

        Filename.
    format : {'ascii', 'salt2', 'snana', 'json'}, optional
        Format of file. Default is 'ascii'. 'salt2' is the new format available
        in snfit version >= 2.3.0.
    delim : str, optional
        **[ascii only]** Character used to separate entries on a line.
        Default is ' '.
    metachar : str, optional
        **[ascii only]** Metadata designator. Default is '@'.
    raw : bool, optional
        **[salt2, snana]** By default, the SALT2 and SNANA writers rename
        some metadata keys and column names in order to comply with what
        snfit and SNANA expect. Set to True to override this.
        Default is False.
    pedantic : bool, optional
        **[salt2, snana]** If True, check that output column names and header
        keys comply with expected formatting, and raise a ValueError if not.
        It is probably a good idea to set to False when raw is True.
        Default is True.
    """

    if format not in WRITERS:
        raise ValueError("Writer not defined for format {0!r}. Options: "
                         .format(format) + ", ".join(WRITERS.keys()))
    if isinstance(data, Table):
        meta = data.meta
        data = np.asarray(data)
    else:
        meta = OrderedDict()
        if not isinstance(data, np.ndarray):

            data = dict_to_array(data)