OB.DAAC Logo
NASA Logo
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.

Macros

#define NUM_SCALE_FACTORS   2
 
#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
 

Functions

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)
 

Variables

int32 MOD_PR02_Failure_Exit_Code = 1
 
int16 L1B_BANDS_AT_RES [NUM_L1A_RESOLUTIONS]
 
int16 L1A_BANDS_AT_RES [NUM_L1A_RESOLUTIONS]
 
int16 DETECT_PER_BAND_AT_RES [NUM_L1A_RESOLUTIONS]
 
int16 BAND_RATIO_AT_RES [NUM_L1A_RESOLUTIONS] = {4,2,1,1}
 
int16 RFLAG
 
int16 RSCL_FLAG
 
char Invalid_MOD01_Msg []
 

Macro Definition Documentation

◆ ASCTIMEBUF

#define ASCTIMEBUF   26

◆ MAX_AGGR_FRAMES

#define MAX_AGGR_FRAMES   7

◆ MAX_BANDS_PER_FDD_SET

#define MAX_BANDS_PER_FDD_SET   16

◆ NUM_SCALE_FACTORS

#define NUM_SCALE_FACTORS   2

◆ WRITE_EV_Aggr_SDS

#define WRITE_EV_Aggr_SDS (   SI_id,
  SI,
  UI_id,
  UI,
  SU_id,
  SU 
)
Value:
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) \

◆ WRITE_MSG

#define WRITE_MSG (   c,
 
)
Value:
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 78 of file Granule.c.

◆ Bad_L1A_Error_Out()

void Bad_L1A_Error_Out ( char *  name,
char *  message 
)

Definition at line 1616 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 192 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 268 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 413 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 1919 of file Granule.c.

◆ Get_Satellite_ID()

PGSt_SMF_status Get_Satellite_ID ( PGSt_PC_Logical  lun,
int32 *  satellite_ID 
)

Definition at line 2924 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 918 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 2450 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 671 of file Granule.c.

◆ Read_Run_Time_Parameters()

PGSt_SMF_status Read_Run_Time_Parameters ( Run_Time_Parameters_t runtime_params)

Definition at line 2989 of file Granule.c.

◆ safe_strcat()

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

Definition at line 834 of file Granule.c.

◆ SMF_ERROR()

void SMF_ERROR ( PGSt_SMF_code  code,
char *  messagestring 
)

Definition at line 1345 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 1673 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 1832 of file Granule.c.

Variable Documentation

◆ actions

char* actions

Definition at line 1236 of file Granule.c.

◆ BAND_RATIO_AT_RES

int16 BAND_RATIO_AT_RES[NUM_L1A_RESOLUTIONS] = {4,2,1,1}

Definition at line 73 of file Granule.c.

◆ DETECT_PER_BAND_AT_RES

int16 DETECT_PER_BAND_AT_RES[NUM_L1A_RESOLUTIONS]
Initial value:

Definition at line 68 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 913 of file Granule.c.

◆ L1A_BANDS_AT_RES

int16 L1A_BANDS_AT_RES[NUM_L1A_RESOLUTIONS]
Initial value:

Definition at line 63 of file Granule.c.

◆ L1B_BANDS_AT_RES

int16 L1B_BANDS_AT_RES[NUM_L1A_RESOLUTIONS]
Initial value:

Definition at line 58 of file Granule.c.

◆ MOD_PR02_Failure_Exit_Code

int32 MOD_PR02_Failure_Exit_Code = 1

Definition at line 52 of file Granule.c.

◆ name

char* name

Definition at line 1234 of file Granule.c.

◆ RFLAG

int16 RFLAG

Definition at line 75 of file Granule.c.

◆ RSCL_FLAG

int16 RSCL_FLAG

Definition at line 76 of file Granule.c.

◆ value

int32 value

Definition at line 1235 of file Granule.c.

#define MODIS_F_WRITE_ERROR
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
#define NUM_500M_BANDS
Definition: Granule.h:431
#define DETECTORS_PER_1KM_BAND
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