Convert a floating point (Degrees or Hours) to sexigecimal.
% float2sex.sh sex2float.sh 12.123456789 h arg1 - floating point number arg2 - units (h=hours, d=degrees) % float2sex.sh 12.55916669 h 12:33:33.0001 % float2sex.sh -12.55916669 d -12:33:33.0001
The routine sex2float takes a sexigecimal string and makes a floating point expression. The float2sex script takes a float and creates the sexigecimal string (not that this routine "wants" to know if it is using units of HOURS or DEGREES). I wrote a test for both routines in my Test_Data_for_Codes section.The test script (TEST1) runs both sex2float and float2sex to verify that they work.
Go to Test dir (got) % cd ./T_runs/cdproj/ex0 % cp S/TEST1 . To test the HOURS mode % ./TEST1 12:33:33.0001 h sex in = 12:33:33.0001 float answer = 12.55916671 new form = 12:33:33.0002 NOTE: Does not work yet!!!!!! The answer---> stupid fortran ------------------------------------------------------- 12:33:33.0001 I'll use my calculator set to 9 decimal places 123456789 12 ---> 12.000000000 33 /60 0.550000000 33.0001 /3600 0.009166694 Final_calculator 12.559166694 ---> 12.55916669 So, I changed fortran code: double precision xx1,xx2,xx3,xnum,xo,sign double precision x60, x3600 c This works: x60 = 60.000000000 x3600 = 3600.000000000 xx2 = x2/x60 xx3 = x3/x3600 c This does NOT work: xx2 = x2/60.0 xx3 = x3/3600.0 Now I get: % !se sex2float.sh 12:33:33.0001 12.55916669 12.55916669 -----> This is my hand-calculation value! Now, I get good agreement to the 8th decimal place: % TEST1 12:33:33.0001 h sex in = 12:33:33.0001 float answer = 12.55916669 new form = 12:33:33.0001
In Nov2017 I added a help message for this routine:
% float2sex.sh --help float2sex: Convert a floating point value, in uniys of hours (h) or degrees (d), and output a sexigecimal form of the value. This is normally used to give the more traditioanlly used (by observes) sexigeciaml versions of Ra and Dec. The input Ra floating point value must always be in units of hours. For use in a script, just use the fpmath.sh script to convert degress to hours befor calling this script. Examples: % float2sex.sh 15.2662 h 15:15:58.3200 % float2sex.sh -30.444 d -30:26:38.4000 RA = 167.2 degrees % fpmath.sh 167.2 d 15.0 11.146667 % float2sex.sh 11.146667 h 11:08:48.0012