JURASSIC
jurassic.h
Go to the documentation of this file.
1/*
2 This file is part of JURASSIC.
3
4 JURASSIC is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 JURASSIC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with JURASSIC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2003-2026 Forschungszentrum Juelich GmbH
18*/
19
133#ifndef JURASSIC_H
134#define JURASSIC_H
135
136/* ------------------------------------------------------------
137 Includes...
138 ------------------------------------------------------------ */
139
140#include <errno.h>
141#include <fcntl.h>
142#include <gsl/gsl_math.h>
143#include <gsl/gsl_blas.h>
144#include <gsl/gsl_linalg.h>
145#include <gsl/gsl_randist.h>
146#include <gsl/gsl_rng.h>
147#include <gsl/gsl_statistics.h>
148#include <math.h>
149#include <netcdf.h>
150#include <omp.h>
151#include <stdint.h>
152#include <stdio.h>
153#include <stdlib.h>
154#include <string.h>
155#include <time.h>
156#include <unistd.h>
157
158/* ------------------------------------------------------------
159 Constants...
160 ------------------------------------------------------------ */
161
163#ifndef C1
164#define C1 1.19104259e-8
165#endif
166
168#ifndef C2
169#define C2 1.43877506
170#endif
171
173#ifndef EPSMIN
174#define EPSMIN 0
175#endif
176
178#ifndef EPSMAX
179#define EPSMAX 1
180#endif
181
183#ifndef G0
184#define G0 9.80665
185#endif
186
188#ifndef H0
189#define H0 7.0
190#endif
191
193#ifndef KB
194#define KB 1.3806504e-23
195#endif
196
198#ifndef ME
199#define ME 5.976e24
200#endif
201
203#ifndef NA
204#define NA 6.02214199e23
205#endif
206
208#ifndef N2
209#define N2 0.78084
210#endif
211
213#ifndef O2
214#define O2 0.20946
215#endif
216
218#ifndef P0
219#define P0 1013.25
220#endif
221
223#ifndef RE
224#define RE 6367.421
225#endif
226
228#ifndef RI
229#define RI 8.3144598
230#endif
231
233#ifndef T0
234#define T0 273.15
235#endif
236
238#ifndef TMAX
239#define TMAX 400.
240#endif
241
243#ifndef TMIN
244#define TMIN 100.
245#endif
246
248#ifndef TSUN
249#define TSUN 5780.
250#endif
251
253#ifndef UMIN
254#define UMIN 0
255#endif
256
258#ifndef UMAX
259#define UMAX 1e30
260#endif
261
262/* ------------------------------------------------------------
263 Dimensions...
264 ------------------------------------------------------------ */
265
267#ifndef LEN
268#define LEN 10000
269#endif
270
272#ifndef M
273#define M (NR*ND)
274#endif
275
277#ifndef N
278#define N ((2 + NG + NW) * NP + NCL + NSF + 3)
279#endif
280
282#ifndef NCL
283#define NCL 8
284#endif
285
287#ifndef ND
288#define ND 128
289#endif
290
292#ifndef NFOV
293#define NFOV 5
294#endif
295
297#ifndef NG
298#define NG 8
299#endif
300
302#ifndef NLOS
303#define NLOS 4096
304#endif
305
307#ifndef NP
308#define NP 256
309#endif
310
312#ifndef NQ
313#define NQ (5 + NG + NW + NCL + NSF)
314#endif
315
317#ifndef NR
318#define NR 256
319#endif
320
322#ifndef NSF
323#define NSF 8
324#endif
325
327#ifndef NSHAPE
328#define NSHAPE 20000
329#endif
330
332#ifndef NTIMER
333#define NTIMER 100
334#endif
335
337#ifndef NW
338#define NW 4
339#endif
340
342#ifndef RFMNPTS
343#define RFMNPTS 10000000
344#endif
345
347#ifndef TBLNP
348#define TBLNP 41
349#endif
350
352#ifndef TBLNS
353#define TBLNS 1200
354#endif
355
357#ifndef TBLNT
358#define TBLNT 30
359#endif
360
362#ifndef TBLNU
363#define TBLNU 512
364#endif
365
366/* ------------------------------------------------------------
367 Quantity indices...
368 ------------------------------------------------------------ */
369
371#define IDXP 0
372
374#define IDXT 1
375
377#define IDXQ(ig) (2 + (ig))
378
380#define IDXK(iw) (2 + (ctl->ng) + (iw))
381
383#define IDXCLZ (2 + (ctl->ng) + (ctl->nw))
384
386#define IDXCLDZ (3 + (ctl->ng) + (ctl->nw))
387
389#define IDXCLK(icl) (4 + (ctl->ng) + (ctl->nw) + (icl))
390
392#define IDXSFT (4 + (ctl->ng) + (ctl->nw) + (ctl->ncl))
393
395#define IDXSFEPS(isf) (5 + (ctl->ng) + (ctl->nw) + (ctl->ncl) + (isf))
396
397/* ------------------------------------------------------------
398 Macros...
399 ------------------------------------------------------------ */
400
418#define ALLOC(ptr, type, n) \
419 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
420 ERRMSG("Out of memory!");
421
448#define BRIGHT(rad, nu) \
449 (C2 * (nu) / gsl_log1p(C1 * POW3(nu) / (rad)))
450
470#define CLAMP(v, lo, hi) \
471 (((v) < (lo)) ? (lo) : (((v) > (hi)) ? (hi) : (v)))
472
485#define CO2_FIT(TIME) \
486 (373.87884731310215e-6 \
487 + 1.9021498612395775e-6 * (((TIME) - 94694400.) / 31557600.) \
488 + 0.016490044598136553e-6 \
489 * POW2((((TIME) - 94694400.) / 31557600.)))
490
505#define DEG2RAD(deg) ((deg) * (M_PI / 180.0))
506
523#define DIST(a, b) sqrt(DIST2(a, b))
524
540#define DIST2(a, b) \
541 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
542
558#define DOTP(a, b) (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
559
578#define FREAD(ptr, type, size, out) { \
579 if(fread(ptr, sizeof(type), size, out)!=size) \
580 ERRMSG("Error while reading!"); \
581 }
582
601#define FWRITE(ptr, type, size, out) { \
602 if(fwrite(ptr, sizeof(type), size, out)!=size) \
603 ERRMSG("Error while writing!"); \
604 }
605
624#define LIN(x0, y0, x1, y1, x) \
625 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
626
645#define LOGY(x0, y0, x1, y1, x) \
646 (((y1)/(y0)>0) \
647 ? ((y0)*exp(log((y1)/(y0))/((x1)-(x0))*((x)-(x0)))) \
648 : LIN(x0, y0, x1, y1, x))
649
666#define MAX(a,b) (((a)>(b))?(a):(b))
667
684#define MIN(a,b) (((a)<(b))?(a):(b))
685
697#define NC(cmd) { \
698 int nc_result=(cmd); \
699 if(nc_result!=NC_NOERR) \
700 ERRMSG("%s", nc_strerror(nc_result)); \
701 }
702
727#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units, level, quant) { \
728 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
729 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
730 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
731 NC_DEF_VAR_QUANTIZE(quant); \
732 if((level) != 0) { \
733 NC(nc_def_var_deflate(ncid, varid, 1, 1, level)); \
734 /* unsigned int ulevel = (unsigned int)level; */ \
735 /* NC(nc_def_var_filter(ncid, varid, 32015, 1, (unsigned int[]){ulevel})); */ \
736 } \
737 }
738
750#ifdef NC_QUANTIZE_GRANULARBR
751#define NC_DEF_VAR_QUANTIZE(quant) do { \
752 if((quant) > 0) \
753 NC(nc_def_var_quantize(ncid, varid, NC_QUANTIZE_GRANULARBR, quant)); \
754 } while(0)
755#else
756#define NC_DEF_VAR_QUANTIZE(quant) do { \
757 if((quant) > 0) \
758 ERRMSG("NetCDF quantization is not supported by this NetCDF version"); \
759 } while(0)
760#endif
761
779#define NC_GET_DOUBLE(varname, ptr, force) { \
780 if(force) { \
781 NC(nc_inq_varid(ncid, varname, &varid)); \
782 NC(nc_get_var_double(ncid, varid, ptr)); \
783 } else { \
784 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
785 NC(nc_get_var_double(ncid, varid, ptr)); \
786 } else \
787 WARN("netCDF variable %s is missing!", varname); \
788 } \
789 }
790
808#define NC_INQ_DIM(dimname, ptr, min, max, check) { \
809 int dimid; size_t naux; \
810 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
811 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
812 *ptr = (int)naux; \
813 if (check) \
814 if ((*ptr) < (min) || (*ptr) > (max)) \
815 ERRMSG("Dimension %s is out of range!", dimname); \
816 }
817
832#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
833 NC(nc_inq_varid(ncid, varname, &varid)); \
834 if(hyperslab) { \
835 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
836 } else { \
837 NC(nc_put_var_double(ncid, varid, ptr)); \
838 } \
839 }
840
856#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
857 NC(nc_inq_varid(ncid, varname, &varid)); \
858 if(hyperslab) { \
859 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
860 } else { \
861 NC(nc_put_var_float(ncid, varid, ptr)); \
862 } \
863 }
864
879#define NC_PUT_INT(varname, ptr, hyperslab) { \
880 NC(nc_inq_varid(ncid, varname, &varid)); \
881 if(hyperslab) { \
882 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
883 } else { \
884 NC(nc_put_var_int(ncid, varid, ptr)); \
885 } \
886 }
887
901#define NC_PUT_ATT(varname, attname, text) { \
902 NC(nc_inq_varid(ncid, varname, &varid)); \
903 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
904 }
905
918#define NC_PUT_ATT_GLOBAL(attname, text) \
919 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
920
950#define NEDT(t_bg, nesr, nu) \
951 (BRIGHT(PLANCK((t_bg), (nu)) + (nesr), (nu)) - (t_bg))
952
979#define NESR(t_bg, nedt, nu) \
980 (PLANCK((t_bg) + (nedt), (nu)) - PLANCK((t_bg), (nu)))
981
996#define NORM(a) sqrt(DOTP(a, a))
997
1027#define PLANCK(T, nu) \
1028 (C1 * POW3(nu) / gsl_expm1(C2 * (nu) / (T)))
1029
1041#define POW2(x) ((x)*(x))
1042
1054#define POW3(x) ((x)*(x)*(x))
1055
1070#define RAD2DEG(rad) ((rad) * (180.0 / M_PI))
1071
1100#define REFRAC_SW53(p, T, h2o) \
1101 (1e-6 * (77.6 * (p) / (T) + 3.73e5 * (h2o) * (p) / ((T) * (T))))
1102
1127#define REFRAC_EDLEN(p, T) \
1128 ((1e-8 \
1129 * (8342.54 + 2406147.0 / (130.0 - 1.0 / (10.0 * 10.0)) \
1130 + 15998.0 / (38.9 - 1.0 / (10.0 * 10.0)))) \
1131 * ((p) / 1013.25) * (288.15 / (T)))
1132
1147#define TBL_LOG(tbl, id, ig) \
1148 do { \
1149 for (int ip = 0; ip < (tbl)->np[(id)][(ig)]; ip++) \
1150 LOG(2, \
1151 "p[%2d]= %.5e hPa | T[0:%2d]= %.2f ... %.2f K | " \
1152 "u[0:%3d]= %.5e ... %.5e molec/cm^2 | " \
1153 "eps[0:%3d]= %.5e ... %.5e", \
1154 (ip), \
1155 (tbl)->p[(id)][(ig)][(ip)], \
1156 (tbl)->nt[(id)][(ig)][(ip)] - 1, \
1157 (tbl)->t[(id)][(ig)][(ip)][0], \
1158 (tbl)->t[(id)][(ig)][(ip)] \
1159 [(tbl)->nt[(id)][(ig)][(ip)] - 1], \
1160 (tbl)->nu[(id)][(ig)][(ip)][0] - 1, \
1161 exp((tbl)->logu[(id)][(ig)][(ip)][0][0]), \
1162 exp((tbl)->logu[(id)][(ig)][(ip)][0] \
1163 [(tbl)->nu[(id)][(ig)][(ip)][0] - 1]), \
1164 (tbl)->nu[(id)][(ig)][(ip)][0] - 1, \
1165 exp((tbl)->logeps[(id)][(ig)][(ip)][0][0]), \
1166 exp((tbl)->logeps[(id)][(ig)][(ip)][0] \
1167 [(tbl)->nu[(id)][(ig)][(ip)][0] - 1])); \
1168 } while (0)
1169
1181#define SELECT_TIMER(id, group) \
1182 {timer_group(id, group, 0);}
1183
1191#define PRINT_TIMERS \
1192 {timer_group("END", "END", 1);}
1193
1212#define TOK(line, tok, format, var) { \
1213 if(((tok)=strtok((line), " \t"))) { \
1214 if(sscanf(tok, format, &(var))!=1) continue; \
1215 } else ERRMSG("Error while reading!"); \
1216 }
1217
1229#define USAGE \
1230 do { \
1231 int iusage; \
1232 for (iusage = 1; iusage < argc; iusage++) \
1233 if (!strcmp(argv[iusage], "-h") \
1234 || !strcmp(argv[iusage], "--help")) { \
1235 usage(); \
1236 return EXIT_SUCCESS; \
1237 } \
1238 } while (0)
1239
1240/* ------------------------------------------------------------
1241 Log messages...
1242 ------------------------------------------------------------ */
1243
1245#ifndef LOGLEV
1246#define LOGLEV 2
1247#endif
1248
1278#define LOG(level, ...) { \
1279 if(level >= 2) \
1280 printf(" "); \
1281 if(level <= LOGLEV) { \
1282 printf(__VA_ARGS__); \
1283 printf("\n"); \
1284 } \
1285 }
1286
1315#define WARN(...) { \
1316 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
1317 LOG(0, __VA_ARGS__); \
1318 }
1319
1348#define ERRMSG(...) { \
1349 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
1350 LOG(0, __VA_ARGS__); \
1351 exit(EXIT_FAILURE); \
1352 }
1353
1383#define PRINT(format, var) \
1384 printf("Print (%s, %s, l%d): %s= "format"\n", \
1385 __FILE__, __func__, __LINE__, #var, var);
1386
1387/* ------------------------------------------------------------
1388 Structs...
1389 ------------------------------------------------------------ */
1390
1398typedef struct {
1399
1401 int np;
1402
1404 double time[NP];
1405
1407 double z[NP];
1408
1410 double lon[NP];
1411
1413 double lat[NP];
1414
1416 double p[NP];
1417
1419 double t[NP];
1420
1422 double q[NG][NP];
1423
1425 double k[NW][NP];
1426
1428 double clz;
1429
1431 double cldz;
1432
1434 double clk[NCL];
1435
1437 double sft;
1438
1440 double sfeps[NSF];
1441
1442} atm_t;
1443
1451typedef struct {
1452
1454 int ng;
1455
1457 char emitter[NG][LEN];
1458
1461
1464
1467
1470
1472 int nd;
1473
1475 double nu[ND];
1476
1478 int nw;
1479
1481 int window[ND];
1482
1484 int ncl;
1485
1487 double clnu[NCL];
1488
1490 int nsf;
1491
1493 double sfnu[NSF];
1494
1497
1499 double sfsza;
1500
1502 char tblbase[LEN];
1503
1506
1509
1512
1515
1517 double hydz;
1518
1521
1524
1527
1530
1533
1535 double rayds;
1536
1538 double raydz;
1539
1541 char fov[LEN];
1542
1544 double fov_dz[NSHAPE];
1545
1547 double fov_w[NSHAPE];
1548
1551
1554
1557
1560
1563
1565 double retq_zmin[NG];
1566
1568 double retq_zmax[NG];
1569
1571 double retk_zmin[NW];
1572
1574 double retk_zmax[NW];
1575
1578
1581
1584
1587
1590
1593
1596
1599
1601 char rfmbin[LEN];
1602
1604 char rfmhit[LEN];
1605
1607 char rfmxsc[NG][LEN];
1608
1609} ctl_t;
1610
1618typedef struct {
1619
1621 int np;
1622
1624 double z[NLOS];
1625
1627 double lon[NLOS];
1628
1630 double lat[NLOS];
1631
1633 double p[NLOS];
1634
1636 double t[NLOS];
1637
1639 double q[NLOS][NG];
1640
1642 double k[NLOS][ND];
1643
1645 double sft;
1646
1648 double sfeps[ND];
1649
1651 double ds[NLOS];
1652
1654 double u[NLOS][NG];
1655
1657 double cgp[NLOS][NG];
1658
1660 double cgt[NLOS][NG];
1661
1663 double cgu[NLOS][NG];
1664
1666 double eps[NLOS][ND];
1667
1669 double src[NLOS][ND];
1670
1671} los_t;
1672
1680typedef struct {
1681
1683 int nr;
1684
1686 double time[NR];
1687
1689 double obsz[NR];
1690
1692 double obslon[NR];
1693
1695 double obslat[NR];
1696
1698 double vpz[NR];
1699
1701 double vplon[NR];
1702
1704 double vplat[NR];
1705
1707 double tpz[NR];
1708
1710 double tplon[NR];
1711
1713 double tplat[NR];
1714
1716 double tau[ND][NR];
1717
1719 double rad[ND][NR];
1720
1721} obs_t;
1722
1732typedef struct {
1733
1735 char dir[LEN];
1736
1739
1742
1745
1748
1750 double err_formod[ND];
1751
1753 double err_noise[ND];
1754
1757
1760
1763
1765 double err_temp;
1766
1769
1772
1774 double err_q[NG];
1775
1777 double err_q_cz[NG];
1778
1780 double err_q_ch[NG];
1781
1783 double err_k[NW];
1784
1786 double err_k_cz[NW];
1787
1789 double err_k_ch[NW];
1790
1792 double err_clz;
1793
1795 double err_cldz;
1796
1798 double err_clk[NCL];
1799
1801 double err_sft;
1802
1804 double err_sfeps[NSF];
1805
1808
1810 char shared_io_proflist[LEN];
1811
1813 char shared_io_atm_apr_file[LEN];
1814
1816 char shared_io_obs_meas_file[LEN];
1817
1819 char shared_io_atm_final_file[LEN];
1820
1822 char shared_io_obs_final_file[LEN];
1823
1825 char shared_io_matrix_cov_apr_file[LEN];
1826
1828 char shared_io_matrix_kernel_file[LEN];
1829
1831 char shared_io_matrix_cov_ret_file[LEN];
1832
1834 char shared_io_matrix_corr_file[LEN];
1835
1837 char shared_io_matrix_gain_file[LEN];
1838
1840 char shared_io_matrix_avk_file[LEN];
1841
1843 char shared_io_atm_err_total_file[LEN];
1844
1846 char shared_io_atm_err_noise_file[LEN];
1847
1849 char shared_io_atm_err_formod_file[LEN];
1850
1852 char shared_io_atm_cont_file[LEN];
1853
1855 char shared_io_atm_res_file[LEN];
1856
1857} ret_t;
1858
1865typedef struct {
1866
1868 int np[ND][NG];
1869
1871 int nt[ND][NG][TBLNP];
1872
1874 int nu[ND][NG][TBLNP][TBLNT];
1875
1877 double p[ND][NG][TBLNP];
1878
1880 double lnp[ND][NG][TBLNP];
1881
1883 double t[ND][NG][TBLNP][TBLNT];
1884
1886 float *logu[ND][NG][TBLNP][TBLNT];
1887
1889 float *logeps[ND][NG][TBLNP][TBLNT];
1890
1892 int filt_n[ND];
1893
1895 double filt_nu[ND][NSHAPE];
1896
1898 double filt_f[ND][NSHAPE];
1899
1901 double st[TBLNS];
1902
1904 double sr[TBLNS][ND];
1905
1906} tbl_t;
1907
1908/* ------------------------------------------------------------
1909 Functions...
1910 ------------------------------------------------------------ */
1911
1963void analyze_avk(
1964 const ret_t * ret,
1965 const ctl_t * ctl,
1966 const atm_t * atm,
1967 const int *iqa,
1968 const int *ipa,
1969 const gsl_matrix * avk);
1970
2027 const gsl_matrix * avk,
2028 const int iq,
2029 const int *ipa,
2030 const size_t *n0,
2031 const size_t *n1,
2032 double *cont,
2033 double *res);
2034
2061size_t atm2x(
2062 const ctl_t * ctl,
2063 const atm_t * atm,
2064 gsl_vector * x,
2065 int *iqa,
2066 int *ipa);
2067
2089void atm2x_help(
2090 const double value,
2091 const int value_iqa,
2092 const int value_ip,
2093 gsl_vector * x,
2094 int *iqa,
2095 int *ipa,
2096 size_t *n);
2097
2112void cart2geo(
2113 const double *x,
2114 double *z,
2115 double *lon,
2116 double *lat);
2117
2133void climatology(
2134 const ctl_t * ctl,
2135 atm_t * atm);
2136
2161double cos_sza(
2162 const double sec,
2163 const double lon,
2164 const double lat);
2165
2205double cost_function(
2206 const gsl_vector * dx,
2207 const gsl_vector * dy,
2208 const gsl_matrix * s_a_inv,
2209 const gsl_vector * sig_eps_inv);
2210
2216double ctmco2(
2217 const double nu,
2218 const double p,
2219 const double t,
2220 const double u);
2221
2227double ctmh2o(
2228 const double nu,
2229 const double p,
2230 const double t,
2231 const double q,
2232 const double u);
2233
2263double ctmn2(
2264 const double nu,
2265 const double p,
2266 const double t);
2267
2297double ctmo2(
2298 const double nu,
2299 const double p,
2300 const double t);
2301
2326void copy_atm(
2327 const ctl_t * ctl,
2328 atm_t * atm_dest,
2329 const atm_t * atm_src,
2330 const int init);
2331
2356void copy_obs(
2357 const ctl_t * ctl,
2358 obs_t * obs_dest,
2359 const obs_t * obs_src,
2360 const int init);
2361
2382void day2doy(
2383 int year,
2384 int mon,
2385 int day,
2386 int *doy);
2387
2410void doy2day(
2411 int year,
2412 int doy,
2413 int *mon,
2414 int *day);
2415
2435int find_emitter(
2436 const ctl_t * ctl,
2437 const char *emitter);
2438
2464void formod(
2465 const ctl_t * ctl,
2466 const tbl_t * tbl,
2467 atm_t * atm,
2468 obs_t * obs);
2469
2495void formod_continua(
2496 const ctl_t * ctl,
2497 const los_t * los,
2498 const int ip,
2499 double *beta);
2500
2522void formod_fov(
2523 const ctl_t * ctl,
2524 obs_t * obs);
2525
2555void formod_pencil(
2556 const ctl_t * ctl,
2557 const tbl_t * tbl,
2558 const atm_t * atm,
2559 obs_t * obs,
2560 const int ir);
2561
2613void formod_rfm(
2614 const ctl_t * ctl,
2615 const tbl_t * tbl,
2616 const atm_t * atm,
2617 obs_t * obs);
2618
2643void formod_srcfunc(
2644 const ctl_t * ctl,
2645 const tbl_t * tbl,
2646 const double t,
2647 double *src);
2648
2675void geo2cart(
2676 const double z,
2677 const double lon,
2678 const double lat,
2679 double *x);
2680
2708void hydrostatic(
2709 const ctl_t * ctl,
2710 atm_t * atm);
2711
2735void idx2name(
2736 const ctl_t * ctl,
2737 const int idx,
2738 char *quantity);
2739
2769void init_srcfunc(
2770 const ctl_t * ctl,
2771 tbl_t * tbl);
2772
2797void intpol_atm(
2798 const ctl_t * ctl,
2799 const atm_t * atm,
2800 const double z,
2801 double *p,
2802 double *t,
2803 double *q,
2804 double *k);
2805
2839void intpol_tbl_cga(
2840 const ctl_t * ctl,
2841 const tbl_t * tbl,
2842 const los_t * los,
2843 const int ip,
2844 double tau_path[ND][NG],
2845 double tau_seg[ND]);
2846
2885void intpol_tbl_ega(
2886 const ctl_t * ctl,
2887 const tbl_t * tbl,
2888 const los_t * los,
2889 const int ip,
2890 double tau_path[ND][NG],
2891 double tau_seg[ND]);
2892
2919double intpol_tbl_eps(
2920 const tbl_t * tbl,
2921 const int ig,
2922 const int id,
2923 const int ip,
2924 const int it,
2925 const double logu);
2926
2957double intpol_tbl_u(
2958 const tbl_t * tbl,
2959 const int ig,
2960 const int id,
2961 const int ip,
2962 const int it,
2963 const double logeps);
2964
2991void jsec2time(
2992 const double jsec,
2993 int *year,
2994 int *mon,
2995 int *day,
2996 int *hour,
2997 int *min,
2998 int *sec,
2999 double *remain);
3000
3042void kernel(
3043 const ctl_t * ctl,
3044 const tbl_t * tbl,
3045 atm_t * atm,
3046 obs_t * obs,
3047 gsl_matrix * k);
3048
3075int locate_irr(
3076 const double *xx,
3077 const int n,
3078 const double x);
3079
3106int locate_reg(
3107 const double *xx,
3108 const int n,
3109 const double x);
3110
3136int locate_tbl(
3137 const float *xx,
3138 const int n,
3139 const double x);
3140
3179void matrix_invert(
3180 gsl_matrix * a);
3181
3226void matrix_product(
3227 const gsl_matrix * a,
3228 const gsl_vector * b,
3229 const int transpose,
3230 gsl_matrix * c);
3231
3259size_t obs2y(
3260 const ctl_t * ctl,
3261 const obs_t * obs,
3262 gsl_vector * y,
3263 int *ida,
3264 int *ira);
3265
3317 ret_t * ret,
3318 ctl_t * ctl,
3319 tbl_t * tbl,
3320 obs_t * obs_meas,
3321 obs_t * obs_i,
3322 atm_t * atm_apr,
3323 atm_t * atm_i,
3324 double *chisq);
3325
3367void raytrace(
3368 const ctl_t * ctl,
3369 const atm_t * atm,
3370 obs_t * obs,
3371 los_t * los,
3372 const int ir);
3373
3423void read_atm(
3424 const char *dirname,
3425 const char *filename,
3426 const ctl_t * ctl,
3427 atm_t * atm,
3428 int profile);
3429
3476void read_atm_asc(
3477 const char *filename,
3478 const ctl_t * ctl,
3479 atm_t * atm);
3480
3530void read_atm_bin(
3531 const char *filename,
3532 const ctl_t * ctl,
3533 atm_t * atm);
3534
3576void read_atm_nc(
3577 const char *filename,
3578 const ctl_t * ctl,
3579 atm_t * atm,
3580 int profile);
3581
3622void read_ctl(
3623 int argc,
3624 char *argv[],
3625 ctl_t * ctl);
3626
3645void read_matrix(
3646 const char *dirname,
3647 const char *filename,
3648 const ctl_t * ctl,
3649 gsl_matrix * matrix,
3650 int dataset);
3651
3683void read_matrix_asc(
3684 const char *dirname,
3685 const char *filename,
3686 gsl_matrix * matrix);
3687
3705void read_matrix_bin(
3706 const char *dirname,
3707 const char *filename,
3708 gsl_matrix * matrix);
3709
3731void read_matrix_nc(
3732 const char *dirname,
3733 const char *filename,
3734 gsl_matrix * matrix,
3735 int dataset);
3736
3773void read_obs(
3774 const char *dirname,
3775 const char *filename,
3776 const ctl_t * ctl,
3777 obs_t * obs,
3778 int profile);
3779
3817void read_obs_asc(
3818 const char *filename,
3819 const ctl_t * ctl,
3820 obs_t * obs);
3821
3863void read_obs_bin(
3864 const char *filename,
3865 const ctl_t * ctl,
3866 obs_t * obs);
3867
3900void read_obs_nc(
3901 const char *filename,
3902 const ctl_t * ctl,
3903 obs_t * obs,
3904 const int profile);
3905
3945double read_obs_rfm(
3946 const char *basename,
3947 const double z,
3948 const double *nu,
3949 const double *f,
3950 const int n);
3951
4026void read_ret(
4027 int argc,
4028 char *argv[],
4029 const ctl_t * ctl,
4030 ret_t * ret);
4031
4072void read_rfm_spec(
4073 const char *filename,
4074 double *nu,
4075 double *rad,
4076 int *npts);
4077
4111void read_shape(
4112 const char *filename,
4113 double *x,
4114 double *y,
4115 int *n);
4116
4153 const ctl_t * ctl);
4154
4190void read_tbl_asc(
4191 const ctl_t * ctl,
4192 tbl_t * tbl,
4193 const int id,
4194 const int ig);
4195
4227void read_tbl_bin(
4228 const ctl_t * ctl,
4229 tbl_t * tbl,
4230 const int id,
4231 const int ig);
4232
4276 const ctl_t * ctl,
4277 tbl_t * tbl,
4278 int id,
4279 int ig,
4280 int ncid);
4281
4336double scan_ctl(
4337 int argc,
4338 char *argv[],
4339 const char *varname,
4340 const int arridx,
4341 const char *defvalue,
4342 char *value);
4343
4397void set_cov_apr(
4398 const ret_t * ret,
4399 const ctl_t * ctl,
4400 const atm_t * atm,
4401 const int *iqa,
4402 const int *ipa,
4403 gsl_matrix * s_a);
4404
4458void set_cov_meas(
4459 const ret_t * ret,
4460 const ctl_t * ctl,
4461 const obs_t * obs,
4462 gsl_vector * sig_noise,
4463 gsl_vector * sig_formod,
4464 gsl_vector * sig_eps_inv);
4465
4492const char *shared_io_input_target(
4493 const ret_t * ret,
4494 const char *shared_file,
4495 const char *legacy_file,
4496 const char **dirname,
4497 int *profile);
4498
4525const char *shared_io_output_target(
4526 const ret_t * ret,
4527 const char *shared_file,
4528 const char *legacy_file,
4529 const char **dirname,
4530 int *profile);
4531
4552int shared_io_lock(
4553 const ret_t * ret);
4554
4569void shared_io_unlock(
4570 int fd);
4571
4592const char *shared_io_output_file(
4593 const ret_t * ret);
4594
4634void tangent_point(
4635 const los_t * los,
4636 double *tpz,
4637 double *tplon,
4638 double *tplat);
4639
4661void tbl_free(
4662 const ctl_t * ctl,
4663 tbl_t * tbl);
4664
4704void tbl_pack(
4705 const tbl_t * tbl,
4706 int id,
4707 int ig,
4708 uint8_t * buf,
4709 size_t *bytes_used);
4710
4721size_t tbl_packed_size(
4722 const tbl_t * tbl,
4723 int id,
4724 int ig);
4725
4764size_t tbl_unpack(
4765 tbl_t * tbl,
4766 int id,
4767 int ig,
4768 const uint8_t * buf);
4769
4770
4795void time2jsec(
4796 const int year,
4797 const int mon,
4798 const int day,
4799 const int hour,
4800 const int min,
4801 const int sec,
4802 const double remain,
4803 double *jsec);
4804
4819void timer_group(
4820 const char *name,
4821 const char *group,
4822 int output);
4823
4872void write_atm(
4873 const char *dirname,
4874 const char *filename,
4875 const ctl_t * ctl,
4876 const atm_t * atm,
4877 int profile);
4878
4930void write_atm_asc(
4931 const char *filename,
4932 const ctl_t * ctl,
4933 const atm_t * atm);
4934
4988void write_atm_bin(
4989 const char *filename,
4990 const ctl_t * ctl,
4991 const atm_t * atm);
4992
5040void write_atm_nc(
5041 const char *filename,
5042 const ctl_t * ctl,
5043 const atm_t * atm,
5044 int profile);
5045
5097void write_atm_rfm(
5098 const char *filename,
5099 const ctl_t * ctl,
5100 const atm_t * atm);
5101
5125void write_matrix(
5126 const char *dirname,
5127 const char *filename,
5128 const ctl_t * ctl,
5129 const gsl_matrix * matrix,
5130 const atm_t * atm,
5131 const obs_t * obs,
5132 const char *rowspace,
5133 const char *colspace,
5134 const char *sort,
5135 int dataset);
5136
5184void write_matrix_asc(
5185 const char *dirname,
5186 const char *filename,
5187 const ctl_t * ctl,
5188 const gsl_matrix * matrix,
5189 const atm_t * atm,
5190 const obs_t * obs,
5191 const char *rowspace,
5192 const char *colspace,
5193 const char *sort);
5194
5209void write_matrix_bin(
5210 const char *dirname,
5211 const char *filename,
5212 const gsl_matrix * matrix);
5213
5240void write_matrix_nc(
5241 const char *dirname,
5242 const char *filename,
5243 const ctl_t * ctl,
5244 const gsl_matrix * matrix,
5245 const atm_t * atm,
5246 const obs_t * obs,
5247 const char *rowspace,
5248 const char *colspace,
5249 const char *sort,
5250 int dataset);
5251
5287void write_obs(
5288 const char *dirname,
5289 const char *filename,
5290 const ctl_t * ctl,
5291 const obs_t * obs,
5292 int profile);
5293
5332void write_obs_asc(
5333 const char *filename,
5334 const ctl_t * ctl,
5335 const obs_t * obs);
5336
5374void write_obs_bin(
5375 const char *filename,
5376 const ctl_t * ctl,
5377 const obs_t * obs);
5378
5416void write_obs_nc(
5417 const char *filename,
5418 const ctl_t * ctl,
5419 const obs_t * obs,
5420 const int profile);
5421
5456void write_shape(
5457 const char *filename,
5458 const double *x,
5459 const double *y,
5460 const int n);
5461
5507void write_stddev(
5508 const char *quantity,
5509 const ret_t * ret,
5510 const ctl_t * ctl,
5511 const atm_t * atm,
5512 const gsl_matrix * s);
5513
5549void write_tbl(
5550 const ctl_t * ctl,
5551 const tbl_t * tbl);
5552
5578void write_tbl_asc(
5579 const ctl_t * ctl,
5580 const tbl_t * tbl,
5581 const int id,
5582 const int ig);
5583
5611void write_tbl_bin(
5612 const ctl_t * ctl,
5613 const tbl_t * tbl,
5614 const int id,
5615 const int ig);
5616
5649void write_tbl_nc(
5650 const ctl_t * ctl,
5651 const tbl_t * tbl,
5652 const int id,
5653 const int ig);
5654
5701void x2atm(
5702 const ctl_t * ctl,
5703 const gsl_vector * x,
5704 atm_t * atm);
5705
5734void x2atm_help(
5735 double *value,
5736 const gsl_vector * x,
5737 size_t *n);
5738
5771void y2obs(
5772 const ctl_t * ctl,
5773 const gsl_vector * y,
5774 obs_t * obs);
5775
5776#endif
double intpol_tbl_eps(const tbl_t *tbl, const int ig, const int id, const int ip, const int it, const double logu)
Interpolate gas emissivity as a function of column amount.
Definition: jurassic.c:4270
void analyze_avk(const ret_t *ret, const ctl_t *ctl, const atm_t *atm, const int *iqa, const int *ipa, const gsl_matrix *avk)
Analyze averaging kernel (AVK) matrix for retrieval diagnostics.
Definition: jurassic.c:29
void read_tbl_bin(const ctl_t *ctl, tbl_t *tbl, const int id, const int ig)
Read a single compact binary emissivity lookup table.
Definition: jurassic.c:6543
#define LEN
Maximum length of ASCII data lines.
Definition: jurassic.h:268
double cost_function(const gsl_vector *dx, const gsl_vector *dy, const gsl_matrix *s_a_inv, const gsl_vector *sig_eps_inv)
Compute the normalized quadratic cost function for optimal estimation.
Definition: jurassic.c:1193
double read_obs_rfm(const char *basename, const double z, const double *nu, const double *f, const int n)
Read and spectrally convolve an RFM output spectrum.
Definition: jurassic.c:6098
void write_atm(const char *dirname, const char *filename, const ctl_t *ctl, const atm_t *atm, int profile)
Write atmospheric data to a file.
Definition: jurassic.c:7319
void read_rfm_spec(const char *filename, double *nu, double *rad, int *npts)
Read a Reference Forward Model (RFM) ASCII spectrum.
Definition: jurassic.c:6243
void tbl_pack(const tbl_t *tbl, int id, int ig, uint8_t *buf, size_t *bytes_used)
Pack a lookup table into a contiguous binary buffer.
Definition: jurassic.c:7053
void read_matrix_nc(const char *dirname, const char *filename, gsl_matrix *matrix, int dataset)
Read a numerical matrix from a netCDF file.
Definition: jurassic.c:5773
double cos_sza(const double sec, const double lon, const double lat)
Calculates the cosine of the solar zenith angle.
Definition: jurassic.c:1152
void read_atm_bin(const char *filename, const ctl_t *ctl, atm_t *atm)
Read atmospheric data in binary format.
Definition: jurassic.c:5330
void write_obs_asc(const char *filename, const ctl_t *ctl, const obs_t *obs)
Write observation data to an ASCII text file.
Definition: jurassic.c:8358
void formod_rfm(const ctl_t *ctl, const tbl_t *tbl, const atm_t *atm, obs_t *obs)
Forward-model radiance and transmittance with the Reference Forward Model (RFM).
Definition: jurassic.c:3708
int locate_reg(const double *xx, const int n, const double x)
Locate index for interpolation on a regular (uniform) grid.
Definition: jurassic.c:4518
void intpol_tbl_ega(const ctl_t *ctl, const tbl_t *tbl, const los_t *los, const int ip, double tau_path[ND][NG], double tau_seg[ND])
Interpolate emissivities and transmittances using the Emissivity Growth Approximation (EGA).
Definition: jurassic.c:4168
double ctmo2(const double nu, const double p, const double t)
Compute O₂ collision-induced absorption coefficient.
Definition: jurassic.c:3208
void write_obs_nc(const char *filename, const ctl_t *ctl, const obs_t *obs, const int profile)
Write one observation profile to a NetCDF file.
Definition: jurassic.c:8482
void tbl_free(const ctl_t *ctl, tbl_t *tbl)
Free lookup table and all internally allocated memory.
Definition: jurassic.c:7014
void write_tbl_asc(const ctl_t *ctl, const tbl_t *tbl, const int id, const int ig)
Write one emissivity lookup table in human-readable ASCII format.
Definition: jurassic.c:8777
void write_tbl_nc(const ctl_t *ctl, const tbl_t *tbl, const int id, const int ig)
Write one packed lookup table to a NetCDF file.
Definition: jurassic.c:8861
void idx2name(const ctl_t *ctl, const int idx, char *quantity)
Convert a quantity index to a descriptive name string.
Definition: jurassic.c:3964
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5528
void formod_continua(const ctl_t *ctl, const los_t *los, const int ip, double *beta)
Compute total extinction including gaseous continua.
Definition: jurassic.c:3470
void read_obs_bin(const char *filename, const ctl_t *ctl, obs_t *obs)
Read binary-formatted observation data from a file.
Definition: jurassic.c:5941
int shared_io_lock(const ret_t *ret)
Acquire an exclusive lock for shared retrieval output files.
Definition: jurassic.c:6892
void raytrace(const ctl_t *ctl, const atm_t *atm, obs_t *obs, los_t *los, const int ir)
Perform line-of-sight (LOS) ray tracing through the atmosphere.
Definition: jurassic.c:4974
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs, int profile)
Read observation data from an input file.
Definition: jurassic.c:5822
void matrix_product(const gsl_matrix *a, const gsl_vector *b, const int transpose, gsl_matrix *c)
Compute structured matrix products of the form or .
Definition: jurassic.c:4589
int locate_irr(const double *xx, const int n, const double x)
Locate index for interpolation on an irregular grid.
Definition: jurassic.c:4488
const char * shared_io_input_target(const ret_t *ret, const char *shared_file, const char *legacy_file, const char **dirname, int *profile)
Resolve retrieval input target for legacy-directory and shared-file modes.
Definition: jurassic.c:6852
void write_matrix_asc(const char *dirname, const char *filename, const ctl_t *ctl, const gsl_matrix *matrix, const atm_t *atm, const obs_t *obs, const char *rowspace, const char *colspace, const char *sort)
Write a fully annotated matrix (e.g., Jacobian or gain matrix) to an ASCII file.
Definition: jurassic.c:7802
void day2doy(int year, int mon, int day, int *doy)
Convert a calendar date to day-of-year.
Definition: jurassic.c:3358
void write_atm_nc(const char *filename, const ctl_t *ctl, const atm_t *atm, int profile)
Write one atmospheric profile to a netCDF file.
Definition: jurassic.c:7541
void write_matrix(const char *dirname, const char *filename, const ctl_t *ctl, const gsl_matrix *matrix, const atm_t *atm, const obs_t *obs, const char *rowspace, const char *colspace, const char *sort, int dataset)
Write a fully annotated matrix (e.g., Jacobian or gain matrix) to file.
Definition: jurassic.c:7765
void time2jsec(const int year, const int mon, const int day, const int hour, const int min, const int sec, const double remain, double *jsec)
Converts time components to seconds since January 1, 2000, 12:00:00 UTC.
Definition: jurassic.c:7217
void x2atm(const ctl_t *ctl, const gsl_vector *x, atm_t *atm)
Map retrieval state vector back to atmospheric structure.
Definition: jurassic.c:8926
void atm2x_help(const double value, const int value_iqa, const int value_ip, gsl_vector *x, int *iqa, int *ipa, size_t *n)
Append a single atmospheric value to the state vector.
Definition: jurassic.c:179
double ctmh2o(const double nu, const double p, const double t, const double q, const double u)
Compute water vapor continuum (optical depth).
Definition: jurassic.c:2087
void write_tbl_bin(const ctl_t *ctl, const tbl_t *tbl, const int id, const int ig)
Write one emissivity lookup table in compact binary format.
Definition: jurassic.c:8819
void intpol_tbl_cga(const ctl_t *ctl, const tbl_t *tbl, const los_t *los, const int ip, double tau_path[ND][NG], double tau_seg[ND])
Interpolate emissivities and transmittances using the Curtis–Godson approximation (CGA).
Definition: jurassic.c:4075
void shared_io_unlock(int fd)
Release a shared retrieval output lock.
Definition: jurassic.c:6919
void write_atm_rfm(const char *filename, const ctl_t *ctl, const atm_t *atm)
Write atmospheric profile in RFM-compatible format.
Definition: jurassic.c:7728
#define ND
Maximum number of radiance channels.
Definition: jurassic.h:288
void set_cov_meas(const ret_t *ret, const ctl_t *ctl, const obs_t *obs, gsl_vector *sig_noise, gsl_vector *sig_formod, gsl_vector *sig_eps_inv)
Construct measurement error standard deviations and their inverse.
Definition: jurassic.c:6803
void write_obs(const char *dirname, const char *filename, const ctl_t *ctl, const obs_t *obs, int profile)
Write observation data to an output file in ASCII or binary format.
Definition: jurassic.c:8287
#define NSHAPE
Maximum number of shape function grid points.
Definition: jurassic.h:328
void write_tbl(const ctl_t *ctl, const tbl_t *tbl)
Write emissivity lookup tables to disk.
Definition: jurassic.c:8734
size_t tbl_unpack(tbl_t *tbl, int id, int ig, const uint8_t *buf)
Unpack a lookup table from a contiguous binary buffer.
Definition: jurassic.c:7141
void read_matrix(const char *dirname, const char *filename, const ctl_t *ctl, gsl_matrix *matrix, int dataset)
Read a numerical matrix from a file.
Definition: jurassic.c:5655
void intpol_atm(const ctl_t *ctl, const atm_t *atm, const double z, double *p, double *t, double *q, double *k)
Interpolate atmospheric state variables at a given altitude.
Definition: jurassic.c:4050
int find_emitter(const ctl_t *ctl, const char *emitter)
Find gas species index by name.
Definition: jurassic.c:3408
void optimal_estimation(ret_t *ret, ctl_t *ctl, tbl_t *tbl, obs_t *obs_meas, obs_t *obs_i, atm_t *atm_apr, atm_t *atm_i, double *chisq)
Perform optimal estimation retrieval using Levenberg–Marquardt minimization.
Definition: jurassic.c:4661
double intpol_tbl_u(const tbl_t *tbl, const int ig, const int id, const int ip, const int it, const double logeps)
Interpolate column amount as a function of emissivity.
Definition: jurassic.c:4315
void timer_group(const char *name, const char *group, int output)
Aggregate wall-clock timings for named code phases.
Definition: jurassic.c:7248
void tangent_point(const los_t *los, double *tpz, double *tplon, double *tplat)
Determine the tangent point along a line of sight (LOS).
Definition: jurassic.c:6971
void formod_pencil(const ctl_t *ctl, const tbl_t *tbl, const atm_t *atm, obs_t *obs, const int ir)
Compute line-of-sight radiances using the pencil-beam forward model.
Definition: jurassic.c:3570
double ctmco2(const double nu, const double p, const double t, const double u)
Compute carbon dioxide continuum (optical depth).
Definition: jurassic.c:1224
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm, int profile)
Read atmospheric input data from a file.
Definition: jurassic.c:5205
void write_matrix_nc(const char *dirname, const char *filename, const ctl_t *ctl, const gsl_matrix *matrix, const atm_t *atm, const obs_t *obs, const char *rowspace, const char *colspace, const char *sort, int dataset)
Write a numerical matrix to a netCDF file.
Definition: jurassic.c:8024
void write_atm_asc(const char *filename, const ctl_t *ctl, const atm_t *atm)
Write atmospheric data to an ASCII file.
Definition: jurassic.c:7390
void write_matrix_bin(const char *dirname, const char *filename, const gsl_matrix *matrix)
Write a numerical matrix to a binary file.
Definition: jurassic.c:7975
void copy_obs(const ctl_t *ctl, obs_t *obs_dest, const obs_t *obs_src, const int init)
Copy or initialize observation geometry and radiance data.
Definition: jurassic.c:3320
#define TBLNT
Maximum number of temperatures in emissivity tables.
Definition: jurassic.h:358
void write_obs_bin(const char *filename, const ctl_t *ctl, const obs_t *obs)
Write observation data in binary format to a file.
Definition: jurassic.c:8414
void x2atm_help(double *value, const gsl_vector *x, size_t *n)
Helper function to extract a single value from the retrieval state vector.
Definition: jurassic.c:8976
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: jurassic.c:200
#define NP
Maximum number of atmospheric data points.
Definition: jurassic.h:308
void formod_fov(const ctl_t *ctl, obs_t *obs)
Apply field-of-view (FOV) convolution to modeled radiances.
Definition: jurassic.c:3506
void doy2day(int year, int doy, int *mon, int *day)
Convert a day-of-year value to a calendar date.
Definition: jurassic.c:3378
void kernel(const ctl_t *ctl, const tbl_t *tbl, atm_t *atm, obs_t *obs, gsl_matrix *k)
Compute the Jacobian (kernel) matrix by finite differences.
Definition: jurassic.c:4394
void read_obs_nc(const char *filename, const ctl_t *ctl, obs_t *obs, const int profile)
Read one observation profile from a NetCDF file.
Definition: jurassic.c:6019
void init_srcfunc(const ctl_t *ctl, tbl_t *tbl)
Initialize source function lookup tables from emissivity data.
Definition: jurassic.c:4003
void matrix_invert(gsl_matrix *a)
Invert a square matrix, optimized for diagonal or symmetric positive-definite matrices.
Definition: jurassic.c:4559
void read_ret(int argc, char *argv[], const ctl_t *ctl, ret_t *ret)
Read retrieval configuration and error parameters.
Definition: jurassic.c:6155
double scan_ctl(int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scan control file or command-line arguments for a configuration variable.
Definition: jurassic.c:6624
void write_shape(const char *filename, const double *x, const double *y, const int n)
Write tabulated shape function data to a text file.
Definition: jurassic.c:8662
void formod(const ctl_t *ctl, const tbl_t *tbl, atm_t *atm, obs_t *obs)
Execute the selected forward model.
Definition: jurassic.c:3421
void read_atm_asc(const char *filename, const ctl_t *ctl, atm_t *atm)
Read atmospheric data in ASCII format.
Definition: jurassic.c:5279
#define NG
Maximum number of emitters.
Definition: jurassic.h:298
void read_tbl_asc(const ctl_t *ctl, tbl_t *tbl, const int id, const int ig)
Read a single ASCII emissivity lookup table.
Definition: jurassic.c:6420
void formod_srcfunc(const ctl_t *ctl, const tbl_t *tbl, const double t, double *src)
Interpolate the source function (Planck radiance) at a given temperature.
Definition: jurassic.c:3869
void analyze_avk_quantity(const gsl_matrix *avk, const int iq, const int *ipa, const size_t *n0, const size_t *n1, double *cont, double *res)
Analyze averaging kernel submatrix for a specific retrieved quantity.
Definition: jurassic.c:101
void jsec2time(const double jsec, int *year, int *mon, int *day, int *hour, int *min, int *sec, double *remain)
Converts Julian seconds to calendar date and time components.
Definition: jurassic.c:4361
#define TBLNS
Maximum number of source function temperature levels.
Definition: jurassic.h:353
void read_matrix_asc(const char *dirname, const char *filename, gsl_matrix *matrix)
Read a numerical matrix from an ASCII file.
Definition: jurassic.c:5681
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
Definition: jurassic.c:6344
void read_matrix_bin(const char *dirname, const char *filename, gsl_matrix *matrix)
Read a numerical matrix from a binary file.
Definition: jurassic.c:5720
void read_tbl_nc_channel(const ctl_t *ctl, tbl_t *tbl, int id, int ig, int ncid)
Read one packed emissivity lookup table from an open NetCDF file.
Definition: jurassic.c:6587
const char * shared_io_output_target(const ret_t *ret, const char *shared_file, const char *legacy_file, const char **dirname, int *profile)
Resolve retrieval output target for legacy-directory and shared-file modes.
Definition: jurassic.c:6872
void read_atm_nc(const char *filename, const ctl_t *ctl, atm_t *atm, int profile)
Read one atmospheric profile from a netCDF file.
Definition: jurassic.c:5424
void copy_atm(const ctl_t *ctl, atm_t *atm_dest, const atm_t *atm_src, const int init)
Copy or initialize atmospheric profile data.
Definition: jurassic.c:3270
size_t obs2y(const ctl_t *ctl, const obs_t *obs, gsl_vector *y, int *ida, int *ira)
Convert observation radiances into a measurement vector.
Definition: jurassic.c:4634
void y2obs(const ctl_t *ctl, const gsl_vector *y, obs_t *obs)
Copy elements from the measurement vector y into the observation structure.
Definition: jurassic.c:8988
void hydrostatic(const ctl_t *ctl, atm_t *atm)
Adjust pressure profile using the hydrostatic equation.
Definition: jurassic.c:3904
void read_shape(const char *filename, double *x, double *y, int *n)
Read a two-column shape function from an ASCII file.
Definition: jurassic.c:6303
double ctmn2(const double nu, const double p, const double t)
Compute N₂ collision-induced absorption coefficient.
Definition: jurassic.c:3139
size_t atm2x(const ctl_t *ctl, const atm_t *atm, gsl_vector *x, int *iqa, int *ipa)
Convert atmospheric data to state vector elements.
Definition: jurassic.c:125
#define TBLNP
Maximum number of pressure levels in emissivity tables.
Definition: jurassic.h:348
void climatology(const ctl_t *ctl, atm_t *atm)
Initializes atmospheric climatology profiles.
Definition: jurassic.c:215
void geo2cart(const double z, const double lon, const double lat, double *x)
Converts geographic coordinates (longitude, latitude, altitude) to Cartesian coordinates.
Definition: jurassic.c:3886
#define NSF
Maximum number of surface layer spectral grid points.
Definition: jurassic.h:323
#define NCL
Maximum number of cloud layer spectral grid points.
Definition: jurassic.h:283
void set_cov_apr(const ret_t *ret, const ctl_t *ctl, const atm_t *atm, const int *iqa, const int *ipa, gsl_matrix *s_a)
Construct the a priori covariance matrix for retrieval parameters.
Definition: jurassic.c:6692
const char * shared_io_output_file(const ret_t *ret)
Return the primary shared retrieval output file configured for locking.
Definition: jurassic.c:6937
void write_stddev(const char *quantity, const ret_t *ret, const ctl_t *ctl, const atm_t *atm, const gsl_matrix *s)
Write retrieval standard deviation profiles to disk.
Definition: jurassic.c:8691
#define NLOS
Maximum number of LOS points.
Definition: jurassic.h:303
size_t tbl_packed_size(const tbl_t *tbl, int id, int ig)
Compute required buffer size (in bytes) for tbl_pack().
Definition: jurassic.c:7107
#define NR
Maximum number of ray paths.
Definition: jurassic.h:318
int locate_tbl(const float *xx, const int n, const double x)
Locate index for interpolation within emissivity table grids.
Definition: jurassic.c:4537
void write_atm_bin(const char *filename, const ctl_t *ctl, const atm_t *atm)
Write atmospheric data to a binary file.
Definition: jurassic.c:7457
void read_obs_asc(const char *filename, const ctl_t *ctl, obs_t *obs)
Read ASCII-formatted observation data from a file.
Definition: jurassic.c:5897
#define NW
Maximum number of spectral windows.
Definition: jurassic.h:338
Atmospheric profile data.
Definition: jurassic.h:1398
double clz
Cloud layer height [km].
Definition: jurassic.h:1428
int np
Number of data points.
Definition: jurassic.h:1401
double cldz
Cloud layer depth [km].
Definition: jurassic.h:1431
double sft
Surface temperature [K].
Definition: jurassic.h:1437
Control parameters.
Definition: jurassic.h:1451
int write_matrix
Write matrix file (0=no, 1=yes).
Definition: jurassic.h:1595
int nw
Number of spectral windows.
Definition: jurassic.h:1478
int atmfmt
Atmospheric data file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1508
double retp_zmin
Minimum altitude for pressure retrieval [km].
Definition: jurassic.h:1553
int ig_co2
Emitter index of CO2.
Definition: jurassic.h:1460
double hydz
Reference height for hydrostatic pressure profile (-999 to skip) [km].
Definition: jurassic.h:1517
int ctm_co2
Compute CO2 continuum (0=no, 1=yes).
Definition: jurassic.h:1520
double rett_zmax
Maximum altitude for temperature retrieval [km].
Definition: jurassic.h:1562
int ret_sfeps
Retrieve surface layer emissivity (0=no, 1=yes).
Definition: jurassic.h:1589
int ret_sft
Retrieve surface layer temperature (0=no, 1=yes).
Definition: jurassic.h:1586
int ret_clz
Retrieve cloud layer height (0=no, 1=yes).
Definition: jurassic.h:1577
int ctm_n2
Compute N2 continuum (0=no, 1=yes).
Definition: jurassic.h:1526
int ctm_h2o
Compute H2O continuum (0=no, 1=yes).
Definition: jurassic.h:1523
int formod
Forward model (0=CGA, 1=EGA, 2=RFM).
Definition: jurassic.h:1598
int ng
Number of emitters.
Definition: jurassic.h:1454
int refrac
Take into account refractivity (0=no, 1=yes).
Definition: jurassic.h:1532
int ig_o2
Emitter index of O2.
Definition: jurassic.h:1469
double rett_zmin
Minimum altitude for temperature retrieval [km].
Definition: jurassic.h:1559
double sfsza
Solar zenith angle at the surface [deg] (-999=auto).
Definition: jurassic.h:1499
int nd
Number of radiance channels.
Definition: jurassic.h:1472
int fov_n
Field-of-view number of data points.
Definition: jurassic.h:1550
int sftype
Surface treatment (0=none, 1=emissions, 2=downward, 3=solar).
Definition: jurassic.h:1496
int matrixfmt
Matrix data file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1514
int ncl
Number of cloud layer spectral grid points.
Definition: jurassic.h:1484
int ig_n2
Emitter index of N2.
Definition: jurassic.h:1466
int obsfmt
Observation data file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1511
int ctm_o2
Compute O2 continuum (0=no, 1=yes).
Definition: jurassic.h:1529
int ret_clk
Retrieve cloud layer extinction (0=no, 1=yes).
Definition: jurassic.h:1583
int nsf
Number of surface layer spectral grid points.
Definition: jurassic.h:1490
double rayds
Maximum step length for raytracing [km].
Definition: jurassic.h:1535
int ret_cldz
Retrieve cloud layer depth (0=no, 1=yes).
Definition: jurassic.h:1580
int ig_h2o
Emitter index of H2O.
Definition: jurassic.h:1463
int tblfmt
Look-up table file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1505
double raydz
Vertical step length for raytracing [km].
Definition: jurassic.h:1538
int write_bbt
Use brightness temperature instead of radiance (0=no, 1=yes).
Definition: jurassic.h:1592
double retp_zmax
Maximum altitude for pressure retrieval [km].
Definition: jurassic.h:1556
Line-of-sight data.
Definition: jurassic.h:1618
double sft
Surface temperature [K].
Definition: jurassic.h:1645
int np
Number of LOS points.
Definition: jurassic.h:1621
Observation geometry and radiance data.
Definition: jurassic.h:1680
int nr
Number of ray paths.
Definition: jurassic.h:1683
Retrieval control parameters.
Definition: jurassic.h:1732
double err_press_cz
Vertical correlation length for pressure error [km].
Definition: jurassic.h:1759
double err_press
Pressure error [%].
Definition: jurassic.h:1756
int err_ana
Carry out error analysis (0=no, 1=yes).
Definition: jurassic.h:1747
double err_temp_cz
Vertical correlation length for temperature error [km].
Definition: jurassic.h:1768
double conv_dmin
Minimum normalized step size in state space.
Definition: jurassic.h:1744
double err_temp
Temperature error [K].
Definition: jurassic.h:1765
double err_clz
Cloud height error [km].
Definition: jurassic.h:1792
double err_sft
Surface temperature error [K].
Definition: jurassic.h:1801
double err_temp_ch
Horizontal correlation length for temperature error [km].
Definition: jurassic.h:1771
int kernel_recomp
Re-computation of kernel matrix (number of iterations).
Definition: jurassic.h:1738
int conv_itmax
Maximum number of iterations.
Definition: jurassic.h:1741
double err_cldz
Cloud depth error [km].
Definition: jurassic.h:1795
double err_press_ch
Horizontal correlation length for pressure error [km].
Definition: jurassic.h:1762
int shared_io_profile
Profile index used for shared netCDF retrieval inputs and outputs.
Definition: jurassic.h:1807
Emissivity look-up tables.
Definition: jurassic.h:1865