Ejemplo n.º 1
0
    def command_zero(self, command):
        """
        Zero a column at a record.

        Parameters
        ----------
        command : str
            command from r file

        Notes
        -----
        The Xlook command is `zero column_number record_index`.

        See Also
        --------
        pylook.calc.zero
        """
        if not self._check_number_of_arguments(command, 3):
            return
        (_, input_col_idx, zero_record) = command.split()
        input_col_idx = int(input_col_idx)
        zero_record = int(zero_record)
        result = lc.zero(
            self._get_data_by_index(input_col_idx) * units('dimensionless'),
            zero_record)
        self._set_data_by_index(
            input_col_idx, result.m)  # We are not touching units and names
Ejemplo n.º 2
0
def test_zero_mode_after():
    """Test zero with the mode of after."""
    data = np.arange(10) * units('mm')

    result = zero(data, 5, mode='after')

    truth = np.array([-5, -4, -3, -2, -1, 0, 0, 0, 0, 0]) * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 3
0
def test_zero_mode_before():
    """Test zero with the mode of before."""
    data = np.arange(10) * units('mm')

    result = zero(data, 5, mode='before')

    truth = np.array([0, 0, 0, 0, 0, 0, 1, 2, 3, 4]) * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 4
0
def test_zero_defaults():
    """Test zero with all of the default args."""
    data = np.arange(10) * units('mm')

    result = zero(data, 5)

    truth = np.array([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 5
0
def test_zero_value_after_mode():
    """Test zeroing with an offset value in the after mode."""
    data = np.arange(10) * units('mm')

    result = zero(data, 5, value=1.5 * units('mm'), mode='after')

    truth = np.array([-3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 1.5, 1.5, 1.5, 1.5
                      ]) * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 6
0
def test_zero_value_before_mode():
    """Test zeroing with an offset value in the before mode."""
    data = np.arange(10) * units('mm')

    result = zero(data, 5, value=1.5 * units('mm'), mode='before')

    truth = np.array([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 2.5, 3.5, 4.5, 5.5
                      ]) * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 7
0
def test_zero_value_at_mode():
    """Test zeroing with an offset value in the default at mode."""
    data = np.arange(10) * units('mm')

    result = zero(data, 5, value=1.5 * units('mm'))

    truth = np.array([-3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5
                      ]) * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 8
0
def test_zero_window():
    """Test zero with a window to get an average zero value."""
    data = np.array([0, 1, 2, 2.2, 2.5, 2.3, 2.2, 2.6, 2.7, 2.9, 3
                     ]) * units('mm')

    result = zero(data, 5, window=2)

    truth = data - 2.36 * units('mm')

    assert_array_almost_equal(result, truth)
Ejemplo n.º 9
0
output_notebook()

##############################

p = figure(title='Find the normal stress zero row',
           tools='box_zoom, reset, hover')
p.line(data['rec_num'].m, data['Normal Stress'].m)
show(p)

##############################
# Row 42 looks pretty good, so we zero the normal stress there. We'd also like to set
# everything before that row to zero since it's just noise. In r files that took some math
# commands, we zero has options in pylook! We also don't need to worry about adding small
# values to avoid divide by zero errors as the friction calculation handles that properly.

data['Normal Stress'] = lc.zero(data['Normal Stress'], 42, mode='before')

##############################
# While we are zeroing, it is a good time to deal with the normal displacement as well.

data['Normal Displacement'] = lc.remove_offset(data['Normal Displacement'],
                                               0,
                                               42,
                                               set_between=True)

##############################
# Now we need to find the zero point for the shear load and stress.

p = figure(title='Find the shear stress zero row',
           tools='box_zoom, reset, hover')
p.line(data['rec_num'].m, data['Shear Stress'].m)