OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
calfile_utils.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <libgen.h>
#include <math.h>
#include <netcdf.h>
#include "passthebuck.h"
#include "filehandle.h"
#include "dfutils.h"
#include "l2prod_struc.h"
#include "calfile_utils.h"
#include "l12_proto.h"
Include dependency graph for calfile_utils.c:

Go to the source code of this file.

Functions

idDS calfile_open (char *ofile, int sensorID, int ydim, int xdim, int nprods, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], long *numExistingRecords, caltype ctype)
 
int calfile_close (idDS ds_id)
 
int calfile_create (char *ofile, idDS *ds_id, int sensorID, int ydim, int xdim, int nprods, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], caltype ctype)
 
int calfile_write (idDS ds_id, calstr *calrec, int recnum, int ydim, int xdim, int nprods, int nbands, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], caltype ctype)
 
void inversion_init (long ndets, long iscan, int nbands, long ipix, aestr *aerec, tgstr *tgrec)
 
calstr * alloc_calrec (int ydim, int nbands, int nprods, int nvar1d)
 
void free_calrec (calstr *calrec, int nbands, int nprods)
 
void free_prodptr (l2prodstr **p)
 

Function Documentation

◆ alloc_calrec()

calstr* alloc_calrec ( int  ydim,
int  nbands,
int  nprods,
int  nvar1d 
)

alloc_calrec Allocate space for a detector run record

Parameters
ydim- y-dimension of records to allocate
nbands- number of wavelength bands
nprods- number of output products (2D)
nvar1d- number of 1 dimensional arrays in output product
Returns
- allocated calrec structure

Definition at line 516 of file calfile_utils.c.

◆ calfile_close()

int calfile_close ( idDS  ds_id)

calfile_close - close an open output file

Parameters
ds_id
Returns

Definition at line 210 of file calfile_utils.c.

◆ calfile_create()

int calfile_create ( char *  ofile,
idDS ds_id,
int  sensorID,
int  ydim,
int  xdim,
int  nprods,
int  nvars1d,
char  l2prods[L1_MAXPROD][32],
char  vars1Dnames[L1_MAXPROD][32],
caltype  ctype 
)

calfile_create - creates a output file

Parameters
ofile- filename to open for writing
ds_id- HDF/netCDF dataset id (idDS)
sensorID- sensorID
ydim- size of y-dimension for output arrays
xdim- size of x-dimension for output arrays
nprods- number of output products
nvars1d- number of 1D output products
l2prods- output product names
vars1Dnames- 1D product names
ctype- calibration type (e.g. DET2DET, CROSSCAL)
Returns

Definition at line 230 of file calfile_utils.c.

◆ calfile_open()

idDS calfile_open ( char *  ofile,
int  sensorID,
int  ydim,
int  xdim,
int  nprods,
int  nvars1d,
char  l2prods[L1_MAXPROD][32],
char  vars1Dnames[L1_MAXPROD][32],
long *  numExistingRecords,
caltype  ctype 
)

det_open opens an output file, if it doesn't exist it creates one, if it does exist it appends by copying existing file to a temporary location and bumping the size of the arrays to create a new output file of the same name

Parameters
ofile- filename to open for writing
sensorID- sensor ID number
ydim- size of y-dimension for output arrays
xdim- size of x-dimension for output arrays
nprods- number of output products
nvars1d- number of 1D output products
l2prods- output product names
vars1Dnames- 1D product names
numExistingRecords- number of existing records, used for appending...
ctype- calibration type (e.g. DET2DET, CROSSCAL, BINMATCH)
Returns

Definition at line 48 of file calfile_utils.c.

◆ calfile_write()

int calfile_write ( idDS  ds_id,
calstr *  calrec,
int  recnum,
int  ydim,
int  xdim,
int  nprods,
int  nbands,
int  nvars1d,
char  l2prods[L1_MAXPROD][32],
char  vars1Dnames[L1_MAXPROD][32],
caltype  ctype 
)

calfile_write() - writes data to output file

Parameters
ds_id- HDF/netCDF dataset id (idDS)
calrec- structure containing data to write
recnum- record number for record to write
ydim- size of y-dimension for output arrays
xdim- size of x-dimension for output arrays
nprods- number of output products
nbands- number of wavelength bands
nvars1d- number of 1 dimensional arrays
l2prods- output product names
vars1Dnames- 1D product names
ctype- calibration type (e.g. DET2DET, CROSSCAL)
Returns

Definition at line 348 of file calfile_utils.c.

◆ free_calrec()

void free_calrec ( calstr *  calrec,
int  nbands,
int  nprods 
)

free_calrec - free allocated calibration structures

Parameters
calrec
nbands- number of wavelength bands
nprods- number of output products (2D)
nvars1d- number of 1 dimensional arrays in output product

Definition at line 578 of file calfile_utils.c.

◆ free_prodptr()

void free_prodptr ( l2prodstr **  p)

free_prodptr - free array of product info structures

Parameters
p

Definition at line 599 of file calfile_utils.c.

◆ inversion_init()

void inversion_init ( long  ndets,
long  iscan,
int  nbands,
long  ipix,
aestr *  aerec,
tgstr *  tgrec 
)

inversion_init Initialize the average nLw and aot arrays for input into inversion

Parameters
ndets- number of contiguous detectors
iscan- scan number of l1 file
nbands- number of wavelength bands
ipix- pixel number
aerec- aerosol calibration record structure
tgrec- nlw calibration record structure

Definition at line 480 of file calfile_utils.c.