OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
make_L3_v1.1.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include "path.h"
#include "proto.h"
#include "proj_proto.h"
#include "mfhdf.h"
Include dependency graph for make_L3_v1.1.c:

Go to the source code of this file.

Classes

struct  OUTPUT
 
struct  PROCESSINFO
 
struct  INPUT
 
struct  SDS
 

Macros

#define DBL_MAX   1.7976931348623157E+308 /* max decimal value of a "double"*/
 
#define DEFPROJECTION   HAMMER /* Default output projection */
 
#define FAST   FALSE
 
#define ATMCOR   TRUE /* Do atmospheric correction */
 
#define UPDATE   TRUE
 
#define TILTSCANS   FALSE
 
#define MAXMEMDEF   500 /* Maximum memory to allocate (in Mbytes) */
 
#define STEP   1
 
#define DEFPIXSZ   10000. /* Pixel size (in m) for output image files (if compatible) */
 
#define UNDEF   -999. /* Undefined value */
 
#define FILL_UINT8   255 /* Fill value */
 
#define FILL_INT16   -32767 /* Fill value */
 
#define MINREFL   0.00 /* Minimum reflectance allowed for min. blue compositing */
 
#define MAXSENZDEF   55. /* Maximum view angle */
 
#define UMASK   002 /* Set permission for created files */
 
#define BLUEBAND   BAND2 /* Blue band for minimum blue compositing */
 
#define WATER_VAL   -16384 /* Water (non-land) pixel value */
 
#define WAVELENGTH   { "412", "443", "490", "510", "555", "670", "765", "865"} /* Band wavelength */
 
#define IRRAD   {171.07, 189.91, 194.33, 188.24, 185.93, 152.14, 123.55, 100.00} /* TOA solar irradiance */
 
#define TAURAY   {0.3139, 0.2341, 0.1561, 0.1324, 0.0942, 0.0439, 0.0257, 0.0155} /* TOA molecular reflectance */
 
#define OZONE   {.00103, .00400, .02536, .04200, .09338, .04685, .00837, .00485} /* Coef. for ozone absorption */
 
#define WVAPOR   {0.0000, 0.0000, 0.0000, 0.0000, 0.0008, 0.0043, 0.0007, 0.0057} /* Coef. for water vapor abs. */
 
#define OXYGEN   {0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000} /* Coef. for oxygen absorption */
 
#define UOZ   0.270 /* Ozone abundance (cm.atm) */
 
#define PSURF   1013. /* Sea surface pressure */
 
#define NLPSURF   2160 /* Number of rows in surface pressure file */
 
#define NPPSURF   4320 /* Number of columns in surface pressure file */
 
#define TWO_THIRDS   0.666666666666666666667
 
#define FOUR_THIRDS   1.333333333333333333333
 
#define TWO_PI   6.28318530717958647692
 
#define RAD2DEG   57.29577951308232087684 /* 180.0 / M_PI */
 
#define NpixelsLAC   1285
 
#define OMF2   0.99330562 /* (1.0 - F) * (1.0 - F) */
 
#define R   6371007.181 /* Earth radius (m) */
 
#define MAXLENGTH   100
 
#define EPSILON   1e-6
 
#define N_CONVOL   7
 
#define CONVOL_MAX   30.0
 
#define CROSS_PRODUCT(x1, y1, x2, y2, x3, y3)   ( ((x2) - (x1)) * ((y3) - (y1)) - ((y2) - (y1)) * ((x3) - (x1)) )
 
#define VERSION   "1.1.1"
 
#define IFOV   0.0015835 /* Instantaneous FOV (rad) */
 
#define L2FIELDS   (2 * NBANDS + 9)
 

Enumerations

enum  {
  PLATECARREE, SINUSOIDAL, MOLLWEIDE, ROBINSON,
  HAMMER, NUMBEROFPROJECTIONS
}
 
enum  { MINBLUE, MAXNDVI, MINSENZ, LASTIN }
 
enum  { GLOBAL, USERBOX }
 
enum  {
  BAND1, BAND2, BAND3, BAND4,
  BAND5, BAND6, BAND7, BAND8,
  NBANDS
}
 
enum  { L1A, L2 }
 

Functions

int alloc_new_array (void **data, int size, int32 num_type, int maxmem)
 
void check_process_parameters (PROCESSINFO *process, char **wl)
 
int get_geolocation_scan (int iscan, INPUT *input, PROCESSINFO process)
 
int get_lonlat (double xproj, double yproj, double *lon, double *lat, int projtype, double lon_center)
 
int get_xyproj (double lon, double lat, double *xproj, double *yproj, int projtype, double lon_center)
 
void init_output_file (OUTPUT *proj, INPUT input, PROCESSINFO process)
 
void init_output_projection (OUTPUT *proj, PROCESSINFO process)
 
void memcpy_block (int offset2, int offset1, int Nrows, int Ncols, OUTPUT *proj)
 
void parse_command_line (int argc, char **argv, OUTPUT *proj, PROCESSINFO *process)
 
void process_pixel (int ipix, int iline_out, int ipix_out, char **wl, INPUT input, OUTPUT *proj, PROCESSINFO process)
 
int project_scan (int iscan, char **wl, INPUT *input, OUTPUT *proj, PROCESSINFO process)
 
int read_file_block (char *filename, char **wl, int offset, int startline, int buflines, OUTPUT *proj)
 
int read_l2 (int iscan, INPUT *input, char **wl)
 
void resample_geo_scan (int Npixels, float *inlon, float *inlat, double *outlon, double *outlat)
 
void set_buffer_parameters (OUTPUT *proj, PROCESSINFO *process)
 
void set_proj_parameters (OUTPUT *proj)
 
int update_file (char *filename, char **wl, int offset, int startline, int buflines, OUTPUT *proj, char verbose, char gzip)
 
void update_pixel (INPUT input, int16 ndvi, int ipix, int idx_out, int ifno, OUTPUT *proj)
 
void write_cmd_line (int32 sd_id, char *cmd_line)
 
int16 EVI (float blue, float red, float nir)
 
int16 NDVI (float red, float nir)
 
int16 GEMI (float red, float nir)
 
int16 SMOKE (float **rho, int ipix)
 
unsigned char read_mask (double lon, double lat, int16 close)
 
int main (int argc, char **argv)
 

Variables

float64 sf_refl = 0.0001
 
float64 sf_angle = 0.01
 
float64 sf_smoke = 0.0001
 
float64 sf_vi = 0.0001
 

Macro Definition Documentation

◆ ATMCOR

#define ATMCOR   TRUE /* Do atmospheric correction */

Definition at line 64 of file make_L3_v1.1.c.

◆ BLUEBAND

#define BLUEBAND   BAND2 /* Blue band for minimum blue compositing */

Definition at line 76 of file make_L3_v1.1.c.

◆ CONVOL_MAX

#define CONVOL_MAX   30.0

Definition at line 101 of file make_L3_v1.1.c.

◆ CROSS_PRODUCT

#define CROSS_PRODUCT (   x1,
  y1,
  x2,
  y2,
  x3,
  y3 
)    ( ((x2) - (x1)) * ((y3) - (y1)) - ((y2) - (y1)) * ((x3) - (x1)) )

Definition at line 103 of file make_L3_v1.1.c.

◆ DBL_MAX

#define DBL_MAX   1.7976931348623157E+308 /* max decimal value of a "double"*/

Definition at line 60 of file make_L3_v1.1.c.

◆ DEFPIXSZ

#define DEFPIXSZ   10000. /* Pixel size (in m) for output image files (if compatible) */

Definition at line 69 of file make_L3_v1.1.c.

◆ DEFPROJECTION

#define DEFPROJECTION   HAMMER /* Default output projection */

Definition at line 62 of file make_L3_v1.1.c.

◆ EPSILON

#define EPSILON   1e-6

Definition at line 98 of file make_L3_v1.1.c.

◆ FAST

#define FAST   FALSE

Definition at line 63 of file make_L3_v1.1.c.

◆ FILL_INT16

#define FILL_INT16   -32767 /* Fill value */

Definition at line 72 of file make_L3_v1.1.c.

◆ FILL_UINT8

#define FILL_UINT8   255 /* Fill value */

Definition at line 71 of file make_L3_v1.1.c.

◆ FOUR_THIRDS

#define FOUR_THIRDS   1.333333333333333333333

Definition at line 91 of file make_L3_v1.1.c.

◆ IFOV

#define IFOV   0.0015835 /* Instantaneous FOV (rad) */

Definition at line 746 of file make_L3_v1.1.c.

◆ IRRAD

#define IRRAD   {171.07, 189.91, 194.33, 188.24, 185.93, 152.14, 123.55, 100.00} /* TOA solar irradiance */

Definition at line 80 of file make_L3_v1.1.c.

◆ L2FIELDS

#define L2FIELDS   (2 * NBANDS + 9)

Definition at line 2142 of file make_L3_v1.1.c.

◆ MAXLENGTH

#define MAXLENGTH   100

Definition at line 97 of file make_L3_v1.1.c.

◆ MAXMEMDEF

#define MAXMEMDEF   500 /* Maximum memory to allocate (in Mbytes) */

Definition at line 67 of file make_L3_v1.1.c.

◆ MAXSENZDEF

#define MAXSENZDEF   55. /* Maximum view angle */

Definition at line 74 of file make_L3_v1.1.c.

◆ MINREFL

#define MINREFL   0.00 /* Minimum reflectance allowed for min. blue compositing */

Definition at line 73 of file make_L3_v1.1.c.

◆ N_CONVOL

#define N_CONVOL   7

Definition at line 100 of file make_L3_v1.1.c.

◆ NLPSURF

#define NLPSURF   2160 /* Number of rows in surface pressure file */

Definition at line 87 of file make_L3_v1.1.c.

◆ NpixelsLAC

#define NpixelsLAC   1285

Definition at line 94 of file make_L3_v1.1.c.

◆ NPPSURF

#define NPPSURF   4320 /* Number of columns in surface pressure file */

Definition at line 88 of file make_L3_v1.1.c.

◆ OMF2

#define OMF2   0.99330562 /* (1.0 - F) * (1.0 - F) */

Definition at line 95 of file make_L3_v1.1.c.

◆ OXYGEN

#define OXYGEN   {0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000} /* Coef. for oxygen absorption */

Definition at line 84 of file make_L3_v1.1.c.

◆ OZONE

#define OZONE   {.00103, .00400, .02536, .04200, .09338, .04685, .00837, .00485} /* Coef. for ozone absorption */

Definition at line 82 of file make_L3_v1.1.c.

◆ PSURF

#define PSURF   1013. /* Sea surface pressure */

Definition at line 86 of file make_L3_v1.1.c.

◆ R

#define R   6371007.181 /* Earth radius (m) */

Definition at line 96 of file make_L3_v1.1.c.

◆ RAD2DEG

#define RAD2DEG   57.29577951308232087684 /* 180.0 / M_PI */

Definition at line 93 of file make_L3_v1.1.c.

◆ STEP

#define STEP   1

Definition at line 68 of file make_L3_v1.1.c.

◆ TAURAY

#define TAURAY   {0.3139, 0.2341, 0.1561, 0.1324, 0.0942, 0.0439, 0.0257, 0.0155} /* TOA molecular reflectance */

Definition at line 81 of file make_L3_v1.1.c.

◆ TILTSCANS

#define TILTSCANS   FALSE

Definition at line 66 of file make_L3_v1.1.c.

◆ TWO_PI

#define TWO_PI   6.28318530717958647692

Definition at line 92 of file make_L3_v1.1.c.

◆ TWO_THIRDS

#define TWO_THIRDS   0.666666666666666666667

Definition at line 90 of file make_L3_v1.1.c.

◆ UMASK

#define UMASK   002 /* Set permission for created files */

Definition at line 75 of file make_L3_v1.1.c.

◆ UNDEF

#define UNDEF   -999. /* Undefined value */

Definition at line 70 of file make_L3_v1.1.c.

◆ UOZ

#define UOZ   0.270 /* Ozone abundance (cm.atm) */

Definition at line 85 of file make_L3_v1.1.c.

◆ UPDATE

#define UPDATE   TRUE

Definition at line 65 of file make_L3_v1.1.c.

◆ VERSION

#define VERSION   "1.1.1"

Definition at line 105 of file make_L3_v1.1.c.

◆ WATER_VAL

#define WATER_VAL   -16384 /* Water (non-land) pixel value */

Definition at line 77 of file make_L3_v1.1.c.

◆ WAVELENGTH

#define WAVELENGTH   { "412", "443", "490", "510", "555", "670", "765", "865"} /* Band wavelength */

Definition at line 79 of file make_L3_v1.1.c.

◆ WVAPOR

#define WVAPOR   {0.0000, 0.0000, 0.0000, 0.0000, 0.0008, 0.0043, 0.0007, 0.0057} /* Coef. for water vapor abs. */

Definition at line 83 of file make_L3_v1.1.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PLATECARREE 
SINUSOIDAL 
MOLLWEIDE 
ROBINSON 
HAMMER 
NUMBEROFPROJECTIONS 

Definition at line 40 of file make_L3_v1.1.c.

◆ anonymous enum

anonymous enum
Enumerator
MINBLUE 
MAXNDVI 
MINSENZ 
LASTIN 

Definition at line 44 of file make_L3_v1.1.c.

◆ anonymous enum

anonymous enum
Enumerator
GLOBAL 
USERBOX 

Definition at line 48 of file make_L3_v1.1.c.

◆ anonymous enum

anonymous enum
Enumerator
BAND1 
BAND2 
BAND3 
BAND4 
BAND5 
BAND6 
BAND7 
BAND8 
NBANDS 

Definition at line 52 of file make_L3_v1.1.c.

◆ anonymous enum

anonymous enum
Enumerator
L1A 
L2 

Definition at line 56 of file make_L3_v1.1.c.

Function Documentation

◆ alloc_new_array()

int alloc_new_array ( void **  data,
int  size,
int32  num_type,
int  maxmem 
)

Definition at line 1372 of file make_L3_v1.1.c.

◆ check_process_parameters()

void check_process_parameters ( PROCESSINFO process,
char **  wl 
)

Definition at line 1762 of file make_L3_v1.1.c.

◆ EVI()

int16 EVI ( float  blue,
float  red,
float  nir 
)

Definition at line 1304 of file make_L3_v1.1.c.

◆ GEMI()

int16 GEMI ( float  red,
float  nir 
)

Definition at line 1356 of file make_L3_v1.1.c.

◆ get_geolocation_scan()

int get_geolocation_scan ( int  iscan,
INPUT input,
PROCESSINFO  process 
)

Definition at line 748 of file make_L3_v1.1.c.

◆ get_lonlat()

int get_lonlat ( double  xproj,
double  yproj,
double *  lon,
double *  lat,
int  projtype,
double  lon_center 
)

Definition at line 1195 of file make_L3_v1.1.c.

◆ get_xyproj()

int get_xyproj ( double  lon,
double  lat,
double *  xproj,
double *  yproj,
int  projtype,
double  lon_center 
)

Definition at line 1171 of file make_L3_v1.1.c.

◆ init_output_file()

void init_output_file ( OUTPUT proj,
INPUT  input,
PROCESSINFO  process 
)

Definition at line 1917 of file make_L3_v1.1.c.

◆ init_output_projection()

void init_output_projection ( OUTPUT proj,
PROCESSINFO  process 
)

Definition at line 1848 of file make_L3_v1.1.c.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 175 of file make_L3_v1.1.c.

◆ memcpy_block()

void memcpy_block ( int  offset2,
int  offset1,
int  Nrows,
int  Ncols,
OUTPUT proj 
)

Definition at line 1036 of file make_L3_v1.1.c.

◆ NDVI()

int16 NDVI ( float  red,
float  nir 
)

Definition at line 1290 of file make_L3_v1.1.c.

◆ parse_command_line()

void parse_command_line ( int  argc,
char **  argv,
OUTPUT proj,
PROCESSINFO process 
)

Definition at line 1480 of file make_L3_v1.1.c.

◆ process_pixel()

void process_pixel ( int  ipix,
int  iline_out,
int  ipix_out,
char **  wl,
INPUT  input,
OUTPUT proj,
PROCESSINFO  process 
)

Definition at line 1066 of file make_L3_v1.1.c.

◆ project_scan()

int project_scan ( int  iscan,
char **  wl,
INPUT input,
OUTPUT proj,
PROCESSINFO  process 
)

Definition at line 1962 of file make_L3_v1.1.c.

◆ read_file_block()

int read_file_block ( char *  filename,
char **  wl,
int  offset,
int  startline,
int  buflines,
OUTPUT proj 
)

Definition at line 902 of file make_L3_v1.1.c.

◆ read_l2()

int read_l2 ( int  iscan,
INPUT input,
char **  wl 
)

Definition at line 2144 of file make_L3_v1.1.c.

◆ read_mask()

unsigned char read_mask ( double  lon,
double  lat,
int16  close 
)

Definition at line 14 of file read_mask.c.

◆ resample_geo_scan()

void resample_geo_scan ( int  Npixels,
float *  inlon,
float *  inlat,
double *  outlon,
double *  outlat 
)

Definition at line 874 of file make_L3_v1.1.c.

◆ set_buffer_parameters()

void set_buffer_parameters ( OUTPUT proj,
PROCESSINFO process 
)

Definition at line 1695 of file make_L3_v1.1.c.

◆ set_proj_parameters()

void set_proj_parameters ( OUTPUT proj)

Definition at line 1409 of file make_L3_v1.1.c.

◆ SMOKE()

int16 SMOKE ( float **  rho,
int  ipix 
)

Definition at line 1279 of file make_L3_v1.1.c.

◆ update_file()

int update_file ( char *  filename,
char **  wl,
int  offset,
int  startline,
int  buflines,
OUTPUT proj,
char  verbose,
char  gzip 
)

Definition at line 975 of file make_L3_v1.1.c.

◆ update_pixel()

void update_pixel ( INPUT  input,
int16  ndvi,
int  ipix,
int  idx_out,
int  ifno,
OUTPUT proj 
)

Definition at line 1223 of file make_L3_v1.1.c.

◆ write_cmd_line()

void write_cmd_line ( int32  sd_id,
char *  cmd_line 
)

Definition at line 1383 of file make_L3_v1.1.c.

Variable Documentation

◆ sf_angle

float64 sf_angle = 0.01

Definition at line 173 of file make_L3_v1.1.c.

◆ sf_refl

float64 sf_refl = 0.0001

Definition at line 173 of file make_L3_v1.1.c.

◆ sf_smoke

float64 sf_smoke = 0.0001

Definition at line 173 of file make_L3_v1.1.c.

◆ sf_vi

float64 sf_vi = 0.0001

Definition at line 173 of file make_L3_v1.1.c.