VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
atm1d.h
Go to the documentation of this file.
1 /* © 1998 JRM Technologies, Inc.*/
2 
3 
4 
5 /***********************************
6 Copyright JRM Enterprises, Inc. 1998
7 All rights reserved.
8 
9 This code is the intellectual property of JRM Enterprises, Inc.
10 It may not be used or released as source or compiled binary form
11 without the prior written consent of JRM Enterprises, Inc.
12 ***********************************/
13 
14 #ifndef _ATM1D_H_
15 #define _ATM1D_H_
16 
17 #include "JRMlibrary.h"
18 #include "Ellipsoid.h"
19 #include "atm_common.h"
20 #include "SSModRadStruct.h"
21 #include "SigSimDefines.h"
22 #include "sigsim.h"
23 #include "sigsimOGL.h"
24 #include "sigsimDLLstub.h"
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31  typedef struct
32  {
33  double pathlength; // [m]
34  double avescat; // [unitless]
35  double avehenyey; // [unitless]
36  double avextinct; // [m-1]
37  } LAYER_PROP;
38 
39 
40  //int AllocateAtmosphericLayers(ATMCOEF **atm, ATMINFO inf);
41  //SIGSIM_API int FreeAtmosphericLayers(ATMCOEF **atm);
42  //SIGSIM_API int FreeATMINFO(ATMINFO *inf);
43  //int ShiftLayerStructure(ATMINFO *inf, double altlo_old, double althi_old, double altlo_new, double althi_new);
44  //int MergeATMGrids(ATMCOEF *atmin1, ATMINFO infin1, ATMCOEF *atmin2, ATMINFO infin2, ATMCOEF **atmout, ATMINFO *infout, double weight2);
45  int SubtractATMGrids(ATMCOEF *atmin1, ATMINFO infin1, ATMCOEF *atmin2, ATMINFO infin2, ATMCOEF **atmout, ATMINFO *infout);
46  int SetConstantATMGrid(ATMCOEF *atm, ATMINFO inf, double extcoef, double scatcoef, double realindex, double degK);
47 
48 
49 
50  // The following routines read and write the 1D atmospheric grid to/from a file:
51  // GetAtmGridFileInfo() and ReadKnownAtmGrid() are used when you are allocating the grid yourself.
52  // ReadAtmGrid() does the same thing, but allocates and fills the grid for you.
53 
54 
55  // WriteATMGrid() writes an array of ATMCOEFs and associated ATMINFO to a 1D atmospheric state file on disk.
56  // Inputs : outputfilename = string giving path/filename of 1D state file to be written.
57  // atm = array of ATMCOEFs to be written.
58  // inf = single ATMINFO structure to be written, giving earth radii, layers and wavelengths, and min/max altitudes.
59  // Notes : It is up to the user to ensure that the state file will only be read again when using the same set of SENSORs.
60  // Returns: SIGSIM_FILE_NOT_FOUND if the state file cannot be created.
61  // SIGSIM_FILE_FORMAT_ERROR if the state file cannot be written to properly.
62  // SIGSIM_SUCCESS upon successful completion.
63  SIGSIM_API int WriteAtmGrid(char *outputfilename, ATMCOEF *atm, ATMINFO inf);
64  SIGSIM_API int WriteAtmGridMetin(char *outputfilename, METIN *metin);
65 
66 
67  // GetATMGridFileInfo() reads the header of a 1D atmospheric state file to determine the earth radius, numbers of wavelengths and layers, and min/max altitudes.
68  // Inputs : inputfilename = string specifying path/filename of a 1D atmospheric state file.
69  // Outputs: inf = pointer to ATMINFO structure containing the desired header information.
70  // Returns: SIGSIM_FILE_NOT_FOUND if the state file cannot be found.
71  // SIGSIM_FILE_FORMAT_ERROR if the state file is found, but is not of valid form.
72  // SIGSIM_SUCCESS upon successful completion.
73  SIGSIM_API int GetAtmGridFileInfo(char *inputfilename, ATMINFO *inf);
74 
75  // ReadKnownAtmGrid() reads a 1D atmospheric state file from disk into an array of ATMCOEFs..
76  // The ATMCOEF array is assumed pre-allocated, its size being passed in via the inf ATMINFO structure.
77  // Inputs : inputfilename = string containing the path/filename of the input 1D state file to be read.
78  // inf = filled ATMINFO structure giving the earth radius, numbers of wavelengths and layers, and min/max altitudes.
79  // Outputs: atm = array of ATMCOEFs, pre-allocated but now filled with spectral/layer information.
80  // Returns: SIGSIM_FILE_NOT_FOUND if the state file cannot be found.
81  // SIGSIM_FILE_FORMAT_ERROR if the state file is found, but is not of valid form.
82  // SIGSIM_SUCCESS upon successful completion.
83  SIGSIM_API int ReadKnownAtmGrid(char *inputfilename, ATMCOEF *atm, ATMINFO inf);
84 
85  // ReadAtmGrid() reads a 1D atmospheric state file from disk into an array of ATMCOEFs and corresponding single ATMINFO structure.
86  // The ATMCOEF array will be allocated with this function
87  // Inputs : inputfilename = string containing the path/filename of the input 1D state file to be read.
88  // Outputs: *inf = filled ATMINFO structure giving the earth radius, numbers of wavelengths and layers, and min/max altitudes.
89  // atm = pointer to array of ATMCOEFs, allocated and filled with spectral/layer information.
90  // Returns: SIGSIM_FILE_NOT_FOUND if the state file cannot be found.
91  // SIGSIM_FILE_FORMAT_ERROR if the state file is found, but is not of valid form.
92  // SIGSIM_MEMORY_ALLOCATION_ERROR if the atm array cannot be allocated.
93  // SIGSIM_SUCCESS upon successful completion.
94  SIGSIM_API int ReadAtmGrid(char *inputfilename, ATMCOEF **atm, ATMINFO *inf);
95 
96  // The following routines allocate ATMCOEF grids and perform operations on them. Should use FreeAtmosphericLayers and FreeATMINFO after use.
98  SIGSIM_API int ShiftLayerStructure(ATMINFO *inf, double altlo_old, double althi_old, double altlo_new, double althi_new);
99  SIGSIM_API int MergeATMGrids(ATMCOEF *atmin1, ATMINFO infin1, ATMCOEF *atmin2, ATMINFO infin2, ATMCOEF **atmout, ATMINFO *infout, double weight2);
101  SIGSIM_API int FreeATMINFO(ATMINFO *inf);
102 
103 
104  // SetupAtmosphericProfile() allocates/fills the atmospheric grid (ATM_COEF) with path-independent
105  // values later utilized for transmission, path radiance, and irradiance calculations.
106  // sigsim_data_dir specifies the root data directory for SigSim input.
107  // sigsim_cache_dir specifies the root cache directory for SigSim output.
108  // atm_file is the name (no path) of the atmospheric grid as stored in sigsim_data_dir/ATM_DIR/atm_file.
109  // modcard_file is the name (no path) of the modcard file on disk that should be associated with this profile.
110  // (atmreset=TRUE) allocates the atm atmospheric grid, fills it using the SigSim/Modtran library, and saves it to disk.
111  // (atmreset=FALSE) reads the atmospheric grid from the disk file and fills the ATMCOLUMN structures accordingly.
112  // dumcol applies only when atmreset=TRUE and metin->Atm3D = TRUE.
113  // (dumcol=TRUE) assumes you are testing, and have no actual column data. It allocates and fills a set of columns with dummy data.
114  // (dumcol=FALSE) assumes the columns are already allocated and filled, and all that is to be done is to allocate and fill the ATM_COEF's.
115  SIGSIM_API int SetupAtmosphericProfile1D(jrmbool atmreset, char *sigsim_data_dir, char* sigsim_cache_dir, char *atm_file, char *modcard_file, long nlayers, METIN *metin);
116 
117 #ifdef USEMODRAD
118  void SetPathGeometry(MODPATH mp, EPHEMERIS fm, int source, MODCARD *mc);
119  SIGSIM_API int FillAtmosphericGrid(char *sigsim_atm_dir, METIN *metin);
120  SIGSIM_API int SetupModcard(MODCARD *mc, jrmbool multscat, EPHEMERIS fm, ATM_DEFAULT atm_default, char *sigsim_data_dir);
121  SIGSIM_API int SetBand(BAND band, MODCARD *mc);
122  SIGSIM_API int RunStandAloneModtranPath(MODCARD mc, SEUPATH seu, EPHEMERIS fm, jrmbool sunsource, long *nlamb, float **lamb, float **xmit, float **prad, float **scat, float **dirc, char *moddir);
123  SIGSIM_API int RunModtranPath(MODCARD mc, SEUPATH seu, EPHEMERIS fm, jrmbool sunsource, long nlamb, float *lamb, float *xmit, float *prad, float *scat, float *dirc);
124  SIGSIM_API int RunModtranPathBands(BAND *band, int nbands, MODCARD mc, SEUPATH seu, EPHEMERIS fm, jrmbool sunsource, double *xmit, double *prad, double *scat, double *dirc);
125  SIGSIM_API int PrintModtran1DPathAtmospherics(jrmbool sunsource, jrmbool multscat, jrmbool includegnd, MODPATH mp, EPHEMERIS fm, ATM_DEFAULT atm_default, BAND band, char *sigsim_data_dir, char *tag);
126  // PrintModtran1DPathAtmospherics: Uses Modtran engine directly, to produce file on disk of path atmospherics. "Tag" is an optional string included in the output filename.
127 
128  BAND CalcModBand(METIN *metin);
129 
130 
131  // ProcessPlumeVolume() fills an ATM_VOL_PROP's atm_out spectral array of ATMCOEF's with extinction, thermal radiance, and scattering information via a call to MODTRAN.
132  // Inputs: sigsim_atm_dir = string specifying the location of SigSim's data/atm directory.
133  // metin = pointer to METIN structure which carries the wavelength information.
134  // plume = pointer to single PLUME, which carries its own input atmospheric information in its atm_in array.
135  // dalt_km = arbitrary depth over which to calculate Modtran volume properties
136  // Uses : metin->atm_default.mc.c1Modtrn[0] to specify Lowtran or Modtran mode.
137  // metin->nbands, band, nlambda, lambda_um for wavelength array.
138  // metin->fm for ephemeris info.
139  // Outputs: plume->atm_out : extinction, thermal radiance, and scattering coefficients.
140  // Returns: SIGSIM_MEMORY_ALLOCATION_ERROR if internal wavelength and layer arrays cannot be allocated.
141  // SIGSIM_SUCCESS upon successful completion.
142  SIGSIM_API int ProcessPlumeVolume(char *sigsim_atm_dir, METIN *metin, ATM_VOL_PROPS *atm, double dalt_km);
143 
144  // UpdateATMVolumeSinglePassbandOGL() inputs single ATM_VOL_PROPS and pointer to a single MATL_OGL_TABLE structure.
145  // This volume is assumed to have been run through ProcessPlumeVolume() so that spectral extinction and thermal radiance info is available.
146  // The current routine will perform sensor passband integrals over these arrays and convert them to OpenGL alpha and emission values.
147  // SCALING: In OpenGL, alpha=0=transparent and alpha=1=opaque. We are given extinction coefficient per meter.
148  // We intend to arrive at a transmission through the volume from a side axis near the base, then scale such that alpha=(1-T).
149  // Thus, we need the distance in meters through the shell from this side view.
150  // OpenGL emission will be volume ((atm_out.intense) * shell width - Mmin)/Mscale + sens->level, as usual.
151  // Inputs : atm = pointer to single ATM_VOL_PROPS, which should have been pre=processed with ProcessPlumeVolume().
152  // sens = pointer to single SENSOR containing dynamic range and passband information.
153  // metin = pointer to single METIN structure containing wavelength information.
154  // shell_id = integer which simply labels the mogl_table->matl_index.
155  // Uses : metin->nlambda, lambda_um to define wavelength array.
156  // sens->{band, Tmin, Tmax, max_light_level} for dynamic range and passband.
157  // Outputs: mogl_table = pointer to MATL_OGL_TABLE, corresponding to the volume.
158  SIGSIM_API int UpdateATMVolumeSinglePassbandOGL(ATM_VOL_PROPS *atm, MATL_OGL_TABLE *mogl_table, SENSOR *sens, METIN *metin, double dist, int shell_id);
159 
160 #endif
161 
162  int FastDiffuseSkyIrrad(METIN* metin, double alt, long ax_index, long bx_index);
163  int FastDiffuseScatIrrad(METIN* metin, double alt, long ax_index, long bx_index);
164  //int FastDirectIrrad(METIN* metin, double alt, long ax_index, long bx_index);
165  //int FastDiffuseIrrad(METIN* metin, double alt, long ax_index, long bx_index);
166  int FasterDiffuseIrrad(ATMCOEF *atm, ATMINFO inf, double *solarTOA, double *lunarTOA, METIN* metin, double alt, VECTOR sun, VECTOR moon);
167  int FastDiffuseSSIrrad(ATMCOEF *atm, ATMINFO inf, double *solarTOA, double *lunarTOA, METIN* metin, double alt, VECTOR sun, VECTOR moon);
168 
169  void computeLayerFluxAnalytic(METIN *metin, int nIntervals, jrmbool IncludeDirect, double grndAlbedo, double mu0,
170  double *laythick, double *upMSFlux, double *downMSFlux, double *upSSFlux, double *downSSFlux);
171 
172  SIGSIM_API int PrepareMetin(EPHEMERIS fm, ATM_DEFAULT atm_default, jrmbool multscat, BAND *band, int nbands, double alt_m, char *sigsim_data_dir, char* sigsim_cache_dir, METIN *metin, jrmbool atm_reset);
173  SIGSIM_API int RunSigSimPath(BAND band, METIN *metin, SEUPATH seu, jrmbool multscat, jrmbool sunsource, jrmbool includegnd, double **xmit, double **prad, double **scat, double **dirc);
174  SIGSIM_API int RunSigSimPathBands(BAND *band, int nbands, METIN *metin, SEUPATH seu, jrmbool multscat, jrmbool sunsource, jrmbool includegnd, double *xmit, double *prad, double *scat, double *dirc);
175  SIGSIM_API int PrintSigSim1DPathAtmospherics(jrmbool sunsource, jrmbool multscat, jrmbool includegnd, MODPATH mp, EPHEMERIS fm, ATM_DEFAULT atm_default, BAND band, char *sigsim_data_dir, char* sigsim_cache_dir, char *tag);
176  // PrintSigSim1DPathAtmospherics: Uses SigSimC engine, to produce file on disk of path atmospherics. "Tag" is an optional string included in the output filename.
177 
178  int ValidatePathEndpoints(ATMINFO inf, jrmbool hitflag, VECTOR sensor, VECTOR matsys_unvalidated, VECTOR *tosensor_km, VECTOR *frommatsys_km, VECTOR *look);
179  int GetPathIntervals(VECTOR s, VECTOR m, jrmbool hitflag, jrmbool SSflag, ATMINFO inf, long *ns, long **atm_index_s, double **length_s, long *nm, long **atm_index_m, double **length_m);
180  int GetPathIntervals2(VECTOR s, VECTOR m, jrmbool hitflag, jrmbool SSflag, ATMINFO inf, int minimum_n, long *n, long **atm_index, double **length);
181  int GetPathIntervals3(VECTOR s, VECTOR m, ATMINFO inf, double *delta, int *n, long **atm_index, double **length);
182  int GetPathIntervals4(VECTOR s, VECTOR m, ATMINFO inf, double *delta, int *n, int **lay_index, double **length, jrmbool subdivide);
183  int GetPathIntervals5(VECTOR s, VECTOR m, ATMINFO inf, double *delta, int *n, int **lay_index, double **length, double **avecostheta, jrmbool subdivide);
184  SIGSIM_API int GetPathIntervals6(VECTOR s, VECTOR m, ATMINFO inf, double *delta, int *n, int **lay_index, double **length, double **avecostheta, jrmbool subdivide);
185  SIGSIM_API double getLayerFraction(double altitude, ATMINFO inf, int *pInterpolatedLayer);
186 
187  /* ------------- START FROM LOS_PROP.c ----------------------------------------------------------------------- */
188 
189  SIGSIM_API void GetLOSPathIntervals(GEOCENTRIC_LOCATION startC, GEOCENTRIC_LOCATION endC, int SSflag, METIN *metin,
190  long *ns, long **atm_index_s, double **length_s, long *nm, long **atm_index_m, double **length_m,
191  VECTOR *toobj, VECTOR *xhat, jrmbool hitflag);
192 
193  // GetLOSAtmosphericsKE() inputs the atmospheric state, and a line-of-sight defined by starting and ending locations, and an initial startFRD orientation,
194  // and outputs the actual refracted initial and final refracted orientations (w.r.t NED),
195  // as well as spectral transmittance, atmospheric thermal path radiance, and scattered source radiance over that LOS path,
196  // with a desired spectral resolution given by spectrum. Function returns range from sensor.
197  // "source_type" specifies which sources to include in the scattered radiance return:
198  // UNSPECIFIED gives the total of all sources
199  // DIFFUSE_SOLAR,DIFFUSE_LUNAR,DIFFUSE_STELLAR,DIFFUSE_MANMADE, and RADAR give scattered return appropriate to that type.
200  // All other valid choices return no scattered source radiance.
201  // Out-of-range choices return no atmospheric thermal path radiance, either.
202  // startFRD is an initial sensor orientation w.r.t. local NED, which will be adjusted by this routine to look at the endpoint.
203  // endFRD returns this sensor orientation as projected along the line of sight at the endpoint, w.r.t the endpoint's local NED.
204  // (*trans) is [unitless] and has spectrum.nlambda elements.
205  // (*pathrad) has units [W/cm2/sr/um] and has spectrum.nlambda elements.
206  // (*scatrad) has units [W/cm2/sr/um] and has spectrum.nlambda elements.
207  SIGSIM_API double GetLOSAtmosphericsKE(GEOCENTRIC_LOCATION startC, EULERzyx *startFRD, GEOCENTRIC_LOCATION endC, EULERzyx *endFRD, METIN *metin, SOURCE_TYPE source_type, SPECTRAL_DOMAIN spectrum, double **trans, double **pathrad, double **scatrad);
208 
209  // GetLOSAtmosphericsKE_new performs the same function as GetLOSAtmosphericsKE, but it has the sensor as an input to handle the
210  // case where nlambda is 1 and also adds a flag to turn off scattering.
211  SIGSIM_API double GetLOSAtmosphericsKE_new(jrmbool SSflag, GEOCENTRIC_LOCATION startC, EULERzyx *startFRD, GEOCENTRIC_LOCATION endC, EULERzyx *endFRD, METIN *metin, SOURCE_TYPE source_type, SENSOR sens, double **trans, double **pathrad, double **scatrad);
212 
213  // GetLOSAtmosphericsKE_gpulut performs the same function as GetLOSAtmosphericsKE, but it is optimized to generate the gpu lut as quickly as possible.
214  SIGSIM_API double GetLOSAtmosphericsKE_gpulut(int SSflag, GEOCENTRIC_LOCATION startC, EULERzyx *startFRD, GEOCENTRIC_LOCATION endC, EULERzyx *endFRD,
215  METIN *metin, SOURCE_TYPE source_type, SENSOR sens,
216  double *trans, double *pathrad, double *scatrad, int nScatAngles, double *scatAngles);
217 
218  /* ------------- END FROM LOS_PROP.c ----------------------------------------------------------------------- */
219 
220  SIGSIM_API int GetMaximumPathLengthArray(ATMINFO inf, ATMCOEF *atm, long ax_index, long bx_index, int laymin, int laymax, double anglefactor, double **delta);
222  (
223  jrmbool reset, // TRUE=Overwrite {Xmit,Prad,Scat} arrays, FALSE=Keep arrays & add contributions from these path intervals.
224  jrmbool PRflag, // TRUE=Calculate atmospheric thermal path radiance
225  jrmbool SSflag, // TRUE=Calculate source scattered radiance
226  ATMCOEF *atm, // Array of atmospheric data
227  ATMINFO inf, // Wavelength and atmospheric layer altitude arrays
228  VECTOR *pathposition_m, // [m] Initial position of point to which the radiance is propagated. If SSflag=TRUE, this is adjusted as the path progresses. If SSflag=FALSE, it is not needed.
229  VECTOR look, // Unit vector toward end of path opposite that of pathposition_m
230  long nintervals, // Number of intervals in atm_index and length arrays.
231  long *atm_index, // Array of indices into atm array, one index per path interval. Points to 1st wavelength for the appropriate layer.
232  double *length, // [km] Array of pathlength for each path interval.
233  int nsources, // Number of sources for which scattering should be calculated.
234  VECTOR *tosource, // Unit vector to source
235  double *TOAirrad, // [W/m2/um] Top-Of-Atmosphere irradiance from source.
236  double *Xmit, // [unitless] Spectral transmittance array returned over path (accumulates if this function is iteratively called with reset=TRUE).
237  double *Prad, // [W/cm2/sr/um] Spectral atmospheric path radiance returned over path (accumulates if this function is iteratively called with reset=TRUE).
238  double *Scat // [W/cm2/sr/um] Per-source spectral scattered source radiance returned over path (accumulates if this function is iteratively called with reset=TRUE). Indexed as Scat[(source_index)*inf.spectrum.nlambda+(lambda_index)].
239  );
240  //int XmitPradScatCEMS(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, int nsources, double *TOAirrad, VECTOR *tosource, double* Xmit, double* Prad, double *Scat);
241  int XmitPradScatCE1S2(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, double *TOAirrad, VECTOR tosource, double* Xmit, double* Prad, double *Scat);
242  //int BandXmitPradScatCERanged(ATMCOEF *atm, ATMINFO inf, double ax, double bx, METIN *metin, VECTOR sensor, VECTOR matsys, int nranges, double *range, double *Xmit, double *Prad, double *Scat, jrmbool PRflag, jrmbool SSflag, jrmbool hitflag);
243  int CalcXmitAndPathRadCE(ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys, double *Xmit, double *Pathrad, jrmbool hitflag);
244  SIGSIM_API int BandXmitAndPathRadCE(ATMCOEF *atm, ATMINFO inf, double ax, double bx, METIN *metin, VECTOR sensor, VECTOR matsys, double *Xmit, double *Pathrad, jrmbool hitflag);
245  int XmittanceCE(ATMCOEF *atm, ATMINFO inf, double* Xmit, VECTOR sensor, VECTOR matsys_unvalidated, jrmbool hitflag);
246  int PathRadCE(ATMCOEF *atm, ATMINFO inf, double* Prad, VECTOR sensor, VECTOR matsys_unvalidated, jrmbool hitflag);
247  int PathRadScatCE(ATMCOEF *atm, ATMINFO inf, double *solarTOA, double *lunarTOA, double* Prad, double *SolScat, double *LunScat, VECTOR sensor, VECTOR matsys_unvalidated, VECTOR sun, VECTOR moon, jrmbool hitflag);
248  int XmitPradScatCE1S(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, double *TOAirrad, VECTOR tosource, double* Xmit, double* Prad, double *Scat);
249  SIGSIM_API int XmitPradScatCE1S_new(jrmbool PRflag, int SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor,
250  VECTOR matsys_unvalidated, double *TOAirrad, VECTOR tosource,
251  int start_lambda, int end_lambda,
252  double* Xmit, double* Prad, double *Scat, int nScatAngles, double *scatAngles);
253  SIGSIM_API int XmitPradScatCE(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, double* Xmit, double* Prad, double *solarTOA, double *lunarTOA, VECTOR sun, VECTOR moon, double *SunScat, double *LunScat);
254  int XmitPradScatCE_EvenSpace(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, double* Xmit, double* Prad, double *solarTOA, double *lunarTOA, VECTOR sun, VECTOR moon, double *SunScat, double *LunScat);
255  SIGSIM_API int XmitPradScatCE_MS(jrmbool PRflag, jrmbool SSflag, jrmbool MSflag, jrmbool hitflag, jrmbool includeSun, jrmbool includeMoon, VECTOR sensor, VECTOR matsys_unvalidated, METIN *metin);
256  SIGSIM_API int XmitPradScatCEMS(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, int nsources, double *TOAirrad, VECTOR *tosource, double* Xmit, double* Prad, double *Scat);
257  SIGSIM_API int BandXmitPradScatCERanged(ATMCOEF *atm, ATMINFO inf, double ax, double bx, METIN *metin, VECTOR sensor, VECTOR matsys, int nranges, double *range, double *Xmit, double *Prad, double *Scat, jrmbool PRflag, jrmbool SSflag, jrmbool hitflag);
258 
259  // UpdateAtmosphericsSinglePassbandRanged1D() calculates passband transmittance, path radiance, and scattered source radiance over a given path.
260  // INPUTS:
261  // *max_range is the desired sensor range in [m].
262  // sens->{fov.FRD_orientation,geodetic_loc} provide the sensor position and orientation information.
263  // metin->{atm,inf} define the atmospheric grid
264  // htiflag crops the max_range if it hits the earth or TOA.
265  // nranges is the number of ranges requested
266  // range[i] [meters] can be pre-filled, in which case it doesn't change
267  // OUTPUTS:
268  // range[i] will be filled by the function if not already filled in increasing order.
269  // Xmit_axbx[i] is the resultant passband transmittance for each range [i]
270  // Prad_axbx[i] is the resultant passband path radiance for each range [i] (can be NULL if PRflag=FALSE).
271  // Scat_axbx[i] is the resultant passband scattered solar + lunar radiance for each range [i] (can be NULL if SSflag=FALSE).
272  SIGSIM_API double UpdateAtmosphericsSinglePassbandRanged1D(double *max_range, METIN *metin, SENSOR *sens, int nranges, double *range, double *Xmit_axbx, double *Prad_axbx, double *Scat_axbx, jrmbool hitflag, jrmbool PRflag, jrmbool SSflag);
273 
274  SIGSIM_API int XmitPradScatCE_MS_AB( jrmbool PRflag, jrmbool SSflag, jrmbool MSflag, jrmbool hitflag, jrmbool includeSun, jrmbool includeMoon, jrmbool includegnd, jrmbool subdivide,
275  long ax_index, long bx_index,
276  VECTOR sensor, VECTOR matsys_unvalidated, VECTOR sun, VECTOR moon,
277  ATMCOEF *atm, ATMINFO inf, ATM_DEFAULT atm_default, double *solarTOA, double *lunarTOA,
278  double *solarDWlayer, double *solarUWlayer, double *lunarDWlayer, double *lunarUWlayer, double *thermalDWlayer, double *thermalUWlayer,
279  double* Xmit, double* Prad, double *SunScat, double *LunScat
280  );
281  SIGSIM_API int XmitPradScatCE_MS_AB_METIN(jrmbool PRflag, jrmbool SSflag, jrmbool MSflag, jrmbool hitflag, jrmbool includeSun, jrmbool includeMoon, jrmbool includegnd, jrmbool subdivide,
282  long ax_index, long bx_index,
283  VECTOR sensor, VECTOR matsys_unvalidated, METIN *metin,
284  double* Xmit, double* Prad, double *SunScat, double *LunScat);
285  SIGSIM_API int XmitPradScatCE_MS_AB_SB(jrmbool PRflag, jrmbool SSflag, jrmbool MSflag, jrmbool hitflag, jrmbool includeSun, jrmbool includeMoon, long ax_index, long bx_index,
286  VECTOR sensor, VECTOR matsys_unvalidated, VECTOR sun, VECTOR moon,
287  ATMCOEF *atm, ATMINFO inf, ATM_DEFAULT atm_default, float *LayerPressure, double *solarTOA, double *lunarTOA,
288  double *solarDWlayer, double *solarUWlayer, double *lunarDWlayer, double *lunarUWlayer, double *thermalDWlayer, double *thermalUWlayer,
289  double* Xmit, double* Prad, double *SunScat, double *LunScat);
290 
292  {
304  };
305 
306  SIGSIM_API double AtmCoefficientFitting( double altitude, int nAtmCoeffIndex, int nSpectralIndex, int *nLayersForFitting, int coeff,
307  ATMCOEF *atm, ATMINFO *inf, float *LayerPressure, double *AmplitudeFactor, double *ExponentialFactor );
308 
309  int Fill_NonModtranATMGrid(char *sigsim_atm_dir, METIN *metin);
310  int FillLowestLayerExtinctions(char *sigsim_atm_dir, METIN *metin);
311  int XmitPradScatCE_LOFI(jrmbool PRflag, jrmbool SSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, double* Xmit, double* Prad, double *solarTOA, double *lunarTOA, VECTOR sun, VECTOR moon, double *SunScat, double *LunScat);
312 
313 
314  SIGSIM_API int GetPathVecsSTP(double *range, VECTOR sensorient, double sensalt, ATMINFO inf, VECTOR *sensor, VECTOR *matsys, jrmbool hitflag);
315 
316  SIGSIM_API int ScatteringIrradianceByLayer(ATMINFO inf, ATMCOEF *atm, VECTOR source, double *sourceTOA, double *downDSS, double *upDSS, double *downMS, double *upMS, jrmbool DRdownflag, jrmbool DRupflag, jrmbool SSflag, jrmbool MSflag, jrmbool Init, long ax_index, long bx_index);
317  SIGSIM_API int ThermalIrradianceByLayer(ATMINFO inf, ATMCOEF *atm, ATM_DEFAULT atm_default, double *downD, double *upD, double *downSSMS, double *upSSMS, jrmbool DRdownflag, jrmbool DRupflag, jrmbool SSflag, jrmbool MSflag, jrmbool Init, long ax_index, long bx_index);
318  //int MultipleScatteringIrradianceByLayer2(ATMINFO inf, ATMCOEF *atm, VECTOR source, double *sourceTOA, double *MSIrrad);
319  //int ScatteringIrradianceByLayer2(ATMINFO inf, ATMCOEF *atm, VECTOR source, double *sourceTOA, double *downwell, double *upwell, jrmbool DRdownflag, jrmbool DRupflag, jrmbool SSflag, jrmbool MSflag);
320 
321  int GetMS2SSRatioSingleLayer(ATMINFO inf, ATMCOEF *atm, long layer, double scatangle, double pathlength, jrmbool TOA, SPECTRAL_DOMAIN spectrum, double *MS2SSratio);
322  SIGSIM_API int GetMultipleScattering2SingleScatteringRatio(SPECTRAL_DOMAIN spectrum, double *MS2SSratio, VECTOR Sensor, VECTOR Matsys, ATMCOEF *atm, ATMINFO inf, VECTOR sun, jrmbool hitflag);
323  int GetPathWeights(ATMCOEF *atm, ATMINFO inf, VECTOR sun, jrmbool hitflag, double lambda_max, VECTOR Sensor, VECTOR Matsys, double *henyey, double *scat, double *phfunc, double *extinct, double *baseMStoSSratio, double *scatangle, double *range_m);
324  SIGSIM_API int GetPathVectors(MODPATH *mp, int itype, VECTOR *sensor, VECTOR *matsys);
325  SIGSIM_API int GetLayerPropertiesPerPath(VECTOR sensor, VECTOR matsys, ATMCOEF *atm, ATMINFO inf, LAYER_PROP *layprop, double lambda_um, jrmbool hitflag);
326  SIGSIM_API int XmitPradScatCE2(jrmbool PRflag, jrmbool SSflag, jrmbool MSflag, jrmbool hitflag, ATMCOEF *atm, ATMINFO inf, VECTOR sensor, VECTOR matsys_unvalidated, double* Xmit, double* Prad, double *solarTOA, double *lunarTOA, VECTOR sun, VECTOR moon, double *SunScat, double *LunScat);
327 
328  SIGSIM_API double expint(double alt, double altlo, double althi, double Qlo, double Qhi);
329  double Hscale(double altlo, double althi, double Qlo, double Qhi);
330 
331  SIGSIM_API int FastDirectIrrad(METIN* metin, double alt, long ax_index, long bx_index);
332  SIGSIM_API int FastDiffuseIrrad(METIN* metin, double alt, long ax_index, long bx_index);
333 
334  // ------------------ CIE STANDARD SKY RADIANCE FUNCTIONS -----------------------------
335 
336  typedef struct
337  {
338  double a;
339  double b;
340  double c;
341  double d;
342  double e;
343  double A1;
344  double A2;
345  double B;
346  double C;
347  double D;
348  double E;
350 
351  typedef enum
352  {
353  I1=0, /* Standard Overcast, alternative : Steep gradation toward zenith, azimuthally uniform */
354  I2, /* Overcast : Steep gradation and slight brightening toward sun. */
355  II1, /* Overcast : Moderate gradation, azimuthally uniform */
356  II2, /* Overcast : Moderate gradation, slight brightening toward sun. */
357  III1, /* Uniform Luminance */
358  III2, /* Partly cloudy : No gradation toward zenith, slight brightening toward sun. */
359  III3, /* Partly cloudy : No gradation toward zenith, brighter circumsolar region */
360  III4, /* Partly cloudy : No gradation toward zenith, distinct solar corona */
361  IV2, /* Partly cloudy : Obscured sun. */
362  IV3, /* Partly cloudy : Brighter circumsolar region. */
363  IV4, /* White-blue : Distinct solar corona */
364  V4, /* Standard Clear, low illuminance turbidity */
365  V5, /* Standard Clear, polluted. */
366  VI5, /* Cloudless turbid : Broad solar corona */
367  VI6 /* White-blue turbid : Broad solar corona */
368  } CIE_ATM_TYPE;
369 
371  double ElementToSunDistance(double Z, double alpha, double Zs, double alphas);
372  double LuminanceGradationFunction(double z, double a, double b);
373  double ScatteringIndicatrix(double chi, double c, double d, double e);
374  double IdealOpticalMass(double Zs);
375  double IdealLuminousExtinction(double m);
376  double LuminousTurbidity(double Pv, double Ev, double av, double m);
377  double ZenithLuminance(double Zs, double Tv, double A1, double A2, double C, double D);
378  double Luminance(double Z, double alpha, double Zs, double alphas, CIE_ATM_TYPE atmtype, double Pv, double Ev);
379 
380  typedef struct
381  {
382  double RG; // [km] Earth Radius
383  double RT; // [km] TOA Radius
384  double RR; // [um4/m] Rayleigh Ratio <(n2-1)2/N> = (3*PI/8)*(lam/PI)^4*betaSR for given {lam, betaSR} at ground.
385  double HR; // [km] Rayleigh uniform thickness
386  double HM; // [km] Mie uniform thickness
387  double AB; // [unitless] Ground Albedo (alpha-bar)
388  double MR; // [um2/m] Mie Ratio = 0.25*(lam/PI)^2*betaSM for given {lam, betaSM} at ground.
389  double MBR; // [unitless] betaSM/betaEM Ratio of Mie scattering to extinction
390  double G; // [unitless] Mie Cornette-Shanks asymmetry parameter.
391  } BNN_ATM_PARAMS;
392 
393  SIGSIM_API int CreateBNNATM(BNN_ATM_PARAMS bnn, ATMINFO *inf, ATMCOEF **atm);
394  SIGSIM_API int PrintCIESkyRadianceMapForGivenBNNATM(char *filespec, BNN_ATM_PARAMS bnn, CIE_ATM_TYPE atmtype, double Zs, double alphas, SPECTRUM *solarTOA, double zenithResolution_deg, double azimuthResolution_deg);
395  // ------------------------------------------------------------------------------------
396 
397 
398  // ---- REFRACTION ----
399  SIGSIM_API double RefractivePathCorrection(MODPATH *mp, double n0, double h0);
400  SIGSIM_API int ComputeExponentialRefractiveIndex(ATMCOEF *atm, ATMINFO inf, double ax, double bx, double *n0, double *h0);
401  SIGSIM_API FOV GetRefractionAlteredFOV(FOV fov, ellipsoid E, double n0, double h0, jrmbool getRefracted);
402  SIGSIM_API void CalculateRequiredLOSAngles(double Eratio, RTPATH rt, double *angle, double *phi, double *range);
403  SIGSIM_API int InverseCalculateRequiredLOSAngle(double Eratio, MODPATH mp, double *angle0);
404  // --------------------
405 
406  // ----- ATMOSPHERIC IRRADIANCE ANGULAR DISTRIBUTION FITTING ----
407  SIGSIM_API int EffectiveHenyeyAsymmetry(METIN *metin, double tod, double ax, double bx, int o, double *g);
408  SIGSIM_API int EffectiveHorizonDropCoefficient(METIN *metin, double ax, double bx, int o, double *c);
409  // ---------------------------------
410 
411 
412 
413 #ifdef __cplusplus
414 }
415 #endif
416 
417 #endif // _ATM1D_H_
418 


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