OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
readL2scan.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <netcdf.h>
#include <genutils.h>
#include "readL2scan.h"
#include "navigation.h"
#include <sensorInfo.h>
#include <timeutils.h>
#include <nc4utils.h>
#include <hdf.h>
#include <mfhdf.h>
Include dependency graph for readL2scan.c:

Go to the source code of this file.

Classes

struct  cache_struct
 
struct  pixelAreaInfo_t
 

Macros

#define TITLE   "title"
 
#define TITLE_OLD   "Title"
 
#define INFILES   "input_sources"
 
#define INFILES_OLD   "Input Files"
 
#define SENNME   "instrument"
 
#define SENNME_OLD   "Sensor Name"
 
#define DCENTER   "project"
 
#define DCENTER_OLD   "Data Center"
 
#define NFREC   "Filled Scan Lines"
 
#define PCTFLAG   "flag_percentages"
 
#define PCTFLAG_OLD   "Flag Percentages"
 
#define NTIME   "equatorCrossingDateTime"
 
#define NTIME_OLD   "Node Crossing Time"
 
#define SNODE   "startDirection"
 
#define SNODE_OLD   "Start Node"
 
#define ENODE   "endDirection"
 
#define ENODE_OLD   "End Node"
 
#define MISSION   "platform"
 
#define MISSION_OLD   "Mission"
 
#define MSNCHAR   "Mission Characteristics"
 
#define SENSOR   "Sensor"
 
#define SNSCHAR   "Sensor Characteristics"
 
#define ORBNUM   "orbit_number"
 
#define ORBNUM_OLD   "Orbit Number"
 
#define NLAT   "northernmost_latitude"
 
#define NLAT_OLD   "Northernmost Latitude"
 
#define SLAT   "southernmost_latitude"
 
#define SLAT_OLD   "Southernmost Latitude"
 
#define WLON   "westernmost_longitude"
 
#define WLON_OLD   "Westernmost Longitude"
 
#define ELON   "easternmost_longitude"
 
#define ELON_OLD   "Easternmost Longitude"
 
#define STCLAT   "start_center_latitude"
 
#define STCLAT_OLD   "Start Center Latitude"
 
#define STCLON   "start_center_longitude"
 
#define STCLON_OLD   "Start Center Longitude"
 
#define ENDCLAT   "end_center_latitude"
 
#define ENDCLAT_OLD   "End Center Latitude"
 
#define ENDCLON   "end_center_longitude"
 
#define ENDCLON_OLD   "End Center Longitude"
 
#define NODEL   "equatorCrossingLongitude"
 
#define NODEL_OLD   "Orbit Node Longitude"
 
#define LAC_PX_ST   "LAC Pixel Start Number"
 
#define LAC_PX_SUBSAMP   "LAC Pixel Subsampling"
 
#define FREE(ptr)   if((ptr) != 0x0) free(ptr);
 

Typedefs

typedef idDS ds_id_prod_t[1000]
 
typedef int32_t prodtype_t[1000]
 
typedef float slope_t[1000]
 
typedef idDS ds_id_ll_t[3]
 
typedef idDS ds_id_geonav_t[6]
 
typedef int32_t grp_id_t[6]
 

Functions

void enableL2PixelArea (enum L2PixelMode_t val)
 
int32_t get_dtype (int32_t dtype, ds_format_t fileformat)
 
void free_rowgroup_cache ()
 
void init_rowgroup_cache ()
 
void allocateDatabuf (l2_prod *l2_str, int maxThirdDim)
 
int32_t openL2 (const char *fname, char *plist, l2_prod *l2_str)
 
int32_t reopenL2 (int32_t fileindex, l2_prod *l2_str)
 
int32_t readdata_cached (idDS ds_id, char *name, int32_t *start, int32_t *stride, int32_t *edges, void *data, unsigned char *scan_in_rowgroup, cache_str *cache, int32_t dtype)
 
void clampDeltaLon (float *deltaLon)
 
void interpolatePixelCorners (float *lat0, float *lon0, float *lat1, float *lon1, float *latOut, float *lonOut, int32_t numPoints)
 
void extrapolatePixelCorners (float *lat0, float *lon0, float *lat1, float *lon1, float *latOut, float *lonOut, int32_t numPoints)
 
void calculatePixelDeltas (float *lat0, float *lon0, float *lat1, float *lon1, float *latOut, float *lonOut, int32_t numPoints)
 
int32_t readL2 (l2_prod *l2_str, int32_t ifile, int32_t recnum, int32_t iprod, unsigned char *scan_in_rowgroup)
 
int32_t readlonlat (l2_prod *l2_str, int32_t ifile, int32_t *start, int32_t *edges, unsigned char *scan_in_rowgroup)
 
int32_t closeL2 (l2_prod *l2_str, int32_t ifile)
 
int32_t freeL2 (l2_prod *l2_str)
 
int32_t findprod (l2_prod *l2_str, char *prodname)
 
int32_t readL2meta (meta_l2Type *meta_l2, int32_t ifile)
 
int32_t freeL2meta (meta_l2Type *meta_l2)
 
int32_t getL3units (l2_prod *l2_str, int32_t ifile, char *l3b_prodname, char *units)
 

Macro Definition Documentation

◆ DCENTER

#define DCENTER   "project"

Definition at line 76 of file readL2scan.c.

◆ DCENTER_OLD

#define DCENTER_OLD   "Data Center"

Definition at line 77 of file readL2scan.c.

◆ ELON

#define ELON   "easternmost_longitude"

Definition at line 100 of file readL2scan.c.

◆ ELON_OLD

#define ELON_OLD   "Easternmost Longitude"

Definition at line 101 of file readL2scan.c.

◆ ENDCLAT

#define ENDCLAT   "end_center_latitude"

Definition at line 106 of file readL2scan.c.

◆ ENDCLAT_OLD

#define ENDCLAT_OLD   "End Center Latitude"

Definition at line 107 of file readL2scan.c.

◆ ENDCLON

#define ENDCLON   "end_center_longitude"

Definition at line 108 of file readL2scan.c.

◆ ENDCLON_OLD

#define ENDCLON_OLD   "End Center Longitude"

Definition at line 109 of file readL2scan.c.

◆ ENODE

#define ENODE   "endDirection"

Definition at line 85 of file readL2scan.c.

◆ ENODE_OLD

#define ENODE_OLD   "End Node"

Definition at line 86 of file readL2scan.c.

◆ FREE

#define FREE (   ptr)    if((ptr) != 0x0) free(ptr);

◆ INFILES

#define INFILES   "input_sources"

Definition at line 72 of file readL2scan.c.

◆ INFILES_OLD

#define INFILES_OLD   "Input Files"

Definition at line 73 of file readL2scan.c.

◆ LAC_PX_ST

#define LAC_PX_ST   "LAC Pixel Start Number"

Definition at line 112 of file readL2scan.c.

◆ LAC_PX_SUBSAMP

#define LAC_PX_SUBSAMP   "LAC Pixel Subsampling"

Definition at line 113 of file readL2scan.c.

◆ MISSION

#define MISSION   "platform"

Definition at line 87 of file readL2scan.c.

◆ MISSION_OLD

#define MISSION_OLD   "Mission"

Definition at line 88 of file readL2scan.c.

◆ MSNCHAR

#define MSNCHAR   "Mission Characteristics"

Definition at line 89 of file readL2scan.c.

◆ NFREC

#define NFREC   "Filled Scan Lines"

Definition at line 78 of file readL2scan.c.

◆ NLAT

#define NLAT   "northernmost_latitude"

Definition at line 94 of file readL2scan.c.

◆ NLAT_OLD

#define NLAT_OLD   "Northernmost Latitude"

Definition at line 95 of file readL2scan.c.

◆ NODEL

#define NODEL   "equatorCrossingLongitude"

Definition at line 110 of file readL2scan.c.

◆ NODEL_OLD

#define NODEL_OLD   "Orbit Node Longitude"

Definition at line 111 of file readL2scan.c.

◆ NTIME

#define NTIME   "equatorCrossingDateTime"

Definition at line 81 of file readL2scan.c.

◆ NTIME_OLD

#define NTIME_OLD   "Node Crossing Time"

Definition at line 82 of file readL2scan.c.

◆ ORBNUM

#define ORBNUM   "orbit_number"

Definition at line 92 of file readL2scan.c.

◆ ORBNUM_OLD

#define ORBNUM_OLD   "Orbit Number"

Definition at line 93 of file readL2scan.c.

◆ PCTFLAG

#define PCTFLAG   "flag_percentages"

Definition at line 79 of file readL2scan.c.

◆ PCTFLAG_OLD

#define PCTFLAG_OLD   "Flag Percentages"

Definition at line 80 of file readL2scan.c.

◆ SENNME

#define SENNME   "instrument"

Definition at line 74 of file readL2scan.c.

◆ SENNME_OLD

#define SENNME_OLD   "Sensor Name"

Definition at line 75 of file readL2scan.c.

◆ SENSOR

#define SENSOR   "Sensor"

Definition at line 90 of file readL2scan.c.

◆ SLAT

#define SLAT   "southernmost_latitude"

Definition at line 96 of file readL2scan.c.

◆ SLAT_OLD

#define SLAT_OLD   "Southernmost Latitude"

Definition at line 97 of file readL2scan.c.

◆ SNODE

#define SNODE   "startDirection"

Definition at line 83 of file readL2scan.c.

◆ SNODE_OLD

#define SNODE_OLD   "Start Node"

Definition at line 84 of file readL2scan.c.

◆ SNSCHAR

#define SNSCHAR   "Sensor Characteristics"

Definition at line 91 of file readL2scan.c.

◆ STCLAT

#define STCLAT   "start_center_latitude"

Definition at line 102 of file readL2scan.c.

◆ STCLAT_OLD

#define STCLAT_OLD   "Start Center Latitude"

Definition at line 103 of file readL2scan.c.

◆ STCLON

#define STCLON   "start_center_longitude"

Definition at line 104 of file readL2scan.c.

◆ STCLON_OLD

#define STCLON_OLD   "Start Center Longitude"

Definition at line 105 of file readL2scan.c.

◆ TITLE

#define TITLE   "title"

Definition at line 70 of file readL2scan.c.

◆ TITLE_OLD

#define TITLE_OLD   "Title"

Definition at line 71 of file readL2scan.c.

◆ WLON

#define WLON   "westernmost_longitude"

Definition at line 98 of file readL2scan.c.

◆ WLON_OLD

#define WLON_OLD   "Westernmost Longitude"

Definition at line 99 of file readL2scan.c.

Typedef Documentation

◆ ds_id_geonav_t

typedef idDS ds_id_geonav_t[6]

Definition at line 141 of file readL2scan.c.

◆ ds_id_ll_t

typedef idDS ds_id_ll_t[3]

Definition at line 137 of file readL2scan.c.

◆ ds_id_prod_t

typedef idDS ds_id_prod_t[1000]

Definition at line 127 of file readL2scan.c.

◆ grp_id_t

typedef int32_t grp_id_t[6]

Definition at line 144 of file readL2scan.c.

◆ prodtype_t

typedef int32_t prodtype_t[1000]

Definition at line 130 of file readL2scan.c.

◆ slope_t

typedef float slope_t[1000]

Definition at line 133 of file readL2scan.c.

Function Documentation

◆ allocateDatabuf()

void allocateDatabuf ( l2_prod *  l2_str,
int  maxThirdDim 
)

Definition at line 283 of file readL2scan.c.

◆ calculatePixelDeltas()

void calculatePixelDeltas ( float *  lat0,
float *  lon0,
float *  lat1,
float *  lon1,
float *  latOut,
float *  lonOut,
int32_t  numPoints 
)

calculate the half width and height of the pixels into Out, given 0 and 1.

Parameters
lat0first row lat
lon0first row lon
lat1second row lat
lon1second row lon
latOutoutput lat delta
lonOutoutput lon delta
numPointsnumber of elements in the input arrays

Definition at line 1231 of file readL2scan.c.

◆ clampDeltaLon()

void clampDeltaLon ( float *  deltaLon)

Definition at line 1124 of file readL2scan.c.

◆ closeL2()

int32_t closeL2 ( l2_prod *  l2_str,
int32_t  ifile 
)

Definition at line 1936 of file readL2scan.c.

◆ enableL2PixelArea()

void enableL2PixelArea ( enum L2PixelMode_t  val)

Turn on the calculation of the lat/lon deltas. Used for area weighting.

Parameters
valL2PixelOff(0)=off, L2PixelCorner(1)=pixel corners, L2PixelDelta(2)=pixel deltas

Definition at line 193 of file readL2scan.c.

◆ extrapolatePixelCorners()

void extrapolatePixelCorners ( float *  lat0,
float *  lon0,
float *  lat1,
float *  lon1,
float *  latOut,
float *  lonOut,
int32_t  numPoints 
)

extrapolate Out points given 0 and 1. Note the the output array has one extra element in it.

Parameters
lat0first row lat
lon0first row lon
lat1second row lat
lon1second row lon
latOutoutput lat (has one more element than input)
lonOutoutput lon (has one more element than input)
numPointsnumber of elements in the input arrays

Definition at line 1191 of file readL2scan.c.

◆ findprod()

int32_t findprod ( l2_prod *  l2_str,
char *  prodname 
)

Definition at line 2071 of file readL2scan.c.

◆ free_rowgroup_cache()

void free_rowgroup_cache ( )

Definition at line 236 of file readL2scan.c.

◆ freeL2()

int32_t freeL2 ( l2_prod *  l2_str)

Definition at line 2026 of file readL2scan.c.

◆ freeL2meta()

int32_t freeL2meta ( meta_l2Type *  meta_l2)

Definition at line 2255 of file readL2scan.c.

◆ get_dtype()

int32_t get_dtype ( int32_t  dtype,
ds_format_t  fileformat 
)

get_dtype get proper data type for reading This converts to appropriate NCDF type given an HDF type May want a better mouse trap, but for now solves the problem

Definition at line 211 of file readL2scan.c.

◆ getL3units()

int32_t getL3units ( l2_prod *  l2_str,
int32_t  ifile,
char *  l3b_prodname,
char *  units 
)

Definition at line 2274 of file readL2scan.c.

◆ init_rowgroup_cache()

void init_rowgroup_cache ( )

Definition at line 265 of file readL2scan.c.

◆ interpolatePixelCorners()

void interpolatePixelCorners ( float *  lat0,
float *  lon0,
float *  lat1,
float *  lon1,
float *  latOut,
float *  lonOut,
int32_t  numPoints 
)

interpolate Out points given 0 and 1. Note the the output array has one extra element in it.

Parameters
lat0first row lat
lon0first row lon
lat1second row lat
lon1second row lon
latOutoutput lat (has one more element than input)
lonOutoutput lon (has one more element than input)
numPointsnumber of elements in the input arrays

Definition at line 1150 of file readL2scan.c.

◆ openL2()

int32_t openL2 ( const char *  fname,
char *  plist,
l2_prod *  l2_str 
)

Definition at line 296 of file readL2scan.c.

◆ readdata_cached()

int32_t readdata_cached ( idDS  ds_id,
char *  name,
int32_t *  start,
int32_t *  stride,
int32_t *  edges,
void *  data,
unsigned char *  scan_in_rowgroup,
cache_str *  cache,
int32_t  dtype 
)

Definition at line 1059 of file readL2scan.c.

◆ readL2()

int32_t readL2 ( l2_prod *  l2_str,
int32_t  ifile,
int32_t  recnum,
int32_t  iprod,
unsigned char *  scan_in_rowgroup 
)

Definition at line 1250 of file readL2scan.c.

◆ readL2meta()

int32_t readL2meta ( meta_l2Type *  meta_l2,
int32_t  ifile 
)

Definition at line 2081 of file readL2scan.c.

◆ readlonlat()

int32_t readlonlat ( l2_prod *  l2_str,
int32_t  ifile,
int32_t *  start,
int32_t *  edges,
unsigned char *  scan_in_rowgroup 
)

Definition at line 1745 of file readL2scan.c.

◆ reopenL2()

int32_t reopenL2 ( int32_t  fileindex,
l2_prod *  l2_str 
)

Definition at line 975 of file readL2scan.c.