NASA Logo
Ocean Color Science Software

ocssw V2022
get_ctht.h
Go to the documentation of this file.
1 /*
2  get_ctht.h will hold the structures for cloud top height storage
3 */
4 #ifndef __CTHT__
5 #define __CTHT__
6 
7 #include "l12_proto.h"
8 #include "l2prod.h"
9 #include "l1.h"
10 #include <gsl/gsl_matrix_double.h>
11 #include <gsl/gsl_linalg.h>
12 #include <gsl/gsl_cblas.h>
13 
14 /*
15  * these keep the lines of cloud heght products, the height, pressure, temp
16  * need to be for a set of lines so that the cloud code can use it
17  */
18 typedef struct ctht_lin_struct
19  {
20  int32_t npix;
21  int32_t iscan;
22  // final product arrays all size npix
23  float *cth, *ctp, *ctt; // the variables needed by cloud microphys props cmp
24  unsigned char *ct_phase; // phase determined - 0 - water, 1 ice, or
25  // BAD_UBYTE for un-retrieved
26 
27  // product for all phases, make band-sequential to simplify output (thats
28  // the way the 3-d products are - band chaanging fastest
29  // only the cost and acost do not have _all to denote all phases
30  float *cth_all, *ctp_all, *ctt_all;
33  float *oe_akdiag, *dlcod, *dcod, *dcth, *dctp;
34  float *dctt, *dalb;
35  int32_t *nitr;
36  } ctht_lin_str;
37 
38 typedef struct ctht_lins_struct
39  {
40  int32_t nrec;
41  int32_t cscan;
42  ctht_lin_str **ct; // array of structures for each line
43  } ctht_lins_str;
44 /*
45  * uncertainty data, Also known as the Sy
46  */
47 typedef struct ctht_unc_struct
48  {
49  int32_t nbands, nsurf, nphase; // # bands, land sfc type, cld top phase
50  float *icpts; // Uncertainty fit intercepts
51  float *grads; // Uncertainty fit gradients
52  float *fit_rms; // Uncertainty fit RMS
53  float *err_corrs_category; // Spectral correlation in forward
54  // model uncertainty
55  float noise_err, cal_err; // noise and calibration error, goes with
56  // the rest here
57  } ctht_unc_str;
58 /*
59  * LUT data, also called lut, one for each cloud phase
60  */
61 typedef struct ctht_lut_struct
62  {
63  // axis sizes
64  int32_t lut_nsolz; // view angle
65  int32_t lut_nsenz;
66  int32_t lut_nrelaz;
67  int32_t lut_nlev; // levels
68  int32_t lut_npress; //pressure
69  int32_t lut_nalb; // albedo
70  int32_t lut_ncod; // cloud optical depth
71  int32_t lut_naod; // aerosol optical depth
72  int32_t lut_nwave; // bands
73  int32_t lut_ncth; // cloud top height
74  // axis values
75  float *lut_solz; // view angle
76  float *lut_senz;
77  float *lut_relaz;
78  // levels - none as separate
79  float *lut_press; //pressure
80  float *lut_alb; // albedo
81  float *lut_cod; // cloud optical depth
82  float *lut_lcod; // log cloud optical depth, why not?
83  float *lut_aod; // aerosol optical depth
84  float *lut_wave; // band wavelengths
85  float *lut_cth; // cloud top height
86  // basic arrays
87  float *z_and_pp0; // relation between height and relative p - an array
88  // of size [# lev, 2] with 0 = height, 1 = pressure
89  float *lut_pp0; // actually derived from z_and_pp0 for each phase table
90  float *lut; // the spectra f( geom, p, band, cod, cth, sfc albedo )
91  // Lut is sized
92  // [ solz, senz, relaz, press, band, cod, cth, alb ]
93  // with solz fastest
94 
95  // There are many more for the lut, some of questionable need, so later
96  } ctht_lut_str;
97 
98 // the oe_info_str contains all the inversion results from ams_oe_inversion
99 // (however, much more manipulation is required to get ctht)
100 typedef struct oe_info_struct
101  {
102  float *x_prd_state; // the final state vector or the product set found
103  // this is the 'x'
104  gsl_matrix *gm_sx; // the sx
105  int32_t conv_flag; // conv
106  double cost; // j, or j_cost
107  double acost; // a-priori cost or ja
108  gsl_matrix *gm_ak; // gm_av_kernel or avkernel
109  gsl_matrix *gm_gain; // gm_gain or G in IDL code
110  int32_t nitr; // nitr
111 
112  // There are more, but we'll make the above be a place holder
113  } oe_info_str;
114 /*
115  * define the routines
116  */
117 float *get_ctht_lin( l2str *, int );
118 int32_t comp_ctht( l2str * );
119 int32_t comp_ctht_lin( l1str *, ctht_lin_str * );
120 int32_t init_ctht_parms( ctht_lin_str *, int32_t );
121 int32_t comp_ctht_tst(l1str *, int32_t, ctht_lin_str * );
122 int32_t ctht_tbl_init( int32_t, l1str *, ctht_unc_str *, ctht_lut_str *, ctht_lut_str * );
123 // float ctht_glint( solz, senz, relaz, windsp )
124 float ctht_glint( float, float, float, float );
125 int32_t int_4d( float *sxax[4], int32_t snax[4], int64_t n_block, float x[4],
126  int64_t[16], float[16], float[4] );
127 int32_t iint_3d( int32_t[3], double[3], int64_t[9], float[9], float[3] );
128 gsl_matrix *invert_a_matrix(gsl_matrix *);
129 // ams_oe_inversion( rhot, gm_sy, xa, gm_sa, tmp_lut, min_cost_loc )
130 int32_t ams_oe_inversion( double *, gsl_matrix *, double *, gsl_matrix *,
131  double *, int32_t *, int32_t *, oe_info_str * );
132 int32_t my_lut_funct_3d_oe( gsl_vector *, double *, int32_t *, int32_t,
133  double *, double * );
134 float axis_interp( float *, int32_t, float );
135 // these 2 are for some diagnostics
136 void print_mat_contents(gsl_matrix *matrix, int nrow, int ncol );
137 
138 #endif
int32_t int_4d(float *sxax[4], int32_t snax[4], int64_t n_block, float x[4], int64_t[16], float[16], float[4])
Definition: int_4d.c:12
float axis_interp(float *, int32_t, float)
Definition: axis_interp.c:19
int32_t my_lut_funct_3d_oe(gsl_vector *, double *, int32_t *, int32_t, double *, double *)
float * lut_alb
Definition: get_ctht.h:80
ctht_lin_str ** ct
Definition: get_ctht.h:42
float * cth_lcod_all
Definition: get_ctht.h:31
float * lut_wave
Definition: get_ctht.h:84
float * lut
Definition: get_ctht.h:90
int32_t cscan
Definition: get_ctht.h:41
float * ctp_all
Definition: get_ctht.h:30
float * cth_all
Definition: get_ctht.h:30
float * lut_pp0
Definition: get_ctht.h:89
int32_t nbands
Definition: get_ctht.h:49
float ** matrix(long nrl, long nrh, long ncl, long nch)
Definition: nrutil.c:60
float * cth_cod_all
Definition: get_ctht.h:31
int32_t lut_naod
Definition: get_ctht.h:71
float * lut_solz
Definition: get_ctht.h:75
int32_t lut_nsolz
Definition: get_ctht.h:64
int32_t iscan
Definition: get_ctht.h:21
float * err_corrs_category
Definition: get_ctht.h:53
float * dctp
Definition: get_ctht.h:33
gsl_matrix * gm_gain
Definition: get_ctht.h:109
float * icpts
Definition: get_ctht.h:50
int32_t ams_oe_inversion(double *, gsl_matrix *, double *, gsl_matrix *, double *, int32_t *, int32_t *, oe_info_str *)
float * ctt
Definition: get_ctht.h:23
gsl_matrix * invert_a_matrix(gsl_matrix *)
Definition: get_ctht.c:1722
float * oe_akdiag
Definition: get_ctht.h:33
float * z_and_pp0
Definition: get_ctht.h:87
float cal_err
Definition: get_ctht.h:55
int32_t comp_ctht_tst(l1str *, int32_t, ctht_lin_str *)
Definition: get_ctht.c:1289
int32_t lut_ncth
Definition: get_ctht.h:73
int32_t comp_ctht(l2str *)
Definition: get_ctht.c:295
int32_t lut_ncod
Definition: get_ctht.h:70
float * cth_raw
Definition: get_ctht.h:32
int32_t nitr
Definition: get_ctht.h:110
gsl_matrix * gm_sx
Definition: get_ctht.h:104
int32_t nsurf
Definition: get_ctht.h:49
float * fit_rms
Definition: get_ctht.h:52
float * acost
Definition: get_ctht.h:32
float * ctt_all
Definition: get_ctht.h:30
int32_t ctht_tbl_init(int32_t, l1str *, ctht_unc_str *, ctht_lut_str *, ctht_lut_str *)
Definition: get_ctht.c:1349
float * ctp
Definition: get_ctht.h:23
void print_mat_contents(gsl_matrix *matrix, int nrow, int ncol)
Definition: get_ctht.c:1755
float * lut_lcod
Definition: get_ctht.h:82
float * get_ctht_lin(l2str *, int)
Definition: get_ctht.c:14
float * cost_ss
Definition: get_ctht.h:32
float noise_err
Definition: get_ctht.h:55
float * lut_cth
Definition: get_ctht.h:85
int32_t lut_nwave
Definition: get_ctht.h:72
double acost
Definition: get_ctht.h:107
float * dcth
Definition: get_ctht.h:33
float * dlcod
Definition: get_ctht.h:33
int32_t comp_ctht_lin(l1str *, ctht_lin_str *)
Definition: get_ctht.c:463
int32_t conv_flag
Definition: get_ctht.h:105
int32_t lut_npress
Definition: get_ctht.h:68
float * cth_alb_all
Definition: get_ctht.h:32
int32_t * nitr
Definition: get_ctht.h:35
int32_t nphase
Definition: get_ctht.h:49
float * dalb
Definition: get_ctht.h:34
int32_t iint_3d(int32_t[3], double[3], int64_t[9], float[9], float[3])
Definition: int_4d.c:117
float * lut_relaz
Definition: get_ctht.h:77
int32_t nrec
Definition: get_ctht.h:40
unsigned char * ct_phase
Definition: get_ctht.h:24
float * lut_aod
Definition: get_ctht.h:83
int32_t lut_nsenz
Definition: get_ctht.h:65
int32_t init_ctht_parms(ctht_lin_str *, int32_t)
Definition: get_ctht.c:1247
float * lut_press
Definition: get_ctht.h:79
double cost
Definition: get_ctht.h:106
float * lut_senz
Definition: get_ctht.h:76
float * grads
Definition: get_ctht.h:51
int32_t lut_nalb
Definition: get_ctht.h:69
gsl_matrix * gm_ak
Definition: get_ctht.h:108
float * lut_cod
Definition: get_ctht.h:81
float * dcod
Definition: get_ctht.h:33
int32_t lut_nlev
Definition: get_ctht.h:67
float * dctt
Definition: get_ctht.h:34
float ctht_glint(float, float, float, float)
Definition: get_ctht.c:1635
float * x_prd_state
Definition: get_ctht.h:102
int32_t npix
Definition: get_ctht.h:20
int32_t lut_nrelaz
Definition: get_ctht.h:66
float * cth
Definition: get_ctht.h:23