ncglm
1.0
|
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"
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... | |
Code to read data from the GOES-17 Global Lightning Mapper.
#define NUM_TRIALS 10 |
Number of timing runs when -t option is used.
#define PLATFORM_ID "platform_ID" |
Name of platform_ID attribute.
#define SUMMARY "summary" |
Name of summary attribute.
#define TITLE "title" |
Name of title attribute.
int glm_read_dims | ( | int | ncid, |
size_t * | nevent, | ||
size_t * | ngroup, | ||
size_t * | nflash | ||
) |
Read the dimensions.
ncid | ID of already opened GLM file. |
nevent | Pointer that gets the number of events. Ignored if NULL. |
ngroup | Pointer that gets the number of groups. Ignored if NULL. |
nflash | Pointer that gets the number of flashes. Ignored if NULL. |
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.
file_name | Name of the GLM file. |
verbose | Non-zero for some printf output. |
int glm_read_file_arrays | ( | char * | file_name, |
int | verbose | ||
) |
Read the contents of the GLM file into arrays of data.
file_name | GLM file to open and read. |
verbose | Non-zero to get some printf output as file is read. |
int read_scalars | ( | int | ncid, |
GLM_SCALAR_T * | glm_scalar | ||
) |
Read the scalars and small variables from the GLM file.
ncid | ID of already opened GLM file. |
glm_scalar | Pointer to already allocated GLM_SCALAR_T. |