Fwd: Re: [CCR PATCH] PO2 Calculations extracted to separate function.
Willem Ferguson
willemferguson at zoology.up.ac.za
Mon Sep 15 05:05:18 PDT 2014
-------- Forwarded Message --------
Subject: Re: [CCR PATCH] PO2 Calculations extracted to separate function.
Date: Mon, 15 Sep 2014 14:01:14 +0200
From: Willem Ferguson <willemferguson at zoology.up.ac.za>
Reply-To: willemferguson at zoology.up.ac.za
Organization: University of Pretoria
To: Robert Helling <helling at atdotde.de>
On 15/09/2014 12:09, Robert Helling wrote:
>
> On 14.09.2014, at 20:39, Willem Ferguson
> <willemferguson at zoology.up.ac.za
> <mailto:willemferguson at zoology.up.ac.za>> wrote:
>
> Willem,
>
>> This patch takes the po2 calculations in calculate_gas_information()
>> and puts these in a separate function calc_po2(). This was suggested
>> by Robert Helling. Several variables are required to do this calcu-
>> lation, passed to the function as a pointer to a structure defined
>> in profile.h
>
> I must admit, I dont quite get this. What is the point of that new
> structure? I dont see what you earn from combining the ambient
> pressure and some info from struct gasmix. Why dont you pass the
> ambient pressure and a pointer to the gasmix to your new function.
>
> Another warning: The ambient pressure variable is double (and not int)
> because it has units of bar (and not mbar) different from what the
> comment in the header file says. So have the partial pressure fields
> in entry as they are plotted and the user wants to see bars, not our
> internal units.
>
> To me, it would make much more sense to have a helper function that
> returns all three partial pressures given a gas mix and an ambient
> pressure (and a measured pO2 and possibly another variable indicating
> the type of dive i.e. OC, CCR or PSCR).
>
> BTW, code with a similar function (i.e. get partial pressures from an
> ambient pressure and gas mix) are also found in add_segemnt in deco.c.
> There, you also want to use your helper functions.
>
> Best
> Robert
>
Robert, thanks for the comment. Interesting stuff. If this could be
written in a way to be of benefit elsewhere, it's the undisputed route.
As is at the moment ambient pressure is defined as a double in
gas_record (in profile.h). But that is beside the point. I would like us
to communicate clearly because I think you have a good idea to pursue
here. The input structure for the function enables several variables to
be passed in an efficient way. With the expansion to CCR dive data, this
will become important. If you have any feeling about an efficient
approach to do this, please tell me what your thoughts are.
As I intend it, the type of dive computer (OC, CCR ate present, but
nothing preventing to add SCR also) needs to be an *input parameter* to
the function so that the appropriate part of the algorithm will be used.
It is not intended that it should be an output parameter.
Also, returning several values complicates things. One possibility is to
expand the gasmix structure (dive.h) to be a general communication
mechanism between the calc_po2() function and the outside world. The
three different computed partial pressures would then be stored in the
structure, as well as the measured po2, ambient pressure and dc type
(the latter three are already input parameters). In that case, the name
of the function is likely to change to calc_partial_pressures().
Does this make sense?
Kind regards,
willem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140915/04e3afe5/attachment-0001.html>
More information about the subsurface
mailing list