DAS  3.1.6 - 18/09/2017
Functions | Variables
DOAS.c File Reference

DOAS procedures. More...

#include <windows.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/timeb.h>
#include <math.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dil.h"
#include "DOAS.h"
#include "bil.h"
+ Include dependency graph for DOAS.c:

Go to the source code of this file.

Functions

int BuildLogRatio (void)
 first attempt to apply the DOAS algorithm (..on going!!!) More...
 
void CalcSpectrumLimits (int mod, int pos, int spix, int epix, int refpix)
 
void FixedStep (void)
 
int Pix2Wl (int mod, int pos, int spix, int epix, struct doas *pd)
 

Variables

doas DOAS
 

Detailed Description

DOAS procedures.

Author
Daniele Bortoli

Definition in file DOAS.c.

Function Documentation

§ BuildLogRatio()

int BuildLogRatio ( void  )

first attempt to apply the DOAS algorithm (..on going!!!)

Definition at line 178 of file DOAS.c.

References AllocFloatMat(), BIL, spectrumheader::ccdex, spectrumheader::ccdwx, bil::DPLOT, doas::FFTFilter, FilterData(), GrafoIMG(), IDX, IDY, d_view::ImatOrig, doas::IoMat, doas::IoSmoothed, doas::IsSmoothed, doas::lambda, doas::LogRatioMat, doas::LogRatioSmoothed, ON_OFFLINEPLOT, SmoothData(), SmoothFloatData(), bil::SPH, and doas::VarY.

Referenced by DB_ToolsKeyB_CB(), and PlotToolsPBs().

179 {
180 
181  int x, y, BlindPix_1;
182  FILE *fd;
183  float low = 65535;
184  float high= -65535;
185 
186  IDY = IDY -1;
187 
188 
189  BlindPix_1 = 0;
190  if (BIL.SPH.ccdwx - (BIL.SPH.ccdex +1) != 0) // se i pixel del sensore sono piu' di quelli in param.ini
191  BlindPix_1 = BIL.SPH.ccdwx - (BIL.SPH.ccdex +1) ;
192 
193 
194 // FixedStep();
195 
196 
197 
200 
202 
204 
206 
207  FilterData(DOAS.IoMat, IDX, IDY, 5, BlindPix_1);
208  FilterData(BIL.DPLOT.ImatOrig, IDX, IDY, 5, BlindPix_1);
209 
212 
213  for(x = 2; x < IDX - BlindPix_1; x++)
214  {
215 
216  for(y = 0; y < IDY; y++)
217  {
218  DOAS.LogRatioMat[y * IDX + x] = (float) log( DOAS.IoMat[y * IDX + x] / ( BIL.DPLOT.ImatOrig[y * IDX + x] * (DOAS.IoSmoothed[y * IDX + x] / DOAS.IsSmoothed[y * IDX + x])));
219  }
220  }
221 
223 
224 // for(x = 2; x < IDX - BlindPix_1 + 1; x++)
225  for(x = 2; x < IDX - BlindPix_1; x++)
226  {
227 
228  for(y = 0; y < IDY; y++)
229  {
230  DOAS.VarY[y * IDX + x] = DOAS.LogRatioMat[y * IDX + x] - DOAS.LogRatioSmoothed[y * IDX + x];
231  }
232  }
233 
234 
235  fd = fopen("TestLogRatio.dat", "w");
236  if(fd < 0) return 1;
237 
238 
239 // for(x = 2; x < IDX - BlindPix_1 + 1; x++)
240  for(x = 2; x < IDX - BlindPix_1; x++)
241  {
242 
243  fprintf(fd, " %9.4lf", DOAS.lambda[x]);
244  for(y = 0; y < IDY; y++)
245  {
246 
247 
248 // DOAS.LogRatioMat[y * IDX + x] = log( DOAS.IoMat[y * IDX + x] / ( BIL.DPLOT.ImatOrig[y * IDX + x] * (DOAS.IoSmoothed[y * IDX + x] / DOAS.IsSmoothed[y * IDX + x])));
249  fprintf(fd, " %9.4lf", DOAS.VarY[y * IDX + x]);
250  }
251  fprintf(fd, "\n", NULL);
252  }
253  fprintf(fd, "\n", NULL);
254  fclose(fd);
255 
256 
257 
258 
259 
260 // for(x = 2; x < IDX - BlindPix_1 + 1; x++)
261  for(x = 2; x < IDX - BlindPix_1; x++)
262  {
263  for(y = 0; y < IDY; y++)
264  {
265  if(DOAS.VarY[y * IDX + x] < low) low = DOAS.VarY[y * IDX + x];
266  if(DOAS.VarY[y * IDX + x] > high) high = DOAS.VarY[y * IDX + x];
267  }
268  }
269 
270 
271 // for(x = 2; x < IDX - BlindPix_1 + 1; x++)
272  for(x = 2; x < IDX - BlindPix_1; x++)
273  {
274 
275  for(y = 0; y < IDY; y++)
276  {
277  BIL.DPLOT.ImatOrig[y * IDX + x] = (unsigned short)((DOAS.VarY[y * IDX + x] - low) * 100000);
278  }
279  }
280 
281 
282 
283 
284 
285 
286 // SwapMatrix((unsigned short *) DOAS.VarY, BIL.DPLOT.ImatOrig, IDX, IDY);
288 
289 /*
290  DOAS.IoSmoothed = DeallocFloatMat(DOAS.IoSmoothed);
291  DOAS.IsSmoothed = DeallocFloatMat(DOAS.IsSmoothed);
292 
293  DOAS.LogRatioMat = DeallocFloatMat(DOAS.LogRatioMat);
294 
295  DOAS.LogRatioSmoothed = DeallocFloatMat(DOAS.LogRatioSmoothed);
296 
297  DOAS.VarY = DeallocFloatMat(DOAS.VarY);
298 */
299  return 0;
300 
301 }
int SmoothFloatData(float *source, float *destination, int horpix, int verpix, int filw, int bp)
Calc. the smoothed matrix of a float one. .
Definition: Save.c:890
float * IsSmoothed
Smoothed measured spectrum.
Definition: DOASdef.h:29
void GrafoIMG(int mode)
Definition: Spat_Plot.c:1242
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
float * IoSmoothed
Smoothed ref spectrum.
Definition: DOASdef.h:28
int FilterData(unsigned short *mat, int horpix, int verpix, int filw, int bp)
Definition: FFT.c:250
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
int SmoothData(unsigned short *source, float *destination, int horpix, int verpix, int filw, int bp)
Calc. the smoothed matrix of an unsigned short one. .
Definition: Save.c:973
float * LogRatioSmoothed
Definition: DOASdef.h:32
unsigned short * ImatOrig
Definition: bildef.h:180
d_view DPLOT
Definition: bildef.h:254
double lambda[1055]
Wavelength series.
Definition: DOASdef.h:18
int ON_OFFLINEPLOT
Definition: DAS_Spat.c:117
float * VarY
Definition: DOASdef.h:31
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
int FFTFilter
Fast Fourier Trasform Filter windows.
Definition: DOASdef.h:25
bil BIL
Definition: 2DPlot.c:28
unsigned short * IoMat
Reference spectrum.
Definition: DOASdef.h:27
doas DOAS
Definition: DOAS.c:20
float * AllocFloatMat(int hp, int vp)
Definition: Spat_Plot.c:2009
float * LogRatioMat
log of the ratio
Definition: DOASdef.h:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ CalcSpectrumLimits()

void CalcSpectrumLimits ( int  mod,
int  pos,
int  spix,
int  epix,
int  refpix 
)

Definition at line 67 of file DOAS.c.

References doas::k1, doas::k2, doas::lambda, and wl.

Referenced by DrawAreaPlotCB().

68 {
69 
70 /* Da calcoli di Giorgio
71 2773 0.675070513 -3.42932E-05
72 3312 0.608620686 -1.22438E-05
73 3840 0.513266027 9.38545E-06
74 4358 0.580417561 -8.00615E-06
75 4866 1.094769302 -1.17723E-04
76 5363 0.637981086 -2.18565E-05
77 5850 0.450432353 9.64196E-06
78 6237 0.926432179 -6.81376E-05
79 6795 0.509714198 -3.59181E-06
80 7253 0.961946259 -6.73045E-05
81 */
82 
83 /* Da calcoli di Danbo in DispersioneSPATRAM_EV.xls
84 
85  ATTENZIONE LA procedura di linearizzazione utilizza l'equazione: dl = K1 - K2 * l,
86  mentre la procedura di regressione di EXCEL utilizza (giustamente) dl = K1 + K2 * l,
87  quindi i valori di k2 in excel hanno il segno "-" mentre qui devono essere inseriti nel
88  vettore kk2 con il segno positivo.
89 
90 2823 dl = 2.35808044 - 0.000628126 * l
91 3337 dl = 0.767112208 - 4.67502E-05 * l
92 3850 dl = 0.824026577 - 5.67659E-05 * l
93 4358 dl = 3.011942876 - 0.000572933 * l
94 4861
95 5332
96 5814
97 6282
98 6734
99 7201
100 7677
101 8195
102 8622
103 9023
104 9405
105 9758
106 10066
107 10358
108 1.094769302 -1.17723E-04
109 
110 
111 
112 */
113 
114  int k, i, c = pos;
115 /* Da calcoli di Giorgio*/
116 // double kk1[] = {0.675070513,0.608620686,0.513266027,0.580417561,1.094769302,6,7,8,9,10,11,12,13,14,15,16,17,18};
117 // double kk2[] = {-3.42932E-05,-1.22438E-05,9.38545E-06,-8.00615E-06,-1.17723E-04,6,7,8,9,10,11,12,13,14,15,16,17,18};
118 
119 /* Da calcoli di Danbo*/
120 // double kk1[] = {2.35808044,0.767112208,0.824026577,3.011942876,1.094769302,1,1,1,1,1,1,1,1,1,1,1,1,1};
121 // double kk2[] = {0.000628126,4.67502E-05,5.67659E-05,0.000572933,1.17723E-04,1,1,1,1,1,1,1,1,1,1,1,1,1};
122 
123  double lm[1055];
124 
125  double k1,k2;
126 
127  for(i = 0;i< 18 ;i++)
128  {
129  if(pos == wl[i])
130  {
131 // k1 = kk1[i];
132 // k2 = kk2[i];
133  k1 = DOAS.k1[i];
134  k2 = DOAS.k2[i];
135  }
136  }
137 /*
138  DOAS.lambda[512] = (2 * pos - k1) / (2 - k2); // dl for wl at pix 512
139 
140  DOAS.lambda[512] = (DOAS.lambda[512]) + (k1 - k2 * DOAS.lambda[512]); // tot wl at pix 512
141 
142 
143  //Wavelenth series is build for decreasing pixel number
144  for(k = 511; k >= 0; k--)
145  DOAS.lambda[k] = ((2 + k2) * DOAS.lambda[k + 1] - 2 * k1) / (2 - k2);
146 
147  //Wavelenth series is build for increasing pixel number
148  for (k = 513; k <= IDX; k++)
149  DOAS.lambda[k] = ((2 - k2) * DOAS.lambda[k - 1] + 2 * k1) / (2 + k2);
150 */
151 
152  lm[refpix] = (2 * pos - k1) / (2 - k2); // dl for wl at pix pixref
153 
154  lm[refpix] = (lm[refpix]) + (k1 - k2 * lm[refpix]); // tot wl at pix pixref
155 
156 
157  //Wavelenth series is build for decreasing pixel number
158  for(k = refpix - 1 ; k >= spix; k--)
159  lm[k] = ((2 + k2) * lm[k + 1] - 2 * k1) / (2 - k2);
160 
161  //Wavelenth series is build for increasing pixel number
162  for (k = refpix + 1; k <= epix +1; k++)
163  lm[k] = ((2 - k2) * lm[k - 1] + 2 * k1) / (2 + k2);
164 
165  for(i = spix; i<=epix; i++)
166  DOAS.lambda[i] = lm[i];
167 
168 }
double k2[20]
k2 dispersion parameter -slope (x stretch2
Definition: DOASdef.h:23
double lambda[1055]
Wavelength series.
Definition: DOASdef.h:18
double k1[20]
k1 dispersion parameter - intercept (x stretch1)
Definition: DOASdef.h:22
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
doas DOAS
Definition: DOAS.c:20
+ Here is the caller graph for this function:

§ FixedStep()

void FixedStep ( void  )

Definition at line 170 of file DOAS.c.

171 {
172 
173 
174 }

§ Pix2Wl()

int Pix2Wl ( int  mod,
int  pos,
int  spix,
int  epix,
struct doas pd 
)

Definition at line 26 of file DOAS.c.

References doas::dhg, doas::k1, doas::k2, doas::lambda, doas::pixref, doas::wlc, and doas::wlref.

Referenced by D_pbr_CB(), DrawAreaPlotCB(), and WriteColumn().

27 {
28  int k, i, c = pos, t=0;
29 
30  for(i = 0;i< 18 ;i++)
31  {
32  if(pos == pd->wlc[i])
33  {
34  t = i;
35  }
36  }
37  // dl for wl at pix pixref
38  pd->lambda[pd->pixref[t]] = (2 * pd->wlref[t] - pd->k1[t]) / (2 - pd->k2[t]);
39 
40  // tot wl at pix pixref
41  pd->lambda[pd->pixref[t]] =
42  (pd->lambda[pd->pixref[t]]) + (pd->k1[t] - pd->k2[t] * pd->lambda[pd->pixref[t]]) * pd->dhg[t];
43 
44 
45  //Wavelenth series is build for decreasing pixel number
46  for(k = pd->pixref[t] - 1 ; k >= spix; k--)
47  pd->lambda[k] = ((2 + pd->k2[t]) * pd->lambda[k + 1] - 2 * pd->k1[t]) / (2 - pd->k2[t]);
48 
49  //Wavelenth series is build for increasing pixel number
50  for (k = pd->pixref[t] + 1; k <= epix +1; k++)
51  pd->lambda[k] = ((2 - pd->k2[t]) * pd->lambda[k - 1] + 2 * pd->k1[t]) / (2 + pd->k2[t]);
52 
53  return 0;
54 }
double k2[20]
k2 dispersion parameter -slope (x stretch2
Definition: DOASdef.h:23
double wlref[20]
reference wavelength
Definition: DOASdef.h:20
int pixref[20]
reference pixel
Definition: DOASdef.h:21
double lambda[1055]
Wavelength series.
Definition: DOASdef.h:18
double dhg[20]
shift parameter
Definition: DOASdef.h:24
double k1[20]
k1 dispersion parameter - intercept (x stretch1)
Definition: DOASdef.h:22
int wlc[20]
Central wavelength.
Definition: DOASdef.h:19
+ Here is the caller graph for this function:

Variable Documentation

§ DOAS

doas DOAS

Definition at line 20 of file DOAS.c.

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:55 for DAS - Rel. 3.1.6 - 18/09/2017.