OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_poly_fit.c
Go to the documentation of this file.
1 /* file: poly_fit.c */
2 
3 #include "PGS_MODIS_35251.h"
4 #include "smfio.h"
5 #include "GEO_geo.h"
6 #include "GEO_util.h"
7 
9  double const *coef,
10  double const in_x,
11  int const degree,
12  double * const out_fit
13 )
14 /*
15 !C*****************************************************************************
16 !Description: subroutine in the utility functions of the Level-1A geolocation
17  software to evaluate a polynomial.
18 
19 !Input Parameters:
20  double *coef - the array of coefficients for the polynomial
21  double in_x - the input independent variable x
22  int degree - the degree of the polynomial
23 
24 !Output Parameters:
25  double *out_fit - the output value
26 
27 Call functions: modsmf(MODIS_X_MNEMONIC_STRING, "user message string", "function,
28  GEO_poly_fit.c") - writes error status messages to log
29 
30 !Revision History:
31  $Log: GEO_poly_fit.c,v $
32  Revision 6.1 2011/02/14 21:34:00 kuyper
33  Corrected const qualification of parameter which points at input data.
34 
35  Revision 1.6 1997/07/21 16:24:34 kuyper
36  Baselined Version 1
37 
38  * Revision 1.6 1997/03/26 18:10:52 fhliang
39  * Initial revision of SDST delivery of GEO_poly_fit.c.
40  *
41  Revision 1.5 1997/02/13 19:52:19 kuyper
42  Merged seed files.
43 
44  Revision 1.4 1996/07/24 21:09:07 kuyper
45  Standardized order of #include files.
46  Declared arguments const.
47 
48  Revision 1.3 1996/07/23 23:30:28 kuyper
49  Inserted required '!'s in comments.
50  Changed constants to double, to avoid conversions.
51 
52  Revision 1.2 1996/07/18 19:54:18 kuyper
53  Included self-checking header file.
54  Added other required header file.
55  James Kuyper Jr (kuyper@ltpmail.gsfc.nasa.gov)
56 
57  10/10/95
58  Tracey W. Holmes
59  Added debug option.
60 
61  6/30/95
62  Tracey W. Holmes (holmes@modis-xl.gsfc.nasa.gov)
63  Added SDP error messages.
64 
65  6/12/95
66  Frederick S. Patt (patt@modis-xl.gsfc.nasa.gov)
67  Revised prolog and initialized internal variables
68 
69  4/5/95
70  Ruiming Chen
71  Finished coding
72 
73 !Team-unique Header:
74  This software is developed by the MODIS Science Data Support
75  Team for the National Aeronautics and Space Administration,
76  Goddard Space Flight Center, under contract NAS5-32373.
77 
78 !END*************************************************************************
79 */
80 {
81 
82  double x_power_degree = 1.0; /* degree power of x */
83  int i = 0; /* iteration parameter */
84 
85  if (degree <= 0) {
86  /* write to SDP event message */
87  modsmf(MODIS_E_UTIL_POLY, "", "GEO_poly_fit, GEO_poly_fit.c");
88 
89  return FAIL;
90  }
91 
92  if (degree > MAX_POLY_DEGREE) {
93  /* write to SDP event message */
94  modsmf(MODIS_E_UTIL_MAX_POLY, "", "GEO_poly_fit, GEO_poly_fit.c");
95 
96  return FAIL;
97  }
98 
99  /* initialize out_fit */
100  *out_fit = 0.0;
101 
102  /* calculate the fit number */
103  for (i = 0; i <= degree; i++) {
104  *out_fit += coef[i]*x_power_degree;
105  x_power_degree = x_power_degree * in_x;
106  }
107 
108  return SUCCESS;
109 }
110 
#define SUCCESS
Definition: ObpgReadGrid.h:15
#define FAIL
Definition: ObpgReadGrid.h:18
const int MAX_POLY_DEGREE
#define MODIS_E_UTIL_POLY
int GEO_poly_fit(double const *coef, double const in_x, int const degree, double *const out_fit)
Definition: GEO_poly_fit.c:8
int i
Definition: decode_rs.h:71
#define MODIS_E_UTIL_MAX_POLY