In [17]:
import deco
import deco_mix
import numpy

Validate against GFDECO.F by Eric Baker

# GFDECO.SET &Program_Settings Units='msw' Altitude_Dive_Algorithm='OFF' Minimum_Deco_Stop_Time=1.0 Gradient_Factor_Lo=0.1 Gradient_Factor_Hi=0.9 RMV_During_Dive=20.0 RMV_During_Deco=15.0 # GFDECO.IN dive to 50 meters of seawater gauge (mswg) for 25 minutes on 21/35 1 0.21,0.35,0.44 1 0,50,10,1 2 50,25,1 99 1 50,1,-10,3 0 Program Run: 04-11-2014 at 03:48 pm Model: ZH-L16B/GF Description: dive to 50 meters of seawater gauge (mswg) for 25 minutes on air Gasmix Summary: FO2 FHe FN2 Gasmix # 1 0.210 0.350 0.440 DIVE PROFILE Seg- Segm. Run | Gasmix | Ascent From To Rate | Constant ment Time Time | Used | or Depth Depth +Dn/-Up | Depth # (min) (min) | # | Descent (mswg) (mswg) (msw/min) | (mswg) ----- ----- ----- | ------ | ------- ------ ------ --------- | -------- 1 5.0 5.0 | 1 | Descent 0. 50. 10.0 | 2 20.0 25.0 | 1 | | 50. DECOMPRESSION PROFILE Leading compartment enters the decompression zone at 34.2 mswg Deepest possible decompression stop is 33.0 mswg Seg- Segm. Run | Gasmix | Ascent Ascent | DECO STOP RUN ment Time Time | Used | To Rate Grad. | STOP TIME TIME # (min) (min) | # | (mswg) (msw/min) Factor | (mswg) (min) (min) ----- ----- ----- | ------ | ------ --------- ------ | ------ ----- ----- 3 1.7 26.7 | 1 | 33. -10.0 | 4 0.3 27.0 | 1 | 0.10 | 33 1 27 5 0.3 27.3 | 1 | 30. -10.0 | 6 0.7 28.0 | 1 | 0.17 | 30 1 28 7 0.3 28.3 | 1 | 27. -10.0 | 8 0.7 29.0 | 1 | 0.25 | 27 1 29 9 0.3 29.3 | 1 | 24. -10.0 | 10 0.7 30.0 | 1 | 0.32 | 24 1 30 11 0.3 30.3 | 1 | 21. -10.0 | 12 0.7 31.0 | 1 | 0.39 | 21 1 31 13 0.3 31.3 | 1 | 18. -10.0 | 14 0.7 32.0 | 1 | 0.46 | 18 1 32 15 0.3 32.3 | 1 | 15. -10.0 | 16 1.7 34.0 | 1 | 0.54 | 15 2 34 17 0.3 34.3 | 1 | 12. -10.0 | 18 3.7 38.0 | 1 | 0.61 | 12 4 38 19 0.3 38.3 | 1 | 9. -10.0 | 20 6.7 45.0 | 1 | 0.68 | 9 7 45 21 0.3 45.3 | 1 | 6. -10.0 | 22 10.7 56.0 | 1 | 0.75 | 6 11 56 23 0.3 56.3 | 1 | 3. -10.0 | 24 23.7 80.0 | 1 | 0.83 | 3 24 80 25 0.3 80.3 | 1 | 0. -10.0 | 0.90 |

In [18]:
# Globals
settings = deco.deco_settings(
    last_stop = 3,
    gf_low = 0.1,
    gf_high = 0.90)
precision = numpy.float32

In [19]:
mix_ctx = deco_mix.deco_mix_ctx()

mix_ctx.set_mix(
    1,
    deco_mix.deco_mix(
        f_o2 = 0.21,
        f_he = 0.35,
        switch_depth = 0,
        enabled = False))

#print(gasmixes)
#print(mix_ctx)

In [20]:
# Initialize decompression context
deco_ctx = deco.deco_zhl16b(
    settings = settings,
    mix_ctx = mix_ctx,
    p_surface = 1.0,
    salinity = 1.0)

#print(deco_ctx)

In [21]:
# Simulate dive profile.
deco_ctx.mix_ctx.set_active_mix(1)

deco_ctx.update_asc_desc(
    time = 5,
    p_begin = deco_ctx.p_surface,
    p_end = deco_ctx.depth_to_pressure(50))

deco_ctx.update_constant(
    time = 20,
    p_amb = deco_ctx.depth_to_pressure(50))

# Get deco info.
di = deco.deco_info()

di = deco_ctx.decotime_update(
    p_amb = deco_ctx.depth_to_pressure(50),
    di = di)

print (di)

assert di.time_to_surface == 57
assert di.stops[0]['depth'] == 33
assert di.stops[0]['time'] == 1
assert di.stops[1]['depth'] == 30
assert di.stops[1]['time'] == 1
assert di.stops[2]['depth'] == 27
assert di.stops[2]['time'] == 1
assert di.stops[3]['depth'] == 24
assert di.stops[3]['time'] == 1
assert di.stops[4]['depth'] == 21
assert di.stops[4]['time'] == 1
assert di.stops[5]['depth'] == 18
assert di.stops[5]['time'] == 1
assert di.stops[6]['depth'] == 15
assert di.stops[6]['time'] == 2
assert di.stops[7]['depth'] == 12
assert di.stops[7]['time'] == 4
assert di.stops[8]['depth'] == 9
assert di.stops[8]['time'] == 7
assert di.stops[9]['depth'] == 6
assert di.stops[9]['time'] == 12
assert di.stops[10]['depth'] == 3
assert di.stops[10]['time'] == 24


TX21/35 @ 33 m for 1 min.
TX21/35 @ 30 m for 1 min.
TX21/35 @ 27 m for 1 min.
TX21/35 @ 24 m for 1 min.
TX21/35 @ 21 m for 1 min.
TX21/35 @ 18 m for 1 min.
TX21/35 @ 15 m for 2 min.
TX21/35 @ 12 m for 4 min.
TX21/35 @ 9 m for 7 min.
TX21/35 @ 6 m for 12 min.
TX21/35 @ 3 m for 24 min.
Total deco time: 57 min.