AIRS Code Collection
nlte.c
Go to the documentation of this file.
1/*
2 This file is part of the AIRS Code Collection.
3
4 the AIRS Code Collections is free software: you can redistribute it
5 and/or modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation, either version 3 of
7 the License, or (at your option) any later version.
8
9 The AIRS Code Collection is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with the AIRS Code Collection. If not, see
16 <http://www.gnu.org/licenses/>.
17
18 Copyright (C) 2019-2025 Forschungszentrum Juelich GmbH
19*/
20
26#include <mpi.h>
27#include <omp.h>
28#include <netcdf.h>
29#include "jurassic.h"
30
31/* ------------------------------------------------------------
32 Macros...
33 ------------------------------------------------------------ */
34
36#define NC(cmd) { \
37 int nc_result=(cmd); \
38 if(nc_result!=NC_NOERR) \
39 ERRMSG("%s", nc_strerror(nc_result)); \
40}
41
42/* ------------------------------------------------------------
43 Dimensions...
44 ------------------------------------------------------------ */
45
47#define L1_NCHAN 34
48
50#define L1_NTRACK 135
51
53#define L1_NXTRACK 90
54
56#define L2_NLAY 27
57
59#define L2_NTRACK 45
60
62#define L2_NXTRACK 30
63
64/* ------------------------------------------------------------
65 Structs...
66 ------------------------------------------------------------ */
67
69typedef struct {
70
72 int ncid;
73
75 int np;
76
78 double l1_time[L1_NTRACK][L1_NXTRACK];
79
81 double l1_lon[L1_NTRACK][L1_NXTRACK];
82
84 double l1_lat[L1_NTRACK][L1_NXTRACK];
85
87 double l1_sat_z[L1_NTRACK];
88
90 double l1_sat_lon[L1_NTRACK];
91
93 double l1_sat_lat[L1_NTRACK];
94
96 double l1_nu[L1_NCHAN];
97
99 float l1_rad[L1_NTRACK][L1_NXTRACK][L1_NCHAN];
100
102 double l2_z[L2_NTRACK][L2_NXTRACK][L2_NLAY];
103
105 double l2_p[L2_NLAY];
106
108 double l2_t[L2_NTRACK][L2_NXTRACK][L2_NLAY];
109
111 float ret_z[NP];
112
114 float ret_p[L1_NTRACK * L1_NXTRACK];
115
117 float ret_t[L1_NTRACK * L1_NXTRACK * NP];
118
119} ncd_t;
120
122typedef struct {
123
126
129
131 double conv_dmin;
132
134 double err_formod[ND];
135
137 double err_noise[ND];
138
140 double err_press;
141
144
147
149 double err_temp;
150
153
156
158 double err_q[NG];
159
161 double err_q_cz[NG];
162
164 double err_q_ch[NG];
165
167 double err_k[NW];
168
170 double err_k_cz[NW];
171
173 double err_k_ch[NW];
174
175} ret_t;
176
177/* ------------------------------------------------------------
178 Functions...
179 ------------------------------------------------------------ */
180
182void add_var(
183 int ncid,
184 const char *varname,
185 const char *unit,
186 const char *longname,
187 int type,
188 int dimid[],
189 int *varid,
190 int ndims);
191
193double cost_function(
194 gsl_vector * dx,
195 gsl_vector * dy,
196 gsl_matrix * s_a_inv,
197 gsl_vector * sig_eps_inv);
198
200void fill_gaps(
201 double x[L2_NTRACK][L2_NXTRACK][L2_NLAY],
202 double cx,
203 double cy);
204
206void init_l2(
207 ncd_t * ncd,
208 int track,
209 int xtrack,
210 ctl_t * ctl,
211 atm_t * atm);
212
214void matrix_invert(
215 gsl_matrix * a);
216
218void matrix_product(
219 gsl_matrix * a,
220 gsl_vector * b,
221 int transpose,
222 gsl_matrix * c);
223
226 ret_t * ret,
227 ctl_t * ctl,
228 obs_t * obs_meas,
229 obs_t * obs_i,
230 atm_t * atm_apr,
231 atm_t * atm_i,
232 double *chisq);
233
235void read_nc(
236 char *filename,
237 ncd_t * ncd);
238
240void read_ret_ctl(
241 int argc,
242 char *argv[],
243 ctl_t * ctl,
244 ret_t * ret);
245
247void set_cov_apr(
248 ret_t * ret,
249 ctl_t * ctl,
250 atm_t * atm,
251 int *iqa,
252 int *ipa,
253 gsl_matrix * s_a);
254
256void set_cov_meas(
257 ret_t * ret,
258 ctl_t * ctl,
259 obs_t * obs,
260 gsl_vector * sig_noise,
261 gsl_vector * sig_formod,
262 gsl_vector * sig_eps_inv);
263
264/* ------------------------------------------------------------
265 Main...
266 ------------------------------------------------------------ */
267
269 int argc,
270 char *argv[]) {
271
272 static ctl_t ctl;
273 static atm_t atm_apr, atm_clim, atm_i;
274 static obs_t obs_i, obs_meas;
275 static ncd_t ncd;
276 static ret_t ret;
277
278 static FILE *in, *out;
279
280 static char filename[LEN], filename2[2 * LEN];
281
282 static double chisq[L1_NTRACK][L1_NXTRACK], ni[L1_NTRACK][L1_NXTRACK],
283 z[NP];
284
285 static int channel[ND], n, ntask = -1, rank, size;
286
287 /* ------------------------------------------------------------
288 Init...
289 ------------------------------------------------------------ */
290
291 /* MPI... */
292 MPI_Init(&argc, &argv);
293 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
294 MPI_Comm_size(MPI_COMM_WORLD, &size);
295
296 /* Measure CPU time... */
297 TIMER("total", 1);
298
299 /* Check arguments... */
300 if (argc < 3)
301 ERRMSG("Give parameters: <ctl> <filelist>");
302
303 /* Read control parameters... */
304 read_ctl(argc, argv, &ctl);
305 read_ret_ctl(argc, argv, &ctl, &ret);
306
307 /* Read retrieval grid... */
308 const int nz = (int) scan_ctl(argc, argv, "NZ", -1, "", NULL);
309 if (nz > NP)
310 ERRMSG("Too many altitudes!");
311 for (int iz = 0; iz < nz; iz++)
312 z[iz] = scan_ctl(argc, argv, "Z", iz, "", NULL);
313
314 /* Read track range... */
315 const int track0 = (int) scan_ctl(argc, argv, "TRACK_MIN", -1, "0", NULL);
316 const int track1 = (int) scan_ctl(argc, argv, "TRACK_MAX", -1, "134", NULL);
317
318 /* Read xtrack range... */
319 const int xtrack0 = (int) scan_ctl(argc, argv, "XTRACK_MIN", -1, "0", NULL);
320 const int xtrack1 =
321 (int) scan_ctl(argc, argv, "XTRACK_MAX", -1, "89", NULL);
322
323 /* Background smoothing... */
324 const double sx = scan_ctl(argc, argv, "SX", -1, "8", NULL);
325 const double sy = scan_ctl(argc, argv, "SY", -1, "2", NULL);
326
327 /* ------------------------------------------------------------
328 Distribute granules...
329 ------------------------------------------------------------ */
330
331 /* Open filelist... */
332 printf("Read filelist: %s\n", argv[2]);
333 if (!(in = fopen(argv[2], "r")))
334 ERRMSG("Cannot open filelist!");
335
336 /* Loop over netCDF files... */
337 while (fscanf(in, "%s", filename) != EOF) {
338
339 /* Distribute files with MPI... */
340 if ((++ntask) % size != rank)
341 continue;
342
343 /* Write info... */
344 printf("Retrieve file %s on rank %d of %d (with %d threads)...\n",
345 filename, rank + 1, size, omp_get_max_threads());
346
347 /* ------------------------------------------------------------
348 Initialize retrieval...
349 ------------------------------------------------------------ */
350
351 /* Read netCDF file... */
352 read_nc(filename, &ncd);
353
354 /* Identify radiance channels... */
355 for (int id = 0; id < ctl.nd; id++) {
356 channel[id] = -999;
357 for (int i = 0; i < L1_NCHAN; i++)
358 if (fabs(ctl.nu[id] - ncd.l1_nu[i]) < 0.1)
359 channel[id] = i;
360 if (channel[id] < 0)
361 ERRMSG("Cannot identify radiance channel!");
362 }
363
364 /* Fill data gaps... */
365 fill_gaps(ncd.l2_t, sx, sy);
366 fill_gaps(ncd.l2_z, sx, sy);
367
368 /* Set climatological data for center of granule... */
369 atm_clim.np = nz;
370 for (int iz = 0; iz < nz; iz++)
371 atm_clim.z[iz] = z[iz];
372 climatology(&ctl, &atm_clim);
373
374 /* ------------------------------------------------------------
375 Retrieval...
376 ------------------------------------------------------------ */
377
378 /* Loop over swaths... */
379 for (int track = track0; track <= track1; track++) {
380
381 /* Measure CPU time... */
382 TIMER("retrieval", 1);
383
384 /* Loop over scan... */
385 for (int xtrack = xtrack0; xtrack <= xtrack1; xtrack++) {
386
387 /* Store observation data... */
388 obs_meas.nr = 1;
389 obs_meas.time[0] = ncd.l1_time[track][xtrack];
390 obs_meas.obsz[0] = ncd.l1_sat_z[track];
391 obs_meas.obslon[0] = ncd.l1_sat_lon[track];
392 obs_meas.obslat[0] = ncd.l1_sat_lat[track];
393 obs_meas.vplon[0] = ncd.l1_lon[track][xtrack];
394 obs_meas.vplat[0] = ncd.l1_lat[track][xtrack];
395 for (int id = 0; id < ctl.nd; id++)
396 obs_meas.rad[id][0] = ncd.l1_rad[track][xtrack][channel[id]];
397
398 /* Flag out 4 micron channels... */
399 for (int id = 0; id < ctl.nd; id++)
400 if (ctl.nu[id] >= 2000)
401 obs_meas.rad[id][0] = GSL_NAN;
402
403 /* Prepare atmospheric data... */
404 copy_atm(&ctl, &atm_apr, &atm_clim, 0);
405 for (int ip = 0; ip < atm_apr.np; ip++) {
406 atm_apr.time[ip] = obs_meas.time[0];
407 atm_apr.lon[ip] = obs_meas.vplon[0];
408 atm_apr.lat[ip] = obs_meas.vplat[0];
409 }
410
411 /* Merge Level-2 data... */
412 init_l2(&ncd, track, xtrack, &ctl, &atm_apr);
413
414 /* Retrieval... */
415 optimal_estimation(&ret, &ctl, &obs_meas, &obs_i,
416 &atm_apr, &atm_i, &chisq[track][xtrack]);
417
418 /* Run forward model including 4 micron channels... */
419 for (int id = 0; id < ctl.nd; id++)
420 obs_meas.rad[id][0] = obs_i.rad[id][0]
421 = ncd.l1_rad[track][xtrack][channel[id]];
422 formod(&ctl, &atm_i, &obs_i);
423
424 /* Calculate non-LTE index... */
425 n = 0;
426 ni[track][xtrack] = 0;
427 for (int id = 0; id < ctl.nd; id++)
428 if (ctl.nu[id] >= 2000 && gsl_finite(obs_meas.rad[id][0])) {
429 ni[track][xtrack] +=
430 (BRIGHT(obs_meas.rad[id][0], ncd.l1_nu[channel[id]])
431 - BRIGHT(obs_i.rad[id][0], ncd.l1_nu[channel[id]]));
432 n++;
433 }
434 ni[track][xtrack] /= n;
435 }
436
437 /* Measure CPU time... */
438 TIMER("retrieval", 3);
439 }
440
441 /* ------------------------------------------------------------
442 Write output...
443 ------------------------------------------------------------ */
444
445 /* Set filename... */
446 sprintf(filename2, "%s.nlte.tab", filename);
447
448 /* Create output file... */
449 printf("Write non-LTE data: %s\n", filename2);
450 if (!(out = fopen(filename2, "w")))
451 ERRMSG("Cannot create file!");
452
453 /* Write header... */
454 fprintf(out,
455 "# $1 = time (seconds since 2000-01-01, 00:00 UTC)\n"
456 "# $2 = longitude [deg]\n"
457 "# $3 = latitude [deg]\n"
458 "# $4 = solar zenith angle [deg]\n"
459 "# $5 = non-LTE index [K]\n" "# $6 = chi^2 of retrieval fit\n");
460
461 /* Write data... */
462 for (int track = track0; track <= track1; track++) {
463 fprintf(out, "\n");
464 for (int xtrack = xtrack0; xtrack <= xtrack1; xtrack++)
465 fprintf(out, "%.2f %g %g %g %g %g\n",
466 ncd.l1_time[track][xtrack],
467 ncd.l1_lon[track][xtrack],
468 ncd.l1_lat[track][xtrack],
469 sza(ncd.l1_time[track][xtrack], ncd.l1_lon[track][xtrack],
470 ncd.l1_lat[track][xtrack]), ni[track][xtrack],
471 chisq[track][xtrack]);
472 }
473
474 /* Close output file... */
475 fclose(out);
476
477 /* Write info... */
478 printf("Retrieval finished on rank %d of %d!\n", rank, size);
479 }
480
481 /* Close file list... */
482 fclose(in);
483
484 /* Measure CPU time... */
485 TIMER("total", 3);
486
487 /* Report memory usage... */
488 printf("MEMORY_ATM = %g MByte\n", 4. * sizeof(atm_t) / 1024. / 1024.);
489 printf("MEMORY_CTL = %g MByte\n", 1. * sizeof(ctl_t) / 1024. / 1024.);
490 printf("MEMORY_NCD = %g MByte\n", 1. * sizeof(ncd_t) / 1024. / 1024.);
491 printf("MEMORY_OBS = %g MByte\n", 3. * sizeof(atm_t) / 1024. / 1024.);
492 printf("MEMORY_RET = %g MByte\n", 1. * sizeof(ret_t) / 1024. / 1024.);
493 printf("MEMORY_TBL = %g MByte\n", 1. * sizeof(tbl_t) / 1024. / 1024.);
494
495 /* Report problem size... */
496 printf("SIZE_TASKS = %d\n", size);
497 printf("SIZE_THREADS = %d\n", omp_get_max_threads());
498
499 /* MPI... */
500 MPI_Finalize();
501
502 return EXIT_SUCCESS;
503}
504
505/*****************************************************************************/
506
508 int ncid,
509 const char *varname,
510 const char *unit,
511 const char *longname,
512 int type,
513 int dimid[],
514 int *varid,
515 int ndims) {
516
517 /* Check if variable exists... */
518 if (nc_inq_varid(ncid, varname, varid) != NC_NOERR) {
519
520 /* Define variable... */
521 NC(nc_def_var(ncid, varname, type, ndims, dimid, varid));
522
523 /* Set long name... */
524 NC(nc_put_att_text
525 (ncid, *varid, "long_name", strlen(longname), longname));
526
527 /* Set units... */
528 NC(nc_put_att_text(ncid, *varid, "units", strlen(unit), unit));
529 }
530}
531
532/*****************************************************************************/
533
535 gsl_vector *dx,
536 gsl_vector *dy,
537 gsl_matrix *s_a_inv,
538 gsl_vector *sig_eps_inv) {
539
540 double chisq_a, chisq_m = 0;
541
542 /* Get sizes... */
543 const size_t m = dy->size;
544 const size_t n = dx->size;
545
546 /* Allocate... */
547 gsl_vector *x_aux = gsl_vector_alloc(n);
548 gsl_vector *y_aux = gsl_vector_alloc(m);
549
550 /* Determine normalized cost function...
551 (chi^2 = 1/m * [dy^T * S_eps^{-1} * dy + dx^T * S_a^{-1} * dx]) */
552 for (size_t i = 0; i < m; i++)
553 chisq_m +=
554 gsl_pow_2(gsl_vector_get(dy, i) * gsl_vector_get(sig_eps_inv, i));
555 gsl_blas_dgemv(CblasNoTrans, 1.0, s_a_inv, dx, 0.0, x_aux);
556 gsl_blas_ddot(dx, x_aux, &chisq_a);
557
558 /* Free... */
559 gsl_vector_free(x_aux);
560 gsl_vector_free(y_aux);
561
562 /* Return cost function value... */
563 return (chisq_m + chisq_a) / (double) m;
564}
565
566/************************************************************************/
567
569 double x[L2_NTRACK][L2_NXTRACK][L2_NLAY],
570 double cx,
571 double cy) {
572
573 double help[L2_NTRACK][L2_NXTRACK];
574
575 /* Loop over layers... */
576 for (int lay = 0; lay < L2_NLAY; lay++) {
577
578 /* Loop over grid points... */
579 for (int track = 0; track < L2_NTRACK; track++)
580 for (int xtrack = 0; xtrack < L2_NXTRACK; xtrack++) {
581
582 /* Init... */
583 help[track][xtrack] = 0;
584 double wsum = 0;
585
586 /* Averrage data points... */
587 for (int track2 = 0; track2 < L2_NTRACK; track2++)
588 for (int xtrack2 = 0; xtrack2 < L2_NXTRACK; xtrack2++)
589 if (gsl_finite(x[track2][xtrack2][lay])
590 && x[track2][xtrack2][lay] > 0) {
591 const double w = exp(-gsl_pow_2((xtrack - xtrack2) / cx)
592 - gsl_pow_2((track - track2) / cy));
593 help[track][xtrack] += w * x[track2][xtrack2][lay];
594 wsum += w;
595 }
596
597 /* Normalize... */
598 if (wsum > 0)
599 help[track][xtrack] /= wsum;
600 else
601 help[track][xtrack] = GSL_NAN;
602 }
603
604 /* Copy grid points... */
605 for (int track = 0; track < L2_NTRACK; track++)
606 for (int xtrack = 0; xtrack < L2_NXTRACK; xtrack++)
607 x[track][xtrack][lay] = help[track][xtrack];
608 }
609}
610
611/************************************************************************/
612
614 ncd_t *ncd,
615 int track,
616 int xtrack,
617 ctl_t *ctl,
618 atm_t *atm) {
619
620 static atm_t atm_airs;
621
622 double k[NW], p, q[NG], t, zmax = 0, zmin = 1000;
623
624 /* Reset track- and xtrack-index to match Level-2 data... */
625 track /= 3;
626 xtrack /= 3;
627
628 /* Store AIRS data in atmospheric data struct... */
629 atm_airs.np = 0;
630 for (int lay = 0; lay < L2_NLAY; lay++)
631 if (gsl_finite(ncd->l2_z[track][xtrack][lay])) {
632 atm_airs.z[atm_airs.np] = ncd->l2_z[track][xtrack][lay];
633 atm_airs.p[atm_airs.np] = ncd->l2_p[lay];
634 atm_airs.t[atm_airs.np] = ncd->l2_t[track][xtrack][lay];
635 if ((++atm_airs.np) > NP)
636 ERRMSG("Too many layers!");
637 }
638
639 /* Check number of levels... */
640 if (atm_airs.np <= 0)
641 return;
642
643 /* Get height range of AIRS data... */
644 for (int ip = 0; ip < atm_airs.np; ip++) {
645 zmax = GSL_MAX(zmax, atm_airs.z[ip]);
646 zmin = GSL_MIN(zmin, atm_airs.z[ip]);
647 }
648
649 /* Merge AIRS data... */
650 for (int ip = 0; ip < atm->np; ip++) {
651
652 /* Interpolate AIRS data... */
653 intpol_atm(ctl, &atm_airs, atm->z[ip], &p, &t, q, k);
654
655 /* Weighting factor... */
656 double w = 1;
657 if (atm->z[ip] > zmax)
658 w = GSL_MAX(1 - (atm->z[ip] - zmax) / 50, 0);
659 if (atm->z[ip] < zmin)
660 w = GSL_MAX(1 - (zmin - atm->z[ip]) / 50, 0);
661
662 /* Merge... */
663 atm->t[ip] = w * t + (1 - w) * atm->t[ip];
664 atm->p[ip] = w * p + (1 - w) * atm->p[ip];
665 }
666}
667
668/*****************************************************************************/
669
671 gsl_matrix *a) {
672
673 size_t diag = 1;
674
675 /* Get size... */
676 const size_t n = a->size1;
677
678 /* Check if matrix is diagonal... */
679 for (size_t i = 0; i < n && diag; i++)
680 for (size_t j = i + 1; j < n; j++)
681 if (gsl_matrix_get(a, i, j) != 0) {
682 diag = 0;
683 break;
684 }
685
686 /* Quick inversion of diagonal matrix... */
687 if (diag)
688 for (size_t i = 0; i < n; i++)
689 gsl_matrix_set(a, i, i, 1 / gsl_matrix_get(a, i, i));
690
691 /* Matrix inversion by means of Cholesky decomposition... */
692 else {
693 gsl_linalg_cholesky_decomp(a);
694 gsl_linalg_cholesky_invert(a);
695 }
696}
697
698/*****************************************************************************/
699
701 gsl_matrix *a,
702 gsl_vector *b,
703 int transpose,
704 gsl_matrix *c) {
705
706 /* Set sizes... */
707 const size_t m = a->size1;
708 const size_t n = a->size2;
709
710 /* Allocate... */
711 gsl_matrix *aux = gsl_matrix_alloc(m, n);
712
713 /* Compute A^T B A... */
714 if (transpose == 1) {
715
716 /* Compute B^1/2 A... */
717 for (size_t i = 0; i < m; i++)
718 for (size_t j = 0; j < n; j++)
719 gsl_matrix_set(aux, i, j,
720 gsl_vector_get(b, i) * gsl_matrix_get(a, i, j));
721
722 /* Compute A^T B A = (B^1/2 A)^T (B^1/2 A)... */
723 gsl_blas_dgemm(CblasTrans, CblasNoTrans, 1.0, aux, aux, 0.0, c);
724 }
725
726 /* Compute A B A^T... */
727 else if (transpose == 2) {
728
729 /* Compute A B^1/2... */
730 for (size_t i = 0; i < m; i++)
731 for (size_t j = 0; j < n; j++)
732 gsl_matrix_set(aux, i, j,
733 gsl_matrix_get(a, i, j) * gsl_vector_get(b, j));
734
735 /* Compute A B A^T = (A B^1/2) (A B^1/2)^T... */
736 gsl_blas_dgemm(CblasNoTrans, CblasTrans, 1.0, aux, aux, 0.0, c);
737 }
738
739 /* Free... */
740 gsl_matrix_free(aux);
741}
742
743/*****************************************************************************/
744
746 ret_t *ret,
747 ctl_t *ctl,
748 obs_t *obs_meas,
749 obs_t *obs_i,
750 atm_t *atm_apr,
751 atm_t *atm_i,
752 double *chisq) {
753
754 static int ipa[N], iqa[N];
755
756 double disq = 0, lmpar = 0.001;
757
758 /* ------------------------------------------------------------
759 Initialize...
760 ------------------------------------------------------------ */
761
762 /* Get sizes... */
763 const size_t m = obs2y(ctl, obs_meas, NULL, NULL, NULL);
764 const size_t n = atm2x(ctl, atm_apr, NULL, iqa, ipa);
765 if (m == 0 || n == 0) {
766 *chisq = GSL_NAN;
767 return;
768 }
769
770 /* Allocate... */
771 gsl_matrix *a = gsl_matrix_alloc(n, n);
772 gsl_matrix *cov = gsl_matrix_alloc(n, n);
773 gsl_matrix *k_i = gsl_matrix_alloc(m, n);
774 gsl_matrix *s_a_inv = gsl_matrix_alloc(n, n);
775
776 gsl_vector *b = gsl_vector_alloc(n);
777 gsl_vector *dx = gsl_vector_alloc(n);
778 gsl_vector *dy = gsl_vector_alloc(m);
779 gsl_vector *sig_eps_inv = gsl_vector_alloc(m);
780 gsl_vector *sig_formod = gsl_vector_alloc(m);
781 gsl_vector *sig_noise = gsl_vector_alloc(m);
782 gsl_vector *x_a = gsl_vector_alloc(n);
783 gsl_vector *x_i = gsl_vector_alloc(n);
784 gsl_vector *x_step = gsl_vector_alloc(n);
785 gsl_vector *y_aux = gsl_vector_alloc(m);
786 gsl_vector *y_i = gsl_vector_alloc(m);
787 gsl_vector *y_m = gsl_vector_alloc(m);
788
789 /* Set initial state... */
790 copy_atm(ctl, atm_i, atm_apr, 0);
791 copy_obs(ctl, obs_i, obs_meas, 0);
792 formod(ctl, atm_i, obs_i);
793
794 /* Set state vectors and observation vectors... */
795 atm2x(ctl, atm_apr, x_a, NULL, NULL);
796 atm2x(ctl, atm_i, x_i, NULL, NULL);
797 obs2y(ctl, obs_meas, y_m, NULL, NULL);
798 obs2y(ctl, obs_i, y_i, NULL, NULL);
799
800 /* Set inverse a priori covariance S_a^-1... */
801 set_cov_apr(ret, ctl, atm_apr, iqa, ipa, s_a_inv);
802 matrix_invert(s_a_inv);
803
804 /* Get measurement errors... */
805 set_cov_meas(ret, ctl, obs_meas, sig_noise, sig_formod, sig_eps_inv);
806
807 /* Determine dx = x_i - x_a and dy = y - F(x_i) ... */
808 gsl_vector_memcpy(dx, x_i);
809 gsl_vector_sub(dx, x_a);
810 gsl_vector_memcpy(dy, y_m);
811 gsl_vector_sub(dy, y_i);
812
813 /* Compute cost function... */
814 *chisq = cost_function(dx, dy, s_a_inv, sig_eps_inv);
815
816 /* Compute initial kernel... */
817 kernel(ctl, atm_i, obs_i, k_i);
818
819 /* ------------------------------------------------------------
820 Levenberg-Marquardt minimization...
821 ------------------------------------------------------------ */
822
823 /* Outer loop... */
824 for (int it = 1; it <= ret->conv_itmax; it++) {
825
826 /* Store current cost function value... */
827 double chisq_old = *chisq;
828
829 /* Compute kernel matrix K_i... */
830 if (it > 1 && it % ret->kernel_recomp == 0)
831 kernel(ctl, atm_i, obs_i, k_i);
832
833 /* Compute K_i^T * S_eps^{-1} * K_i ... */
834 if (it == 1 || it % ret->kernel_recomp == 0)
835 matrix_product(k_i, sig_eps_inv, 1, cov);
836
837 /* Determine b = K_i^T * S_eps^{-1} * dy - S_a^{-1} * dx ... */
838 for (size_t i = 0; i < m; i++)
839 gsl_vector_set(y_aux, i, gsl_vector_get(dy, i)
840 * gsl_pow_2(gsl_vector_get(sig_eps_inv, i)));
841 gsl_blas_dgemv(CblasTrans, 1.0, k_i, y_aux, 0.0, b);
842 gsl_blas_dgemv(CblasNoTrans, -1.0, s_a_inv, dx, 1.0, b);
843
844 /* Inner loop... */
845 for (int it2 = 0; it2 < 20; it2++) {
846
847 /* Compute A = (1 + lmpar) * S_a^{-1} + K_i^T * S_eps^{-1} * K_i ... */
848 gsl_matrix_memcpy(a, s_a_inv);
849 gsl_matrix_scale(a, 1 + lmpar);
850 gsl_matrix_add(a, cov);
851
852 /* Solve A * x_step = b by means of Cholesky decomposition... */
853 gsl_linalg_cholesky_decomp(a);
854 gsl_linalg_cholesky_solve(a, b, x_step);
855
856 /* Update atmospheric state... */
857 gsl_vector_add(x_i, x_step);
858 copy_atm(ctl, atm_i, atm_apr, 0);
859 copy_obs(ctl, obs_i, obs_meas, 0);
860 x2atm(ctl, x_i, atm_i);
861
862 /* Check atmospheric state... */
863 for (int ip = 0; ip < atm_i->np; ip++) {
864 atm_i->p[ip] = GSL_MIN(GSL_MAX(atm_i->p[ip], 5e-7), 5e4);
865 atm_i->t[ip] = GSL_MIN(GSL_MAX(atm_i->t[ip], 100), 400);
866 for (int ig = 0; ig < ctl->ng; ig++)
867 atm_i->q[ig][ip] = GSL_MIN(GSL_MAX(atm_i->q[ig][ip], 0), 1);
868 for (int iw = 0; iw < ctl->nw; iw++)
869 atm_i->k[iw][ip] = GSL_MAX(atm_i->k[iw][ip], 0);
870 }
871
872 /* Forward calculation... */
873 formod(ctl, atm_i, obs_i);
874 obs2y(ctl, obs_i, y_i, NULL, NULL);
875
876 /* Determine dx = x_i - x_a and dy = y - F(x_i) ... */
877 gsl_vector_memcpy(dx, x_i);
878 gsl_vector_sub(dx, x_a);
879 gsl_vector_memcpy(dy, y_m);
880 gsl_vector_sub(dy, y_i);
881
882 /* Compute cost function... */
883 *chisq = cost_function(dx, dy, s_a_inv, sig_eps_inv);
884
885 /* Modify Levenberg-Marquardt parameter... */
886 if (*chisq > chisq_old) {
887 lmpar *= 10;
888 gsl_vector_sub(x_i, x_step);
889 } else {
890 lmpar /= 10;
891 break;
892 }
893 }
894
895 /* Get normalized step size in state space... */
896 gsl_blas_ddot(x_step, b, &disq);
897 disq /= (double) n;
898
899 /* Convergence test... */
900 if ((it == 1 || it % ret->kernel_recomp == 0) && disq < ret->conv_dmin)
901 break;
902 }
903
904 /* ------------------------------------------------------------
905 Finalize...
906 ------------------------------------------------------------ */
907
908 gsl_matrix_free(a);
909 gsl_matrix_free(cov);
910 gsl_matrix_free(k_i);
911 gsl_matrix_free(s_a_inv);
912
913 gsl_vector_free(b);
914 gsl_vector_free(dx);
915 gsl_vector_free(dy);
916 gsl_vector_free(sig_eps_inv);
917 gsl_vector_free(sig_formod);
918 gsl_vector_free(sig_noise);
919 gsl_vector_free(x_a);
920 gsl_vector_free(x_i);
921 gsl_vector_free(x_step);
922 gsl_vector_free(y_aux);
923 gsl_vector_free(y_i);
924 gsl_vector_free(y_m);
925}
926
927/*****************************************************************************/
928
930 char *filename,
931 ncd_t *ncd) {
932
933 int varid;
934
935 /* Open netCDF file... */
936 printf("Read netCDF file: %s\n", filename);
937 NC(nc_open(filename, NC_WRITE, &ncd->ncid));
938
939 /* Read Level-1 data... */
940 NC(nc_inq_varid(ncd->ncid, "l1_time", &varid));
941 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_time[0]));
942 NC(nc_inq_varid(ncd->ncid, "l1_lon", &varid));
943 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_lon[0]));
944 NC(nc_inq_varid(ncd->ncid, "l1_lat", &varid));
945 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_lat[0]));
946 NC(nc_inq_varid(ncd->ncid, "l1_sat_z", &varid));
947 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_sat_z));
948 NC(nc_inq_varid(ncd->ncid, "l1_sat_lon", &varid));
949 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_sat_lon));
950 NC(nc_inq_varid(ncd->ncid, "l1_sat_lat", &varid));
951 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_sat_lat));
952 NC(nc_inq_varid(ncd->ncid, "l1_nu", &varid));
953 NC(nc_get_var_double(ncd->ncid, varid, ncd->l1_nu));
954 NC(nc_inq_varid(ncd->ncid, "l1_rad", &varid));
955 NC(nc_get_var_float(ncd->ncid, varid, ncd->l1_rad[0][0]));
956
957 /* Read Level-2 data... */
958 NC(nc_inq_varid(ncd->ncid, "l2_z", &varid));
959 NC(nc_get_var_double(ncd->ncid, varid, ncd->l2_z[0][0]));
960 NC(nc_inq_varid(ncd->ncid, "l2_press", &varid));
961 NC(nc_get_var_double(ncd->ncid, varid, ncd->l2_p));
962 NC(nc_inq_varid(ncd->ncid, "l2_temp", &varid));
963 NC(nc_get_var_double(ncd->ncid, varid, ncd->l2_t[0][0]));
964}
965
966/*****************************************************************************/
967
969 int argc,
970 char *argv[],
971 ctl_t *ctl,
972 ret_t *ret) {
973
974 /* Iteration control... */
975 ret->kernel_recomp =
976 (int) scan_ctl(argc, argv, "KERNEL_RECOMP", -1, "3", NULL);
977 ret->conv_itmax = (int) scan_ctl(argc, argv, "CONV_ITMAX", -1, "30", NULL);
978 ret->conv_dmin = scan_ctl(argc, argv, "CONV_DMIN", -1, "0.1", NULL);
979
980 for (int id = 0; id < ctl->nd; id++)
981 ret->err_formod[id] = scan_ctl(argc, argv, "ERR_FORMOD", id, "0", NULL);
982
983 for (int id = 0; id < ctl->nd; id++)
984 ret->err_noise[id] = scan_ctl(argc, argv, "ERR_NOISE", id, "0", NULL);
985
986 ret->err_press = scan_ctl(argc, argv, "ERR_PRESS", -1, "0", NULL);
987 ret->err_press_cz = scan_ctl(argc, argv, "ERR_PRESS_CZ", -1, "-999", NULL);
988 ret->err_press_ch = scan_ctl(argc, argv, "ERR_PRESS_CH", -1, "-999", NULL);
989
990 ret->err_temp = scan_ctl(argc, argv, "ERR_TEMP", -1, "0", NULL);
991 ret->err_temp_cz = scan_ctl(argc, argv, "ERR_TEMP_CZ", -1, "-999", NULL);
992 ret->err_temp_ch = scan_ctl(argc, argv, "ERR_TEMP_CH", -1, "-999", NULL);
993
994 for (int ig = 0; ig < ctl->ng; ig++) {
995 ret->err_q[ig] = scan_ctl(argc, argv, "ERR_Q", ig, "0", NULL);
996 ret->err_q_cz[ig] = scan_ctl(argc, argv, "ERR_Q_CZ", ig, "-999", NULL);
997 ret->err_q_ch[ig] = scan_ctl(argc, argv, "ERR_Q_CH", ig, "-999", NULL);
998 }
999
1000 for (int iw = 0; iw < ctl->nw; iw++) {
1001 ret->err_k[iw] = scan_ctl(argc, argv, "ERR_K", iw, "0", NULL);
1002 ret->err_k_cz[iw] = scan_ctl(argc, argv, "ERR_K_CZ", iw, "-999", NULL);
1003 ret->err_k_ch[iw] = scan_ctl(argc, argv, "ERR_K_CH", iw, "-999", NULL);
1004 }
1005}
1006
1007/*****************************************************************************/
1008
1010 ret_t *ret,
1011 ctl_t *ctl,
1012 atm_t *atm,
1013 int *iqa,
1014 int *ipa,
1015 gsl_matrix *s_a) {
1016
1017 /* Get sizes... */
1018 const size_t n = s_a->size1;
1019
1020 /* Allocate... */
1021 gsl_vector *x_a = gsl_vector_alloc(n);
1022
1023 /* Get sigma vector... */
1024 atm2x(ctl, atm, x_a, NULL, NULL);
1025 for (size_t i = 0; i < n; i++) {
1026 if (iqa[i] == IDXP)
1027 gsl_vector_set(x_a, i, ret->err_press / 100 * gsl_vector_get(x_a, i));
1028 if (iqa[i] == IDXT)
1029 gsl_vector_set(x_a, i, ret->err_temp);
1030 for (int ig = 0; ig < ctl->ng; ig++)
1031 if (iqa[i] == IDXQ(ig))
1032 gsl_vector_set(x_a, i, ret->err_q[ig] / 100 * gsl_vector_get(x_a, i));
1033 for (int iw = 0; iw < ctl->nw; iw++)
1034 if (iqa[i] == IDXK(iw))
1035 gsl_vector_set(x_a, i, ret->err_k[iw]);
1036 }
1037
1038 /* Check standard deviations... */
1039 for (size_t i = 0; i < n; i++)
1040 if (gsl_pow_2(gsl_vector_get(x_a, i)) <= 0)
1041 ERRMSG("Check a priori data (zero standard deviation)!");
1042
1043 /* Initialize diagonal covariance... */
1044 gsl_matrix_set_zero(s_a);
1045 for (size_t i = 0; i < n; i++)
1046 gsl_matrix_set(s_a, i, i, gsl_pow_2(gsl_vector_get(x_a, i)));
1047
1048 /* Loop over matrix elements... */
1049 for (size_t i = 0; i < n; i++)
1050 for (size_t j = 0; j < n; j++)
1051 if (i != j && iqa[i] == iqa[j]) {
1052
1053 /* Initialize... */
1054 double cz = 0, ch = 0;
1055
1056 /* Set correlation lengths for pressure... */
1057 if (iqa[i] == IDXP) {
1058 cz = ret->err_press_cz;
1059 ch = ret->err_press_ch;
1060 }
1061
1062 /* Set correlation lengths for temperature... */
1063 if (iqa[i] == IDXT) {
1064 cz = ret->err_temp_cz;
1065 ch = ret->err_temp_ch;
1066 }
1067
1068 /* Set correlation lengths for volume mixing ratios... */
1069 for (int ig = 0; ig < ctl->ng; ig++)
1070 if (iqa[i] == IDXQ(ig)) {
1071 cz = ret->err_q_cz[ig];
1072 ch = ret->err_q_ch[ig];
1073 }
1074
1075 /* Set correlation lengths for extinction... */
1076 for (int iw = 0; iw < ctl->nw; iw++)
1077 if (iqa[i] == IDXK(iw)) {
1078 cz = ret->err_k_cz[iw];
1079 ch = ret->err_k_ch[iw];
1080 }
1081
1082 /* Compute correlations... */
1083 if (cz > 0 && ch > 0) {
1084
1085 /* Get Cartesian coordinates... */
1086 double x0[3], x1[3];
1087 geo2cart(0, atm->lon[ipa[i]], atm->lat[ipa[i]], x0);
1088 geo2cart(0, atm->lon[ipa[j]], atm->lat[ipa[j]], x1);
1089
1090 /* Compute correlations... */
1091 const double rho =
1092 exp(-DIST(x0, x1) / ch -
1093 fabs(atm->z[ipa[i]] - atm->z[ipa[j]]) / cz);
1094
1095 /* Set covariance... */
1096 gsl_matrix_set(s_a, i, j, gsl_vector_get(x_a, i)
1097 * gsl_vector_get(x_a, j) * rho);
1098 }
1099 }
1100
1101 /* Free... */
1102 gsl_vector_free(x_a);
1103}
1104
1105/*****************************************************************************/
1106
1108 ret_t *ret,
1109 ctl_t *ctl,
1110 obs_t *obs,
1111 gsl_vector *sig_noise,
1112 gsl_vector *sig_formod,
1113 gsl_vector *sig_eps_inv) {
1114
1115 static obs_t obs_err;
1116
1117 /* Get size... */
1118 const size_t m = sig_eps_inv->size;
1119
1120 /* Noise error (always considered in retrieval fit)... */
1121 copy_obs(ctl, &obs_err, obs, 1);
1122 for (int ir = 0; ir < obs_err.nr; ir++)
1123 for (int id = 0; id < ctl->nd; id++)
1124 obs_err.rad[id][ir]
1125 = (gsl_finite(obs->rad[id][ir]) ? ret->err_noise[id] : GSL_NAN);
1126 obs2y(ctl, &obs_err, sig_noise, NULL, NULL);
1127
1128 /* Forward model error (always considered in retrieval fit)... */
1129 copy_obs(ctl, &obs_err, obs, 1);
1130 for (int ir = 0; ir < obs_err.nr; ir++)
1131 for (int id = 0; id < ctl->nd; id++)
1132 obs_err.rad[id][ir]
1133 = fabs(ret->err_formod[id] / 100 * obs->rad[id][ir]);
1134 obs2y(ctl, &obs_err, sig_formod, NULL, NULL);
1135
1136 /* Total error... */
1137 for (size_t i = 0; i < m; i++)
1138 gsl_vector_set(sig_eps_inv, i,
1139 1 / sqrt(gsl_pow_2(gsl_vector_get(sig_noise, i))
1140 + gsl_pow_2(gsl_vector_get(sig_formod, i))));
1141
1142 /* Check standard deviations... */
1143 for (size_t i = 0; i < m; i++)
1144 if (gsl_vector_get(sig_eps_inv, i) <= 0)
1145 ERRMSG("Check measurement errors (zero standard deviation)!");
1146}
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read forward model control parameters.
Definition: jurassic.c:4547
void x2atm(const ctl_t *ctl, const gsl_vector *x, atm_t *atm)
Decompose parameter vector or state vector.
Definition: jurassic.c:5896
void intpol_atm(const ctl_t *ctl, const atm_t *atm, const double z, double *p, double *t, double *q, double *k)
Interpolate atmospheric data.
Definition: jurassic.c:3685
double sza(const double sec, const double lon, const double lat)
Calculate solar zenith angle.
Definition: jurassic.c:5183
void formod(const ctl_t *ctl, atm_t *atm, obs_t *obs)
Determine ray paths and compute radiative transfer.
Definition: jurassic.c:3026
void copy_obs(const ctl_t *ctl, obs_t *obs_dest, const obs_t *obs_src, const int init)
Copy and initialize observation data.
Definition: jurassic.c:2975
double scan_ctl(int argc, char *argv[], const char *varname, int arridx, const char *defvalue, char *value)
Search control parameter file for variable entry.
Definition: jurassic.c:5114
void copy_atm(const ctl_t *ctl, atm_t *atm_dest, const atm_t *atm_src, const int init)
Copy and initialize atmospheric data.
Definition: jurassic.c:2921
size_t obs2y(const ctl_t *ctl, const obs_t *obs, gsl_vector *y, int *ida, int *ira)
Compose measurement vector.
Definition: jurassic.c:4174
size_t atm2x(const ctl_t *ctl, const atm_t *atm, gsl_vector *x, int *iqa, int *ipa)
Compose state vector or parameter vector.
Definition: jurassic.c:29
void climatology(const ctl_t *ctl, atm_t *atm)
Interpolate climatological data.
Definition: jurassic.c:123
void geo2cart(const double z, const double lon, const double lat, double *x)
Convert geolocation to Cartesian coordinates.
Definition: jurassic.c:3500
void kernel(ctl_t *ctl, atm_t *atm, obs_t *obs, gsl_matrix *k)
Compute Jacobians.
Definition: jurassic.c:4004
JURASSIC library declarations.
#define N
Maximum size of state vector.
Definition: jurassic.h:393
#define LEN
Maximum length of ASCII data lines.
Definition: jurassic.h:383
#define BRIGHT(rad, nu)
Compute brightness temperature.
Definition: jurassic.h:126
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
#define IDXK(iw)
Indices for extinction.
Definition: jurassic.h:460
#define ND
Maximum number of radiance channels.
Definition: jurassic.h:353
#define TIMER(name, mode)
Start or stop a timer.
Definition: jurassic.h:201
#define IDXP
Index for pressure.
Definition: jurassic.h:451
#define NP
Maximum number of atmospheric data points.
Definition: jurassic.h:363
#define NG
Maximum number of emitters.
Definition: jurassic.h:358
#define DIST(a, b)
Compute Cartesian distance between two vectors.
Definition: jurassic.h:134
#define IDXQ(ig)
Indices for volume mixing ratios.
Definition: jurassic.h:457
#define NW
Maximum number of spectral windows.
Definition: jurassic.h:378
#define IDXT
Index for temperature.
Definition: jurassic.h:454
void matrix_product(gsl_matrix *a, gsl_vector *b, int transpose, gsl_matrix *c)
Compute matrix product A^TBA or ABA^T for diagonal matrix B.
Definition: nlte.c:700
int main(int argc, char *argv[])
Definition: nlte.c:268
#define NC(cmd)
Execute netCDF library command and check result.
Definition: nlte.c:36
void set_cov_apr(ret_t *ret, ctl_t *ctl, atm_t *atm, int *iqa, int *ipa, gsl_matrix *s_a)
Set a priori covariance.
Definition: nlte.c:1009
void optimal_estimation(ret_t *ret, ctl_t *ctl, obs_t *obs_meas, obs_t *obs_i, atm_t *atm_apr, atm_t *atm_i, double *chisq)
Carry out optimal estimation retrieval.
Definition: nlte.c:745
void fill_gaps(double x[L2_NTRACK][L2_NXTRACK][L2_NLAY], double cx, double cy)
Fill data gaps in L2 data.
Definition: nlte.c:568
#define L1_NXTRACK
Across-track size of AIRS radiance granule (don't change).
Definition: nlte.c:53
#define L1_NTRACK
Along-track size of AIRS radiance granule (don't change).
Definition: nlte.c:50
#define L2_NXTRACK
Across-track size of AIRS retrieval granule (don't change).
Definition: nlte.c:62
void read_nc(char *filename, ncd_t *ncd)
Read netCDF file.
Definition: nlte.c:929
void add_var(int ncid, const char *varname, const char *unit, const char *longname, int type, int dimid[], int *varid, int ndims)
Create variable in netCDF file.
Definition: nlte.c:507
#define L2_NLAY
Number of AIRS pressure layers (don't change).
Definition: nlte.c:56
void set_cov_meas(ret_t *ret, ctl_t *ctl, obs_t *obs, gsl_vector *sig_noise, gsl_vector *sig_formod, gsl_vector *sig_eps_inv)
Set measurement errors.
Definition: nlte.c:1107
void read_ret_ctl(int argc, char *argv[], ctl_t *ctl, ret_t *ret)
Read retrieval control parameters.
Definition: nlte.c:968
void matrix_invert(gsl_matrix *a)
Invert symmetric matrix.
Definition: nlte.c:670
#define L1_NCHAN
Number of AIRS radiance channels (don't change).
Definition: nlte.c:47
#define L2_NTRACK
Along-track size of AIRS retrieval granule (don't change).
Definition: nlte.c:59
double cost_function(gsl_vector *dx, gsl_vector *dy, gsl_matrix *s_a_inv, gsl_vector *sig_eps_inv)
Compute cost function.
Definition: nlte.c:534
void init_l2(ncd_t *ncd, int track, int xtrack, ctl_t *ctl, atm_t *atm)
Initialize with AIRS Level-2 data.
Definition: nlte.c:613
Atmospheric data.
Definition: jurassic.h:488
double time[NP]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:494
double k[NW][NP]
Extinction [km^-1].
Definition: jurassic.h:515
double lat[NP]
Latitude [deg].
Definition: jurassic.h:503
double lon[NP]
Longitude [deg].
Definition: jurassic.h:500
double t[NP]
Temperature [K].
Definition: jurassic.h:509
int np
Number of data points.
Definition: jurassic.h:491
double z[NP]
Altitude [km].
Definition: jurassic.h:497
double q[NG][NP]
Volume mixing ratio [ppv].
Definition: jurassic.h:512
double p[NP]
Pressure [hPa].
Definition: jurassic.h:506
Forward model control parameters.
Definition: jurassic.h:541
int nw
Number of spectral windows.
Definition: jurassic.h:556
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
Definition: jurassic.h:553
int ng
Number of emitters.
Definition: jurassic.h:544
int nd
Number of radiance channels.
Definition: jurassic.h:550
Buffer for netCDF data.
Definition: diff_apr.c:68
double l1_lat[L1_NTRACK][L1_NXTRACK]
Footprint latitude [deg].
Definition: diff_apr.c:83
double l1_lon[L1_NTRACK][L1_NXTRACK]
Footprint longitude [deg].
Definition: diff_apr.c:80
double l2_z[L2_NTRACK][L2_NXTRACK][L2_NLAY]
Altitude [km].
Definition: diff_apr.c:101
double l1_sat_lat[L1_NTRACK]
Satellite latitude [deg].
Definition: diff_apr.c:92
int ncid
NetCDF file ID.
Definition: diff_apr.c:71
double l1_sat_lon[L1_NTRACK]
Satellite longitude [deg].
Definition: diff_apr.c:89
double l2_p[L2_NLAY]
Pressure [hPa].
Definition: diff_apr.c:104
double l2_t[L2_NTRACK][L2_NXTRACK][L2_NLAY]
Temperature [K].
Definition: diff_apr.c:107
double l1_nu[L1_NCHAN]
Channel frequencies [cm^-1].
Definition: diff_apr.c:95
double l1_sat_z[L1_NTRACK]
Satellite altitude [km].
Definition: diff_apr.c:86
float l1_rad[L1_NTRACK][L1_NXTRACK][L1_NCHAN]
Radiance [W/(m^2 sr cm^-1)].
Definition: diff_apr.c:98
double l1_time[L1_NTRACK][L1_NXTRACK]
Time (seconds since 2000-01-01T00:00Z).
Definition: diff_apr.c:77
Observation geometry and radiance data.
Definition: jurassic.h:734
double rad[ND][NR]
Radiance [W/(m^2 sr cm^-1)].
Definition: jurassic.h:773
double vplat[NR]
View point latitude [deg].
Definition: jurassic.h:758
double obslon[NR]
Observer longitude [deg].
Definition: jurassic.h:746
double obslat[NR]
Observer latitude [deg].
Definition: jurassic.h:749
double obsz[NR]
Observer altitude [km].
Definition: jurassic.h:743
double vplon[NR]
View point longitude [deg].
Definition: jurassic.h:755
double time[NR]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:740
int nr
Number of ray paths.
Definition: jurassic.h:737
Retrieval results.
Definition: libairs.h:237
double err_k_ch[NW]
Horizontal correlation length for extinction error [km].
Definition: nlte.c:173
double err_press_cz
Vertical correlation length for pressure error [km].
Definition: nlte.c:143
double err_k_cz[NW]
Vertical correlation length for extinction error [km].
Definition: nlte.c:170
double err_press
Pressure error [%].
Definition: nlte.c:140
double err_q_ch[NG]
Horizontal correlation length for volume mixing ratio error [km].
Definition: nlte.c:164
double err_noise[ND]
Noise error [W/(m^2 sr cm^-1)].
Definition: nlte.c:137
double err_formod[ND]
Forward model error [%].
Definition: nlte.c:134
double err_q_cz[NG]
Vertical correlation length for volume mixing ratio error [km].
Definition: nlte.c:161
double err_temp_cz
Vertical correlation length for temperature error [km].
Definition: nlte.c:152
double conv_dmin
Minimum normalized step size in state space.
Definition: nlte.c:131
double err_temp
Temperature error [K].
Definition: nlte.c:149
double err_temp_ch
Horizontal correlation length for temperature error [km].
Definition: nlte.c:155
int kernel_recomp
Recomputation of kernel matrix (number of iterations).
Definition: nlte.c:125
int conv_itmax
Maximum number of iterations.
Definition: nlte.c:128
double err_press_ch
Horizontal correlation length for pressure error [km].
Definition: nlte.c:146
double err_q[NG]
Volume mixing ratio error [%].
Definition: nlte.c:158
double err_k[NW]
Extinction error [1/km].
Definition: nlte.c:167
Emissivity look-up tables.
Definition: jurassic.h:778