Example #1
0
    def test_k_val95_between_1_and_120(self):
        dof = 100

        expected_result = statistics.ttable_p95[dof - 1]

        result = statistics.k_val95(dof)
        self.assertEqual(expected_result, result)
Example #2
0
    def test_k_val95_less_1(self):
        dof = -1

        expected_result = statistics.ttable_p95[0]

        result = statistics.k_val95(dof)
        self.assertEqual(expected_result, result)
Example #3
0
    def test_k_val95_greater_120(self):
        dof = 121

        expected_result = 1.96

        result = statistics.k_val95(dof)
        self.assertEqual(expected_result, result)
Example #4
0
def dnaout_sd(obslist, stdev_distconst=0.001, stdev_distppm=1):
    dnaobs = []
    for observation in obslist:
        # GUM Uncertainty Estimation Model
        # Characterised Components (Uncertainty, k Value, Population (no of measurements - 1)
        type_a_esdm = observation.sd_stdev / sqrt(observation.rounds)
        if observation.rounds > 2:
            type_a_uncertainty = (type_a_esdm, 1, observation.rounds - 1)
        else:
            type_a_uncertainty = (type_a_esdm, 1, 1)
        inst_centring = (0.001, 2, 30)
        tgt_centring = (0.001, 2, 30)
        inst_uncertainty_const = (stdev_distconst, 2, 100)
        inst_uncertainty_ppm = (stdev_distppm, 2, 100)
        # Standard Error 1 sigma
        sterr_typea = type_a_uncertainty[0] / type_a_uncertainty[1]
        sterr_inst_centring = inst_centring[0] / inst_centring[1]
        sterr_tgt_centring = tgt_centring[0] / tgt_centring[1]
        sterr_inst_const = inst_uncertainty_const[0] / inst_uncertainty_const[1]
        sterr_inst_ppm = observation.sd_obs * (
            (inst_uncertainty_ppm[0] / inst_uncertainty_ppm[1]) / 1000000)
        combined_stdev1sigma = sqrt(sterr_typea**2 + sterr_inst_centring**2 +
                                    sterr_tgt_centring**2 +
                                    sterr_inst_const**2 + sterr_inst_ppm**2)
        # Effective Degrees of Freedom (Welch-Satterthwaite) and
        vi_eff = (combined_stdev1sigma**4) / (
            (sterr_typea**4) / type_a_uncertainty[2] +
            (sterr_inst_centring**4) / inst_centring[2] +
            (sterr_tgt_centring**4) / tgt_centring[2] +
            (sterr_inst_const**4) / inst_uncertainty_const[2] +
            (sterr_inst_ppm**4) / inst_uncertainty_ppm[2])
        stdev = combined_stdev1sigma * k_val95(int(vi_eff))
        # Exclude slope distances of 0m
        if observation.sd_obs == 0:
            pass
        else:
            # Write line output in DNA v3 Format
            line = ('S ' + observation.from_id.ljust(20) +
                    observation.to_id.ljust(20) + ''.ljust(19) +
                    ('{:.4f}'.format(observation.sd_obs)).rjust(9) +
                    ''.ljust(21) + ('{:.4f}'.format(stdev)).ljust(8) +
                    ('{:.4f}'.format(observation.inst_height).ljust(7)) +
                    ('{:.4f}'.format(observation.target_height)))
            dnaobs.append(line)
    return dnaobs
Example #5
0
    def test_k_val95_typeError(self):
        dof = [[], {}, ""]

        for item in dof:
            with self.assertRaises(TypeError):
                statistics.k_val95(item)