~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to applic/fit/libsrc/lsfun1i.for

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
C @(#)lsfun1i.for       19.1 (ES0-DMD) 02/25/03 13:17:40
 
2
C===========================================================================
 
3
C Copyright (C) 1995 European Southern Observatory (ESO)
 
4
C
 
5
C This program is free software; you can redistribute it and/or 
 
6
C modify it under the terms of the GNU General Public License as 
 
7
C published by the Free Software Foundation; either version 2 of 
 
8
C the License, or (at your option) any later version.
 
9
C
 
10
C This program is distributed in the hope that it will be useful,
 
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
C GNU General Public License for more details.
 
14
C
 
15
C You should have received a copy of the GNU General Public 
 
16
C License along with this program; if not, write to the Free 
 
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
C MA 02139, USA.
 
19
C
 
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
C       Internet e-mail: midas@eso.org
 
22
C       Postal address: European Southern Observatory
 
23
C                       Data Management Division 
 
24
C                       Karl-Schwarzschild-Strasse 2
 
25
C                       D 85748 Garching bei Muenchen 
 
26
C                       GERMANY
 
27
C===========================================================================
 
28
C
 
29
C @(#)lsfun1i.for       2.1.1.1 (ESO-IPG) 9/27/91 18:10:00
 
30
      SUBROUTINE LSFU1I(NRRES,NRPRM,PRM,FCTVEC,PIXEL,WEIGHT,IDIM1,            
 
31
     +                    IDIM2,IDIM3)                                          
 
32
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        
 
33
C                                                                               
 
34
C.MODULE                                                                        
 
35
C       FIT                                                                     
 
36
C                                                                               
 
37
C.NAME                                                                          
 
38
C       LSFUN1_I                                                                
 
39
C                                                                               
 
40
C.PURPOSE                                                                       
 
41
C       Function to compute the approximating function at each point,           
 
42
C       for FIT/IMAG                                                            
 
43
C                                                                               
 
44
C.KEYWORDS                                                                      
 
45
C       Approximating Function.                                                 
 
46
C                                                                               
 
47
C.DESCRIPTION                                                                   
 
48
C       Read the TABLE row by row, and compute the fitting function by          
 
49
C       calling MIDAS functions                                                 
 
50
C                                                                               
 
51
C.LANGUAGE                                                                      
 
52
C       FORTRAN                                                                 
 
53
C                                                                               
 
54
C.CALLING SEQUENCE                                                              
 
55
C  CALL LSFUN1_I(NRRES,NRPRM,PRM,FCTVEC,PIXEL,WEIGHT,IDIM1,IDIM2,IDIM3)         
 
56
C                                                                               
 
57
C.INPUT PARAMETERS                                                              
 
58
C       NRRES               INTEGER  Number of residuals                        
 
59
C       NRPRM             INTEGER  Number of parameters                         
 
60
C       PRM (NRPRM)       DOUBLE   Parameters                                   
 
61
C       PIXEL (IDIM_)       REAL     pixel values of the image                  
 
62
C       WEIGHT (IDIM_)      REAL     weighting factors                          
 
63
C       IDIM_               INTEGER  dimension of the 3-dim image.              
 
64
C                                                                               
 
65
C.MODIFIED PARAMETERS                                                           
 
66
C       none                                                                    
 
67
C                                                                               
 
68
C.OUTPUT PARAMETERS                                                             
 
69
C       FCTVEC (NRRES)      DOUBLE   Approximating values                       
 
70
C                                                                               
 
71
C.FILES                                                                         
 
72
C       FIT_NAG.INC/NOLIST                                                      
 
73
C                                                                               
 
74
C.MODULES CALLED                                                                
 
75
C       FTFUNC                                                                  
 
76
C                                                                               
 
77
C.AUTHOR                                                                        
 
78
C       Ph. DEFERT,      Feb 1986                                               
 
79
C                                                                               
 
80
C.MODIFICATIONS                                                                 
 
81
C                                                                               
 
82
C      MODIF APR92 MP put correct coordinates of pixels  !!!!!             
 
83
C-----------------------------------------------------------------------        
 
84
C      IMPLICIT NONE                                                            
 
85
C                                                                               
 
86
C     .. Scalar Arguments ..                                                    
 
87
      INTEGER NRPRM,NRRES,IDIM1,IDIM2,IDIM3,MADRID(1)                           
 
88
C     ..                                                                        
 
89
C     .. Array Arguments ..                                                     
 
90
      DOUBLE PRECISION FCTVEC(NRRES),PRM(NRPRM)                                 
 
91
      REAL PIXEL(IDIM1,IDIM2,IDIM3),WEIGHT(IDIM1,IDIM2,IDIM3)                   
 
92
C     ..                                                                        
 
93
C     .. Scalars in Common ..                                                   
 
94
      INTEGER NRCOL,ISTAR                                                       
 
95
      CHARACTER WGTTYP*1                                                        
 
96
C     ..                                                                        
 
97
C     .. Arrays in Common ..                                                    
 
98
      INTEGER ICOL(10)                                                          
 
99
C     ..                                                                        
 
100
C     .. Local Scalars ..                                                       
 
101
      DOUBLE PRECISION W,Y,Y1,YOUT,YY                                           
 
102
      INTEGER IFUN,K,BEGFCT,IP,I1,I2,I3,IPNT                                    
 
103
C     ..                                                                        
 
104
C     .. Local Arrays ..                                                        
 
105
      DOUBLE PRECISION DUMMY(10)                                                
 
106
      REAL X(10)                                                                
 
107
C     ..                                                                        
 
108
C     .. Common blocks ..                                                       
 
109
C     ..                                                                        
 
110
C     .. External Files ..                                                      
 
111
       INCLUDE 'MID_INCLUDE:FITNAGI.INC/NOLIST'                                 
 
112
       INCLUDE 'MID_INCLUDE:FITNAGC.INC/NOLIST'                                 
 
113
      COMMON /VMR/MADRID                                                     
 
114
      COMMON /LSQFUN/ICOL,NRCOL,ISTAR,WGTTYP                                    
 
115
C     ..                                                                        
 
116
C     .. Executable Statements ..                                               
 
117
C                                                                               
 
118
C   deal with simple linear constraints                                         
 
119
C                                                                               
 
120
      DO 10 K = 1,NRPRM                                                         
 
121
          IP     = FIXPAR(K)                                                    
 
122
          IF (IP.EQ.0) PRM(K) = PARINI(K)                                       
 
123
          IF (IP.GT.0) THEN                                                     
 
124
              PRM(K) = PRM(IP)*PRPFAC(K)                                        
 
125
              PARAM(K) = PRM(K)                                                 
 
126
          END IF                                                                
 
127
                                                                                
 
128
   10 CONTINUE                                                                  
 
129
C                                                                               
 
130
C   go through the all image                                                    
 
131
C                                                                               
 
132
      X(1)   = START(1)                                                         
 
133
      X(2)   = START(2)                                                         
 
134
      X(3)   = START(3)                                                         
 
135
      IPNT   = 0                                                                
 
136
      DO 50 I3 = 1,NRPIX(3)                                                     
 
137
          X(2) = START(2)
 
138
          DO 40 I2 = 1,NRPIX(2)                                                 
 
139
              X(1) = START(1)
 
140
              DO 30 I1 = 1,NRPIX(1)                                             
 
141
C                                                                               
 
142
C   compute weights                                                             
 
143
C                                                                               
 
144
                  Y      = PIXEL(I1,I2,I3)                                      
 
145
                  IPNT   = IPNT + 1                                             
 
146
                  Y      = PIXEL(I1,I2,I3)                                      
 
147
                  IF (WGTTYP(1:1).EQ.'C') THEN                                  
 
148
                      W      = 1.                                               
 
149
                                                                                
 
150
                  ELSE IF (WGTTYP(1:1).EQ.'W') THEN                             
 
151
                      W      = WEIGHT(I1,I2,I3)                                 
 
152
                                                                                
 
153
                  ELSE IF (WGTTYP(1:1).EQ.'S') THEN                             
 
154
                      YY     = ABS(Y)                                           
 
155
                      IF (YY.LT.1.E-12) THEN                                    
 
156
                          W      = 1.                                           
 
157
                                                                                
 
158
                      ELSE                                                      
 
159
                          W      = 1./YY                                        
 
160
                      END IF                                                    
 
161
                                                                                
 
162
                  ELSE IF (WGTTYP(1:1).EQ.'I') THEN                             
 
163
                      W      = 1./WEIGHT(I1,I2,I3)**2                           
 
164
                  END IF                                                        
 
165
C                                                                               
 
166
C   Compute fitting values                                                      
 
167
C                                                                               
 
168
                  Y1     = 0.D0                                                 
 
169
                  BEGFCT = 1                                                    
 
170
                  DO 20 IFUN = 1,NRFUN                                          
 
171
                      CALL FTFUNC(FCTCOD(IFUN),NRIND,X,ACTPAR(IFUN),            
 
172
     +                            PRM(BEGFCT),YOUT,DUMMY)                       
 
173
                      Y1     = Y1 + YOUT                                        
 
174
                      BEGFCT = BEGFCT + ACTPAR(IFUN)                            
 
175
   20             CONTINUE                                                      
 
176
                  FCTVEC(IPNT) = SQRT(W)* (Y1-Y)                                
 
177
                  X(1)   = X(1) + STEP(1)                                       
 
178
   30         CONTINUE                                                          
 
179
              X(2)   = X(2) + STEP(2)                                           
 
180
   40     CONTINUE                                                              
 
181
          X(3)   = X(3) + STEP(3)                                               
 
182
   50 CONTINUE                                                                  
 
183
      RETURN                                                                    
 
184
                                                                                
 
185
      END                                                                       
 
186