Ocean Color Science Software

ocssw V2022
Granule.c File Reference
#include "L1B_Tables.h"
#include "GranuleP.h"
#include "HDF_Lib.h"
#include "PGS_PC.h"
#include "PGS_TD.h"
#include "PGS_MET.h"
#include "PGS_Error_Codes.h"
#include "FNames.h"
#include <string.h>
#include <math.h>
#include <time.h>
#include "granule_extract_metadata.h"
Include dependency graph for Granule.c:

Go to the source code of this file.


#define MAX_AGGR_FRAMES   7
#define ASCTIMEBUF   26
#define WRITE_MSG(c, m)
#define WRITE_EV_Aggr_SDS(SI_id, SI, UI_id, UI, SU_id, SU)
#define MAX_BANDS_PER_FDD_SET   16


PGSt_SMF_status Aggregate_L1B (L1B_Scan_t *L1B_Scan)
PGSt_SMF_status Close_L1A_Granule (L1A_granule_t *L1A_Gran, L1A_Scan_t *L1A_Scan)
PGSt_SMF_status Close_L1B_Granule (L1B_granule_t *L1B_Gran, L1B_Scan_t *L1B_Scan, boolean skip_night_hi_res)
PGSt_SMF_status Compute_Aggregates (int16 scale, int16 line_dim_lower, int16 frame_dim_lower, uint16 *SI_in, uint8 *UI_in, uint16 *SI_out, uint8 *UI_out, int8 *SU_out)
PGSt_SMF_status Read_L1A_EV_Scan (int16 S, L1A_granule_t *L1A_Gran, L1A_Scan_t *L1A_Scan)
int safe_strcat (char *buf, char *str, int buflen)
void L1BErrorMsg (char *L1B_location, PGSt_SMF_code code, char *input_message, char *assoc_function, int32 lun, char *other_msg, boolean error_out)
void SMF_ERROR (PGSt_SMF_code code, char *messagestring)
void Bad_L1A_Error_Out (char *name, char *message)
PGSt_SMF_status Write_L1B_EV_Scan (int16 S, L1B_granule_t *L1B_Gran, L1B_Scan_t *L1B_Scan, boolean isdaymode)
PGSt_SMF_status Write_L1B_SI_UI (int16 S, L1B_Scan_t *L1B_Scan, int16 R)
PGSt_SMF_status Fill_Dead_Detector_SI (boolean isdaymode, int8 *dead_detector, L1B_Scan_t *L1B_Scan, L1B_granule_t *L1B_Gran, QA_Common_t *QA_Common)
PGSt_SMF_status Open_and_Read_L1A (Run_Time_Parameters_t *runtime_params, L1A_granule_t *L1A_Gran, boolean *skip_night_hi_res)
PGSt_SMF_status Get_Satellite_ID (PGSt_PC_Logical lun, int32 *satellite_ID)
PGSt_SMF_status Read_Run_Time_Parameters (Run_Time_Parameters_t *runtime_params)


int32 MOD_PR02_Failure_Exit_Code = 1
int16 RFLAG
char Invalid_MOD01_Msg []

Macro Definition Documentation


#define ASCTIMEBUF   26


#define MAX_AGGR_FRAMES   7


#define MAX_BANDS_PER_FDD_SET   16




#define WRITE_EV_Aggr_SDS (   SI_id,
if(SDwritedata(SI_id,start,NULL,edge,SI) == FAIL) \
if(SDwritedata(UI_id,start,NULL,edge,UI) == FAIL) \
if(SDwritedata(SU_id,start,NULL,edge,SU) == FAIL) \


#define WRITE_MSG (   c,
if (strlen(m) > (PGS_SMF_MAX_MSGBUF_SIZE - 1)) { \
m[strlen(m)-1] = '\0'; \
} \
returnStatus = PGS_SMF_SetDynamicMsg(c, m, NULL); \
if (returnStatus != PGS_S_SUCCESS) \
internal_failure = PGS_TRUE; \
returnStatus = PGS_SMF_GenerateStatusReport(m); \
if (returnStatus != PGS_S_SUCCESS) \
internal_failure = PGS_TRUE;

Function Documentation

◆ Aggregate_L1B()

PGSt_SMF_status Aggregate_L1B ( L1B_Scan_t L1B_Scan)

Definition at line 81 of file Granule.c.

◆ Bad_L1A_Error_Out()

void Bad_L1A_Error_Out ( char *  name,
char *  message 

Definition at line 1615 of file Granule.c.

◆ Close_L1A_Granule()

PGSt_SMF_status Close_L1A_Granule ( L1A_granule_t L1A_Gran,
L1A_Scan_t L1A_Scan 

Definition at line 195 of file Granule.c.

◆ Close_L1B_Granule()

PGSt_SMF_status Close_L1B_Granule ( L1B_granule_t L1B_Gran,
L1B_Scan_t L1B_Scan,
boolean  skip_night_hi_res 

Definition at line 271 of file Granule.c.

◆ Compute_Aggregates()

PGSt_SMF_status Compute_Aggregates ( int16  scale,
int16  line_dim_lower,
int16  frame_dim_lower,
uint16 *  SI_in,
uint8 *  UI_in,
uint16 *  SI_out,
uint8 *  UI_out,
int8 *  SU_out 

Definition at line 416 of file Granule.c.

◆ Fill_Dead_Detector_SI()

PGSt_SMF_status Fill_Dead_Detector_SI ( boolean  isdaymode,
int8 *  dead_detector,
L1B_Scan_t L1B_Scan,
L1B_granule_t L1B_Gran,
QA_Common_t QA_Common 

Definition at line 1918 of file Granule.c.

◆ Get_Satellite_ID()

PGSt_SMF_status Get_Satellite_ID ( PGSt_PC_Logical  lun,
int32 *  satellite_ID 

Definition at line 2923 of file Granule.c.

◆ L1BErrorMsg()

void L1BErrorMsg ( char *  L1B_location,
PGSt_SMF_code  code,
char *  input_message,
char *  assoc_function,
int32  lun,
char *  other_msg,
boolean  error_out 

Definition at line 921 of file Granule.c.

◆ Open_and_Read_L1A()

PGSt_SMF_status Open_and_Read_L1A ( Run_Time_Parameters_t runtime_params,
L1A_granule_t L1A_Gran,
boolean skip_night_hi_res 

Definition at line 2449 of file Granule.c.

◆ Read_L1A_EV_Scan()

PGSt_SMF_status Read_L1A_EV_Scan ( int16  S,
L1A_granule_t L1A_Gran,
L1A_Scan_t L1A_Scan 

Definition at line 674 of file Granule.c.

◆ Read_Run_Time_Parameters()

PGSt_SMF_status Read_Run_Time_Parameters ( Run_Time_Parameters_t runtime_params)

Definition at line 2988 of file Granule.c.

◆ safe_strcat()

int safe_strcat ( char *  buf,
char *  str,
int  buflen 

Definition at line 837 of file Granule.c.


void SMF_ERROR ( PGSt_SMF_code  code,
char *  messagestring 

Definition at line 1344 of file Granule.c.

◆ Write_L1B_EV_Scan()

PGSt_SMF_status Write_L1B_EV_Scan ( int16  S,
L1B_granule_t L1B_Gran,
L1B_Scan_t L1B_Scan,
boolean  isdaymode 

Definition at line 1672 of file Granule.c.

◆ Write_L1B_SI_UI()

PGSt_SMF_status Write_L1B_SI_UI ( int16  S,
L1B_Scan_t L1B_Scan,
int16  R 

Definition at line 1831 of file Granule.c.

Variable Documentation

◆ actions

char* actions

Definition at line 1235 of file Granule.c.



Definition at line 76 of file Granule.c.


Initial value:

Definition at line 71 of file Granule.c.

◆ Invalid_MOD01_Msg

char Invalid_MOD01_Msg[]
Initial value:
= "\
The MOD01 granule appears to be invalid. Data values are present\n\
that are not allowed by the MOD01 file specifications."

Definition at line 916 of file Granule.c.


Initial value:

Definition at line 66 of file Granule.c.


Initial value:

Definition at line 61 of file Granule.c.

◆ MOD_PR02_Failure_Exit_Code

int32 MOD_PR02_Failure_Exit_Code = 1

Definition at line 55 of file Granule.c.

◆ name

char* name

Definition at line 1233 of file Granule.c.


int16 RFLAG

Definition at line 78 of file Granule.c.



Definition at line 79 of file Granule.c.

◆ value

int32 value

Definition at line 1234 of file Granule.c.

#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
#define NUM_500M_BANDS
Definition: Granule.h:431
Definition: Granule.h:438
#define NUM_1000M_EMISS_BANDS
Definition: Granule.h:434
instead the metadata field ProcessingEnvinronment is filled in from the output of a call to the POSIX compliant function uname from within the L1B code A small bug in L1B_Tables an incorrect comparison of RVS coefficients for TEBs to RVS coefficients for RSBs was being made This was replaced with a comparison between TEB coefficients This error never resulted in an incorrect RVS correction but did lead to recalculating the coefficients for each detector in a thermal band even if the coefficients were the same for all detectors To reduce to overall size of the reflective LUT HDF fill values were eliminated from all LUTs previously dimensioned where and where NUM_TIMES is the number of time dependent table pieces In Preprocess a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed This counter is internal only and is not yet used for any chiefly to casting of were added to make it LINUX compatible Output of code run on LINUX machines displays differences of at most scaled sector incalculable values of the Emissive calibration factor and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal c since none of these quantities are frame dependent Initialization of b1 and XMS values in Preprocess c routine Process_OBCENG_Emiss was moved inside the detector loops The code was altered so that if up to five scans are dropped between the leading middle or middle trailing the leading or trailing granule will still be used in emissive calibration to form a cross granule average QA bits and are set for a gap between the leading middle and middle trailing granules respectively This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule A small bug in the Band correction algorithm was corrected an uncertainty value was being checked against an upper bound whereas the proper quantity to be checked was the corresponding SI
Definition: HISTORY.txt:595
#define NUM_1000M_NIGHT_BANDS
Definition: Granule.h:437
#define NUM_250M_BANDS
Definition: Granule.h:430
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument validate it against the input L1A and LUT and to use it determine the correct files to retrieve the ephemeris and attitude data from Changed to produce a LocalGranuleID starting with MYD03 if run on Aqua data Added the Scan Type file attribute to the Geolocation copied from the L1A and attitude_angels to radians rather than degrees The accumulation of Cumulated gflags was moved from GEO_validate_earth_location c to GEO_locate_one_scan c
Definition: HISTORY.txt:464
#define NUM_1000M_DAY_BANDS
Definition: Granule.h:436
#define NUM_1000M_REFL_BANDS
Definition: Granule.h:432