Visualizing Dive Science (using R)

November 22, 2013
By

(This article was first published on Climate Change Ecology » R, and kindly contributed to R-bloggers)

My friends and co-workers got lucky enough to spend about two weeks living in the Aquarius habitat, NOAA’s undersea research lab in the Florida Keys. I, unfortunately, am stuck on dry land (or on a boat above the habitat, watching them swim around). However, since this is kind of a big deal (and really, really awesome), I thought I’d do a short blog post on visualizing diving science in R.

If you read Andy’s posts, you’ll see that he’s saturating at a depth of about 40′. This allows him to spend 8 hours per day working underwater. Typically, divers are limited by nitrogen buildup in their tissues. Too much is a bad thing, so we have to surface at regular intervals. Since his new ‘surface’ point is about 40′ below the surface, he can now spend long days working on the reef without worrying about decompression.

One other way we get around that is using enriched-air NITROX mixtures. Regular air is about 21% oxygen, but we can jack that up to about 36%, thereby reducing the percentage of nitrogen we are breathing and giving us more bottom time. Essentially, what happens is that our ‘operating’ depth becomes shallower than our actual depth. The richer the mix, the shallower your operating depth, the more bottom time you get:

</pre>
depths <- seq(30, 140, len = 8)
P02 <- 1.4
mix <- seq(21, 36, by = 2)
depthMix <- expand.grid('Depth' = depths, 'O2_Mix' = mix)
depthMix$EAD <- (depthMix$Depth + 33) *((1 - depthMix$O2_Mix/100)/0.79) - 33

ggplot(depthMix, aes(Depth, EAD, color = as.factor(O2_Mix))) +
    geom_line() +
    ylab('Enriched Air Depth') +
    xlab('Actual Depth') +
    guides(color = guide_legend(title = 'Percent O2 in Mix')) +
    theme(
         panel.background = element_rect(fill = NA, color = 'black'),
         axis.text = element_text(size = 12, color = 'black'),
         axis.title = element_text(size = 14),
         axis.ticks = element_line(color = 'black'),
         legend.key = element_blank()
    )

EADs

You’ll notice two things. First, at shallow depths, O2 mixture really doesn’t help a whole lot. The benefits of enriched air (i.e. shallower operating depth) only occur as depth increases. Second, you’ll see the little PO2 in the code. This is the partial pressure of oxygen that you find acceptable to breathe. You see, as you turn up the oxygen concentration, you breathe in more and more oxygen (obviously). As you go deeper, the amount of oxygen you breathe can reach dangerously high levels (as you take in more gas per breath due to the pressure of the water). Typically, NITROX divers restrict their PO2 intake to somewhere between a conservative 1.2 atm (we breathe in 0.21 atm at sea level) and a slightly risker 1.6 atm. Too high of an oxygen intake risks seizures and other dangerous side effects (lumped into an issue called oxygen toxicity – not to be confused with nitrogen narcosis, i.e. the crazy eye from Life Aquatic). This means that, as you enrich your air with oxygen, you intake more and more oxygen at lower depths, so the richer your mix the shallower the maximum depth you can dive before health problems set in

MOD <- 33 * (P02/(mix/100) - 1)
MODs <- data.frame('Depth' = depths, MOD, 'O2_Mix' = mix)

ggplot(MODs, aes(mix, MOD, color = mix)) +
 geom_line(, show_guide = F) +
 scale_color_continuous(low = 'red', high = 'blue') +
 ylab('Maximum Operating Depth') +
 xlab('Percent O2 in Mix') +
 theme(
 panel.background = element_rect(fill = NA, color = 'black'),
 axis.text = element_text(size = 12, color = 'black'),
 axis.title = element_text(size = 14),
 axis.ticks = element_line(color = 'black'),
 legend.key = element_blank()
 )

MODs

This contrasts with the typical perception that NITROX is for deep diving. It isn’t. It’s for medium-depth dives requiring long bottom times (the greatest diving I ever did was NITROX doubles with about 32% EAN, which gave me around 2 hours of bottom time at 70 feet). So the actual plot of ‘operating’ depth vs. actual depth needs to take into consideration the fact that its dangerous to use rich mixtures at depth.

</pre>
test <- split(depthMix, as.factor(depthMix$O2_Mix))

cutOff <- function(x){
 x <- merge(MODs, x, all.y = T)
 cutDepth <- x$MOD[!is.na(x$MOD)]
 x <- x[x$Depth <= cutDepth, ]
 return(x)
}

cutDepths <- lapply(test, cutOff)
cutDepths <- ldply(cutDepths)

ggplot(cutDepths, aes(Depth, EAD, color = as.factor(O2_Mix))) +
 geom_line() +
 ylab('Enriched Air Depth') +
 xlab('Actual Depth') +
 guides(color = guide_legend(title = 'Percent O2 in Mix')) +
 theme(
 panel.background = element_rect(fill = NA, color = 'black'),
 axis.text = element_text(size = 12, color = 'black'),
 axis.title = element_text(size = 14),
 axis.ticks = element_line(color = 'black'),
 legend.key = element_blank()
 )
<pre>
cutDepths

Note that diving with EAN below 100-115 feet is never recommended, regardless of calculated MOD.

And that’s the basics of NITROX diving, which is pretty unimportant for my friend since he’s saturated. For those of you who want to know what its like to live on the ocean floor, stay tuned here. He’ll be posting regularly (I’d like to see him post on exactly how that works, internet on the sea floor).

Stay tuned, and check out the live Aquarius feed here!


To leave a comment for the author, please follow the link and comment on his blog: Climate Change Ecology » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.