NASA Logo
Ocean Color Science Software

ocssw V2022
par_utils.c File Reference
#include "par_utils.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for par_utils.c:

Go to the source code of this file.

Macros

#define NMODEL   12
 
#define NS   15
 
#define NT   9
 
#define FILE_ERROR(str, name)
 

Functions

float kasten_equation (float solz)
 
size_t search (const float *arr, size_t s, size_t e, float val, size_t *i_s, size_t *i_e)
 
size_t get_reduced_product (size_t n_dims, const size_t *dims)
 
size_t get_hyper_cube_index (size_t n_dims, const size_t *dims, const size_t *indexes)
 
float hyper_cube_linear_interp (size_t n_dims, float *hyper_cube, float *width)
 
float interpnd (size_t n_dims, const size_t *dims, const float *point, float **grid, const float *lut)
 
void get_nc_dim (const idDS *struct_nc, const char *name, size_t *len)
 
void get_nc_var (const idDS *struct_nc, const char *name, float *var, const size_t *start, const size_t *count)
 
void get_luts_data (l2str *l2rec, luts_par *luts_data)
 
void GetAerPhase (l2str *l2rec, int ip, int32_t nbands, float angstrom, float *aerphasefunc, float *omega, float *modelAngstrom)
 
void read_aerosol_par (l2str *l2rec, int32_t nbands, float *tablewavelengths, float *tablephaseangles, float *tablealphas, float *tableomegas, float *tableaerphasefunc)
 
float EstimateDobson (int32_t year, int32_t month, int32_t day, float lat)
 
float EstimateWatVap (int32_t year, int32_t month, int32_t day, float lat)
 
float varsol (int32_t jday)
 
void triseset (int32_t jday, float xlon, float xlat, float *trise, float *tset)
 
float get_solz (int32_t jday, float time, float lon, float lat)
 
float interp_as_taulow (float csz, float tau)
 
float interp_as_tauhigh (float csz)
 
void getcldalbe (float *TauCld, float *CF, float cosSZ, float t_obs, float *t_range, float *albe_obs, float *TauCld_obs, float *CF_obs, size_t t_step, float *wl, size_t bands_num)
 
float ff (float u, float v)
 
float getrefm (float wl, const luts_par *luts_data)
 
float getr0 (float wl, float chl, float u0, const luts_par *luts_data)
 
float getosa (float wl, float sza, float wind, float chl, float fr, const luts_par *luts_data)
 
float SunGlint (float sz, float vz, float ra, float ws)
 
void set_searh_grid (size_t pts[][2], float width[], size_t ndims, const size_t *dims, const float *point, float **grid)
 
size_t get6dindex (const size_t *point, const size_t *dims)
 
float interp6d (const size_t *dims, const float *point, float **grid, const float *lut)
 
size_t get4dindex (const size_t *point, const size_t *dims)
 
float interp4d (const size_t *dims, const float *point, float **grid, const float *lut)
 
size_t get3dindex (const size_t *point, const size_t *dims)
 
float interp3d (const size_t *dims, const float *point, float **grid, const float *lut)
 
size_t get1dindex (const size_t *point, const size_t *dims)
 
float interp1d (const size_t *dims, const float *point, float **grid, const float *lut)
 

Macro Definition Documentation

◆ FILE_ERROR

#define FILE_ERROR (   str,
  name 
)
Value:
{ if (str.fid == -1) { \
printf("-Error--: could not open \"%s\" for reading.\n, See line %d in %s. Exiting...", name, __LINE__, __FILE__); \
exit(EXIT_FAILURE);\
}}

Definition at line 53 of file par_utils.c.

◆ NMODEL

#define NMODEL   12

Definition at line 43 of file par_utils.c.

◆ NS

#define NS   15

Definition at line 44 of file par_utils.c.

◆ NT

#define NT   9

Definition at line 45 of file par_utils.c.

Function Documentation

◆ EstimateDobson()

float EstimateDobson ( int32_t  year,
int32_t  month,
int32_t  day,
float  lat 
)

Definition at line 876 of file par_utils.c.

◆ EstimateWatVap()

float EstimateWatVap ( int32_t  year,
int32_t  month,
int32_t  day,
float  lat 
)

Definition at line 1002 of file par_utils.c.

◆ ff()

float ff ( float  u,
float  v 
)

Definition at line 1461 of file par_utils.c.

◆ get1dindex()

size_t get1dindex ( const size_t *  point,
const size_t *  dims 
)

Definition at line 1825 of file par_utils.c.

◆ get3dindex()

size_t get3dindex ( const size_t *  point,
const size_t *  dims 
)

Definition at line 1791 of file par_utils.c.

◆ get4dindex()

size_t get4dindex ( const size_t *  point,
const size_t *  dims 
)

Definition at line 1744 of file par_utils.c.

◆ get6dindex()

size_t get6dindex ( const size_t *  point,
const size_t *  dims 
)

Definition at line 1668 of file par_utils.c.

◆ get_hyper_cube_index()

size_t get_hyper_cube_index ( size_t  n_dims,
const size_t *  dims,
const size_t *  indexes 
)

Definition at line 121 of file par_utils.c.

◆ get_luts_data()

void get_luts_data ( l2str *  l2rec,
luts_par *  luts_data 
)

Get the luts data object For now it includes the MERRA data. Should be moved after the merra data is read.

Definition at line 244 of file par_utils.c.

◆ get_nc_dim()

void get_nc_dim ( const idDS struct_nc,
const char *  name,
size_t *  len 
)

Definition at line 217 of file par_utils.c.

◆ get_nc_var()

void get_nc_var ( const idDS struct_nc,
const char *  name,
float *  var,
const size_t *  start,
const size_t *  count 
)

Definition at line 227 of file par_utils.c.

◆ get_reduced_product()

size_t get_reduced_product ( size_t  n_dims,
const size_t *  dims 
)

Definition at line 113 of file par_utils.c.

◆ get_solz()

float get_solz ( int32_t  jday,
float  time,
float  lon,
float  lat 
)

Definition at line 1172 of file par_utils.c.

◆ GetAerPhase()

void GetAerPhase ( l2str *  l2rec,
int  ip,
int32_t  nbands,
float  angstrom,
float *  aerphasefunc,
float *  omega,
float *  modelAngstrom 
)

Definition at line 680 of file par_utils.c.

◆ getcldalbe()

void getcldalbe ( float *  TauCld,
float *  CF,
float  cosSZ,
float  t_obs,
float *  t_range,
float *  albe_obs,
float *  TauCld_obs,
float *  CF_obs,
size_t  t_step,
float *  wl,
size_t  bands_num 
)

//

from Fitzpatrick et al. (2005), compute cloud albedo

Fitzpatrick, M. F., R. E. Brandt, and S. G. Warren, 2004: Transmission of

Solar # Radiation by Clouds over Snow and Ice Surfaces: A Parameterization in Terms of # Optical Depth, Solar Zenith Angle, and Surface Albedo. Journal of Climate 17, 2: # 266-275, https://doi.org/10.1175/1520-0442(2004)017<0266:TOSRBC>2.0.CO;2

Parameters
TauCld- MERRA 2 input,cloud optical thickness for a given pixel, a 1D array resolved with respect to time, hourly
CF- MERRA 2 input,cloud fraction for a given pixel, aa 1D resolved with respect to time, hourly
cosSZ- cosine of solar zenith angle
t_obs- observed time
t_range- a 1D time array, the same length as TauCld and CF
albe_obs- observed albedo for each wavelentgh
TauCld_obs- observed optical thinckness
CF_obs- obesrved cloud fraction
t_step- size of t_range, TauCld and CF
wl- input wavelength, 1D arrays
bands_numlengh of wl

Definition at line 1384 of file par_utils.c.

◆ getosa()

float getosa ( float  wl,
float  sza,
float  wind,
float  chl,
float  fr,
const luts_par *  luts_data 
)

Definition at line 1544 of file par_utils.c.

◆ getr0()

float getr0 ( float  wl,
float  chl,
float  u0,
const luts_par *  luts_data 
)

Definition at line 1485 of file par_utils.c.

◆ getrefm()

float getrefm ( float  wl,
const luts_par *  luts_data 
)
Parameters
wl
luts_data
Returns

Definition at line 1475 of file par_utils.c.

◆ hyper_cube_linear_interp()

float hyper_cube_linear_interp ( size_t  n_dims,
float *  hyper_cube,
float *  width 
)

Definition at line 131 of file par_utils.c.

◆ interp1d()

float interp1d ( const size_t *  dims,
const float *  point,
float **  grid,
const float *  lut 
)

1-dimensional interpolation

Parameters
dims- arrays which contains dimension sizes
point- point of interest ( array of size n_dims )
grid- two dimensional array, where grid[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
lut- look up table, where lut[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
Returns
float

Definition at line 1827 of file par_utils.c.

◆ interp3d()

float interp3d ( const size_t *  dims,
const float *  point,
float **  grid,
const float *  lut 
)

3-dimensional interpolation

Parameters
dims- arrays which contains dimension sizes
point- point of interest ( array of size n_dims )
grid- two dimensional array, where grid[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
lut- look up table, where lut[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
Returns
float

Definition at line 1795 of file par_utils.c.

◆ interp4d()

float interp4d ( const size_t *  dims,
const float *  point,
float **  grid,
const float *  lut 
)

4-dimensional interpolation

Parameters
dims- arrays which contains dimension sizes
point- point of interest ( array of size n_dims )
grid- two dimensional array, where grid[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
lut- look up table, where lut[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
Returns
float

Definition at line 1749 of file par_utils.c.

◆ interp6d()

float interp6d ( const size_t *  dims,
const float *  point,
float **  grid,
const float *  lut 
)

6-dimensional interpolation

Parameters
dims- arrays which contains dimension sizes
point- point of interest ( array of size n_dims )
grid- two dimensional array, where grid[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
lut- look up table, where lut[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
Returns
float

Definition at line 1675 of file par_utils.c.

◆ interp_as_tauhigh()

float interp_as_tauhigh ( float  csz)

Definition at line 1349 of file par_utils.c.

◆ interp_as_taulow()

float interp_as_taulow ( float  csz,
float  tau 
)

Definition at line 1258 of file par_utils.c.

◆ interpnd()

float interpnd ( size_t  n_dims,
const size_t *  dims,
const float *  point,
float **  grid,
const float *  lut 
)

N-dimensional interpolation.

Parameters
n_dims- number of dimensions
dims- arrays which contains dimension sizes
point- point of interest ( array of size n_dims )
grid- two dimensional array, where grid[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
lut- look up table, where lut[i_dim] is an array of size dims[i_dim] where 0<= i_dim < n_dims
Returns
float

Definition at line 158 of file par_utils.c.

◆ kasten_equation()

float kasten_equation ( float  solz)
inline

Kasten eq to compute airmass.

Parameters
solz- angle
Returns
airmass

Definition at line 58 of file par_utils.c.

◆ read_aerosol_par()

void read_aerosol_par ( l2str *  l2rec,
int32_t  nbands,
float *  tablewavelengths,
float *  tablephaseangles,
float *  tablealphas,
float *  tableomegas,
float *  tableaerphasefunc 
)

Definition at line 802 of file par_utils.c.

◆ search()

size_t search ( const float *  arr,
size_t  s,
size_t  e,
float  val,
size_t *  i_s,
size_t *  i_e 
)

Binary search algorithm.

Parameters
arrinput array, sorted (either desending or ascending order. It is user responsibility to sort the array)
sstart
eend
valvalue
Returns
int index to find

Definition at line 64 of file par_utils.c.

◆ set_searh_grid()

void set_searh_grid ( size_t  pts[][2],
float  width[],
size_t  ndims,
const size_t *  dims,
const float *  point,
float **  grid 
)

Definition at line 1646 of file par_utils.c.

◆ SunGlint()

float SunGlint ( float  sz,
float  vz,
float  ra,
float  ws 
)

Compute sun glint reflectance using wind speed only (no direction)

Parameters
sz-solar zenith angle
vz- view zenith angle
ra- radiance
ws- windspeed
Returns
reflectance glint

Definition at line 1614 of file par_utils.c.

◆ triseset()

void triseset ( int32_t  jday,
float  xlon,
float  xlat,
float *  trise,
float *  tset 
)

Definition at line 1131 of file par_utils.c.

◆ varsol()

float varsol ( int32_t  jday)

Definition at line 1116 of file par_utils.c.

Definition: aerosol.c:136