![]() |
JURASSIC
|
JURASSIC library declarations. More...
#include <errno.h>#include <gsl/gsl_math.h>#include <gsl/gsl_blas.h>#include <gsl/gsl_linalg.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_rng.h>#include <gsl/gsl_statistics.h>#include <math.h>#include <omp.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>Go to the source code of this file.
Data Structures | |
| struct | atm_t |
| Atmospheric profile data. More... | |
| struct | ctl_t |
| Control parameters. More... | |
| struct | los_t |
| Line-of-sight data. More... | |
| struct | obs_t |
| Observation geometry and radiance data. More... | |
| struct | ret_t |
| Retrieval control parameters. More... | |
| struct | tbl_t |
| Emissivity look-up tables. More... | |
| struct | tbl_gas_index_t |
| On-disk index entry describing one frequency table block in a gas file. More... | |
| struct | tbl_gas_t |
| In-memory representation of an open per-gas lookup-table file. More... | |
Macros | |
| #define | C1 1.19104259e-8 |
| First spectroscopic constant (c_1 = 2 h c^2) [W/(m^2 sr cm^-4)]. More... | |
| #define | C2 1.43877506 |
| Second spectroscopic constant (c_2 = h c / k) [K/cm^-1]. More... | |
| #define | EPSMIN 0 |
| Minimum emissivity. More... | |
| #define | EPSMAX 1 |
| Maximum emissivity. More... | |
| #define | G0 9.80665 |
| Standard gravity [m/s^2]. More... | |
| #define | H0 7.0 |
| Standard scale height [km]. More... | |
| #define | KB 1.3806504e-23 |
| Boltzmann constant [kg m^2/(K s^2)]. More... | |
| #define | ME 5.976e24 |
| Mass of Earth [kg]. More... | |
| #define | NA 6.02214199e23 |
| Avogadro's number. More... | |
| #define | N2 0.78084 |
| Nitrogen concentration. More... | |
| #define | O2 0.20946 |
| Oxygen concentration. More... | |
| #define | P0 1013.25 |
| Standard pressure [hPa]. More... | |
| #define | RE 6367.421 |
| Mean radius of Earth [km]. More... | |
| #define | RI 8.3144598 |
| Ideal gas constant [J/(mol K)]. More... | |
| #define | T0 273.15 |
| Standard temperature [K]. More... | |
| #define | TMIN 100. |
| Minimum temperature for source function [K]. More... | |
| #define | TMAX 400. |
| Maximum temperature for source function [K]. More... | |
| #define | TSUN 5780. |
| Effective temperature of the sun [K]. More... | |
| #define | UMIN 0 |
| Minimum column density [molecules/cm^2]. More... | |
| #define | UMAX 1e30 |
| Maximum column density [molecules/cm^2]. More... | |
| #define | NCL 8 |
| Maximum number of cloud layer spectral grid points. More... | |
| #define | ND 128 |
| Maximum number of radiance channels. More... | |
| #define | NG 8 |
| Maximum number of emitters. More... | |
| #define | NP 256 |
| Maximum number of atmospheric data points. More... | |
| #define | NR 256 |
| Maximum number of ray paths. More... | |
| #define | NSF 8 |
| Maximum number of surface layer spectral grid points. More... | |
| #define | NW 4 |
| Maximum number of spectral windows. More... | |
| #define | LEN 10000 |
| Maximum length of ASCII data lines. More... | |
| #define | M (NR*ND) |
| Maximum size of measurement vector. More... | |
| #define | N ((2 + NG + NW) * NP + NCL + NSF + 3) |
| Maximum size of state vector. More... | |
| #define | NQ (5 + NG + NW + NCL + NSF) |
| Maximum number of quantities. More... | |
| #define | NLOS 4096 |
| Maximum number of LOS points. More... | |
| #define | NSHAPE 20000 |
| Maximum number of shape function grid points. More... | |
| #define | NFOV 5 |
| Number of ray paths used for FOV calculations. More... | |
| #define | TBLNP 41 |
| Maximum number of pressure levels in emissivity tables. More... | |
| #define | TBLNT 30 |
| Maximum number of temperatures in emissivity tables. More... | |
| #define | TBLNU 320 |
| Maximum number of column densities in emissivity tables. More... | |
| #define | TBLNS 1200 |
| Maximum number of source function temperature levels. More... | |
| #define | MAX_TABLES 10000 |
| Maximum number of frequency-table entries allowed in a gas table file. More... | |
| #define | RFMNPTS 10000000 |
| Maximum number of RFM spectral grid points. More... | |
| #define | IDXP 0 |
| Index for pressure. More... | |
| #define | IDXT 1 |
| Index for temperature. More... | |
| #define | IDXQ(ig) (2 + (ig)) |
| Indices for volume mixing ratios. More... | |
| #define | IDXK(iw) (2 + (ctl->ng) + (iw)) |
| Indices for extinction. More... | |
| #define | IDXCLZ (2 + (ctl->ng) + (ctl->nw)) |
| Index for cloud layer height. More... | |
| #define | IDXCLDZ (3 + (ctl->ng) + (ctl->nw)) |
| Index for cloud layer depth. More... | |
| #define | IDXCLK(icl) (4 + (ctl->ng) + (ctl->nw) + (icl)) |
| Indices for cloud layer extinction. More... | |
| #define | IDXSFT (4 + (ctl->ng) + (ctl->nw) + (ctl->ncl)) |
| Index for surface layer temperature. More... | |
| #define | IDXSFEPS(isf) (5 + (ctl->ng) + (ctl->nw) + (ctl->ncl) + (isf)) |
| Indices for surface layer emissivity. More... | |
| #define | ALLOC(ptr, type, n) |
| Allocate memory for an array. More... | |
| #define | BRIGHT(rad, nu) (C2 * (nu) / gsl_log1p(C1 * POW3(nu) / (rad))) |
| Compute brightness temperature from radiance. More... | |
| #define | DEG2RAD(deg) ((deg) * (M_PI / 180.0)) |
| Convert degrees to radians. More... | |
| #define | DIST(a, b) sqrt(DIST2(a, b)) |
| Compute Cartesian distance between two 3D vectors. More... | |
| #define | DIST2(a, b) ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])) |
| Compute squared distance between two 3D vectors. More... | |
| #define | DOTP(a, b) (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]) |
| Compute dot product of two 3D vectors. More... | |
| #define | FREAD(ptr, type, size, out) |
| Read binary data from a file. More... | |
| #define | FWRITE(ptr, type, size, out) |
| Write binary data to a file. More... | |
| #define | LIN(x0, y0, x1, y1, x) ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0))) |
| Compute linear interpolation. More... | |
| #define | LOGX(x0, y0, x1, y1, x) |
| Compute logarithmic interpolation in x. More... | |
| #define | LOGY(x0, y0, x1, y1, x) |
| Compute logarithmic interpolation in y. More... | |
| #define | MAX(a, b) (((a)>(b))?(a):(b)) |
| Determine the maximum of two values. More... | |
| #define | MIN(a, b) (((a)<(b))?(a):(b)) |
| Determine the minimum of two values. More... | |
| #define | NEDT(t_bg, nesr, nu) (BRIGHT(PLANCK((t_bg), (nu)) + (nesr), (nu)) - (t_bg)) |
| Convert noise-equivalent spectral radiance (NESR) to noise-equivalent delta temperature (NEDT). More... | |
| #define | NESR(t_bg, nedt, nu) (PLANCK((t_bg) + (nedt), (nu)) - PLANCK((t_bg), (nu))) |
| Convert noise-equivalent delta temperature (NEDT) to noise-equivalent spectral radiance (NESR). More... | |
| #define | NORM(a) sqrt(DOTP(a, a)) |
| Compute the norm (magnitude) of a 3D vector. More... | |
| #define | PLANCK(T, nu) (C1 * POW3(nu) / gsl_expm1(C2 * (nu) / (T))) |
| Compute spectral radiance using Planck’s law. More... | |
| #define | POW2(x) ((x)*(x)) |
| Compute the square of a value. More... | |
| #define | POW3(x) ((x)*(x)*(x)) |
| Compute the cube of a value. More... | |
| #define | RAD2DEG(rad) ((rad) * (180.0 / M_PI)) |
| Convert radians to degrees. More... | |
| #define | REFRAC(p, T) (7.753e-05 * (p) / (T)) |
| Compute air refractivity (n - 1). More... | |
| #define | TIMER(name, mode) {timer(name, __FILE__, __func__, __LINE__, mode);} |
| Start or stop a named timer. More... | |
| #define | TOK(line, tok, format, var) |
| Tokenize a string and parse a variable. More... | |
| #define | LOGLEV 2 |
| Level of log messages (0=none, 1=basic, 2=detailed, 3=debug). More... | |
| #define | LOG(level, ...) |
| Print a log message with a specified logging level. More... | |
| #define | WARN(...) |
| Print a warning message with contextual information. More... | |
| #define | ERRMSG(...) |
| Print an error message with contextual information and terminate the program. More... | |
| #define | PRINT(format, var) |
| Print the value of a variable with contextual information. More... | |
Functions | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| void | cart2geo (const double *x, double *z, double *lon, double *lat) |
| Converts Cartesian coordinates to geographic coordinates. More... | |
| void | climatology (const ctl_t *ctl, atm_t *atm) |
| Initializes atmospheric climatology profiles. More... | |
| double | cos_sza (const double sec, const double lon, const double lat) |
| Calculates the cosine of the solar zenith angle. More... | |
| 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. More... | |
| double | ctmco2 (const double nu, const double p, const double t, const double u) |
| Compute carbon dioxide continuum (optical depth). More... | |
| double | ctmh2o (const double nu, const double p, const double t, const double q, const double u) |
| Compute water vapor continuum (optical depth). More... | |
| double | ctmn2 (const double nu, const double p, const double t) |
| Compute N₂ collision-induced absorption coefficient. More... | |
| double | ctmo2 (const double nu, const double p, const double t) |
| Compute O₂ collision-induced absorption coefficient. More... | |
| 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. More... | |
| 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. More... | |
| int | find_emitter (const ctl_t *ctl, const char *emitter) |
| Find gas species index by name. More... | |
| void | formod (const ctl_t *ctl, const tbl_t *tbl, atm_t *atm, obs_t *obs) |
| Execute the selected forward model. More... | |
| void | formod_continua (const ctl_t *ctl, const los_t *los, const int ip, double *beta) |
| Compute total extinction including gaseous continua. More... | |
| void | formod_fov (const ctl_t *ctl, obs_t *obs) |
| Apply field-of-view (FOV) convolution to modeled radiances. More... | |
| 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. More... | |
| void | formod_rfm (const ctl_t *ctl, const atm_t *atm, obs_t *obs) |
| Interface routine for the Reference Forward Model (RFM). More... | |
| 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. More... | |
| void | geo2cart (const double z, const double lon, const double lat, double *x) |
| Converts geographic coordinates (longitude, latitude, altitude) to Cartesian coordinates. More... | |
| void | hydrostatic (const ctl_t *ctl, atm_t *atm) |
| Adjust pressure profile using the hydrostatic equation. More... | |
| void | idx2name (const ctl_t *ctl, const int idx, char *quantity) |
| Convert a quantity index to a descriptive name string. More... | |
| void | init_srcfunc (const ctl_t *ctl, tbl_t *tbl) |
| Initialize the source-function (Planck radiance) lookup table. More... | |
| 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. More... | |
| 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). More... | |
| 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). More... | |
| double | intpol_tbl_eps (const tbl_t *tbl, const int ig, const int id, const int ip, const int it, const double u) |
| Interpolate emissivity from lookup tables as a function of column density. More... | |
| double | intpol_tbl_u (const tbl_t *tbl, const int ig, const int id, const int ip, const int it, const double eps) |
| Interpolate column density from lookup tables as a function of emissivity. More... | |
| 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. More... | |
| 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. More... | |
| int | locate_irr (const double *xx, const int n, const double x) |
| Locate index for interpolation on an irregular grid. More... | |
| int | locate_reg (const double *xx, const int n, const double x) |
| Locate index for interpolation on a regular (uniform) grid. More... | |
| int | locate_tbl (const float *xx, const int n, const double x) |
| Locate index for interpolation within emissivity table grids. More... | |
| void | matrix_invert (gsl_matrix *a) |
| Invert a square matrix, optimized for diagonal or symmetric positive-definite matrices. More... | |
| void | matrix_product (const gsl_matrix *a, const gsl_vector *b, const int transpose, gsl_matrix *c) |
| Compute structured matrix products of the form \(A^T B A\) or \(A B A^T\). More... | |
| 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. More... | |
| 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. More... | |
| void | read_atm (const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm) |
| Read atmospheric profile data from an ASCII file. More... | |
| void | read_ctl (int argc, char *argv[], ctl_t *ctl) |
| Read model control parameters from command-line and configuration input. More... | |
| void | read_matrix (const char *dirname, const char *filename, gsl_matrix *matrix) |
| Read a numerical matrix from an ASCII file. More... | |
| void | read_obs (const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs) |
| Read observation geometry and radiance data from an ASCII file. More... | |
| 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. More... | |
| void | read_ret (int argc, char *argv[], const ctl_t *ctl, ret_t *ret) |
| Read retrieval configuration and error parameters. More... | |
| void | read_rfm_spec (const char *filename, double *nu, double *rad, int *npts) |
| Read a Reference Forward Model (RFM) ASCII spectrum. More... | |
| void | read_shape (const char *filename, double *x, double *y, int *n) |
| Read a two-column shape function from an ASCII file. More... | |
| tbl_t * | read_tbl (const ctl_t *ctl) |
| Read all emissivity lookup tables for all gases and frequencies. More... | |
| void | read_tbl_asc (const ctl_t *ctl, tbl_t *tbl, const int id, const int ig) |
| Read a single ASCII emissivity lookup table. More... | |
| void | read_tbl_bin (const ctl_t *ctl, tbl_t *tbl, const int id, const int ig) |
| Read a single binary emissivity lookup table. More... | |
| void | read_tbl_gas (const ctl_t *ctl, tbl_t *tbl, const int id, const int ig) |
| Read one frequency block from a per-gas binary table file. More... | |
| int | read_tbl_gas_close (tbl_gas_t *g) |
| Close a per-gas binary table file and optionally rewrite metadata. More... | |
| int | read_tbl_gas_open (const char *path, tbl_gas_t *g) |
| Open a per-gas binary table file for reading and writing. More... | |
| int | read_tbl_gas_single (const tbl_gas_t *g, const double freq, tbl_t *tbl, const int id, const int ig) |
| Read one emissivity table block from a per-gas table file. More... | |
| 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. More... | |
| 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 \(\mathbf{S_a}\) for retrieval parameters. More... | |
| 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. More... | |
| double | sza (double sec, double lon, double lat) |
| Compute the solar zenith angle for a given time and location. More... | |
| void | tangent_point (const los_t *los, double *tpz, double *tplon, double *tplat) |
| Determine the tangent point along a line of sight (LOS). More... | |
| 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. More... | |
| void | timer (const char *name, const char *file, const char *func, int line, int mode) |
| Simple wall-clock timer for runtime diagnostics. More... | |
| void | write_atm (const char *dirname, const char *filename, const ctl_t *ctl, const atm_t *atm) |
| Write atmospheric profile data to a text file. More... | |
| void | write_atm_rfm (const char *filename, const ctl_t *ctl, const atm_t *atm) |
| Write atmospheric profile in RFM-compatible format. More... | |
| 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) |
| Write a fully annotated matrix (e.g., Jacobian or gain matrix) to file. More... | |
| void | write_obs (const char *dirname, const char *filename, const ctl_t *ctl, const obs_t *obs) |
| Write observation geometry and radiance data to a text file. More... | |
| void | write_shape (const char *filename, const double *x, const double *y, const int n) |
| Write tabulated shape function data to a text file. More... | |
| 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. More... | |
| void | write_tbl (const ctl_t *ctl, const tbl_t *tbl) |
| Write all emissivity lookup tables in the format specified by the control structure. More... | |
| void | write_tbl_asc (const ctl_t *ctl, const tbl_t *tbl) |
| Write all lookup tables in human-readable ASCII format. More... | |
| void | write_tbl_bin (const ctl_t *ctl, const tbl_t *tbl) |
| Write all lookup tables in compact binary format. More... | |
| void | write_tbl_gas (const ctl_t *ctl, const tbl_t *tbl) |
| Write lookup tables into per-gas binary table files with indexed blocks. More... | |
| int | write_tbl_gas_create (const char *path) |
| Create a new per-gas table file with an empty index. More... | |
| int | write_tbl_gas_single (tbl_gas_t *g, const double freq, const tbl_t *tbl, const int id, const int ig) |
| Append or overwrite a single frequency-table block in a per-gas file. More... | |
| void | x2atm (const ctl_t *ctl, const gsl_vector *x, atm_t *atm) |
| Map retrieval state vector back to atmospheric structure. More... | |
| void | x2atm_help (double *value, const gsl_vector *x, size_t *n) |
| Helper function to extract a single value from the retrieval state vector. More... | |
| void | y2obs (const ctl_t *ctl, const gsl_vector *y, obs_t *obs) |
Copy elements from the measurement vector y into the observation structure. More... | |
JURASSIC library declarations.
Definition in file jurassic.h.
| #define C1 1.19104259e-8 |
First spectroscopic constant (c_1 = 2 h c^2) [W/(m^2 sr cm^-4)].
Definition at line 128 of file jurassic.h.
| #define C2 1.43877506 |
Second spectroscopic constant (c_2 = h c / k) [K/cm^-1].
Definition at line 133 of file jurassic.h.
| #define EPSMIN 0 |
Minimum emissivity.
Definition at line 138 of file jurassic.h.
| #define EPSMAX 1 |
Maximum emissivity.
Definition at line 143 of file jurassic.h.
| #define G0 9.80665 |
Standard gravity [m/s^2].
Definition at line 148 of file jurassic.h.
| #define H0 7.0 |
Standard scale height [km].
Definition at line 153 of file jurassic.h.
| #define KB 1.3806504e-23 |
Boltzmann constant [kg m^2/(K s^2)].
Definition at line 158 of file jurassic.h.
| #define ME 5.976e24 |
Mass of Earth [kg].
Definition at line 163 of file jurassic.h.
| #define NA 6.02214199e23 |
Avogadro's number.
Definition at line 168 of file jurassic.h.
| #define N2 0.78084 |
Nitrogen concentration.
Definition at line 173 of file jurassic.h.
| #define O2 0.20946 |
Oxygen concentration.
Definition at line 178 of file jurassic.h.
| #define P0 1013.25 |
Standard pressure [hPa].
Definition at line 183 of file jurassic.h.
| #define RE 6367.421 |
Mean radius of Earth [km].
Definition at line 188 of file jurassic.h.
| #define RI 8.3144598 |
Ideal gas constant [J/(mol K)].
Definition at line 193 of file jurassic.h.
| #define T0 273.15 |
Standard temperature [K].
Definition at line 198 of file jurassic.h.
| #define TMIN 100. |
Minimum temperature for source function [K].
Definition at line 203 of file jurassic.h.
| #define TMAX 400. |
Maximum temperature for source function [K].
Definition at line 208 of file jurassic.h.
| #define TSUN 5780. |
Effective temperature of the sun [K].
Definition at line 213 of file jurassic.h.
| #define UMIN 0 |
Minimum column density [molecules/cm^2].
Definition at line 218 of file jurassic.h.
| #define UMAX 1e30 |
Maximum column density [molecules/cm^2].
Definition at line 223 of file jurassic.h.
| #define NCL 8 |
Maximum number of cloud layer spectral grid points.
Definition at line 232 of file jurassic.h.
| #define ND 128 |
Maximum number of radiance channels.
Definition at line 237 of file jurassic.h.
| #define NG 8 |
Maximum number of emitters.
Definition at line 242 of file jurassic.h.
| #define NP 256 |
Maximum number of atmospheric data points.
Definition at line 247 of file jurassic.h.
| #define NR 256 |
Maximum number of ray paths.
Definition at line 252 of file jurassic.h.
| #define NSF 8 |
Maximum number of surface layer spectral grid points.
Definition at line 257 of file jurassic.h.
| #define NW 4 |
Maximum number of spectral windows.
Definition at line 262 of file jurassic.h.
| #define LEN 10000 |
Maximum length of ASCII data lines.
Definition at line 267 of file jurassic.h.
Maximum size of measurement vector.
Definition at line 272 of file jurassic.h.
Maximum size of state vector.
Definition at line 277 of file jurassic.h.
Maximum number of quantities.
Definition at line 282 of file jurassic.h.
| #define NLOS 4096 |
Maximum number of LOS points.
Definition at line 287 of file jurassic.h.
| #define NSHAPE 20000 |
Maximum number of shape function grid points.
Definition at line 292 of file jurassic.h.
| #define NFOV 5 |
Number of ray paths used for FOV calculations.
Definition at line 297 of file jurassic.h.
| #define TBLNP 41 |
Maximum number of pressure levels in emissivity tables.
Definition at line 302 of file jurassic.h.
| #define TBLNT 30 |
Maximum number of temperatures in emissivity tables.
Definition at line 307 of file jurassic.h.
| #define TBLNU 320 |
Maximum number of column densities in emissivity tables.
Definition at line 312 of file jurassic.h.
| #define TBLNS 1200 |
Maximum number of source function temperature levels.
Definition at line 317 of file jurassic.h.
| #define MAX_TABLES 10000 |
Maximum number of frequency-table entries allowed in a gas table file.
Definition at line 322 of file jurassic.h.
| #define RFMNPTS 10000000 |
Maximum number of RFM spectral grid points.
Definition at line 327 of file jurassic.h.
| #define IDXP 0 |
Index for pressure.
Definition at line 335 of file jurassic.h.
| #define IDXT 1 |
Index for temperature.
Definition at line 338 of file jurassic.h.
| #define IDXQ | ( | ig | ) | (2 + (ig)) |
Indices for volume mixing ratios.
Definition at line 341 of file jurassic.h.
| #define IDXK | ( | iw | ) | (2 + (ctl->ng) + (iw)) |
Indices for extinction.
Definition at line 344 of file jurassic.h.
| #define IDXCLZ (2 + (ctl->ng) + (ctl->nw)) |
Index for cloud layer height.
Definition at line 347 of file jurassic.h.
| #define IDXCLDZ (3 + (ctl->ng) + (ctl->nw)) |
Index for cloud layer depth.
Definition at line 350 of file jurassic.h.
| #define IDXCLK | ( | icl | ) | (4 + (ctl->ng) + (ctl->nw) + (icl)) |
Indices for cloud layer extinction.
Definition at line 353 of file jurassic.h.
| #define IDXSFT (4 + (ctl->ng) + (ctl->nw) + (ctl->ncl)) |
Index for surface layer temperature.
Definition at line 356 of file jurassic.h.
| #define IDXSFEPS | ( | isf | ) | (5 + (ctl->ng) + (ctl->nw) + (ctl->ncl) + (isf)) |
Indices for surface layer emissivity.
Definition at line 359 of file jurassic.h.
| #define ALLOC | ( | ptr, | |
| type, | |||
| n | |||
| ) |
Allocate memory for an array.
Allocates a contiguous block of memory for an array of n elements of type type and assigns the pointer to ptr. If allocation fails, the program prints an error message and terminates.
| [out] | ptr | Pointer to be allocated. |
| [in] | type | Data type of the elements to allocate. |
| [in] | n | Number of elements to allocate. |
malloc() with built-in error handling.Definition at line 382 of file jurassic.h.
Compute brightness temperature from radiance.
Computes the equivalent blackbody (brightness) temperature corresponding to a given spectral radiance and wavenumber, using the inverse Planck function. This form assumes the spectroscopic constants C1 and C2 are defined for wavenumber units (cm⁻¹).
| [in] | rad | Spectral radiance [W·m⁻²·sr⁻¹·(cm⁻¹)⁻¹]. |
| [in] | nu | Wavenumber [cm⁻¹]. |
C1 for radiance per unit wavenumber in cm⁻¹.Definition at line 412 of file jurassic.h.
| #define DEG2RAD | ( | deg | ) | ((deg) * (M_PI / 180.0)) |
Convert degrees to radians.
Converts an angle measured in degrees to radians using: \( \text{radians} = \text{degrees} \times \frac{\pi}{180} \).
| [in] | deg | Angle in degrees. |
Definition at line 429 of file jurassic.h.
| #define DIST | ( | a, | |
| b | |||
| ) | sqrt(DIST2(a, b)) |
Compute Cartesian distance between two 3D vectors.
Computes the Euclidean distance between two 3D vectors or points.
| [in] | a | First vector (array of length 3). |
| [in] | b | Second vector (array of length 3). |
Definition at line 447 of file jurassic.h.
| #define DIST2 | ( | a, | |
| b | |||
| ) | ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])) |
Compute squared distance between two 3D vectors.
Computes the square of the Euclidean distance between two 3D vectors. Useful when only relative distances are needed (avoids square root).
| [in] | a | First vector (array of length 3). |
| [in] | b | Second vector (array of length 3). |
Definition at line 464 of file jurassic.h.
| #define DOTP | ( | a, | |
| b | |||
| ) | (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]) |
Compute dot product of two 3D vectors.
Computes the scalar (dot) product between two 3-element vectors: \( a \cdot b = a_x b_x + a_y b_y + a_z b_z \).
| [in] | a | First vector (array of length 3). |
| [in] | b | Second vector (array of length 3). |
Definition at line 482 of file jurassic.h.
| #define FREAD | ( | ptr, | |
| type, | |||
| size, | |||
| out | |||
| ) |
Read binary data from a file.
Reads size elements of type type from the file stream out into the memory pointed to by ptr. If the number of elements read differs from size, an error message is printed and the program terminates.
| [out] | ptr | Pointer to destination memory buffer. |
| [in] | type | Type of each element to read. |
| [in] | size | Number of elements to read. |
| [in,out] | out | File stream opened for reading. |
fread() with error handling.Definition at line 502 of file jurassic.h.
| #define FWRITE | ( | ptr, | |
| type, | |||
| size, | |||
| out | |||
| ) |
Write binary data to a file.
Writes size elements of type type from the memory pointed to by ptr to the file stream out. If the number of elements written differs from size, an error message is printed and the program terminates.
| [in] | ptr | Pointer to memory buffer containing data to write. |
| [in] | type | Type of each element to write. |
| [in] | size | Number of elements to write. |
| [in,out] | out | File stream opened for writing. |
fwrite() with error handling.Definition at line 525 of file jurassic.h.
| #define LIN | ( | x0, | |
| y0, | |||
| x1, | |||
| y1, | |||
| x | |||
| ) | ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0))) |
Compute linear interpolation.
Performs simple linear interpolation between two known points (x₀, y₀) and (x₁, y₁) to estimate the value of y at a given x.
| [in] | x0 | Lower x-value. |
| [in] | y0 | Function value at x₀. |
| [in] | x1 | Upper x-value. |
| [in] | y1 | Function value at x₁. |
| [in] | x | Interpolation point. |
Definition at line 548 of file jurassic.h.
| #define LOGX | ( | x0, | |
| y0, | |||
| x1, | |||
| y1, | |||
| x | |||
| ) |
Compute logarithmic interpolation in x.
Performs interpolation assuming logarithmic variation in the x-axis. If either x/x₀ or x₁/x₀ is nonpositive, reverts to linear interpolation.
| [in] | x0 | Lower x-value. |
| [in] | y0 | Function value at x₀. |
| [in] | x1 | Upper x-value. |
| [in] | y1 | Function value at x₁. |
| [in] | x | Interpolation point. |
Definition at line 569 of file jurassic.h.
| #define LOGY | ( | x0, | |
| y0, | |||
| x1, | |||
| y1, | |||
| x | |||
| ) |
Compute logarithmic interpolation in y.
Performs interpolation assuming exponential variation in the y-axis (logarithmic in y). If y₁/y₀ is nonpositive, reverts to linear interpolation.
| [in] | x0 | Lower x-value. |
| [in] | y0 | Function value at x₀. |
| [in] | x1 | Upper x-value. |
| [in] | y1 | Function value at x₁. |
| [in] | x | Interpolation point. |
Definition at line 592 of file jurassic.h.
| #define MAX | ( | a, | |
| b | |||
| ) | (((a)>(b))?(a):(b)) |
Determine the maximum of two values.
Returns the greater of two scalar values.
| [in] | a | First value. |
| [in] | b | Second value. |
Definition at line 613 of file jurassic.h.
| #define MIN | ( | a, | |
| b | |||
| ) | (((a)<(b))?(a):(b)) |
Determine the minimum of two values.
Returns the smaller of two scalar values.
| [in] | a | First value. |
| [in] | b | Second value. |
Definition at line 631 of file jurassic.h.
Convert noise-equivalent spectral radiance (NESR) to noise-equivalent delta temperature (NEDT).
Computes the temperature noise level corresponding to a given NESR at a background radiance, using the inverse Planck function. The NEDT expresses radiometric sensitivity in temperature units, assuming blackbody emission.
| [in] | t_bg | Background (scene) brightness temperature [K]. |
| [in] | nesr | Noise-equivalent spectral radiance [W·m⁻²·sr⁻¹·(cm⁻¹)⁻¹]. |
| [in] | nu | Wavenumber [cm⁻¹]. |
\[ \mathrm{NEDT} = T_b(L_\nu(T_\mathrm{bg}) + \mathrm{NESR}) - T_\mathrm{bg} \]
where \(T_b\) is the brightness temperature from the inverse Planck function.PLANCK and BRIGHT. Mixing radiance units per meter instead of per cm⁻¹ will yield incorrect results by orders of magnitude.Definition at line 662 of file jurassic.h.
Convert noise-equivalent delta temperature (NEDT) to noise-equivalent spectral radiance (NESR).
Computes the radiance difference corresponding to a temperature noise level at a given background temperature and wavenumber, using Planck’s law. The NESR quantifies the radiometric sensitivity in spectral radiance units.
| [in] | t_bg | Background (scene) brightness temperature [K]. |
| [in] | nedt | Noise-equivalent delta temperature [K]. |
| [in] | nu | Wavenumber [cm⁻¹]. |
\[ \mathrm{NESR} = L_\nu(T_\mathrm{bg} + \mathrm{NEDT}) - L_\nu(T_\mathrm{bg}) \]
where \(L_\nu\) is spectral radiance from Planck’s law.PLANCK. In particular, nu must be given in cm⁻¹.Definition at line 691 of file jurassic.h.
| #define NORM | ( | a | ) | sqrt(DOTP(a, a)) |
Compute the norm (magnitude) of a 3D vector.
Computes the Euclidean norm using the dot product: \( |a| = \sqrt{a \cdot a} \).
| [in] | a | Input vector (array of length 3). |
Definition at line 708 of file jurassic.h.
Compute spectral radiance using Planck’s law.
Evaluates Planck’s blackbody spectral radiance for a given temperature and wavenumber. The expression is formulated in wavenumber space (cm⁻¹) and uses the spectroscopic constants C1 and C2 in wavenumber units.
| [in] | nu | Wavenumber [cm⁻¹]. |
| [in] | T | Temperature [K]. |
\[ L_\nu = \frac{C_{1}\,\nu^{3}} {\exp\!\left(\frac{C_{2}\,\nu}{T}\right) - 1} \]
with \(\nu\) in cm⁻¹. The \(\nu^{3}\) dependence follows from the definition ofC1 for radiance per wavenumber in cm⁻¹.nu in cm⁻¹ and T in kelvin. Mixing wavenumber and frequency formulations, or using radiance per meter instead of per cm⁻¹, will produce results off by orders of magnitude.Definition at line 739 of file jurassic.h.
| #define POW2 | ( | x | ) | ((x)*(x)) |
Compute the square of a value.
Returns x². Inline alternative to pow(x,2).
| [in] | x | Input value. |
Definition at line 753 of file jurassic.h.
| #define POW3 | ( | x | ) | ((x)*(x)*(x)) |
Compute the cube of a value.
Returns x³. Inline alternative to pow(x,3).
| [in] | x | Input value. |
Definition at line 766 of file jurassic.h.
| #define RAD2DEG | ( | rad | ) | ((rad) * (180.0 / M_PI)) |
Convert radians to degrees.
Converts an angle measured in radians to degrees using: \( \text{degrees} = \text{radians} \times \frac{180}{\pi} \).
| [in] | rad | Angle in radians. |
Definition at line 782 of file jurassic.h.
| #define REFRAC | ( | p, | |
| T | |||
| ) | (7.753e-05 * (p) / (T)) |
Compute air refractivity (n - 1).
Approximates the refractivity of air under standard conditions using: \( n - 1 = 7.753\times10^{-5} \frac{p}{T} \), where p is pressure (hPa) and T is temperature (K).
| [in] | p | Pressure [hPa]. |
| [in] | T | Temperature [K]. |
Definition at line 798 of file jurassic.h.
| #define TIMER | ( | name, | |
| mode | |||
| ) | {timer(name, __FILE__, __func__, __LINE__, mode);} |
Start or stop a named timer.
Calls the timer() function with contextual information (file name, function name, and line number) to start or stop timing. Useful for performance profiling.
| [in] | name | Name or label of the timer. |
| [in] | mode | Operation mode (e.g., start or stop). |
timer() function.Definition at line 813 of file jurassic.h.
| #define TOK | ( | line, | |
| tok, | |||
| format, | |||
| var | |||
| ) |
Tokenize a string and parse a variable.
Splits a text line into tokens separated by spaces or tabs, and reads a value from the first token using sscanf() and the provided format. If tokenization or parsing fails, an error message is printed.
| [in,out] | line | Input string buffer to tokenize (modified by strtok()). |
| [out] | tok | Pointer to token string. |
| [in] | format | Format string for sscanf(). |
| [out] | var | Variable to store parsed value. |
strtok() internally and modifies the input buffer.Definition at line 834 of file jurassic.h.
| #define LOGLEV 2 |
Level of log messages (0=none, 1=basic, 2=detailed, 3=debug).
Definition at line 846 of file jurassic.h.
| #define LOG | ( | level, | |
| ... | |||
| ) |
Print a log message with a specified logging level.
This macro prints a formatted log message to the standard output if the specified logging level meets certain conditions. The message will be indented if the logging level is greater than or equal to 2.
| level | The logging level of the message. This should be an integer value. |
| ... | The formatted message string and its arguments, similar to printf. |
The LOG macro provides a simple way to log messages with different levels of importance. The message is only printed if the specified level is less than or equal to the pre-defined LOGLEV macro. If the level is greater than or equal to 2, the message is preceded by two spaces for indentation.
The macro expands to a block of code that:
level is greater than or equal to 2, and if so, prints two spaces.level is less than or equal to LOGLEV, and if so, prints the formatted message followed by a newline.LOGLEV macro must be defined with an appropriate logging level before using the LOG macro.Definition at line 878 of file jurassic.h.
| #define WARN | ( | ... | ) |
Print a warning message with contextual information.
This macro prints a formatted warning message to the standard output, including the file name, function name, and line number where the warning occurred. The message is then passed to the LOG macro with a logging level of 0.
| ... | The formatted warning message string and its arguments, similar to printf. |
The WARN macro is used to print warning messages with additional context about where the warning was triggered. The message includes the following contextual information:
__FILE__).__func__).__LINE__).After printing this contextual information, the macro uses the LOG macro with a logging level of 0 to print the actual warning message. This ensures that warning messages are always logged, regardless of the value of LOGLEV.
LOG macro must be defined before using the WARN macro.Definition at line 915 of file jurassic.h.
| #define ERRMSG | ( | ... | ) |
Print an error message with contextual information and terminate the program.
This macro prints a formatted error message to the standard output, including the file name, function name, and line number where the error occurred. After printing the message, the program is terminated with an exit status indicating failure.
| ... | The formatted error message string and its arguments, similar to printf. |
The ERRMSG macro is used to report critical errors that require the program to terminate immediately. The message includes the following contextual information:
__FILE__).__func__).__LINE__).After printing this contextual information, the macro uses the LOG macro with a logging level of 0 to print the actual error message. Finally, the program exits with a failure status (EXIT_FAILURE).
LOG macro must be defined before using the ERRMSG macro.Definition at line 948 of file jurassic.h.
| #define PRINT | ( | format, | |
| var | |||
| ) |
Print the value of a variable with contextual information.
This macro prints the value of a variable to the standard output, including the file name, function name, and line number where the macro is called. The output also includes the variable's name and value in a formatted string.
| format | The format string used to print the variable's value, similar to printf. |
| var | The variable to be printed. |
The PRINT macro is used to output the value of a variable along with additional context about where the macro is called. The message includes:
__FILE__).__func__).__LINE__).#var).format).This macro is particularly useful for debugging purposes, providing a convenient way to trace variable values and their locations in the code.
Definition at line 983 of file jurassic.h.
| 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.
Decomposes and evaluates the averaging kernel matrix \(\mathbf{A}\) to quantify the retrieval sensitivity and vertical resolution for each retrieved quantity (pressure, temperature, trace gases, extinction, etc.). The results are written to diagnostic atmospheric files for visualization.
| [in] | ret | Retrieval control and configuration structure (ret_t). |
| [in] | ctl | Global control structure (ctl_t) defining retrieval setup and quantities. |
| [in] | atm | Retrieved atmospheric state structure (atm_t). |
| [in] | iqa | Array mapping state vector indices to physical quantities (e.g., IDXP, IDXT, IDXQ(...)). |
| [in] | ipa | Array mapping state vector indices to atmospheric grid points. |
| [in] | avk | Averaging kernel matrix \(\mathbf{A}\) (gsl_matrix, n×n). |
The averaging kernel matrix \(\mathbf{A}\) describes the sensitivity of the retrieved state \(\hat{x}\) to the true state \(x\):
\[ \hat{x} - x_a = \mathbf{A} (x - x_a) \]
where \(x_a\) is the a priori state.
This function separates and evaluates:
Internally, this function:
analyze_avk_quantity() for each retrieved parameter type to compute quantitative measures of contribution and resolution.atm_cont.tab — contribution functions (sensitivity).atm_res.tab — resolution functions (vertical response width).iqa[i] to the quantity constants (e.g., IDXT, IDXQ(ig), etc.).ret->dir).ret->dir.Definition at line 29 of file jurassic.c.

| 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.
Computes the contribution (sensitivity) and resolution (information density) profiles for a given physical quantity from its corresponding submatrix of the full averaging kernel matrix \(\mathbf{A}\).
| [in] | avk | Averaging kernel matrix \(\mathbf{A}\) (gsl_matrix, n×n), describing the sensitivity of the retrieved state to the true state. |
| [in] | iq | Quantity index identifier (e.g., IDXP, IDXT, IDXQ(ig), IDXK(iw), IDXCLZ, etc.). |
| [in] | ipa | Array mapping state vector indices to atmospheric grid indices. |
| [in] | n0 | Array of starting indices for each quantity sub-block in the state vector. |
| [in] | n1 | Array of lengths (number of elements) for each quantity sub-block. |
| [out] | cont | Array of contribution values, representing the total sensitivity or response of the retrieval at each grid point. |
| [out] | res | Array of resolution measures, representing the vertical information density or averaging kernel width at each grid point. |
For a given quantity \(q\), the function extracts its corresponding block \(\mathbf{A}_q\) from the full averaging kernel matrix and computes:
\[ \text{cont}_i = \sum_j A_{ij}^{(q)} \]
giving the total response of retrieved element \(i\) to perturbations in all true elements \(j\) of the same quantity.\[ \text{res}_i = \frac{1}{A_{ii}^{(q)}} \]
approximating the degree of vertical resolution or smoothing at level \(i\).The results are stored in the provided arrays cont[] and res[], indexed according to the atmospheric profile index via ipa[].
iq) are processed.atm->np).A_ii is zero or near-zero, the corresponding resolution value may be undefined or numerically unstable.n0[iq] and n1[iq] must have been computed by analyze_avk().Definition at line 86 of file jurassic.c.
Convert atmospheric data to state vector elements.
Extracts selected quantities from an atmospheric profile (atm_t) according to retrieval settings in ctl_t, and appends them to the state vector x. For each included quantity, the function also stores its quantity index (iqa) and profile index (ipa).
The function respects retrieval altitude limits defined in ctl (e.g., retp_zmin/zmax, rett_zmin/zmax, etc.) and includes only variables flagged for retrieval (e.g., ret_clz, ret_sft, etc.).
| [in] | ctl | Control settings defining retrieval configuration and limits. |
| [in] | atm | Atmospheric profile data to extract from. |
| [out] | x | GSL vector to store state-vector elements. |
| [out] | iqa | Quantity index array corresponding to elements in x. |
| [out] | ipa | Profile index array corresponding to elements in x. |
Definition at line 110 of file jurassic.c.

| 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.
Helper routine for atm2x(). Inserts one scalar value and its corresponding quantity and profile indices into the state vector and tracking arrays, then increments the element counter.
| [in] | value | Value to add to the state vector. |
| [in] | value_iqa | Quantity index (e.g., IDXP, IDXT, etc.). |
| [in] | value_ip | Profile index within the atmospheric profile. |
| [out] | x | GSL vector containing state-vector elements (may be NULL). |
| [out] | iqa | Quantity index array corresponding to x (may be NULL). |
| [out] | ipa | Profile index array corresponding to x (may be NULL). |
| [in,out] | n | Current number of elements in the state vector; incremented on return. |
Definition at line 164 of file jurassic.c.
| void cart2geo | ( | const double * | x, |
| double * | z, | ||
| double * | lon, | ||
| double * | lat | ||
| ) |
Converts Cartesian coordinates to geographic coordinates.
This function converts a point from Cartesian coordinates (x, y, z) to geographic coordinates (longitude, latitude, and altitude). It uses the spherical Earth approximation for the conversion.
| x | Pointer to an array containing the Cartesian coordinates (x, y, z) in kilometers. |
| z | Pointer to a double where the computed altitude (above the reference ellipsoid) will be stored, in kilometers. |
| lon | Pointer to a double where the computed longitude (in degrees) will be stored. |
| lat | Pointer to a double where the computed latitude (in degrees) will be stored. |
Definition at line 185 of file jurassic.c.
Initializes atmospheric climatology profiles.
This function populates the atmospheric state (atm) with standard climatological profiles of pressure, temperature, and trace gas concentrations (e.g., H2O, CH4, CO, O3, etc.) as a function of altitude. The profiles are based on reference climatological datasets and are used for atmospheric modeling and radiative transfer calculations.
| [in] | ctl | Control parameters structure. |
| [out] | atm | Atmospheric state structure to be populated with climatological data. |
Definition at line 200 of file jurassic.c.

| double cos_sza | ( | const double | sec, |
| const double | lon, | ||
| const double | lat | ||
| ) |
Calculates the cosine of the solar zenith angle.
This function computes the cosine of the solar zenith angle (SZA), which describes the angle between the local zenith (straight up) and the line connecting the observer to the center of the Sun. The cosine of the SZA is often used directly in radiative transfer and photochemical calculations to avoid unnecessary use of trigonometric inverse functions.
| sec | Seconds elapsed since 2000-01-01T12:00Z. |
| lon | Observer's longitude in degrees. |
| lat | Observer's latitude in degrees. |
The cosine of the solar zenith angle is computed based on the observer's position (longitude and latitude) and the specified time in seconds elapsed since 2000-01-01T12:00Z.
Definition at line 1138 of file jurassic.c.
| 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.
Evaluates the cost function
\[ J = \frac{1}{m} \left[ (\mathbf{y} - \mathbf{y_a})^T \mathbf{S_\epsilon^{-1}} (\mathbf{y} - \mathbf{y_a}) + (\mathbf{x} - \mathbf{x_a})^T \mathbf{S_a^{-1}} (\mathbf{x} - \mathbf{x_a}) \right] \]
where \(\mathbf{dx} = \mathbf{x} - \mathbf{x_a}\) and \(\mathbf{dy} = \mathbf{y} - \mathbf{y_a}\) represent the deviations from a priori state and measurement vectors, respectively.
| [in] | dx | State deviation vector (x - x_a). |
| [in] | dy | Measurement deviation vector (y - y_a). |
| [in] | s_a_inv | Inverse of the a priori covariance matrix ( \(\mathbf{S_a^{-1}}\)). |
| [in] | sig_eps_inv | Vector of inverse measurement uncertainties ( \(\mathbf{S_\epsilon^{-1/2}}\) diagonal elements). |
Definition at line 1179 of file jurassic.c.
| double ctmco2 | ( | const double | nu, |
| const double | p, | ||
| const double | t, | ||
| const double | u | ||
| ) |
Compute carbon dioxide continuum (optical depth).
Definition at line 1212 of file jurassic.c.
| double ctmh2o | ( | const double | nu, |
| const double | p, | ||
| const double | t, | ||
| const double | q, | ||
| const double | u | ||
| ) |
Compute water vapor continuum (optical depth).
Definition at line 2075 of file jurassic.c.
| double ctmn2 | ( | const double | nu, |
| const double | p, | ||
| const double | t | ||
| ) |
Compute N₂ collision-induced absorption coefficient.
Calculates the nitrogen (N₂) absorption coefficient due to collision-induced absorption (CIA) near the 4.3 µm CO₂ band using tabulated laboratory data for the absorption strength (B) and temperature exponent (β).
The function linearly interpolates B and β as a function of wavenumber, then applies a temperature- and pressure-dependent scaling relation to compute the absorption coefficient.
| [in] | nu | Wavenumber [cm⁻¹]. |
| [in] | p | Pressure [hPa]. |
| [in] | t | Temperature [K]. |
Definition at line 3127 of file jurassic.c.

| double ctmo2 | ( | const double | nu, |
| const double | p, | ||
| const double | t | ||
| ) |
Compute O₂ collision-induced absorption coefficient.
Calculates the molecular oxygen (O₂) absorption coefficient due to collision-induced absorption (CIA) using tabulated laboratory data for the absorption strength (B) and temperature exponent (β).
The function linearly interpolates B and β as a function of wavenumber and applies a pressure- and temperature-dependent scaling relation to compute the absorption coefficient.
| [in] | nu | Wavenumber [cm⁻¹]. |
| [in] | p | Pressure [hPa]. |
| [in] | t | Temperature [K]. |
Definition at line 3196 of file jurassic.c.

Copy or initialize atmospheric profile data.
Copies all fields from one atmospheric structure (atm_src) to another (atm_dest), including geolocation, thermodynamic, gas, extinction, cloud, and surface parameters. If init is nonzero, the destination fields are instead initialized to default values (zeros for most fields, unity for surface emissivity).
| [in] | ctl | Control structure defining array dimensions. |
| [out] | atm_dest | Destination atmospheric structure. |
| [in] | atm_src | Source atmospheric structure. |
| [in] | init | Initialization flag:
|
atm_src->np) determines the amount of data copied. The function performs shallow copies using memcpy for efficiency.Definition at line 3258 of file jurassic.c.
Copy or initialize observation geometry and radiance data.
Copies all observation fields from a source structure (obs_src) to a destination structure (obs_dest), including observer, view, and tangent point geometry, as well as radiance and transmittance data. If init is nonzero, radiance and transmittance values are reset to zero wherever finite values are found.
| [in] | ctl | Control structure defining the number of channels (ctl_t::nd) and other dimensions. |
| [out] | obs_dest | Destination observation structure. |
| [in] | obs_src | Source observation structure. |
| [in] | init | Initialization flag:
|
obs_src->nr) defines the copied data size. Shallow copies are performed via memcpy for efficiency.Definition at line 3308 of file jurassic.c.
| int find_emitter | ( | const ctl_t * | ctl, |
| const char * | emitter | ||
| ) |
Find gas species index by name.
Searches the list of emitter (gas) names defined in the control structure for a case-insensitive match to the given string. Returns the corresponding gas index if found, or -1 otherwise.
| [in] | ctl | Control structure containing the list of gas emitters. |
| [in] | emitter | Name of the gas species to search for (e.g. "H2O", "CO2"). |
strcasecmp().Definition at line 3346 of file jurassic.c.
Execute the selected forward model.
Computes synthetic radiances or brightness temperatures for the given atmospheric state and observation geometry using the selected forward-model method (CGA, EGA, or RFM). The function also applies hydrostatic adjustment, field-of-view convolution, and optional brightness-temperature conversion.
| [in] | ctl | Control structure defining model settings and options. |
| [in] | tbl | Emissivity and source-function lookup tables. |
| [in,out] | atm | Atmospheric profile; may be adjusted for hydrostatic balance. |
| [in,out] | obs | Observation geometry and radiance data; populated with model output. |
obs->rad elements marked as invalid (NaN) by applying an internal observation mask.Definition at line 3359 of file jurassic.c.

Compute total extinction including gaseous continua.
Calculates the total extinction coefficient for a given line-of-sight point by summing spectrally dependent extinction and optional gaseous continuum contributions (CO₂, H₂O, N₂, O₂).
The function updates the extinction array beta for each spectral channel based on line-by-line extinction and enabled continua flags specified in ctl.
| [in] | ctl | Control structure defining model setup and continuum options. |
| [in] | los | Line-of-sight data containing pressure, temperature, gas concentrations, and extinction coefficients. |
| [in] | ip | Index of the line-of-sight point to process. |
| [out] | beta | Array of total extinction coefficients [km⁻¹] per channel. |
Definition at line 3409 of file jurassic.c.

Apply field-of-view (FOV) convolution to modeled radiances.
Convolves pencil-beam radiances and transmittances along each ray path with the instrument field-of-view weighting function defined in the control structure. This simulates finite FOV effects on measured radiances and transmittances.
| [in] | ctl | Control structure containing FOV parameters (offsets ctl_t::fov_dz and weights ctl_t::fov_w). |
| [in,out] | obs | Observation structure; input pencil-beam data are replaced with FOV-convolved radiances and transmittances. |
| ERRMSG | if insufficient data are available for convolution. |
Definition at line 3445 of file jurassic.c.

| 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.
Simulates monochromatic radiances and transmittances along a single line of sight using a layer-by-layer pencil-beam approximation. The model includes gaseous absorption, continuum extinction, surface emission, reflection, and optional solar illumination.
| [in] | ctl | Control structure defining model configuration, gas setup, surface type, and spectral parameters. |
| [in] | tbl | Emissivity and source-function lookup tables. |
| [in] | atm | Atmospheric state containing pressure, temperature, and gas profiles. |
| [in,out] | obs | Observation data; updated with modeled radiances and transmittances for the specified ray path. |
| [in] | ir | Index of the current ray path in obs. |
Definition at line 3510 of file jurassic.c.

Interface routine for the Reference Forward Model (RFM).
Prepares input data, executes the RFM executable, and imports simulated radiances and transmittances into the observation structure. The routine converts the atmospheric and geometric configuration from internal JURASSIC data structures into RFM-compatible driver and atmosphere files, then reads the RFM output spectra.
| [in] | ctl | Control structure defining model configuration, RFM executable path, HITRAN database, and spectral setup. |
| [in] | atm | Atmospheric state structure containing pressure, temperature, and gas profiles. |
| [in,out] | obs | Observation geometry and radiance data to be populated with RFM-computed radiances and transmittances. |
atm. It automatically determines whether the geometry is limb, nadir, or observer-based.RAD, TRA, MIX, CTM) based on the control settings. Temporary files such as rfm.drv, rfm.atm, and rad_*.asc are created and removed automatically.| ERRMSG | on inconsistent geometry, failed I/O, or system call errors. |
Definition at line 3645 of file jurassic.c.

Interpolate the source function (Planck radiance) at a given temperature.
Computes source function values by linearly interpolating between precomputed Planck radiances in the lookup table. The resulting radiance spectrum corresponds to the input temperature and is stored in src for all spectral channels.
| [in] | ctl | Control structure defining the number of spectral channels. |
| [in] | tbl | Emissivity and source-function lookup table containing Planck radiances (tbl_t::sr) and corresponding temperatures (tbl_t::st). |
| [in] | t | Temperature [K] for which the source function is evaluated. |
| [out] | src | Output array of interpolated source-function values [W·m⁻²·sr⁻¹·cm⁻¹] per spectral channel. |
Definition at line 3786 of file jurassic.c.

| void geo2cart | ( | const double | z, |
| const double | lon, | ||
| const double | lat, | ||
| double * | x | ||
| ) |
Converts geographic coordinates (longitude, latitude, altitude) to Cartesian coordinates.
This function converts geographic coordinates specified by longitude, latitude, and altitude into Cartesian coordinates. The Earth is approximated as a sphere with radius defined by the constant RE.
| z | The altitude above the Earth's surface in kilometers. |
| lon | The longitude in degrees. |
| lat | The latitude in degrees. |
| x | Pointer to an array of three doubles where the computed Cartesian coordinates (x, y, z) will be stored. |
The function computes the Cartesian coordinates using the given altitude, longitude, and latitude. It assumes the Earth is a perfect sphere and uses the following formulas:
RE is defined as the Earth's radius in kilometers. Definition at line 3803 of file jurassic.c.
Adjust pressure profile using the hydrostatic equation.
Recomputes the atmospheric pressure field to ensure hydrostatic equilibrium with respect to altitude and temperature. Starting from a reference altitude (ctl_t::hydz), the routine integrates the hydrostatic balance equation both upward and downward through the profile using small interpolation steps.
The air density is corrected for humidity using the mean molecular mass of dry air and water vapor.
| [in] | ctl | Control structure providing model constants and reference altitude (ctl_t::hydz) and H₂O index (ctl_t::ig_h2o). |
| [in,out] | atm | Atmospheric state; input temperatures, heights, and humidities are used to update pressure [hPa]. |
Definition at line 3823 of file jurassic.c.
| void idx2name | ( | const ctl_t * | ctl, |
| const int | idx, | ||
| char * | quantity | ||
| ) |
Convert a quantity index to a descriptive name string.
Translates a model quantity index (e.g., pressure, temperature, gas mixing ratio, extinction, or surface parameter) into a human-readable name. The function uses the index mapping defined in the control structure to assign appropriate labels.
| [in] | ctl | Control structure containing gas, window, cloud, and surface setup information. |
| [in] | idx | Quantity index (see IDXP, IDXT, IDXQ, IDXK, etc.). |
| [out] | quantity | Character buffer to receive the descriptive quantity name (e.g., "PRESSURE", "H2O", "CLOUD_HEIGHT", "SURFACE_EMISSIVITY_1000.0"). |
quantity using sprintf(). The caller must ensure sufficient buffer size (≥ LEN).Definition at line 3883 of file jurassic.c.
Initialize the source-function (Planck radiance) lookup table.
Computes channel-averaged Planck radiances for a range of temperatures and stores them in the source-function table. For each spectral channel, the Planck function is integrated over the instrument filter function defined in the corresponding filter file (*.filt).
| [in] | ctl | Control structure defining spectral channels and table base name. |
| [out] | tbl | Emissivity and source-function lookup table to populate. |
<tblbase>_<wavenumber>.filt.Definition at line 3922 of file jurassic.c.

| 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.
Computes pressure, temperature, volume mixing ratios, and extinction coefficients at the specified altitude by interpolating between adjacent model levels in the atmospheric profile.
| [in] | ctl | Control structure defining the number of gases (ctl_t::ng) and spectral windows (ctl_t::nw). |
| [in] | atm | Atmospheric profile providing altitude, pressure, temperature, gas mixing ratios, and extinction data. |
| [in] | z | Target altitude [km]. |
| [out] | p | Interpolated pressure [hPa]. |
| [out] | t | Interpolated temperature [K]. |
| [out] | q | Interpolated gas volume mixing ratios [ppv], length ctl_t::ng. |
| [out] | k | Interpolated extinction coefficients [km⁻¹], length ctl_t::nw. |
Definition at line 3976 of file jurassic.c.

| 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).
Computes gas transmittance along a line-of-sight segment by interpolating precomputed emissivity values from lookup tables. The interpolation is performed in pressure, temperature, and column density space using bilinear (in p, T) and logarithmic (in p) interpolation.
| [in] | ctl | Control structure defining number of gases (ctl_t::ng) and channels (ctl_t::nd). |
| [in] | tbl | Emissivity lookup tables (tbl_t) containing tabulated pressure, temperature, and column density grids. |
| [in] | los | Line-of-sight structure providing Curtis–Godson mean parameters and column densities. |
| [in] | ip | Index of the current LOS point. |
| [in,out] | tau_path | Path transmittance array [nd][ng]; updated cumulatively for each gas. |
| [out] | tau_seg | Total segment transmittance per channel [nd]. |
tbl->eps) for each gas and channel.Definition at line 4001 of file jurassic.c.

| 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).
Computes gas transmittance along a line-of-sight segment by interpolating emissivity values from lookup tables based on the Emissivity Growth Approximation (EGA). The interpolation is performed in pressure, temperature, and effective column density space derived from the local LOS properties.
| [in] | ctl | Control structure defining number of gases (ctl_t::ng) and channels (ctl_t::nd). |
| [in] | tbl | Emissivity lookup tables (tbl_t) containing tabulated pressure, temperature, and column density grids. |
| [in] | los | Line-of-sight structure providing local pressure, temperature, and column density data. |
| [in] | ip | Index of the current LOS point. |
| [in,out] | tau_path | Path transmittance array [nd][ng]; updated cumulatively for each gas. |
| [out] | tau_seg | Total segment transmittance per channel [nd]. |
tbl->eps) and performs bilinear interpolation in pressure and temperature.Definition at line 4090 of file jurassic.c.

|
inline |
Interpolate emissivity from lookup tables as a function of column density.
Retrieves the emissivity corresponding to a given column density u for a specific gas, channel, pressure level, and temperature index from the precomputed emissivity tables.
| [in] | tbl | Emissivity lookup tables (tbl_t). |
| [in] | ig | Gas index. |
| [in] | id | Channel index. |
| [in] | ip | Pressure level index. |
| [in] | it | Temperature level index. |
| [in] | u | Column density [molecules/cm²]. |
u for u < u_min.eps → 1 as u → ∞).tbl->u and tbl->eps.Definition at line 4186 of file jurassic.c.

|
inline |
Interpolate column density from lookup tables as a function of emissivity.
Returns the column density corresponding to a given emissivity eps for a specific gas, channel, pressure level, and temperature index from the precomputed emissivity tables.
| [in] | tbl | Emissivity lookup tables (tbl_t). |
| [in] | ig | Gas index. |
| [in] | id | Channel index. |
| [in] | ip | Pressure level index. |
| [in] | it | Temperature level index. |
| [in] | eps | Emissivity value (0–1). |
eps < eps_min, applies linear extrapolation proportional to emissivity.eps > eps_max, applies exponential extrapolation following the emissivity growth law.tbl->eps and tbl->u.Definition at line 4218 of file jurassic.c.

| 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.
This function converts Julian seconds to calendar date and time components, including year, month, day, hour, minute, and second. It also calculates the fractional part of the seconds.
| jsec | Julian seconds to convert. |
| year | Pointer to store the year. |
| mon | Pointer to store the month. |
| day | Pointer to store the day. |
| hour | Pointer to store the hour. |
| min | Pointer to store the minute. |
| sec | Pointer to store the second. |
| remain | Pointer to store the fractional part of seconds. |
The function initializes a time structure t0 with a fixed starting date and time. It then converts the Julian seconds to a time_t type by adding the seconds to the epoch time. Next, it converts the time_t value to a UTC time structure t1. Finally, it extracts the year, month, day, hour, minute, and second components from t1 and calculates the fractional part of seconds, which is stored in remain.
Definition at line 4250 of file jurassic.c.
Compute the Jacobian (kernel) matrix by finite differences.
Evaluates the sensitivity of the simulated radiances to each element of the atmospheric state vector by perturbing one parameter at a time and re-running the forward model. The result is the Jacobian matrix \( K = \partial y / \partial x \), where y is the measurement vector and x is the state vector.
| [in] | ctl | Control structure defining retrieval configuration and model setup. |
| [in] | tbl | Emissivity lookup tables used by the forward model. |
| [in] | atm | Atmospheric state vector and profile data. |
| [in] | obs | Observation geometry and radiance data. |
| [out] | k | Jacobian matrix [m×n], where m is the number of measurements and n the number of state variables. |
h depending on its physical type (pressure, temperature, VMR, etc.).Definition at line 4283 of file jurassic.c.

| int locate_irr | ( | const double * | xx, |
| const int | n, | ||
| const double | x | ||
| ) |
Locate index for interpolation on an irregular grid.
Finds the lower index ilo such that \( xx[ilo] \le x < xx[ilo+1] \) for monotonically increasing or decreasing grids.
Used in interpolation routines for altitude, pressure, temperature, or wavenumber profiles that are not evenly spaced.
| [in] | xx | Array of monotonic grid values (increasing or decreasing). |
| [in] | n | Number of grid points. |
| [in] | x | Target value to locate within the grid range. |
ilo of the lower grid point surrounding x.x lies within the range of xx; no bounds checking beyond the first and last grid points is performed.Definition at line 4378 of file jurassic.c.
| int locate_reg | ( | const double * | xx, |
| const int | n, | ||
| const double | x | ||
| ) |
Locate index for interpolation on a regular (uniform) grid.
Computes the lower index i such that \( xx[i] \le x < xx[i+1] \) for evenly spaced grid points. Used for quick index lookup when the grid spacing is constant.
| [in] | xx | Array of regularly spaced grid values. |
| [in] | n | Number of grid points. |
| [in] | x | Target value to locate within the grid range. |
i of the lower grid point surrounding x.[0, n - 2] to avoid out-of-bounds indices.Definition at line 4408 of file jurassic.c.
|
inline |
Locate index for interpolation within emissivity table grids.
Finds the lower index ilo such that \( xx[ilo] \le x < xx[ilo+1] \) in a monotonically increasing single-precision grid.
Used for emissivity and column density interpolation in table-based routines such as intpol_tbl_eps and intpol_tbl_u.
| [in] | xx | Monotonic (increasing) single-precision grid array. |
| [in] | n | Number of grid points. |
| [in] | x | Target value to locate within the grid range. |
ilo of the lower grid point surrounding x.float to minimize memory use.x lies within the table range.Definition at line 4427 of file jurassic.c.
| void matrix_invert | ( | gsl_matrix * | a | ) |
Invert a square matrix, optimized for diagonal or symmetric positive-definite matrices.
Performs in-place inversion of the matrix \(\mathbf{A}\) using either:
| [in,out] | a | Square matrix (gsl_matrix) to be inverted in place. |
The function first checks whether the input matrix is diagonal by testing all off-diagonal elements. If diagonal, each diagonal element \(a_{ii}\) is replaced by its reciprocal \(1/a_{ii}\).
For non-diagonal matrices, a Cholesky decomposition is performed:
\[ \mathbf{A} = \mathbf{L}\mathbf{L}^T \]
followed by inversion using the Cholesky factors, yielding \(\mathbf{A}^{-1}\).
This approach assumes \(\mathbf{A}\) is symmetric and positive-definite.
Definition at line 4449 of file jurassic.c.
| void matrix_product | ( | const gsl_matrix * | a, |
| const gsl_vector * | b, | ||
| const int | transpose, | ||
| gsl_matrix * | c | ||
| ) |
Compute structured matrix products of the form \(A^T B A\) or \(A B A^T\).
Evaluates matrix products commonly used in covariance propagation and optimal estimation, depending on the specified transpose mode:
The vector \(\mathbf{b}\) represents the diagonal elements of \(\mathbf{B}\), i.e. a diagonal weighting or covariance matrix.
| [in] | a | Input matrix \(\mathbf{A}\) (size m×n). |
| [in] | b | Vector representing the diagonal of \(\mathbf{B}\) (length m or n). |
| [in] | transpose | Operation selector:
|
| [out] | c | Output matrix to store the resulting product. |
dgemm routines for efficiency: \[ A^T B A = (B^{1/2}A)^T (B^{1/2}A), \quad A B A^T = (A B^{1/2}) (A B^{1/2})^T \]
transpose is not 1 or 2, the function performs no operation.Definition at line 4479 of file jurassic.c.
Convert observation radiances into a measurement vector.
Extracts all finite radiance values from the observation structure and stores them sequentially in a GSL vector.
Optionally records detector (id) and ray path (ir) indices for each measurement element.
| [in] | ctl | Control structure containing observation setup (e.g. number of detectors). |
| [in] | obs | Observation data structure containing radiances. |
| [out] | y | Measurement vector to store radiances (may be NULL). |
| [out] | ida | Optional array to store detector indices (may be NULL). |
| [out] | ira | Optional array to store ray path indices (may be NULL). |
nd) and ray paths (nr).NaN or Inf) radiance values.ida and ira must be preallocated with sufficient size to hold all finite radiances if provided.Definition at line 4524 of file jurassic.c.
Perform line-of-sight (LOS) ray tracing through the atmosphere.
Computes the geometric path of a viewing ray from the observer to the atmosphere (and possibly the surface), accounting for spherical geometry, optional refraction, and cloud or surface interactions.
Fills the LOS structure with pressure, temperature, gas concentrations, extinction, and path length at each step.
| [in] | ctl | Control structure containing model and numerical settings. |
| [in] | atm | Atmospheric state structure (profiles of p, T, q, k, etc.). |
| [in,out] | obs | Observation geometry and radiance data; updated tangent point. |
| [out] | los | Line-of-sight structure to be populated with sampled quantities. |
| [in] | ir | Index of the current ray path in the observation set. |
ds determined by altitude and user-specified controls (rayds, raydz).n(p, T).NLOS.Definition at line 4551 of file jurassic.c.

Read atmospheric profile data from an ASCII file.
Loads an atmospheric state profile into the atm_t structure from a text file containing altitude-dependent quantities such as pressure, temperature, volume mixing ratios, and extinction coefficients.
Optionally reads cloud and surface parameters for the first level.
| [in] | dirname | Directory containing the input file (may be NULL). |
| [in] | filename | Atmospheric profile filename. |
| [in] | ctl | Control structure defining number of gases, windows, etc. |
| [out] | atm | Atmospheric data structure to be filled with profile data. |
ng emitters,nw windows. clz, cldz, clk) and surface (sft, sfeps) parameters if enabled in ctl.NP.Definition at line 4787 of file jurassic.c.
| void read_ctl | ( | int | argc, |
| char * | argv[], | ||
| ctl_t * | ctl | ||
| ) |
Read model control parameters from command-line and configuration input.
Parses all numerical and string parameters required to initialize a JURASSIC simulation, including atmospheric composition, radiative channels, cloud and surface options, continua, ray-tracing setup, retrieval parameters, and output settings.
Populates the ctl_t structure with all configuration values.
| [in] | argc | Argument count from the command line. |
| [in] | argv | Argument vector containing user-specified options. |
| [out] | ctl | Control structure to be filled with parsed settings. |
NG, EMITTER),ND, NU, WINDOW),NCL, CLNU),NSF, SFNU, SFTYPE, SFSZA),HYDZ),CTM_CO2, CTM_H2O, CTM_N2, CTM_O2),REFRAC, RAYDS, RAYDZ),FOV),RETP_ZMIN, RETQ_ZMAX, etc.),WRITE_BBT, WRITE_MATRIX),RFMBIN, RFMHIT, RFMXSC).NG > NG_MAX).NCL > 1, NSF > 1).ERRMSG() aborts.Definition at line 4889 of file jurassic.c.

| void read_matrix | ( | const char * | dirname, |
| const char * | filename, | ||
| gsl_matrix * | matrix | ||
| ) |
Read a numerical matrix from an ASCII file.
Loads values into a GSL matrix from a text file containing sparse or indexed entries in tabular format.
Each valid line is parsed for row and column indices and the corresponding value.
| [in] | dirname | Directory path containing the matrix file (may be NULL). |
| [in] | filename | Name of the matrix file to read. |
| [out] | matrix | Pointer to the GSL matrix to be filled with values. |
gsl_matrix_set().Definition at line 5003 of file jurassic.c.
Read observation geometry and radiance data from an ASCII file.
Loads line-of-sight (LOS) and radiance information into the obs_t structure from a text file. Each record represents one observation ray with associated geometry (observer, view point, tangent point) and optionally measured radiances and transmittances for multiple spectral channels.
| [in] | dirname | Directory containing the input file (may be NULL). |
| [in] | filename | Observation data filename. |
| [in] | ctl | Control structure defining number of radiance channels. |
| [out] | obs | Observation data structure to be populated. |
nd channels,WRITE_BBT flag.NR or no data are read.Definition at line 5043 of file jurassic.c.
| 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.
Opens the appropriate RFM ASCII spectrum file for a given tangent or observation altitude and convolves the high-resolution spectrum with a provided instrument filter function.
Returns the integrated (filtered) radiance value.
| [in] | basename | Base filename of the RFM output (e.g. "rad" or "tra"). |
| [in] | z | Altitude [km] used to select the corresponding RFM file. |
| [in] | nu | Wavenumber grid [cm⁻¹] of the filter function. |
| [in] | f | Filter transmission values corresponding to nu. |
| [in] | n | Number of points in nu and f arrays. |
basename_<altitude_in_meters>.asc (e.g. rad_04500.asc).nurfm) and radiances (rad).\[ R = \frac{\int f(\nu) \, I(\nu) \, d\nu}{\int f(\nu) \, d\nu} \]
nu and f arrays are monotonic and have at least two points.Definition at line 5144 of file jurassic.c.

Read retrieval configuration and error parameters.
Initializes the retrieval control structure (ret_t) by reading all iteration and uncertainty parameters from the command line or an input control file using the scan_ctl() interface.
| [in] | argc | Number of command-line arguments. |
| [in] | argv | Command-line argument vector. |
| [in] | ctl | Pointer to global control structure (ctl_t) defining the number of emitters, detectors, windows, clouds, etc. |
| [out] | ret | Pointer to retrieval configuration structure (ret_t) to be populated with iteration and error settings. |
The function performs the following initialization steps:
KERNEL_RECOMP — number of iterations between kernel recomputations. CONV_ITMAX — maximum number of retrieval iterations. CONV_DMIN — minimum normalized step size for convergence.ERR_ANA — enables or disables retrieval error analysis (0 = off, 1 = on).ERR_FORMOD[id] — relative (%) forward model uncertainty per detector channel. ERR_NOISE[id] — absolute instrument noise per detector channel write_bbt.ERR_PRESS, ERR_PRESS_CZ, ERR_PRESS_CH — pressure error [%] and correlation lengths [km]. ERR_TEMP, ERR_TEMP_CZ, ERR_TEMP_CH — temperature error [K] and correlation lengths [km].ERR_Q[ig], ERR_Q_CZ[ig], ERR_Q_CH[ig] — per gas [%] and correlation lengths [km].ERR_K[iw], ERR_K_CZ[iw], ERR_K_CH[iw] — per spectral window [km⁻¹] and correlation lengths [km].ERR_CLZ — cloud top height error [km]. ERR_CLDZ — cloud depth error [km]. ERR_CLK[icl] — cloud extinction error per frequency [km⁻¹].ERR_SFT — surface temperature error [K]. ERR_SFEPS[isf] — surface emissivity errors (dimensionless).-999 indicate uncorrelated (diagonal) treatment.ctl and ret dimensions.Definition at line 5202 of file jurassic.c.

| void read_rfm_spec | ( | const char * | filename, |
| double * | nu, | ||
| double * | rad, | ||
| int * | npts | ||
| ) |
Read a Reference Forward Model (RFM) ASCII spectrum.
Parses an RFM output file containing high-resolution spectral radiances and fills the provided arrays with wavenumber and radiance values.
| [in] | filename | Name of the RFM ASCII spectrum file (e.g. "rad_04500.asc"). |
| [out] | nu | Array to receive the spectral wavenumber grid [cm⁻¹]. |
| [out] | rad | Array to receive the corresponding radiances. |
| [out] | npts | Pointer to integer receiving the number of spectral points. |
npts),nu0 [cm⁻¹],dnu [cm⁻¹],nu1 [cm⁻¹].nu0 and nu1: \[ \nu_i = \nu_0 + i \, \frac{\nu_1 - \nu_0}{N - 1}, \quad i = 0,\dots,N-1 \]
RFMNPTS..asc output.Definition at line 5255 of file jurassic.c.
| void read_shape | ( | const char * | filename, |
| double * | x, | ||
| double * | y, | ||
| int * | n | ||
| ) |
Read a two-column shape function from an ASCII file.
Loads tabulated x–y data pairs (e.g., filter transmission or field-of-view weighting function) into the provided arrays.
| [in] | filename | Name of the ASCII file containing the shape function. |
| [out] | x | Array to receive the abscissa values. |
| [out] | y | Array to receive the ordinate values. |
| [out] | n | Pointer to integer receiving the number of data points read. |
x), typically wavenumber [cm⁻¹] or angular offset [deg].y), typically transmission or weighting value.NSHAPE.x values.Definition at line 5316 of file jurassic.c.
Read all emissivity lookup tables for all gases and frequencies.
This function allocates a new tbl_t structure and fills it by reading emissivity lookup tables for each trace gas (ig) and each frequency index (id) specified in the control structure. The lookup tables may be read from ASCII, binary, or per-gas table files depending on ctl->tblfmt.
After loading all tables, the source function is initialized with init_srcfunc().
| ctl | Pointer to control structure containing table metadata, number of gases, number of frequencies, filenames, etc. |
tbl_t structure containing all loaded lookup-table data. The caller owns the returned pointer and must free it when done.ERRMSG() if unexpected table formats or dimension overflows occur.Definition at line 5358 of file jurassic.c.

Read a single ASCII emissivity lookup table.
This reads one ASCII table corresponding to frequency index id and gas index ig. The table format is:
pressure temperature column_density emissivity
The function automatically determines the pressure, temperature, and column-density indices based on new values appearing in the file.
Out-of-range values for u or eps are skipped and counted.
| ctl | Pointer to control structure specifying filenames and grids. |
| tbl | Pointer to the table structure to be filled. |
| id | Frequency index. |
| ig | Gas index. |
ERRMSG() if table dimensions exceed TBLNP/TBLNT/TBLNU.Definition at line 5410 of file jurassic.c.
Read a single binary emissivity lookup table.
Reads the binary table stored as:
The function fills the corresponding entries of the tbl_t structure.
| ctl | Pointer to control structure specifying filenames and grids. |
| tbl | Pointer to the table structure to be filled. |
| id | Frequency index. |
| ig | Gas index. |
ERRMSG() if table dimensions exceed TBLNP/TBLNT/TBLNU.Definition at line 5508 of file jurassic.c.
Read one frequency block from a per-gas binary table file.
Opens the gas-specific table file (e.g., base_emitter.tbl) and reads the table block corresponding to frequency ctl->nu[id]. The block is appended to the in-memory tbl_t.
| ctl | Pointer to control structure containing table metadata. |
| tbl | Pointer to table structure to populate. |
| id | Frequency index. |
| ig | Gas index. |
Definition at line 5568 of file jurassic.c.

| int read_tbl_gas_close | ( | tbl_gas_t * | g | ) |
Close a per-gas binary table file and optionally rewrite metadata.
If the table was modified (g->dirty != 0), the header and index are rewritten before closing the file. After closing, memory associated with the table index is freed.
| g | Pointer to an open gas-table handle. |
Definition at line 5598 of file jurassic.c.
| int read_tbl_gas_open | ( | const char * | path, |
| tbl_gas_t * | g | ||
| ) |
Open a per-gas binary table file for reading and writing.
Reads and validates the file header, then loads the entire index of table blocks. The resulting tbl_gas_t structure tracks the file pointer, index, and table count.
| path | Path to the .tbl file. |
| g | Output parameter: populated table-file handle. |
ERRMSG() on invalid magic or format.Definition at line 5631 of file jurassic.c.
| int read_tbl_gas_single | ( | const tbl_gas_t * | g, |
| const double | freq, | ||
| tbl_t * | tbl, | ||
| const int | id, | ||
| const int | ig | ||
| ) |
Read one emissivity table block from a per-gas table file.
Locates the index entry corresponding to the requested frequency freq. If found, seeks to the stored offset and reads:
The data are stored into tbl[id][ig].
| g | Pointer to an open gas-table handle. |
| freq | Frequency to be read. |
| tbl | Pointer to output table structure. |
| id | Frequency index. |
| ig | Gas index. |
Definition at line 5660 of file jurassic.c.
| 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.
Searches for a named variable in the JURASSIC control file or command-line arguments, returning its value as a double. Optionally stores the value as a string and supports array-style parameters (e.g., EMITTER[0], NU[5]).
| [in] | argc | Number of command-line arguments. |
| [in] | argv | Command-line argument vector. |
| [in] | varname | Name of the control variable to read. |
| [in] | arridx | Array index (use -1 for scalar variables). |
| [in] | defvalue | Default value if variable is not found (can be empty). |
| [out] | value | Optional pointer to a string buffer receiving the value (may be NULL if only numeric output is required). |
double.argv[1]), unless it starts with '-'.VAR (scalar)VAR[index] (explicit array index)VAR[*] (wildcard entry applying to all indices)defvalue is used (if non-empty).ctl_t checks to ensure consistency.Definition at line 5738 of file jurassic.c.
| 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 \(\mathbf{S_a}\) for retrieval parameters.
Builds the full a priori covariance matrix based on specified retrieval error assumptions and correlation lengths defined in the ret_t structure. Each diagonal element represents the variance of an individual state vector element, while off-diagonal terms encode spatial correlations between parameters of the same type.
| [in] | ret | Retrieval configuration and error parameters (ret_t). |
| [in] | ctl | Control structure defining retrieval setup and state vector mapping (ctl_t). |
| [in] | atm | Atmospheric profile structure containing geolocation and altitude information (atm_t). |
| [in] | iqa | Index array linking state vector elements to physical quantities (e.g. pressure, temperature, gas, extinction, etc.). |
| [in] | ipa | Index array linking state vector elements to atmospheric grid points. |
| [out] | s_a | Output a priori covariance matrix \(\mathbf{S_a}\) (gsl_matrix), dimension n×n. |
atm2x) and scales them according to their a priori uncertainties:\[ \rho_{ij} = \exp\left(-\frac{d_{ij}}{L_h} - \frac{|z_i - z_j|}{L_v}\right) \]
where:iqa[i] == iqa[j]) are assumed to share correlation properties.ret_t, differing by parameter type:err_press_cz, err_press_cherr_temp_cz, err_temp_cherr_q_cz[], err_q_ch[]err_k_cz[], err_k_ch[]Definition at line 5807 of file jurassic.c.

| 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.
Builds the total measurement uncertainty vector used in the optimal estimation retrieval, accounting for both instrument noise and forward model (systematic) errors.
| [in] | ret | Retrieval configuration and error parameters (ret_t). |
| [in] | ctl | Control structure defining spectral channels and setup (ctl_t). |
| [in] | obs | Observation dataset (obs_t), containing measured radiances or brightness temperatures. |
| [out] | sig_noise | Vector of instrument noise standard deviations (gsl_vector), length m. |
| [out] | sig_formod | Vector of forward model error standard deviations (gsl_vector), length m. |
| [out] | sig_eps_inv | Vector of inverse total standard deviations, \(\sigma_\epsilon^{-1}\), used for normalization. |
\[ \sigma_{\epsilon,i}^2 = \sigma_{\text{noise},i}^2 + \sigma_{\text{formod},i}^2 \]
and stores its reciprocal square root:\[ (\sigma_{\epsilon,i}^{-1}) = \frac{1}{\sqrt{\sigma_{\epsilon,i}^2}} \]
sig_noise)** ret->err_noise[id] for each spectral channel. The noise term is always included in the fit.sig_formod)** ret->err_formod[id]) of the measured radiance (or brightness temperature) per channel. This represents uncertainty due to imperfect forward modeling.sig_eps_inv) is used to normalize the measurement residuals \((y - F(x))\) in the cost function.NAN.obs and ctl are consistent in dimension and indexing.Definition at line 5918 of file jurassic.c.

| double sza | ( | double | sec, |
| double | lon, | ||
| double | lat | ||
| ) |
Compute the solar zenith angle for a given time and location.
Calculates the apparent solar zenith angle (SZA) [deg] based on the observer’s longitude, latitude, and time since 2000-01-01 T00:00 Z.
| [in] | sec | Seconds since 2000-01-01 T00:00 Z. |
| [in] | lon | Observer longitude [deg]. |
| [in] | lat | Observer latitude [deg]. |
\[ \cos(\theta) = \sin(\varphi)\sin(\delta) + \cos(\varphi)\cos(\delta)\cos(h) \]
where \(\varphi\) = latitude, \(\delta\) = declination, \(h\) = hour angle.| void tangent_point | ( | const los_t * | los, |
| double * | tpz, | ||
| double * | tplon, | ||
| double * | tplat | ||
| ) |
Determine the tangent point along a line of sight (LOS).
Computes the location of the tangent point — the point of minimum altitude — along the current line of sight, based on the LOS geometry stored in los_t.
| [in] | los | Pointer to the line-of-sight (LOS) structure containing altitude, longitude, latitude, and segment length data. |
| [out] | tpz | Pointer to variable receiving tangent point altitude [km]. |
| [out] | tplon | Pointer to variable receiving tangent point longitude [deg]. |
| [out] | tplat | Pointer to variable receiving tangent point latitude [deg]. |
ds) must be consistent with the geometric spacing between altitude points for the interpolation to be accurate.Definition at line 5962 of file jurassic.c.

| 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.
This function calculates the number of seconds elapsed since January 1, 2000, 12:00:00 UTC, based on the provided year, month, day, hour, minute, and second. It also includes a fractional part to represent the remaining seconds.
| year | The year. |
| mon | The month (1-12). |
| day | The day of the month (1-31). |
| hour | The hour of the day (0-23). |
| min | The minute (0-59). |
| sec | The second (0-59). |
| remain | The fractional part of seconds. |
| jsec | Pointer to store the calculated number of seconds since January 1, 2000, 12:00:00 UTC. |
The function calculates the time elapsed since January 1, 2000, 12:00:00 UTC, up to the specified time and includes any fractional seconds indicated by the "remain" parameter.
Definition at line 6006 of file jurassic.c.
| void timer | ( | const char * | name, |
| const char * | file, | ||
| const char * | func, | ||
| int | line, | ||
| int | mode | ||
| ) |
Simple wall-clock timer for runtime diagnostics.
Provides a lightweight timing utility based on omp_get_wtime() to measure wall-clock durations between marked code regions. The function supports up to ten concurrent nested timers.
| [in] | name | Name or label of the timed code section. |
| [in] | file | Source file name (usually __FILE__ macro). |
| [in] | func | Function name (usually __func__ macro). |
| [in] | line | Source line number (usually __LINE__ macro). |
| [in] | mode | Timer operation mode:
|
mode == 1 starts a new timer instance and stores its start time and corresponding source line.mode == 2 or mode == 3 is called, the elapsed wall-clock time (in seconds) is computed using: \[ \Delta t = t_{\text{now}} - t_{\text{start}} \]
and written to the log via the LOG macro.mode == 2 or 3 without a prior start causes an internal error.Definition at line 6037 of file jurassic.c.
| void write_atm | ( | const char * | dirname, |
| const char * | filename, | ||
| const ctl_t * | ctl, | ||
| const atm_t * | atm | ||
| ) |
Write atmospheric profile data to a text file.
Exports an atmospheric state (pressure, temperature, and composition) to an ASCII file for diagnostic output or reuse as model input.
| [in] | dirname | Output directory path (may be NULL). |
| [in] | filename | Output file name. |
| [in] | ctl | Pointer to control structure defining model setup. |
| [in] | atm | Pointer to atmospheric data structure to write. |
ctl->emitter[]) [ppv] N...M: Spectral-window extinction coefficients [km⁻¹]NP.Definition at line 6075 of file jurassic.c.
Write atmospheric profile in RFM-compatible format.
Exports the current atmospheric state to a file formatted for use with the Reference Forward Model (RFM). The file includes altitude, pressure, temperature, and volume mixing ratio profiles for each active emitter.
| [in] | filename | Output file name for the RFM atmosphere file. |
| [in] | ctl | Pointer to the control structure defining active emitters. |
| [in] | atm | Pointer to the atmospheric profile to export. |
atm->np).*HGT, *PRE, etc.) and lists one value per line.Definition at line 6192 of file jurassic.c.
| 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 | ||
| ) |
Write a fully annotated matrix (e.g., Jacobian or gain matrix) to file.
Outputs a numerical matrix along with detailed metadata describing the row and column spaces. Depending on configuration, the rows and columns may correspond to measurement or state variables.
| [in] | dirname | Output directory path (may be NULL). |
| [in] | filename | Output file name. |
| [in] | ctl | Pointer to control structure defining model setup and metadata. |
| [in] | matrix | Pointer to GSL matrix to write (e.g., Jacobian, kernel, or covariance). |
| [in] | atm | Pointer to atmospheric data structure (used when state-space indexing applies). |
| [in] | obs | Pointer to observation data structure (used when measurement-space indexing applies). |
| [in] | rowspace | Selects row labeling: "y" = measurement space, otherwise state space. |
| [in] | colspace | Selects column labeling: "y" = measurement space, otherwise state space. |
| [in] | sort | Determines writing order: "r" = row-major, otherwise column-major. |
ctl->write_matrix — output is skipped if disabled.sort to support row-major or column-major output.Definition at line 6230 of file jurassic.c.

| void write_obs | ( | const char * | dirname, |
| const char * | filename, | ||
| const ctl_t * | ctl, | ||
| const obs_t * | obs | ||
| ) |
Write observation geometry and radiance data to a text file.
Exports observation metadata, viewing geometry, and simulated or measured radiance data to an ASCII file. The format is compatible with read_obs() and provides detailed column labeling for clarity and reproducibility.
| [in] | dirname | Output directory path (may be NULL). |
| [in] | filename | Output file name. |
| [in] | ctl | Pointer to control structure defining spectral setup. |
| [in] | obs | Pointer to observation data structure to write. |
The file layout:
ctl->write_bbt is true, radiances are expressed as brightness temperatures [K].NR.Definition at line 6408 of file jurassic.c.
| void write_shape | ( | const char * | filename, |
| const double * | x, | ||
| const double * | y, | ||
| const int | n | ||
| ) |
Write tabulated shape function data to a text file.
Exports a shape function (typically a weighting or field-of-view profile) defined by paired arrays of x and y values to an ASCII file.
| [in] | filename | Output file name. |
| [in] | x | Pointer to array of x-values (independent variable). |
| [in] | y | Pointer to array of y-values (dependent variable). |
| [in] | n | Number of data points to write. |
read_shape() for re-import.Definition at line 6518 of file jurassic.c.
| 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.
Extracts the diagonal elements of a covariance matrix (a priori, posterior, or error covariance) to obtain the standard deviations of retrieved quantities and writes them as an atmospheric profile file.
| [in] | quantity | Name of the retrieved quantity (e.g., "apr", "pos", "err"), used to label the output file. |
| [in] | ret | Retrieval configuration structure (ret_t), providing the working directory for output files. |
| [in] | ctl | Global control structure (ctl_t) defining retrieval setup and quantities. |
| [in] | atm | Reference atmospheric state (atm_t) for spatial/geometric metadata. |
| [in] | s | Covariance matrix (gsl_matrix, n×n) from which standard deviations are derived (typically posterior covariance \(\mathbf{S}\)). |
This function performs the following operations:
atm) into an auxiliary structure (atm_aux) to preserve coordinate and geometric metadata.x2atm(), thereby mapping elements of the state vector to the corresponding atmospheric quantities.\[ \texttt{<ret->dir>/atm\_err\_<quantity>.tab} \]
using the standard JURASSIC atmospheric file format.atm_err_<quantity>.tab (e.g., atm_err_apr.tab, atm_err_pos.tab).ctl.s must be symmetric and positive-definite.x2atm) must correspond to the matrix ordering.Definition at line 6548 of file jurassic.c.

Write all emissivity lookup tables in the format specified by the control structure.
This function dispatches to one of three table writers depending on ctl->tblfmt:
1: ASCII tables written by write_tbl_asc()2: Binary tables written by write_tbl_bin()3: Per-gas binary tables written by write_tbl_gas()If an unknown format is given, the function aborts via ERRMSG().
| ctl | Control structure specifying table format, filenames, number of gases, number of frequencies, etc. |
| tbl | Fully populated lookup-table structure to be written. |
Definition at line 6581 of file jurassic.c.

Write all lookup tables in human-readable ASCII format.
For every gas index (ig) and frequency index (id), the function generates a file of the form:
<base>_<nu[id]>_<emitter[ig]>.tab
The ASCII file contains four columns:
1. pressure [hPa] 2. temperature [K] 3. column density [molecules/cm²] 4. emissivity [-]
Table dimensions are taken from the tbl_t structure.
Missing files cause the program to abort via ERRMSG().
| ctl | Control structure providing grid metadata and filename base. |
| tbl | Table data to be written. |
Definition at line 6604 of file jurassic.c.
Write all lookup tables in compact binary format.
For each gas index (ig) and frequency index (id), a binary file named
<base>_<nu[id]>_<emitter[ig]>.bin
is created. The format is:
| ctl | Control structure containing filename base and spectral grid. |
| tbl | Table data to be serialized. |
Definition at line 6649 of file jurassic.c.
Write lookup tables into per-gas binary table files with indexed blocks.
This function creates (if necessary) and updates gas-specific files of the form:
<base>_<emitter>.tbl
Each file contains:
For each frequency index (id), a block is appended (or overwritten) using write_tbl_gas_single(), which stores both the serialized table and its offset/size in the on-disk index.
| ctl | Control structure containing spectral grid, emitters, and filenames. |
| tbl | Table data from which individual frequency blocks are extracted. |
Definition at line 6704 of file jurassic.c.

| int write_tbl_gas_create | ( | const char * | path | ) |
Create a new per-gas table file with an empty index.
Writes the “GTL1” magic header, initializes the table count to zero, and creates a MAX_TABLES-sized index whose entries are zeroed.
The resulting file layout is:
magic[4] = "GTL1" ntables = 0 index[MAX_TABLES] (all zero)
| path | Path to the table file to create. |
Definition at line 6744 of file jurassic.c.
| int write_tbl_gas_single | ( | tbl_gas_t * | g, |
| const double | freq, | ||
| const tbl_t * | tbl, | ||
| const int | id, | ||
| const int | ig | ||
| ) |
Append or overwrite a single frequency-table block in a per-gas file.
Searches the in-memory index for an entry matching freq. If found, the corresponding block is updated. Otherwise a new entry is created (subject to the MAX_TABLES limit) and the block is appended to the end of the file.
The block format written is identical to the binary format used in write_tbl_bin():
The index entry is then updated with:
| g | Open gas-table handle obtained from read_tbl_gas_open(). |
| freq | Frequency associated with the table block. |
| tbl | Full lookup table from which one block is extracted. |
| id | Frequency index into tbl. |
| ig | Gas index into tbl. |
Definition at line 6775 of file jurassic.c.
Map retrieval state vector back to atmospheric structure.
Updates the atmospheric data structure (atm_t) from the contents of a retrieval state vector (x). This function performs the inverse transformation of atm2x(), assigning retrieved quantities such as pressure, temperature, gas volume mixing ratios, extinction, and cloud/surface parameters to the corresponding atmospheric fields.
| [in] | ctl | Pointer to control structure defining retrieval settings, vertical range limits, and active retrieval flags. |
| [in] | x | Pointer to retrieval state vector containing the updated values. |
| [out] | atm | Pointer to atmospheric data structure to be updated. |
ctl->ret*_zmin/ctl->ret*_zmax).x2atm_help() is called to sequentially read the next element from the state vector.atm2x() to ensure one-to-one correspondence between state vector indices and atmospheric fields.Quantities mapped:
p[zmin:zmax])t[zmin:zmax])q[ig][zmin:zmax])k[iw][zmin:zmax])clz, cldz, clk)sft, sfeps)ctl (e.g. ret_sft, ret_clk) are modified.n) advances automatically as each element is read.x2atm_help() abstracts sequential access to vector elements.Definition at line 6872 of file jurassic.c.

| void x2atm_help | ( | double * | value, |
| const gsl_vector * | x, | ||
| size_t * | n | ||
| ) |
Helper function to extract a single value from the retrieval state vector.
Retrieves the next element from the state vector x and assigns it to the provided scalar variable. This function is used by x2atm() to sequentially map the contents of the retrieval vector into the corresponding fields of the atmospheric structure.
| [out] | value | Pointer to the scalar variable to be updated. |
| [in] | x | Pointer to the retrieval state vector (gsl_vector). |
| [in,out] | n | Pointer to the current index in the state vector. The index is incremented after each extraction. |
atm2x() and x2atm().*n after reading a value, maintaining the correct position in the vector for subsequent calls.Definition at line 6922 of file jurassic.c.
Copy elements from the measurement vector y into the observation structure.
Decomposes the 1-D measurement vector y into its radiance components and writes them into the 2-D observation array obs->rad[id][ir], using the same ordering as produced by the corresponding forward model.
Only entries for which obs->rad[id][ir] is finite are updated. This allows missing or masked radiances to remain untouched in the observation structure.
| [in] | ctl | Control settings defining the number of detector channels (ctl->nd) and other retrieval configuration parameters. |
| [in] | y | Measurement vector containing radiances in forward-model order. |
| [out] | obs | Observation structure whose radiance array (obs->rad) is to be filled with values from y. |
The function loops over all ray paths (obs->nr) and detector channels (ctl->nd). For each pair (detector id, ray ir) where an existing value in obs->rad[id][ir] is finite, the next element from the measurement vector y is inserted. The counter m tracks progression through y.
This function is the inverse operation of the packing performed when constructing the measurement vector from an obs_t structure.
y must contain as many finite elements as the number of finite entries in obs->rad, in the same scanning order.Definition at line 6934 of file jurassic.c.