Hi Phil,
On Wed, 31 Mar 2004, Phil Hodge wrote:
In iraffunctions.py:
def clSexagesimal(d, m, s=0):
"""Convert d:m:s value to float"""
return (d+(m+s/60.0)/60.0)
This does not work correctly for negative values of d. Also, since d, m, s
are already float (rather than strings), it would be difficult to handle a
value such as -0:18:30.
Do we actually recommend anywhere that people use this function directly?
The parser does not include the minus sign in d, so this works in all
cases within CL code. E.g., using the (little known) CL compatibility
mode with a switch that echos the python equivalent of each CL line:
* --> clCompatibilityMode 1
Entering CL-compatibility (verbose) mode...
* cl>print(0:18:30)
0.308333333333
----- Python -----
iraf.clPrint(iraf.clSexagesimal(0,18,30), _save=1)
------------------
* cl>print(-0:18:30)
-0.308333333333
----- Python -----
iraf.clPrint( - iraf.clSexagesimal(0,18,30), _save=1)
------------------
(I put a * in front of the actual comments to make them easier to
find.)
Oh, on poking around I do see one bug in the iraffunctions.py code: If
you call real("0:18:30") it automatically does a call to clSexagesimal.
But that call does *not* handle minus signs correctly -- it just does a
split on ':' and converts each part to real. So the real() function
should be fixed to handle minus signs correctly. Maybe this was somehow
what you encountered?
Rick