diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /math/slalib/pdq2h.f | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'math/slalib/pdq2h.f')
-rw-r--r-- | math/slalib/pdq2h.f | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/math/slalib/pdq2h.f b/math/slalib/pdq2h.f new file mode 100644 index 00000000..678bb3d7 --- /dev/null +++ b/math/slalib/pdq2h.f @@ -0,0 +1,116 @@ + SUBROUTINE slPDQH (P, D, Q, H1, J1, H2, J2) +*+ +* - - - - - - +* P D Q H +* - - - - - - +* +* Hour Angle corresponding to a given parallactic angle +* +* (double precision) +* +* Given: +* P d latitude +* D d declination +* Q d parallactic angle +* +* Returned: +* H1 d hour angle: first solution if any +* J1 i flag: 0 = solution 1 is valid +* H2 d hour angle: second solution if any +* J2 i flag: 0 = solution 2 is valid +* +* Called: slDA1P +* +* P.T.Wallace Starlink 6 October 1994 +* +* Copyright (C) 1995 Rutherford Appleton Laboratory +* +* License: +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program (see SLA_CONDITIONS); if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +* Copyright (C) 1995 Association of Universities for Research in Astronomy Inc. +*- + + IMPLICIT NONE + + DOUBLE PRECISION P,D,Q,H1 + INTEGER J1 + DOUBLE PRECISION H2 + INTEGER J2 + + DOUBLE PRECISION DPI + PARAMETER (DPI=3.141592653589793238462643D0) + DOUBLE PRECISION D90 + PARAMETER (D90=DPI/2D0) + DOUBLE PRECISION TINY + PARAMETER (TINY=1D-12) + DOUBLE PRECISION PN,QN,DN,SQ,CQ,SQSD,QT,QB,HPT,T + DOUBLE PRECISION slDA1P + + +* Preset status flags to OK + J1=0 + J2=0 + +* Adjust latitude, declination, parallactic angle to avoid critical values + PN=slDA1P(P) + IF (ABS(ABS(PN)-D90).LT.TINY) THEN + PN=PN-SIGN(TINY,PN) + ELSE IF (ABS(PN).LT.TINY) THEN + PN=TINY + END IF + QN=slDA1P(Q) + IF (ABS(ABS(QN)-DPI).LT.TINY) THEN + QN=QN-SIGN(TINY,QN) + ELSE IF (ABS(QN).LT.TINY) THEN + QN=TINY + END IF + DN=slDA1P(D) + IF (ABS(ABS(D)-ABS(P)).LT.TINY) THEN + DN=DN-SIGN(TINY,DN) + ELSE IF (ABS(ABS(D)-D90).LT.TINY) THEN + DN=DN-SIGN(TINY,DN) + END IF + +* Useful functions + SQ=SIN(QN) + CQ=COS(QN) + SQSD=SQ*SIN(DN) + +* Quotient giving sin(h+t) + QT=SIN(PN)*SQ*COS(DN) + QB=COS(PN)*SQRT(CQ*CQ+SQSD*SQSD) + +* Any solutions? + IF (ABS(QT).LE.QB) THEN + +* Yes: find h+t and t + HPT=ASIN(QT/QB) + T=ATAN2(SQSD,CQ) + +* The two solutions + H1=slDA1P(HPT-T) + H2=slDA1P(-HPT-(T+DPI)) + +* Reject if h and Q different signs + IF (H1*QN.LT.0D0) J1=-1 + IF (H2*QN.LT.0D0) J2=-1 + ELSE + J1=-1 + J2=-1 + END IF + + END |