ncglm  1.0
Macros | Functions
glm_read.c File Reference

Code to read data from the GOES-17 Global Lightning Mapper. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
#include <assert.h>
#include <netcdf.h>
#include "ncglm.h"
Include dependency graph for glm_read.c:

Macros

#define TITLE   "title"
 Name of title attribute. More...
 
#define SUMMARY   "summary"
 Name of summary attribute. More...
 
#define PLATFORM_ID   "platform_ID"
 Name of platform_ID attribute. More...
 
#define NUM_TRIALS   10
 Number of timing runs when -t option is used. More...
 

Functions

int glm_read_dims (int ncid, size_t *nevent, size_t *ngroup, size_t *nflash)
 Read the dimensions. More...
 
int read_scalars (int ncid, GLM_SCALAR_T *glm_scalar)
 Read the scalars and small variables from the GLM file. More...
 
int glm_read_file (char *file_name, int verbose)
 From GOES R SERIESPRODUCT DEFINITION AND USERS’ GUIDE(PUG) Vol 3 (https://www.goes-r.gov/users/docs/PUG-L1b-vol3.pdf) More...
 
int glm_read_file_arrays (char *file_name, int verbose)
 Read the contents of the GLM file into arrays of data. More...
 

Detailed Description

Code to read data from the GOES-17 Global Lightning Mapper.

Author
Ed Hartnett, 10/10/19, Amsterdam

Macro Definition Documentation

◆ NUM_TRIALS

#define NUM_TRIALS   10

Number of timing runs when -t option is used.

◆ PLATFORM_ID

#define PLATFORM_ID   "platform_ID"

Name of platform_ID attribute.

◆ SUMMARY

#define SUMMARY   "summary"

Name of summary attribute.

◆ TITLE

#define TITLE   "title"

Name of title attribute.

Function Documentation

◆ glm_read_dims()

int glm_read_dims ( int  ncid,
size_t *  nevent,
size_t *  ngroup,
size_t *  nflash 
)

Read the dimensions.

Parameters
ncidID of already opened GLM file.
neventPointer that gets the number of events. Ignored if NULL.
ngroupPointer that gets the number of groups. Ignored if NULL.
nflashPointer that gets the number of flashes. Ignored if NULL.
Returns
0 for success, error code otherwise.
Author
Ed Hartnett

◆ glm_read_file()

int glm_read_file ( char *  file_name,
int  verbose 
)

From GOES R SERIESPRODUCT DEFINITION AND USERS’ GUIDE(PUG) Vol 3 (https://www.goes-r.gov/users/docs/PUG-L1b-vol3.pdf)

The classic model for netCDF (used by the GS) does not support unsigned integers larger than 8 bits. Many of the variables in GOES-R netCDF files are unsigned integers of 16-bit or 32-bit length. The following process is recommended to convert these unsigned integers:

1.Retrieve the variable data from the netCDF file.

2.For this variable, retrieve the attribute “_Unsigned”.

3.If the “_Unsigned” attribute is set to “true” or “True”, then cast the variable data to be unsigned.

The steps above must be completed before applying the scale_factor and add_offset values to convert from scaled integer to science units. Also, the valid_range and _FillValue attribute values are to be governed by the “_Unsigned” attribute

From a netCDF group email: https://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2002/msg00034.html

Normally you store a group of numbers, all with the same scale and offset. So first you calculate the min and max of that group of numbers. Also let max_integer = maximum integer (eg for INTEGER*2 this equals 32,167).

then offset = min scale = max_integer / (max - min)

store this number into netcdf file:

store_x = (x - offset) * scale = max_integer * (x - min) / (max - min)

note that when x = min, store_x = 0, and when x = max, store_x max_integer.

the reading program should use the formula

x = store_x/scale + offset.

Parameters
file_nameName of the GLM file.
verboseNon-zero for some printf output.
Returns
0 for success, error code otherwise.
Author
Ed Hartnett

◆ glm_read_file_arrays()

int glm_read_file_arrays ( char *  file_name,
int  verbose 
)

Read the contents of the GLM file into arrays of data.

Parameters
file_nameGLM file to open and read.
verboseNon-zero to get some printf output as file is read.
Returns
0 for success, error code otherwise.
Author
Ed Hartnett

◆ read_scalars()

int read_scalars ( int  ncid,
GLM_SCALAR_T *  glm_scalar 
)

Read the scalars and small variables from the GLM file.

Parameters
ncidID of already opened GLM file.
glm_scalarPointer to already allocated GLM_SCALAR_T.
Returns
0 for success, error code otherwise.
Author
Ed Hartnett