Exemple #1
0
def _get_defaults(s1,
                  s2,
                  var,
                  wunit='default',
                  Iunit='default',
                  medium='default',
                  resample=True):
    ''' See get_distance, get_diff '''

    # Check inputs, get defaults
    # ----
    if Iunit == 'default':
        try:
            Iunit = s1.units[var]
        except KeyError:  # unit not defined in dictionary
            raise KeyError('Iunit not defined in spectrum. Cant plot')
    # Format units
    if wunit == 'default':
        wunit = s1.get_waveunit()
    wunit = cast_waveunit(wunit)
    if medium == 'default':
        medium = s1.conditions.get('medium', None)

    # Get data
    # ----
    w1, I1 = s1.get(var, wunit=wunit, Iunit=Iunit, medium=medium)
    w2, I2 = s2.get(var, wunit=wunit, Iunit=Iunit, medium=medium)

    if not resample:
        if not array_allclose(w1, w2):
            raise AssertionError(
                'Wavespace are not the same: use Spectrum.resample()')

    return w1, I1, w2, I2
Exemple #2
0
def _get_defaults(s1,
                  s2,
                  var,
                  wunit="default",
                  Iunit="default",
                  assert_same_wavelength=False):
    # type: (Spectrum, Spectrum, str, str, str, bool) -> (np.array, np.array, np.array, np.array)
    """Returns w1, I1, w2, I2  in the same waveunit, unit and medium.

    See get_distance, get_diff for more information"""

    # Check inputs, get defaults
    # ----
    if Iunit == "default":
        try:
            Iunit = s1.units[var]
        except KeyError:  # unit not defined in dictionary
            raise KeyError(
                "Iunit not defined in spectrum for variable {0}".format(var))
    # Format units
    if wunit == "default":
        wunit = s1.get_waveunit()
    wunit = cast_waveunit(wunit)

    # Get data
    # ----
    w1, I1 = s1.get(var, wunit=wunit, Iunit=Iunit)
    w2, I2 = s2.get(var, wunit=wunit, Iunit=Iunit)

    if assert_same_wavelength:
        if not array_allclose(w1, w2):
            raise AssertionError(
                "Wavespace are not the same: use Spectrum.resample()")

    return w1, I1, w2, I2
Exemple #3
0
def _get_defaults(s1,
                  s2,
                  var,
                  wunit='default',
                  Iunit='default',
                  medium='default',
                  assert_same_wavelength=False):
    # type: (Spectrum, Spectrum, str, str, str, bool) -> (np.array, np.array, np.array, np.array)
    ''' Returns w1, I1, w2, I2  in the same waveunit, unit and medium.
    
    See get_distance, get_diff for more information '''

    # Check inputs, get defaults
    # ----
    if Iunit == 'default':
        try:
            Iunit = s1.units[var]
        except KeyError:  # unit not defined in dictionary
            raise KeyError(
                'Iunit not defined in spectrum for variable {0}'.format(var))
    # Format units
    if wunit == 'default':
        wunit = s1.get_waveunit()
    wunit = cast_waveunit(wunit)
    if medium == 'default':
        medium = s1.conditions.get('medium', None)

    # Get data
    # ----
    w1, I1 = s1.get(var, wunit=wunit, Iunit=Iunit, medium=medium)
    w2, I2 = s2.get(var, wunit=wunit, Iunit=Iunit, medium=medium)

    if assert_same_wavelength:
        if not array_allclose(w1, w2):
            raise AssertionError(
                'Wavespace are not the same: use Spectrum.resample()')

    return w1, I1, w2, I2