Exemple #1
0
    def ceiling(self):
        """Determine the current ceiling depth.

        :returns: ceiling depth in meter
        :rtype: float
        """
        pressure = 0.0
        for comp in self.tissues:
            # Get compartment tolerated ambient pressure and convert from
            # absolute pressure to depth
            comp_pressure = comp.get_max_amb(
                self.gradient.gf) - settings.AMBIANT_PRESSURE_SURFACE
            if comp_pressure > pressure:
                pressure = comp_pressure
        return tools.pressure_to_depth(pressure)
Exemple #2
0
    def ceiling(self):
        """Determine the current ceiling depth.

        :returns: ceiling depth in meter
        :rtype: float
        """
        pressure = 0.0
        for comp in self.tissues:
            # Get compartment tolerated ambient pressure and convert from
            # absolute pressure to depth
            comp_pressure = comp.get_max_amb(
                self.gradient.gf) - settings.AMBIANT_PRESSURE_SURFACE
            if comp_pressure > pressure:
                pressure = comp_pressure
        return tools.pressure_to_depth(pressure)
Exemple #3
0
    def get_end_for_given_depth(self, depth):
        """calculate end (equivalent narcotic depth)
        based on given depth and based on gaz inside the tank

        .. note::
            end calculation is based on narcotic index for all gases.

            By default, dipplanner considers that oxygen is narcotic
            (same narcotic index than nitrogen)

            All narcotic indexes can by changed in the config file,
            in the [advanced] section

        *Keyword arguments:*
            depth -- int -- in meter

        *Returns:*
            end -- int -- equivalent narcotic depth in meter

        *Raise:*
            <nothing>
        """
        p_absolute = depth_to_pressure(depth) + settings.AMBIANT_PRESSURE_SURFACE
        # calculate the reference narcotic effect of air
        # Air consists of: Nitrogen N2: 78.08%,
        #                  Oxygen O2: 20.95%,
        #                  Argon Ar: 0.934%
        reference_narcotic = settings.AMBIANT_PRESSURE_SURFACE * (
            settings.N2_NARCOTIC_VALUE * 0.7808
            + settings.O2_NARCOTIC_VALUE * 0.2095
            + settings.AR_NARCOTIC_VALUE * 0.00934
        )
        # OC mode
        narcotic_index = p_absolute * (
            self.f_n2 * settings.N2_NARCOTIC_VALUE
            + self.f_o2 * settings.O2_NARCOTIC_VALUE
            + self.f_he * settings.HE_NARCOTIC_VALUE
        )

        end = pressure_to_depth(narcotic_index / reference_narcotic - settings.AMBIANT_PRESSURE_SURFACE)
        if end < 0:
            end = 0
        return end
Exemple #4
0
    def get_mod_for_given_end(self, end):
        """calculate a mod based on given end and based on gaz inside the tank

        .. note::
            end calculation is based on narcotic index for all gases.

            By default, dipplanner considers that oxygen is narcotic
            (same narcotic index than nitrogen)

            All narcotic indexes can by changed in the config file,
            in the [advanced] section

        *Keyword arguments:*
            :end: (int) -- equivalent narcotic depth in meter

        *Returns:*
            int -- mod: depth in meter based on given end

        *Raise:*
            <nothing>
        """
        # calculate the reference narcotic effect of air
        # Air consists of: Nitrogen N2: 78.08%,
        #                  Oxygen O2: 20.95%,
        #                  Argon Ar: 0.934%
        # OC
        reference_narcotic = settings.AMBIANT_PRESSURE_SURFACE * (
            settings.N2_NARCOTIC_VALUE * 0.7808
            + settings.O2_NARCOTIC_VALUE * 0.2095
            + settings.AR_NARCOTIC_VALUE * 0.00934
        )
        # OC mode
        narcotic_tank = (
            self.f_n2 * settings.N2_NARCOTIC_VALUE
            + self.f_o2 * settings.O2_NARCOTIC_VALUE
            + self.f_he * settings.HE_NARCOTIC_VALUE
        )

        p_absolute = (depth_to_pressure(end) + settings.AMBIANT_PRESSURE_SURFACE) * reference_narcotic / narcotic_tank
        mod = pressure_to_depth(p_absolute - settings.AMBIANT_PRESSURE_SURFACE)
        return mod
Exemple #5
0
    def ceiling(self):
        """Determine the current ceiling depth

        *Keyword arguments:*
            <none>

        *Returns:*
            float -- ceiling depth in meter

        *Raise:*
            <nothing>
        """
        pressure = 0.0
        for comp in self.tissues:
            #Get compartment tolerated ambient pressure and convert from
            # absolute pressure to depth
            comp_pressure = comp.get_max_amb(
                self.gradient.gf) - settings.AMBIANT_PRESSURE_SURFACE
            if comp_pressure > pressure:
                pressure = comp_pressure
        return tools.pressure_to_depth(pressure)
Exemple #6
0
    def get_mod_for_given_end(self, end):
        """Calculate a mod based on given end and based on gaz inside the tank.

        .. note::
            end calculation is based on narcotic index for all gases.

            By default, dipplanner considers that oxygen is narcotic
            (same narcotic index than nitrogen)

            All narcotic indexes can by changed in the config file,
            in the [advanced] section

        :param int end: equivalent narcotic depth in meter

        :returns: mod: depth in meter based on given end
        :rtype int:

        .. todo:: get and return float instead of int ?
        """
        # calculate the reference narcotic effect of air
        # Air consists of: Nitrogen N2: 78.08%,
        #                  Oxygen O2: 20.95%,
        #                  Argon Ar: 0.934%
        # OC
        reference_narcotic = settings.AMBIANT_PRESSURE_SURFACE * (
            settings.N2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FN2 +
            settings.O2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FO2 +
            settings.AR_NARCOTIC_VALUE * settings.DEFAULT_AIR_FAR)
        # OC mode
        narcotic_tank = (self.f_n2 * settings.N2_NARCOTIC_VALUE +
                         self.f_o2 * settings.O2_NARCOTIC_VALUE +
                         self.f_he * settings.HE_NARCOTIC_VALUE)

        p_absolute = ((depth_to_pressure(end) +
                       settings.AMBIANT_PRESSURE_SURFACE) *
                      reference_narcotic / narcotic_tank)
        mod = pressure_to_depth(p_absolute - settings.AMBIANT_PRESSURE_SURFACE)
        return mod
Exemple #7
0
    def get_mod_for_given_end(self, end):
        """Calculate a mod based on given end and based on gaz inside the tank.

        .. note::
            end calculation is based on narcotic index for all gases.

            By default, dipplanner considers that oxygen is narcotic
            (same narcotic index than nitrogen)

            All narcotic indexes can by changed in the config file,
            in the [advanced] section

        :param int end: equivalent narcotic depth in meter

        :returns: mod: depth in meter based on given end
        :rtype int:

        .. todo:: get and return float instead of int ?
        """
        # calculate the reference narcotic effect of air
        # Air consists of: Nitrogen N2: 78.08%,
        #                  Oxygen O2: 20.95%,
        #                  Argon Ar: 0.934%
        # OC
        reference_narcotic = settings.AMBIANT_PRESSURE_SURFACE * (
            settings.N2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FN2 +
            settings.O2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FO2 +
            settings.AR_NARCOTIC_VALUE * settings.DEFAULT_AIR_FAR)
        # OC mode
        narcotic_tank = (self.f_n2 * settings.N2_NARCOTIC_VALUE +
                         self.f_o2 * settings.O2_NARCOTIC_VALUE +
                         self.f_he * settings.HE_NARCOTIC_VALUE)

        p_absolute = (
            (depth_to_pressure(end) + settings.AMBIANT_PRESSURE_SURFACE) *
            reference_narcotic / narcotic_tank)
        mod = pressure_to_depth(p_absolute - settings.AMBIANT_PRESSURE_SURFACE)
        return mod
Exemple #8
0
 def test_depth_to_pressure_60(self):
     self.assertAlmostEqual(pressure_to_depth(6.06258), 60, 5,
                            'Wrong depth pressure at 60m : %s'
                            % depth_to_pressure(6.06258))
Exemple #9
0
 def test_depth_to_pressure_80(self):
     self.assertAlmostEqual(pressure_to_depth(8.08344), 80, 5,
                            'Wrong depth pressure at 80m : %s'
                            % depth_to_pressure(8.08344))
Exemple #10
0
 def test_depth_to_pressure_70(self):
     self.assertAlmostEqual(pressure_to_depth(7.07301), 70, 5,
                            'Wrong depth pressure at 70m : %s'
                            % depth_to_pressure(7.07301))
Exemple #11
0
    def get_end_for_given_depth(self, depth, setpoint=0.0):
        """Calculate end (equivalent narcotic depth).

        based on given depth and based on gaz inside the tank

        .. note::
            end calculation is based on narcotic index for all gases.

            By default, dipplanner considers that oxygen is narcotic
            (same narcotic index than nitrogen)

            All narcotic indexes can by changed in the config file,
            in the [advanced] section

        Instead of Mvplan, dipplanner uses a 'calculation method' based on
        narcosis effet of all gas used, assuming there is no trace of
        other gases (like argon) in the breathing gas, but compare the narcotic
        effect with surface gas, wich is 'air' and contains
        a small amount of argon

        :param int depth: in meter
        :param float setpoint: ppo2 in bar. If 0: OC mode, if > 0.0, CCR mode.

        :returns: end -- equivalent narcotic depth in meter
        :rtype: float
        """
        p_absolute = (depth_to_pressure(depth) +
                      settings.AMBIANT_PRESSURE_SURFACE)
        # calculate the reference narcotic effect of air
        # Air consists of: Nitrogen N2: 78.08%,
        #                  Oxygen O2: 20.95%,
        #                  Argon Ar: 0.934%
        reference_narcotic = settings.AMBIANT_PRESSURE_SURFACE * (
            settings.N2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FN2 +
            settings.O2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FO2 +
            settings.AR_NARCOTIC_VALUE * settings.DEFAULT_AIR_FAR)

        if setpoint > 0:
            # CCR mode
            f_inert = self.f_he + self.f_n2
            if f_inert > 0:
                pp_inert = p_absolute - setpoint
            else:
                pp_inert = 0
            if pp_inert > 0:
                # sort of approximation here ?
                # calculate here a narcotic index based on the proportion
                # of innertgases in the dilluent tank
                # should (perhaps) calculate based on proportion
                # of innert gases inthe loop ?
                ppn2_inspired = (pp_inert * self.f_n2) / f_inert
                pphe_inspired = (pp_inert * self.f_he) / f_inert
                narcotic_index = (ppn2_inspired * settings.N2_NARCOTIC_VALUE +
                                  setpoint * settings.O2_NARCOTIC_VALUE +
                                  pphe_inspired * settings.HE_NARCOTIC_VALUE)

                self.logger.debug("pabs: %.3f, pp_inert: %.3f at %sm, "
                                  "ppn2i:%s, pphei:%s, narco idx:%s",
                                  p_absolute, pp_inert,
                                  depth, ppn2_inspired,
                                  pphe_inspired, narcotic_index)
            else:
                narcotic_index = 0
        else:
            # OC mode
            narcotic_index = p_absolute * (
                self.f_n2 * settings.N2_NARCOTIC_VALUE +
                self.f_o2 * settings.O2_NARCOTIC_VALUE +
                self.f_he * settings.HE_NARCOTIC_VALUE)

        end = pressure_to_depth(narcotic_index / reference_narcotic -
                                settings.AMBIANT_PRESSURE_SURFACE)
        if end < 0:
            end = 0
        return end
Exemple #12
0
 def test_depth_to_pressure_90(self):
     self.assertAlmostEqual(pressure_to_depth(9.09387), 90, 5,
                            'Wrong depth pressure at 90m : %s'
                            % depth_to_pressure(9.09387))
Exemple #13
0
 def test_depth_to_pressure_10(self):
     self.assertAlmostEqual(pressure_to_depth(1.01043), 10, 5,
                            'Wrong depth pressure at 10m : %s'
                            % depth_to_pressure(1.01043))
Exemple #14
0
 def test_depth_to_pressure_60(self):
     self.assertAlmostEqual(
         pressure_to_depth(6.06258), 60, 5,
         'Wrong depth pressure at 60m : %s' % depth_to_pressure(6.06258))
Exemple #15
0
 def test_depth_to_pressure_50(self):
     self.assertAlmostEqual(pressure_to_depth(5.05215), 50, 5,
                            'Wrong depth pressure at 50m : %s'
                            % depth_to_pressure(5.05215))
Exemple #16
0
 def test_depth_to_pressure_30(self):
     self.assertAlmostEqual(pressure_to_depth(3.03129), 30, 5,
                            'Wrong depth pressure at 30m : %s'
                            % depth_to_pressure(3.03129))
Exemple #17
0
 def test_depth_to_pressure_0(self):
     self.assertAlmostEqual(
         pressure_to_depth(0.0), 0, 0,
         'Wrong depth pressure at 0m : %s' % depth_to_pressure(0.0))
Exemple #18
0
 def test_depth_to_pressure_80(self):
     self.assertAlmostEqual(
         pressure_to_depth(8.08344), 80, 5,
         'Wrong depth pressure at 80m : %s' % depth_to_pressure(8.08344))
Exemple #19
0
 def test_depth_to_pressure_10(self):
     self.assertAlmostEqual(
         pressure_to_depth(1.01043), 10, 5,
         'Wrong depth pressure at 10m : %s' % depth_to_pressure(1.01043))
Exemple #20
0
 def test_depth_to_pressure_20(self):
     self.assertAlmostEqual(
         pressure_to_depth(2.02086), 20, 5,
         'Wrong depth pressure at 20m : %s' % depth_to_pressure(2.02086))
Exemple #21
0
 def test_depth_to_pressure_30(self):
     self.assertAlmostEqual(
         pressure_to_depth(3.03129), 30, 5,
         'Wrong depth pressure at 30m : %s' % depth_to_pressure(3.03129))
Exemple #22
0
 def test_depth_to_pressure_40(self):
     self.assertAlmostEqual(
         pressure_to_depth(4.04172), 40, 5,
         'Wrong depth pressure at 40m : %s' % depth_to_pressure(4.04172))
Exemple #23
0
 def test_depth_to_pressure_50(self):
     self.assertAlmostEqual(
         pressure_to_depth(5.05215), 50, 5,
         'Wrong depth pressure at 50m : %s' % depth_to_pressure(5.05215))
Exemple #24
0
 def test_depth_to_pressure_40(self):
     self.assertAlmostEqual(pressure_to_depth(4.04172), 40, 5,
                            'Wrong depth pressure at 40m : %s'
                            % depth_to_pressure(4.04172))
Exemple #25
0
    def get_end_for_given_depth(self, depth, setpoint=0.0):
        """Calculate end (equivalent narcotic depth).

        based on given depth and based on gaz inside the tank

        .. note::
            end calculation is based on narcotic index for all gases.

            By default, dipplanner considers that oxygen is narcotic
            (same narcotic index than nitrogen)

            All narcotic indexes can by changed in the config file,
            in the [advanced] section

        Instead of Mvplan, dipplanner uses a 'calculation method' based on
        narcosis effet of all gas used, assuming there is no trace of
        other gases (like argon) in the breathing gas, but compare the narcotic
        effect with surface gas, wich is 'air' and contains
        a small amount of argon

        :param int depth: in meter
        :param float setpoint: ppo2 in bar. If 0: OC mode, if > 0.0, CCR mode.

        :returns: end -- equivalent narcotic depth in meter
        :rtype: float
        """
        p_absolute = (depth_to_pressure(depth) +
                      settings.AMBIANT_PRESSURE_SURFACE)
        # calculate the reference narcotic effect of air
        # Air consists of: Nitrogen N2: 78.08%,
        #                  Oxygen O2: 20.95%,
        #                  Argon Ar: 0.934%
        reference_narcotic = settings.AMBIANT_PRESSURE_SURFACE * (
            settings.N2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FN2 +
            settings.O2_NARCOTIC_VALUE * settings.DEFAULT_AIR_FO2 +
            settings.AR_NARCOTIC_VALUE * settings.DEFAULT_AIR_FAR)

        if setpoint > 0:
            # CCR mode
            f_inert = self.f_he + self.f_n2
            if f_inert > 0:
                pp_inert = p_absolute - setpoint
            else:
                pp_inert = 0
            if pp_inert > 0:
                # sort of approximation here ?
                # calculate here a narcotic index based on the proportion
                # of innertgases in the dilluent tank
                # should (perhaps) calculate based on proportion
                # of innert gases inthe loop ?
                ppn2_inspired = (pp_inert * self.f_n2) / f_inert
                pphe_inspired = (pp_inert * self.f_he) / f_inert
                narcotic_index = (ppn2_inspired * settings.N2_NARCOTIC_VALUE +
                                  setpoint * settings.O2_NARCOTIC_VALUE +
                                  pphe_inspired * settings.HE_NARCOTIC_VALUE)

                self.logger.debug(
                    "pabs: %.3f, pp_inert: %.3f at %sm, "
                    "ppn2i:%s, pphei:%s, narco idx:%s", p_absolute, pp_inert,
                    depth, ppn2_inspired, pphe_inspired, narcotic_index)
            else:
                narcotic_index = 0
        else:
            # OC mode
            narcotic_index = p_absolute * (
                self.f_n2 * settings.N2_NARCOTIC_VALUE +
                self.f_o2 * settings.O2_NARCOTIC_VALUE +
                self.f_he * settings.HE_NARCOTIC_VALUE)

        end = pressure_to_depth(narcotic_index / reference_narcotic -
                                settings.AMBIANT_PRESSURE_SURFACE)
        if end < 0:
            end = 0
        return end
Exemple #26
0
 def test_depth_to_pressure_20(self):
     self.assertAlmostEqual(pressure_to_depth(2.02086), 20, 5,
                            'Wrong depth pressure at 20m : %s'
                            % depth_to_pressure(2.02086))
Exemple #27
0
 def test_depth_to_pressure_90(self):
     self.assertAlmostEqual(
         pressure_to_depth(9.09387), 90, 5,
         'Wrong depth pressure at 90m : %s' % depth_to_pressure(9.09387))
Exemple #28
0
 def test_depth_to_pressure_0(self):
     self.assertAlmostEqual(pressure_to_depth(0.0), 0, 0,
                            'Wrong depth pressure at 0m : %s'
                            % depth_to_pressure(0.0))
Exemple #29
0
 def test_depth_to_pressure_70(self):
     self.assertAlmostEqual(
         pressure_to_depth(7.07301), 70, 5,
         'Wrong depth pressure at 70m : %s' % depth_to_pressure(7.07301))