# Path: sncosmo/utils.py
# def alias_map(aliased, aliases, required=()):
#     """For each key in ``aliases``, find the item in ``aliased`` matching
#     exactly one of the corresponding items in ``aliases``.
# 
#     Parameters
#     ----------
#     aliased : list of str
#         Input keys, will be values in output map.
#     aliases : dict of sets
#         Dictionary where keys are "canonical name" and values are sets of
#         possible aliases.
#     required : list_like
#         Keys in ``aliases`` that are considered required. An error is raised
#         if no alias is found in ``aliased``.
# 
# 
#     Returns
#     -------
# 
#     Example::
# 
#         >>> aliases = {'a':set(['a', 'a_']), 'b':set(['b', 'b_'])}
#         >>> alias_map(['A', 'B_', 'foo'], aliases)
#         {'a': 'A', 'b': 'B_'}
# 
# 
# 
#     """
#     lowered_to_orig = {key.lower(): key for key in aliased}
#     lowered = set(lowered_to_orig.keys())
#     mapping = {}
#     for key, key_aliases in aliases.items():
#         common = lowered & key_aliases
#         if len(common) == 1:
#             mapping[key] = lowered_to_orig[common.pop()]
# 
#         elif len(common) == 0 and key in required:
#             raise ValueError('no alias found for {!r} (possible '
#                              'case-independent aliases: {})'.format(
#                                  key,
#                                  ', '.join(repr(ka) for ka in key_aliases)))
#         elif len(common) > 1:
#             raise ValueError('multiple aliases found for {!r}: {}'
#                              .format(key, ', '.join(repr(a) for a in common)))
# 
#     return mapping


import copy
import numpy as np
from collections import OrderedDict
from astropy.cosmology import FlatLambdaCDM
from astropy.table import Table
from numpy import random
from scipy.interpolate import InterpolatedUnivariateSpline as Spline1d
from .utils import alias_map
    Notes
    -----
    ``skynoise`` is the image background contribution to the flux measurement
    error (in units corresponding to the specified zeropoint and zeropoint
    system). To get the error on a given measurement, ``skynoise`` is added
    in quadrature to the photon noise from the source.

    It is left up to the user to calculate ``skynoise`` as they see fit as the
    details depend on how photometry is done and possibly how the PSF is
    is modeled. As a simple example, assuming a Gaussian PSF, and perfect
    PSF photometry, ``skynoise`` would be ``4 * pi * sigma_PSF * sigma_pixel``
    where ``sigma_PSF`` is the standard deviation of the PSF in pixels and
    ``sigma_pixel`` is the background noise in a single pixel in counts.

    """

    RESULT_COLNAMES = ('time', 'band', 'flux', 'fluxerr', 'zp', 'zpsys')
    lcs = []

    # Copy model so we don't mess up the user's model.
    model = copy.copy(model)

    # get observations as a Table
    if not isinstance(observations, Table):
        if isinstance(observations, np.ndarray):
            observations = Table(observations)
        else:
            raise ValueError("observations not understood")

    # map column name aliases

# Path: sncosmo/utils.py
# def alias_map(aliased, aliases, required=()):
#     """For each key in ``aliases``, find the item in ``aliased`` matching
#     exactly one of the corresponding items in ``aliases``.
# 
#     Parameters
#     ----------
#     aliased : list of str
#         Input keys, will be values in output map.
#     aliases : dict of sets
#         Dictionary where keys are "canonical name" and values are sets of
#         possible aliases.
#     required : list_like
#         Keys in ``aliases`` that are considered required. An error is raised
#         if no alias is found in ``aliased``.
# 
# 
#     Returns
#     -------
# 
#     Example::
# 
#         >>> aliases = {'a':set(['a', 'a_']), 'b':set(['b', 'b_'])}
#         >>> alias_map(['A', 'B_', 'foo'], aliases)
#         {'a': 'A', 'b': 'B_'}
# 
# 
# 
#     """
#     lowered_to_orig = {key.lower(): key for key in aliased}
#     lowered = set(lowered_to_orig.keys())
#     mapping = {}
#     for key, key_aliases in aliases.items():
#         common = lowered & key_aliases
#         if len(common) == 1:
#             mapping[key] = lowered_to_orig[common.pop()]
# 
#         elif len(common) == 0 and key in required:
#             raise ValueError('no alias found for {!r} (possible '
#                              'case-independent aliases: {})'.format(
#                                  key,
#                                  ', '.join(repr(ka) for ka in key_aliases)))
#         elif len(common) > 1:
#             raise ValueError('multiple aliases found for {!r}: {}'
#                              .format(key, ', '.join(repr(a) for a in common)))
# 
#     return mapping


# Path: sncosmo/simulation.py
import copy
import numpy as np
from collections import OrderedDict
from astropy.cosmology import FlatLambdaCDM
from astropy.table import Table
from numpy import random
from scipy.interpolate import InterpolatedUnivariateSpline as Spline1d
from .utils import alias_map

    Notes
    -----
    ``skynoise`` is the image background contribution to the flux measurement
    error (in units corresponding to the specified zeropoint and zeropoint
    system). To get the error on a given measurement, ``skynoise`` is added
    in quadrature to the photon noise from the source.

    It is left up to the user to calculate ``skynoise`` as they see fit as the
    details depend on how photometry is done and possibly how the PSF is
    is modeled. As a simple example, assuming a Gaussian PSF, and perfect
    PSF photometry, ``skynoise`` would be ``4 * pi * sigma_PSF * sigma_pixel``
    where ``sigma_PSF`` is the standard deviation of the PSF in pixels and
    ``sigma_pixel`` is the background noise in a single pixel in counts.

    """

    RESULT_COLNAMES = ('time', 'band', 'flux', 'fluxerr', 'zp', 'zpsys')
    lcs = []

    # Copy model so we don't mess up the user's model.
    model = copy.copy(model)

    # get observations as a Table
    if not isinstance(observations, Table):
        if isinstance(observations, np.ndarray):
            observations = Table(observations)
        else:
            raise ValueError("observations not understood")

    # map column name aliases

    colname = alias_map(observations.colnames, OBSERVATIONS_ALIASES,