VR-Vantage 2.7 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Eigenmaterials.h
Go to the documentation of this file.
1 /* 2007 JRM Technologies, Inc.*/
2 /* CF071031 */
3 #ifndef EIGENMATERIALS_H_
4 #define EIGENMATERIALS_H_
5 
6 
7 #include "sigsimDLLstub.h"
8 
9 #ifdef __cplusplus
10 extern "C"
11 {
12 #endif
13 
14 #include "JRMlibrary.h"
15 #include "JRMKMeans.h"
16 
17  // ------------------- STANDARD EIGENMATERIALS - CF 071031 --------------------------------------------------------------------------
18 
19 //#define NEIGENMATERIALS 7
20 #define USE_AVERANGE_AREAS FALSE /* Specifies whether to use {Amin,Amax} or {Aave,Aspan} as evapotranspiration axes. */
21 #define LOTOL 0.005 /* Value of (max-min)/(max+min) below which an axis is considered degenerate. */
22 
23 
24  //int WriteFractionFile(char *outfilebasename, MATERIAL_EIGENFRACTIONS *matlfraction, long nmatls, int neigenmaterials);
25  //int ReadFractionFile(char *outfilebasename, MATERIAL_EIGENFRACTIONS **matlfraction, long *nmatls, int *neigenmaterials);
26  //int ActiveIndex(int OriginalIndex, SPACE *space);
27  //int ConvertDegeneratePoint(NPOINT *degenerate, NPOINT *nondegenerate, SPACE *ndspace);
28  //int CreateEigenMaterialsInMemory(char *sigsim_data_dir, char *matl_sys_file, char *outputbasename, MATERIAL_EIGENFRACTIONS **matlfraction, long *nmatls, MATL_PROP_TABLE **eig_table, int *neigenmaterials, double env_update_interval);
29  //int CreateEigenMaterialsOnDisk(char *sigsim_data_dir, char *matl_sys_file, char *outfilebasename, double env_update_interval);
30  //int ReconstructMaterials(char *sigsim_data_dir, char *eigmatl_sys_file, char *outfilebasename, double env_update_interval);
31  //int ReconstructThermalSpinup(char *outfilebasename, int neigenmaterials);
32  //int CreateMaterialsWhichDifferAlongOneAxis(char *sigsim_data_dir, char *matl_sys_file, int referencems, char *outfilebasename, int diffaxis, double minfrac, double maxfrac, int nmatlsout, double env_update_interval);
33 
34  // -------------------- BASIS-FUNCTION TEST - SIMPLE STAND-ALONE VERSION - CF080204 ------------------------------------------------------
35  /*
36  double xphase(double tod);
37  double ThetaLessThan(double x, double y);
38  double Sunshine(double tod);
39  double Skyshine(double tod);
40  double Earthshine(double tod);
41  double Evapotranspiration(double tod);
42  double Constant(double tod);
43  double FitCurve(double tod, double coeff[5], double todL);
44  double TestCurve(double tod);
45  void FillBasisFunctionMatrix(double F[25], double todlag);
46  void FillTestCurveArray(double test[5]);
47  int FitToBasisFunctions(double F[25], double test[5], double coeff[5]);
48  double RMSerror(double todlag, double coeff[5]);
49  int main();
50  */
51 
52 
53  // -------------------- BASIS-FUNCTION TEST - FULL SIGSIM VERSION - CF080205 ------------------------------------------------------
54 
55 #define NCOEFF 6
56 #define HOTOBJECT_EMISSION (CM_SQUARED_2_M_SQUARED*SIGMA * power(500.0, 4)) // Full-band Planck emission of 500degK object, for use as constant irradiance standard.
57 #define CONST300K_EMISSION (CM_SQUARED_2_M_SQUARED*SIGMA * power(300.0, 4)) // Full-band Planck emission of 300degK object, for use as constant irradiance standard.
58 
59  //double FitCurve(double tod, double coeff[NCOEFF], double todL, THERMAL_CACHE *tc, double env_update_interval);
60  //void FillBasisFunctionMatrix(double F[NCOEFF*NCOEFF], double todlag, THERMAL_CACHE *tc, double env_update_interval);
61  //void FillTestCurveArray(double test[NCOEFF], MATL_PROP_TABLE *mp_table);
62  //int FitToBasisFunctions(double F[NCOEFF*NCOEFF], double test[NCOEFF], double coeff[NCOEFF]);
63  //double TestCurve(double tod, MATL_PROP_TABLE *mp_table);
64  //double RMSerror(double todlag, double coeff[NCOEFF], MATL_PROP_TABLE *mp_table, THERMAL_CACHE *tc, double env_update_interval);
65  //void FindOptimumCoefficientsAndLag(MATL_PROP_TABLE *mp_table, THERMAL_CACHE *tc, double env_update_interval, double optcoeff[NCOEFF], double *optlag);
66 
67 
68  // -------------------- ITERATIVE-FIT TEST - FULL SIGSIM VERSION - CF080212 ------------------------------------------------------
69 #define NITCOEFF 4
70 #define TEMPFLUXMAX ((2000.0)*(5000.0)*(10.0)) // [J/m2/degK]
71 #define CONVECTMAX (4.0 + 3.8*pow(100.0, 0.8)) // [W/m2/degK] for windspeedmax=100.0 m/s.
72 #define CONSTEIMAX (CM_SQUARED_2_M_SQUARED*SIGMA*power(500.0,4)) // [W/m2] for 500.0 degK BB
73 
74  //double TemperatureIterativeFitFunction(NPOINT coeff, double *auxiliary, int nauxiliary)
75  //double PolynomialTestIterativeFitFunction(NPOINT coeff, double *auxiliary, int nauxiliary)
76  //void FindOptimalIterativeFitCoeffs(MATL_PROP_TABLE *mp_table, THERMAL_CACHE *tc, double env_update_interval, NPOINT *optcoeff)
77  //double TemperatureFunction(double tod, NPOINT coeff, double startdegK, THERMAL_CACHE *tc, double env_update_interval);
78 
79  // -------------------- BOUNDED-EIGENMATERIAL TEST - FULL SIGSIM VERSION - CF080214 ------------------------------------------------------
80 
81 
82 //#define NEIGENMATERIALS 7
83 
84 typedef struct
85 {
86  char matlname[50];
87  double *eigenfraction;
89 
90  #define NUM_PHYSPROPS 5
91 
92  typedef struct
93  {
99  } AXISSELECT;
100 
101  double GetMaterialNameAxisValue(char *name);
103  int ClusterMaterialSystemsInPhysicalPropertySpace(int mingroups, int maxgroups, MATL_PROP_TABLE *mp_table, int nmatls, int *group_index, int *ngroups, int MIN_MTLSPERGROUP, AXISSELECT axisselect, double EmatTolerance);
104  double RMSDifference(double *a, double *b, long nelements);
106  double RadianceBoundedFitFunction(NPOINT coeff, double *auxiliary, int nauxiliary);
107  //double BoundedFitRadiance(double tod, MATL_PROP_TABLE *mp_table, int *eig_index, int neigenmaterials, MATERIAL_EIGENFRACTIONS *mtlfractions);
108  //double ActualBBRadiance(double tod, MATL_PROP_TABLE *mp_table);
109  void FindOptimalBoundedFitCoeffs(MATL_PROP_TABLE **emat, int nemats, MATL_PROP_TABLE *tofit, NPOINT *optcoeff);
110  void FindExactBoundedFitCoeffs(MATL_PROP_TABLE **emat, int nemats, MATL_PROP_TABLE *tofit, NPOINT *optcoeff);
111  //double RMSFitDifference(MATL_PROP_TABLE *mp_table, int *eig_index, int neigenmaterials, MATERIAL_EIGENFRACTIONS *mtlfractions, int indextotest);
112  int FindExtremalMaterialsInGroup(MATL_PROP_TABLE *mp_table_in, int nmatls_in, int *group_index, int group, int *mtl1, int *mtl2, int *ngroupmtls, double EmatTolerance);
113  int FindEigenmaterialsAndFit(MATL_PROP_TABLE *mp_table_in, int nmatls_in, int *group_index, int ngroups, int **eig_index_out, int *neigenmaterials, MATERIAL_EIGENFRACTIONS **mtlfractions_out, jrmbool MATRIX, jrmbool FITINGROUP, jrmbool ALLOWSINGLEGROUPEMAT, double EmatTolerance);
114  //int BoundedEigenMaterialAnalysis(MATL_PROP_TABLE *mp_table, long nmatls, MATERIAL_EIGENFRACTIONS **mtlfraction, int **eig_index_out, int *neigenmaterials, int maxrequestedemats, int mingroups, int maxgroups, int MIN_MTLSPERGROUP, jrmbool MATRIX, jrmbool FITINGROUP, jrmbool ALLOWSINGLEGROUPEMAT, AXISSELECT axisselect, double EmatTolerance);
115  //int BoundedEigenMaterialFitToKnownGrouping(MATL_PROP_TABLE *mp_table, long nmatls, MATERIAL_EIGENFRACTIONS **mtlfraction, int **eig_index_out, int *neigenmaterials, int *group_index, int ngroups, jrmbool MATRIX, jrmbool ALLOWSINGLEGROUPEMAT, double EmatTolerance);
116  int FindNumberOfMatsInGroup(int whichgroup, int *group_index, int totmatls);
117  int FindNumberOfEmatsInGroup(int whichgroup, int *group_index, int *emat_index, int neigenmaterials);
118  jrmbool IsEmat(int matl_index, int *emat_index, int neigenmaterials);
119  jrmbool DonateMatsToOtherGroups(int ngroups, int *group_index, int nmatls, int **emat_index, int *neigenmaterials, int MIN_MTLSPERGROUP, MATL_PROP_TABLE *mp_table, MATERIAL_EIGENFRACTIONS **mtlfraction, jrmbool ALLOWSINGLEGROUPEMAT);
120  //int WriteEigenmaterialMSFile(char *sigsim_data_dir, char *ms_filename, char *dbname, MATL_PROP_TABLE *mp_table, int *eig_index, int neigenmaterials);
121 
122 
123  // -------------------- STAGED-EIGENMATERIAL ALGORITHM - FULL SIGSIM VERSION - CF110816 ------------------------------------------------------
124 
125 #define NEIGENMATERIALS 6
126 
127 typedef struct
128 {
129  int MSID; // material system index in final combined output MS file
130  char MSName[50]; // material system name
131  int GroupID; // group index identifier
132  double GroupPopulationPercentage; // normalized pixel percentage of this MSID in the final combined output MS file
134 
135 
136 typedef struct
137 {
138  int MSID; // material system index in final combined output MS file
139  char MSName[50]; // material system name
140  int EmatID[NEIGENMATERIALS]; // MSIDs chosen as Emats to mix for this material system
141 } EMAT_SELECT;
142 
143 SIGSIM49_API int AddEMAT_SELECT(EMAT_SELECT **c, int *nc, EMAT_SELECT toadd);
145 SIGSIM49_API int RemoveEMAT_SELECT(EMAT_SELECT **P, int *np, int index);
146 SIGSIM49_API int ReadEmatSelectFile(const char *infile, EMAT_SELECT **eselect, int *neselects);
147 SIGSIM49_API int FitToKnownEigenmaterials(MATL_PROP_TABLE *mp_table_in, int nmatls_in, EMAT_SELECT *eselect, int neselects, int *neigenmaterials, int **eig_index_out, MATERIAL_EIGENFRACTIONS **mtlfractions_out, jrmbool MATRIX);
148 
149 
150  // ----- The following routines employ the proprietary JRM Eigenmaterial approach. BE SURE TO USE FreeMATERIAL_EIGENFRACTIONSArray, FreeIntArray, and Free_MatlPropTables to free this memory!
151 
152 SIGSIM49_API int AllocateMATERIAL_EIGENFRACTIONSArray(MATERIAL_EIGENFRACTIONS **matlfraction, long nmatls, int neigenmaterials);
153 SIGSIM49_API int AllocateMATERIAL_EIGENFRACTIONSFractionArrays(MATERIAL_EIGENFRACTIONS **matlfraction, long nmatls, int neigenmaterials);
155 SIGSIM49_API int WriteFractionFileWithEmatNameHeader(char *outfilebasename, MATERIAL_EIGENFRACTIONS *matlfraction, long nmatls, int *ematIndices, int neigenmaterials);
156 SIGSIM49_API int WriteFractionFile(char *outfilebasename, MATERIAL_EIGENFRACTIONS *matlfraction, long nmatls, int neigenmaterials);
157 SIGSIM49_API int ReadFractionFile(char *outfilebasename, MATERIAL_EIGENFRACTIONS **matlfraction, long *nmatls, int *neigenmaterials);
158 SIGSIM49_API int CreateEigenMaterialsInMemory(char *sigsim_data_dir, char *matl_sys_file, char *outputbasename, MATERIAL_EIGENFRACTIONS **matlfraction, long *nmatls, MATL_PROP_TABLE **eig_table, int *neigenmaterials, double env_update_interval);
159 SIGSIM49_API int CreateEigenMaterialsOnDisk(char *sigsim_data_dir, char *matl_sys_file, char *outfilebasename, double env_update_interval);
160 SIGSIM49_API int ReconstructMaterials(char *sigsim_data_dir, char *eigmatl_sys_file, char *outfilebasename, double env_update_interval);
161 SIGSIM49_API int ReconstructThermalSpinup(char *outfilebasename, int neigenmaterials);
162 SIGSIM49_API int CreateMaterialsWhichDifferAlongOneAxis(char *sigsim_data_dir, char *matl_sys_file, int referencems, char *outfilebasename, int diffaxis, double minfrac, double maxfrac, int nmatlsout, double env_update_interval);
163 SIGSIM49_API double FitCurve(double tod, double coeff[NCOEFF], double todL, THERMAL_CACHE *tc, double env_update_interval);
164 SIGSIM49_API void FillBasisFunctionMatrix(double F[NCOEFF*NCOEFF], double todlag, THERMAL_CACHE *tc, double env_update_interval);
165 SIGSIM49_API void FillTestCurveArray(double test[NCOEFF], MATL_PROP_TABLE *mp_table);
166 SIGSIM49_API int FitToBasisFunctions(double F[NCOEFF*NCOEFF], double test[NCOEFF], double coeff[NCOEFF]);
167 SIGSIM49_API double TestCurve(double tod, MATL_PROP_TABLE *mp_table);
168 SIGSIM49_API double RMSerror(double todlag, double coeff[NCOEFF], MATL_PROP_TABLE *mp_table, THERMAL_CACHE *tc, double env_update_interval);
169 SIGSIM49_API void FindOptimumCoefficientsAndLag(MATL_PROP_TABLE *mp_table, THERMAL_CACHE *tc, double env_update_interval, double optcoeff[NCOEFF], double *optlag);
170 SIGSIM49_API double TemperatureFunction(double tod, NPOINT coeff, double startdegK, THERMAL_CACHE *tc, double env_update_interval);
171 SIGSIM49_API double TemperatureIterativeFitFunction(NPOINT coeff, double *auxiliary, int nauxiliary);
172 SIGSIM49_API double PolynomialTestIterativeFitFunction(NPOINT coeff, double *auxiliary, int nauxiliary);
173 SIGSIM49_API void FindOptimalIterativeFitCoeffs(MATL_PROP_TABLE *mp_table, THERMAL_CACHE *tc, double env_update_interval, NPOINT *optcoeff);
174 SIGSIM49_API int BoundedEigenMaterialAnalysis(MATL_PROP_TABLE *mp_table, long nmatls, MATERIAL_EIGENFRACTIONS **mtlfraction, int **eig_index_out, int *neigenmaterials, int maxrequestedemats, int mingroups, int maxgroups, int MIN_MTLSPERGROUP, jrmbool MATRIX, jrmbool FITINGROUP, jrmbool ALLOWSINGLEGROUPEMAT, AXISSELECT axisselect, double EmatTolerance);
175 SIGSIM49_API int BoundedEigenMaterialFitToKnownGrouping(MATL_PROP_TABLE *mp_table, long nmatls, MATERIAL_EIGENFRACTIONS **mtlfraction, int **eig_index_out, int *neigenmaterials, int *group_index, int ngroups, jrmbool MATRIX, jrmbool ALLOWSINGLEGROUPEMAT, double EmatTolerance);
176 SIGSIM49_API double BoundedFitRadiance(double tod, MATL_PROP_TABLE *mp_table, int *eig_index, int neigenmaterials, MATERIAL_EIGENFRACTIONS *mtlfractions);
177 SIGSIM49_API double ActualBBRadiance(double tod, MATL_PROP_TABLE *mp_table);
178 SIGSIM49_API double RMSFitDifference(MATL_PROP_TABLE *mp_table, int *eig_index, int neigenmaterials, MATERIAL_EIGENFRACTIONS *mtlfractions, int indextotest);
179 SIGSIM49_API int WriteEigenmaterialMSFile(char *sigsim_data_dir, char *ms_filename, char *dbname, MATL_PROP_TABLE *mp_table, int *eig_index, int neigenmaterials);
180 
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 
187 #endif // EIGENMATERIALS_H_


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)