23 static float *wvtbl =
NULL;
24 static float *t_co2 =
NULL;
25 static float *t_o2 =
NULL;
26 static float *t_co =
NULL;
27 static float *t_ch4 =
NULL;
28 static float *t_n2o =
NULL;
29 static float *cwv_all =
NULL;
31 static float *amf_mixed =
NULL;
32 static float *amf_wv =
NULL;
34 static int index_amf_solz, index_amf_senz, index_amf_total;
35 static float ratio_solz, ratio_senz,ratio_total;
36 static float amf_solz,amf_senz,amf_total;
47 int32_t num_water_vapors_id, num_models_id, num_wavelengths_id, num_airmass_id;
52 if ((nc_open(
input->gas_transmittance_file, NC_NOWRITE, &ncid)) != NC_NOERR) {
53 printf(
"-E- %s: Failed to open %s\n", __FILE__,
input->gas_transmittance_file);
56 if ((nc_inq_dimid(ncid,
"n_air_mass_factor", &num_airmass_id)) == NC_NOERR) {
58 if ((nc_inq_dimlen(ncid, num_airmass_id, &
num_airmass)) != NC_NOERR) {
59 printf(
"-E- %s: Failed to read dimension n_water_vapor\n", __FILE__);
63 if ((nc_inq_dimid(ncid,
"n_water_vapor", &num_water_vapors_id)) == NC_NOERR) {
64 if ((nc_inq_dimlen(ncid, num_water_vapors_id, &
num_water_vapors)) != NC_NOERR) {
65 printf(
"-E- %s: Failed to read dimension n_water_vapor\n", __FILE__);
69 printf(
"-E- %s: Failed to find dimension n_water_vapor\n", __FILE__);
72 if((nc_inq_dimid(ncid,
"nmodels", &num_models_id)) == NC_NOERR){
73 if((nc_inq_dimlen(ncid, num_models_id, &
num_models)) != NC_NOERR){
74 printf(
"-E- %s: Failed to read dimension nmodels\n", __FILE__);
78 printf(
"-E- %s: Failed to find dimension nmodels\n", __FILE__);
82 if((nc_inq_dimid(ncid,
"nwavelengths", &num_wavelengths_id)) == NC_NOERR){
83 if((nc_inq_dimlen(ncid, num_wavelengths_id, &
num_wavelengths)) != NC_NOERR){
84 printf(
"-E- %s: Failed to read dimension nwavelengths\n", __FILE__);
88 printf(
"-E- %s: Failed to find dimension nwavelengths\n", __FILE__);
94 printf(
"-E- %s line %d : error allocating memory for water vapor transmittance table.\n",
98 if ((nc_inq_varid(ncid,
"water_vapor_transmittance", &varid)) == NC_NOERR) {
99 if ((nc_get_var_float(ncid, varid,wvtbl)) != NC_NOERR){
100 printf(
"-E- %s: failed to read water_vapor_transmittance from %s\n", __FILE__,
101 input->gas_transmittance_file);
105 printf(
"-E- %s: '%s' does not have water_vapor_transmittance.\n",
106 __FILE__,
input->gas_transmittance_file);
111 if ((amf_mixed = (
float *)malloc(
num_airmass *
sizeof(
float))) ==
NULL) {
112 printf(
"Error: allocating memory for air mass factor mixed\n");
115 if ((nc_inq_varid(ncid,
"air_mass_factor_mixed", &varid)) == NC_NOERR) {
116 if ((nc_get_var_float(ncid, varid, amf_mixed)) != NC_NOERR) {
117 printf(
"-E- %s: failed to read air mass factor mixed from %s\n", __FILE__,
118 input->gas_transmittance_file);
122 printf(
"-E- %s: '%s' does not have air mass factor mixed\n", __FILE__,
123 input->gas_transmittance_file);
128 printf(
"Error: allocating memory for air mass factor for water vapor\n");
131 if ((nc_inq_varid(ncid,
"air_mass_factor_wv", &varid)) == NC_NOERR) {
132 if ((nc_get_var_float(ncid, varid, amf_wv)) != NC_NOERR) {
133 printf(
"-E- %s: failed to read air mass factor for water vapor from %s\n", __FILE__,
134 input->gas_transmittance_file);
138 printf(
"-E- %s: '%s' does not have air mass factor for water vapor\n", __FILE__,
139 input->gas_transmittance_file);
146 printf(
"Error: allocating memory for water vapor table\n");
149 if ((nc_inq_varid(ncid,
"water_vapor", &varid)) == NC_NOERR) {
150 if ((nc_get_var_float(ncid, varid, cwv_all)) != NC_NOERR) {
151 printf(
"-E- %s: failed to read water_vapor from %s\n", __FILE__,
input->gas_transmittance_file);
155 printf(
"-E- %s: '%s' does not have water_vapor\n",
156 __FILE__,
input->gas_transmittance_file);
162 printf(
"-E- %s line %d : error allocating memory for carbon monoxide transmittance table.\n",
166 if ((nc_inq_varid(ncid,
"carbon_monoxide_transmittance", &varid)) == NC_NOERR) {
167 if ((nc_get_var_float(ncid, varid, t_co)) != NC_NOERR) {
168 printf(
"-E- %s: failed to read carbon_monoxide_transmittance from %s\n", __FILE__,
169 input->gas_transmittance_file);
173 printf(
"-E- %s: '%s' does not have carbon_monoxide_transmittance\n",
174 __FILE__,
input->gas_transmittance_file);
180 printf(
"-E- %s line %d : error allocating memory for carbon dioxide transmittance table.\n", __FILE__,
184 if ((nc_inq_varid(ncid,
"carbon_dioxide_transmittance", &varid)) == NC_NOERR) {
185 if ((nc_get_var_float(ncid, varid, t_co2)) != NC_NOERR) {
186 printf(
"-E- %s: failed to read carbon_dioxide_transmittance from %s\n", __FILE__,
187 input->gas_transmittance_file);
191 printf(
"-E- %s: '%s' does not have carbon_dioxide_transmittance\n",
192 __FILE__,
input->gas_transmittance_file);
198 printf(
"-E- %s line %d : error allocating memory for oxygen transmittance table.\n", __FILE__,
202 if ((nc_inq_varid(ncid,
"oxygen_transmittance", &varid)) == NC_NOERR) {
203 if ((nc_get_var_float(ncid, varid, t_o2)) != NC_NOERR) {
204 printf(
"-E- %s: failed to read oxygen_transmittance from %s\n", __FILE__,
205 input->gas_transmittance_file);
209 printf(
"-E- %s: '%s' does not have oxygen_transmittance\n",
210 __FILE__,
input->gas_transmittance_file);
216 printf(
"-E- %s line %d : error allocating memory for nitrous oxide transmittance table.\n", __FILE__,
220 if ((nc_inq_varid(ncid,
"nitrous_oxide_transmittance", &varid)) == NC_NOERR) {
221 if ((nc_get_var_float(ncid, varid, t_n2o)) != NC_NOERR) {
222 printf(
"-E- %s: failed to read nitrous_oxide_transmittance from %s\n", __FILE__,
223 input->gas_transmittance_file);
227 printf(
"-E- %s: '%s' does not have nitrous_oxide_transmittance\n",
228 __FILE__,
input->gas_transmittance_file);
234 printf(
"-E- %s line %d : error allocating memory for methane transmittance table.\n", __FILE__,
238 if ((nc_inq_varid(ncid,
"methane_transmittance", &varid)) == NC_NOERR) {
239 if ((nc_get_var_float(ncid, varid, t_ch4)) != NC_NOERR) {
240 printf(
"-E- %s: failed to read methane_transmittance from %s\n", __FILE__,
241 input->gas_transmittance_file);
245 printf(
"-E- %s: '%s' does not have methane_transmittance\n",
246 __FILE__,
input->gas_transmittance_file);
251 if ((nc_inq_varid(ncid,
"k_no2", &varid)) == NC_NOERR) {
252 if ((nc_get_var_float(ncid, varid,
l1rec->l1file->k_no2)) != NC_NOERR) {
253 printf(
"-E- %s: failed to read k_no2 from %s\n", __FILE__,
254 input->gas_transmittance_file);
259 if ((nc_inq_varid(ncid,
"k_oz", &varid)) == NC_NOERR) {
260 if ((nc_get_var_float(ncid, varid,
l1rec->l1file->k_oz)) != NC_NOERR) {
261 printf(
"-E- %s: failed to read k_oz from %s\n", __FILE__,
262 input->gas_transmittance_file);
268 if ((nc_close(ncid)) != NC_NOERR){
269 printf(
"-E- %s: failed to close %s\n",
270 __FILE__,
input->gas_transmittance_file);
279 for (
i = 0;
i < num_val;
i++)
280 if (
val < table_val[
i])
293 int32_t nwave =
l1file->nbands;
294 int32_t ipb = ip*nwave;
296 for (iw = 0; iw < nwave; iw++) {
298 l1rec->tg_sol[ipb + iw] *= exp(-(tau_oz /
l1rec->csolz[ip]));
299 l1rec->tg_sen[ipb + iw] *= exp(-(tau_oz /
l1rec->csenz[ip]));
300 l1rec->tg[ipb + iw]*=exp(-tau_oz* (1.0/
l1rec->csolz[ip]+1.0/
l1rec->csenz[ip]));
308 int32_t nwave =
l1file->nbands;
309 int32_t ipb = ip*nwave;
317 for (iw = 0; iw < nwave; iw++) {
323 t_co2_interp=t_co2[
index+index_amf_solz]*(1-ratio_solz)+t_co2[
index+index_amf_solz+1]*ratio_solz;
324 l1rec->tg_sol[ipb + iw] *= t_co2_interp;
326 t_co2_interp=t_co2[
index+index_amf_senz]*(1-ratio_senz)+t_co2[
index+index_amf_senz+1]*ratio_senz;
327 l1rec->tg_sen[ipb + iw] *= t_co2_interp;
329 t_co2_interp=t_co2[
index+index_amf_total]*(1-ratio_total)+t_co2[
index+index_amf_total+1]*ratio_total;
330 l1rec->tg[ipb + iw] *= t_co2_interp;
332 l1rec->tg_sol[ipb + iw] *= pow(t_co2[iw], amf_solz);
333 l1rec->tg_sen[ipb + iw] *= pow(t_co2[iw], amf_senz);
334 l1rec->tg [ipb + iw] *= pow(t_co2[iw], amf_total);
344 int32_t nwave =
l1file->nbands;
345 int32_t ipb = ip*nwave;
349 for (iw = 0; iw < nwave; iw++) {
354 float t_co_interp=t_co[
index+index_amf_solz]*(1-ratio_solz)+t_co[
index+index_amf_solz+1]*ratio_solz;
355 l1rec->tg_sol[ipb + iw] *= t_co_interp;
357 t_co_interp=t_co[
index+index_amf_senz]*(1-ratio_senz)+t_co[
index+index_amf_senz+1]*ratio_senz;
358 l1rec->tg_sen[ipb + iw] *= t_co_interp;
360 t_co_interp=t_co[
index+index_amf_total]*(1-ratio_total)+t_co[
index+index_amf_total+1]*ratio_total;
361 l1rec->tg[ipb + iw] *= t_co_interp;
363 l1rec->tg_sol[ipb + iw] *= pow(t_co[iw], amf_solz);
364 l1rec->tg_sen[ipb + iw] *= pow(t_co[iw], amf_senz);
365 l1rec->tg [ipb + iw] *= pow(t_co[iw], amf_total);
369 printf(
"-E- carbon monoxide transmittance can only be computed if gas_opt includes bit %d\n",
GAS_TRANS_TBL_BIT);
379 int32_t nwave =
l1file->nbands;
380 int32_t ipb = ip*nwave;
384 for (iw = 0; iw < nwave; iw++) {
388 float t_ch4_interp=t_ch4[
index+index_amf_solz]*(1-ratio_solz)+t_ch4[
index+index_amf_solz+1]*ratio_solz;
389 l1rec->tg_sol[ipb + iw] *= t_ch4_interp;
391 t_ch4_interp=t_ch4[
index+index_amf_senz]*(1-ratio_senz)+t_ch4[
index+index_amf_senz+1]*ratio_senz;
392 l1rec->tg_sen[ipb + iw] *= t_ch4_interp;
394 t_ch4_interp=t_ch4[
index+index_amf_total]*(1-ratio_total)+t_ch4[
index+index_amf_total+1]*ratio_total;
395 l1rec->tg[ipb + iw] *= t_ch4_interp;
397 l1rec->tg_sol[ipb + iw] *= pow(t_ch4[iw], amf_solz);
398 l1rec->tg_sen[ipb + iw] *= pow(t_ch4[iw], amf_senz);
399 l1rec->tg [ipb + iw] *= pow(t_ch4[iw], amf_total);
403 printf(
"-E- methane transmittance can only be computed if gas_opt includes bit %d\n",
GAS_TRANS_TBL_BIT);
412 int32_t nwave =
l1file->nbands;
413 int32_t ipb = ip*nwave;
417 for (iw = 0; iw < nwave; iw++) {
421 float t_o2_interp=t_o2[
index+index_amf_solz]*(1-ratio_solz)+t_o2[
index+index_amf_solz+1]*ratio_solz;
422 l1rec->tg_sol[ipb + iw] *= t_o2_interp;
424 t_o2_interp=t_o2[
index+index_amf_senz]*(1-ratio_senz)+t_o2[
index+index_amf_senz+1]*ratio_senz;
425 l1rec->tg_sen[ipb + iw] *= t_o2_interp;
427 t_o2_interp=t_o2[
index+index_amf_total]*(1-ratio_total)+t_o2[
index+index_amf_total+1]*ratio_total;
428 l1rec->tg[ipb + iw] *=t_o2_interp;
430 l1rec->tg_sol[ipb + iw] *= pow(t_o2[iw], amf_solz);
431 l1rec->tg_sen[ipb + iw] *= pow(t_o2[iw], amf_senz);
432 l1rec->tg [ipb + iw] *= pow(t_o2[iw], amf_total);
442 int32_t nwave =
l1file->nbands;
443 int32_t ipb = ip*nwave;
447 for (iw = 0; iw < nwave; iw++) {
451 float t_n2o_interp=t_n2o[
index+index_amf_solz]*(1-ratio_solz)+t_n2o[
index+index_amf_solz+1]*ratio_solz;
452 l1rec->tg_sol[ipb + iw] *= t_n2o_interp;
454 t_n2o_interp=t_n2o[
index+index_amf_senz]*(1-ratio_senz)+t_n2o[
index+index_amf_senz+1]*ratio_senz;
455 l1rec->tg_sen[ipb + iw] *= t_n2o_interp;
457 t_n2o_interp=t_n2o[
index+index_amf_total]*(1-ratio_total)+t_n2o[
index+index_amf_total+1]*ratio_total;
458 l1rec->tg[ipb + iw] *= t_n2o_interp;
460 l1rec->tg_sol[ipb + iw] *= pow(t_n2o[iw], amf_solz);
461 l1rec->tg_sen[ipb + iw] *= pow(t_n2o[iw], amf_senz);
462 l1rec->tg [ipb + iw] *= pow(t_n2o[iw], amf_total);
466 printf(
"-E- nitrous oxide transmittance can only be computed if gas_opt includes bit %d\n",
GAS_TRANS_TBL_BIT);
479 int32_t nwave =
l1file->nbands;
480 int32_t ipb = ip*nwave;
482 float sec0 = 1.0 /
l1rec->csolz[ip];
483 float sec = 1.0 /
l1rec->csenz[ip];
485 if (
l1rec->no2_tropo[ip] > 0.0)
489 no2_tr200 =
l1rec->no2_frac[ip] *
l1rec->no2_tropo[ip];
494 for (iw = 0; iw < nwave; iw++) {
496 if (
l1file->k_no2[iw] > 0.0) {
498 a_285 =
l1file->k_no2[iw] * (1.0 - 0.003 * (285.0 - 294.0));
499 a_225 =
l1file->k_no2[iw] * (1.0 - 0.003 * (225.0 - 294.0));
501 tau_to200 = a_285 * no2_tr200 + a_225 *
l1rec->no2_strat[ip];
503 l1rec->tg_sol[ipb + iw] *= exp(-(tau_to200 * sec0));
504 l1rec->tg_sen[ipb + iw] *= exp(-(tau_to200 * sec));
505 l1rec->tg [ipb + iw] *= exp(-(tau_to200 * (sec+sec0)));
511 static float *a_h2o =
NULL;
512 static float *b_h2o =
NULL;
513 static float *c_h2o =
NULL;
514 static float *d_h2o =
NULL;
515 static float *e_h2o =
NULL;
516 static float *f_h2o =
NULL;
517 static float *g_h2o =
NULL;
524 int32_t nwave =
l1file->nbands;
525 int32_t ipb = ip*nwave;
526 float wv =
l1rec->wv[ip];
528 if (amf &&
input->watervapor_bands) {
530 for (iw = 0; iw <
input->nbands_watervapor;) {
532 input->watervapor_bands[iw + 2]);
535 wv /= (
input->nbands_watervapor / 3);
541 int32_t
ja = 0,ja_sen=0,ja_sol=0,ja_total=0;
543 float f00,f11,f01,f10;
544 float ratio_amf_senz,ratio_amf_solz,ratio_amf_total,tempratio;
545 int index_amf_wv_senz,index_amf_wv_solz,index_amf_wv_total;
552 ratio_amf_senz = (amf_senz - amf_wv[index_amf_wv_senz]) /
553 (amf_wv[index_amf_wv_senz + 1] - amf_wv[index_amf_wv_senz]);
554 ratio_amf_solz = (amf_solz - amf_wv[index_amf_wv_solz]) /
555 (amf_wv[index_amf_wv_solz + 1] - amf_wv[index_amf_wv_solz]);
556 ratio_amf_total = (amf_total - amf_wv[index_amf_wv_total]) /
557 (amf_wv[index_amf_wv_total + 1] - amf_wv[index_amf_wv_total]);
564 ratio_wv=(wv -cwv_all[
ja])/(cwv_all[
ja+1]-cwv_all[
ja]);
567 for (iw = 0; iw < nwave; iw++) {
576 t_h2o = (1. - ratio_amf_solz)*(1. - ratio_wv) * f00 + ratio_amf_solz * ratio_wv * f11 + ratio_amf_solz * (1. - ratio_wv) * f10 + ratio_wv * (1. - ratio_amf_solz) * f01;
577 l1rec->tg_sol[ipb + iw] *= t_h2o;
584 t_h2o = (1. - ratio_amf_senz)*(1. - ratio_wv) * f00 + ratio_amf_senz * ratio_wv * f11 + ratio_amf_senz * (1. - ratio_wv) * f10 + ratio_wv * (1. - ratio_amf_senz) * f01;
585 l1rec->tg_sen[ipb + iw] *= t_h2o;
592 t_h2o = (1. - ratio_amf_total)*(1. - ratio_wv) * f00 + ratio_amf_total * ratio_wv * f11 + ratio_amf_total * (1. - ratio_wv) * f10 + ratio_wv * (1. - ratio_amf_total) * f01;
593 l1rec->tg[ipb + iw] *= t_h2o;
597 tempratio=(wv*amf_solz -cwv_all[ja_sol])/(cwv_all[ja_sol+1]-cwv_all[ja_sol]);
598 t_h2o=wvtbl[
index+ja_sol]*(1-tempratio)+wvtbl[
index+ja_sol+1]*tempratio;
599 l1rec->tg_sol[ipb + iw] *= t_h2o;
601 tempratio=(wv*amf_senz -cwv_all[ja_sen])/(cwv_all[ja_sen+1]-cwv_all[ja_sen]);
602 t_h2o=wvtbl[
index+ja_sen]*(1-tempratio)+wvtbl[
index+ja_sen+1]*tempratio;
603 l1rec->tg_sen[ipb + iw] *= t_h2o;
605 tempratio=(wv*amf_total -cwv_all[ja_total])/(cwv_all[ja_total+1]-cwv_all[ja_total]);
606 t_h2o=wvtbl[
index+ja_total]*(1-tempratio)+wvtbl[
index+ja_total+1]*tempratio;
607 l1rec->tg[ipb + iw] *= t_h2o;
622 for (iw = 0; iw < nwave; iw++) {
623 t_h2o = a_h2o[iw] + wv * (b_h2o[iw] + wv * (c_h2o[iw] + wv * (d_h2o[iw]
624 + wv * (e_h2o[iw] + wv * (f_h2o[iw] + wv * g_h2o[iw])))));
625 l1rec->tg_sol[ipb + iw] *= pow(t_h2o, 1.0 /
l1rec->csolz[ip]);
626 l1rec->tg_sen[ipb + iw] *= pow(t_h2o, 1.0 /
l1rec->csenz[ip]);
627 l1rec->tg [ipb + iw] *= pow(t_h2o, 1.0 /
l1rec->csenz[ip]+1.0 /
l1rec->csolz[ip]);
634 static int32_t firstRun =
TRUE;
636 int nwave =
l1rec->l1file->nbands;
640 printf(
"ATREM O2 correction is incompatible with the Ding and Gordon approach\n");
641 printf(
"Either unset the atrem_opt bit %d or set oxaband_opt=0\n",
ATREM_O2);
644 static float *rhot, *tg_tot;
648 if ((rhot = (
float *) calloc(nwave,
sizeof (
float))) ==
NULL) {
649 printf(
"-E- : Error allocating memory to rhot\n");
652 if ((tg_tot = (
float *) calloc(nwave,
sizeof (
float))) ==
NULL) {
653 printf(
"-E- : Error allocating memory to tg_tot\n");
659 for (ib = 0; ib < nwave; ib++) {
660 ipb = ip * nwave + ib;
665 if (
input->atrem_splitpaths == 0) {
666 airmass = 1.0 /
l1rec->csolz[ip] + 1.0 /
l1rec->csenz[ip];
668 for (ib = 0; ib < nwave; ib++) {
669 ipb = ip * nwave + ib;
671 A = -log(tg_tot[ib]) / airmass;
686 amf_solz=1.0/
l1rec->csolz[ip];
687 amf_senz=1.0/
l1rec->csenz[ip];
688 amf_total=amf_solz+amf_senz;
695 ratio_senz = (amf_senz - amf_mixed[index_amf_senz]) /
696 (amf_mixed[index_amf_senz + 1] - amf_mixed[index_amf_senz]);
697 ratio_solz = (amf_solz - amf_mixed[index_amf_solz]) /
698 (amf_mixed[index_amf_solz + 1] - amf_mixed[index_amf_solz]);
699 ratio_total = (amf_total - amf_mixed[index_amf_total]) /
700 (amf_mixed[index_amf_total + 1] - amf_mixed[index_amf_total]);
703 if (
input->oxaband_opt == 2) {
734 for (ib = 0; ib < nwave; ib++) {
735 ipb = ip * nwave + ib;
744 uncertainty_t *uncertainty=
l1rec->uncertainty;
745 int32_t nwave =
l1file->nbands;
748 float tg_oz, tg_co2, tg_no2, dt_oz, dt_co2, dt_no2;
750 float mu0,
mu, tau_oz;
753 float tau_to200, dtau_to200;
754 float no2_tr200, dno2_tr200;
760 for (ip = 0; ip <
npix; ip++) {
764 if (
l1rec->no2_tropo[ip] > 0.0) {
765 no2_tr200 =
l1rec->no2_frac[ip] *
l1rec->no2_tropo[ip];
766 dno2_tr200 =
l1rec->no2_frac[ip] * uncertainty->dno2_tropo[ip];
772 for (ib = 0; ib < nwave; ib++) {
773 ipb = ip * nwave + ib;
778 tg_oz = exp(-tau_oz /
mu0);
779 dt_oz = tg_oz /
mu0 *
l1file->k_oz[ib] * uncertainty->doz[ip];
781 tg_co2 = pow(t_co2[ib], 1.0 /
mu0);
787 if (
l1file->k_no2[ib] > 0) {
788 a_285 =
l1file->k_no2[ib] * (1.0 - 0.003 * (285.0 - 294.0));
789 a_225 =
l1file->k_no2[ib] * (1.0 - 0.003 * (225.0 - 294.0));
791 tau_to200 = a_285 * no2_tr200 + a_225 *
l1rec->no2_strat[ip];
792 dtau_to200 = sqrt(pow(a_285*dno2_tr200, 2) + pow(a_225 * uncertainty->dno2_strat[ip], 2));
794 tg_no2 = exp(-tau_to200 /
mu0);
795 dt_no2 = tg_no2 /
mu0*dtau_to200;
797 uncertainty->dtg_sol[ipb] = sqrt(pow(tg_no2 * tg_co2*dt_oz, 2) + pow(tg_oz * tg_co2*dt_no2, 2) + pow(tg_no2 * tg_oz*dt_co2, 2));
801 tg_oz = exp(-tau_oz /
mu);
802 dt_oz = tg_oz /
mu *
l1file->k_oz[ib] * uncertainty->doz[ip];
804 tg_co2 = pow(t_co2[ib], 1.0 /
mu);
809 if (
l1file->k_no2[ib] > 0) {
810 a_285 =
l1file->k_no2[ib] * (1.0 - 0.003 * (285.0 - 294.0));
811 a_225 =
l1file->k_no2[ib] * (1.0 - 0.003 * (225.0 - 294.0));
813 tau_to200 = a_285 * no2_tr200 + a_225 *
l1rec->no2_strat[ip];
815 dtau_to200 = sqrt(pow(a_285*dno2_tr200, 2) + pow(a_225 * uncertainty->dno2_strat[ip], 2));
817 tg_no2 = exp(-tau_to200 /
mu);
818 dt_no2 = tg_no2 /
mu*dtau_to200;
820 uncertainty->dtg_sen[ipb] = sqrt(pow(tg_no2 * tg_co2*dt_oz, 2) + pow(tg_oz * tg_co2*dt_no2, 2) + pow(tg_no2 * tg_oz*dt_co2, 2));
829 static int firstcall=1;
832 int32_t nwave =
l1file->nbands;
833 int32_t ipb = ip*nwave,
index;
834 float * wave=
l1file->fwave;
835 float *Lt=&
l1rec->Lt[ipb];
837 float u0=
l1rec->csolz[ip];
839 float rhot_interp,trans_wv_true,ratio_wv_total;
840 static float *rhot, *tran_interp;
841 int index_amf_wv_total;
844 int band1,band2,band_absorp;
848 rhot=(
float *)malloc(nwave*
sizeof(
float));
852 band1=
windex(window1,wave,nwave);
853 band2=
windex(window2,wave,nwave);
854 band_absorp=
windex(absorp_band,wave,nwave);
856 for(
i=band1;
i<=band2;
i++)
859 rhot_interp=rhot[band1]+(absorp_band-window1)*(rhot[band2]-rhot[band1])/(window2-window1);
861 trans_wv_true=rhot[band_absorp]/rhot_interp;
865 ratio_wv_total = (amf_total - amf_wv[index_amf_wv_total]) /(amf_wv[index_amf_wv_total + 1] - amf_wv[index_amf_wv_total]);
868 tran_interp[
i] = wvtbl[
index +
i] * ratio_wv_total +
872 if (trans_wv_true >= tran_interp[
i])
880 wv = cwv_all[
i] + (trans_wv_true - tran_interp[
i]) * (cwv_all[
i] - cwv_all[
i - 1]) /
881 (tran_interp[
i] - tran_interp[
i - 1]);