示例#1
0
    def __init__(self, calculations):
        self.title = "The Ostwald Triangle"
        self.maxco2 = calculations.max_co2
        self.maxco = calculations.max_co
        self.maxo2 = calculations.max_o2
        self.O2_SERIES_SCALE = 2
        self.CO2_SERIES_SCALE = 2
        self.set_width(margin_left=10, triangle_width=50)
        self.set_height(margin_top=10, triangle_width=50)
        self.A = Point(self.left, self.top)
        self.B = Point(self.right, self.bot)
        self.C = self.get_position_from_scale(calculations.C.o2, calculations.C.co2)
        self.P = self.get_position_from_scale(calculations.P.o2, calculations.P.co2)
        self.Pco2 = self.get_position_from_scale(0, calculations.P.co2)
        self.Po2 = self.get_position_from_scale(calculations.P.o2, self.maxco2)
        self.co2_diagonal_angle = degrees(atan(self.width/self.height))
        self.co_line_angle = self.co2_diagonal_angle
        self.bot_diagonal_angle = 90 - self.co2_diagonal_angle

        self.coefficient_line_angle = self.calculate_coeff_line_angle()

        self.lines = {"o2": LineInfo(
            Vector(self.left, self.top, self.right, self.top),
            points=self.maxo2 + 1,
            labels={"name": "Oxygen %"},
            series=Series(0, self.maxo2, self.O2_SERIES_SCALE),
        ), "co2": LineInfo(
            Vector(self.left, self.bot, self.left, self.top),
            series=Series(0, self.maxco2, self.CO2_SERIES_SCALE),
            labels={"name": "Carbon dioxide %"}
        ), "co": LineInfo(
            Vector(Point(self.right, self.bot), 180 + self.co_line_angle,
                   self.width * cos(radians(self.co2_diagonal_angle))),
            series=Series(0, self.maxco, 5),
            labels={"name": "Carbon monoxide %"}
        ), "coefficient": LineInfo(
            self.create_coefficient_line(),
            series=Series(0, 1.6, 0.2),
            labels={"name": "Phi coefficient"}  # todo coeff latin smbol
        ), "bot": LineInfo(
            Vector(self.left, self.bot, self.right, self.bot)
        ), "diagonal": LineInfo(
            Vector(self.left, self.top, self.right, self.bot)
        ), "P-co": LineInfo(
            self.create_p_co_line()
        ), "P-o2": LineInfo(
            self.create_p_o2_line()
        ), "P-co2": LineInfo(
            self.create_p_co2_line()
        )
        }
示例#2
0
 def test_change_range_correct_points(self):
     a = Series(0, 1)
     a.change_range(10, 12)
     self.assertEqual(3, a.points)
示例#3
0
 def test_get_values_with_trail2(self):
     a = Series(0, 1.2, 0.5)
     self.assertEqual([0 * 1.2, (1 / 2.4) * 1.2, (2 / 2.4) * 1.2, 1 * 1.2],
                      a.get_values())
示例#4
0
 def test_get_point_wages_with_trail2(self):
     a = Series(0, 1.2, 0.5)
     self.assertEqual([0, 1 / 2.4, 2 / 2.4, 1], a.get_point_wages())
示例#5
0
 def test_get_point_wages_with_trail(self):
     a = Series(0, 3, 2)
     self.assertEqual([0, 1 / 1.5, 1], a.get_point_wages())
示例#6
0
 def test_get_point_wages(self):
     a = Series(0, 4)
     self.assertEqual([0, 0.25, 0.5, 0.75, 1], a.get_point_wages())
示例#7
0
 def test_calculate_full_scale_points_actual(self):
     a = Series(0, 18.9, 2)
     self.assertEqual(10, a.calculate_full_scale_points())
示例#8
0
 def test_calculate_full_scale_points_scale2(self):
     a = Series(0, 5, 2)
     self.assertEqual(3, a.calculate_full_scale_points())
示例#9
0
 def test_calculate_full_scale_points(self):
     a = Series(1, 1.5, 0.5)
     self.assertEqual(2, a.calculate_points())
示例#10
0
 def test_calculate_full_points_not_full_numbers(self):
     a = Series(0.31, 5.5, 2)
     self.assertEqual(3, a.calculate_full_scale_points())
示例#11
0
 def test_calculate_points_scale23(self):
     a = Series(0, 5, 2)
     self.assertEqual(4, a.calculate_points())
示例#12
0
 def test_calculate_points_scale05(self):
     a = Series(0, 2, 0.5)
     self.assertEqual(5, a.calculate_points())
示例#13
0
 def test_calculate_points_scale2(self):
     a = Series(0, 2, 2)
     self.assertEqual(2, a.calculate_points())
示例#14
0
 def test_calculate_points01(self):
     a = Series(0, 1, 0.1)
     self.assertEqual(11, a.calculate_points())
示例#15
0
 def split_coeff_line_series(self, main_series, altitude_drop_ratio):
     line1_series = Series(main_series.start, 1, main_series.scale)
     line2_series = Series(1, 1 / altitude_drop_ratio, main_series.scale)
     return line1_series, line2_series