OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
sst_dsdi.c
Go to the documentation of this file.
1 #include <netcdf.h>
2 #include "l1.h"
3 #include "l2_struc.h"
4 #include "math.h"
5 #include "sst_dsdi.h"
6 #include "l12_proto.h"
7 
8 
9 float dust_correction(float dustExtinction, float csenz, float BT39, float BT85, float BT11, float BT12, int32_t sensorID) {
10 
11  size_t ncoefficients = 13;
12  int32_t i;
13  float dsdi;
14  float correction = 0.0;
15  static float* coef;
16  static float dsdiThreshold = 0.8;
17  static float dustAODThreshold = 0.05;
18  if (!coef) {
19  coef = (float *) calloc(ncoefficients, sizeof (float));
20  if (strlen(input->dsdicoeffile)) {
21  int32_t coeffDimID, coefficientID;
22  int32_t ncid;
23  if (nc_open(input->dsdicoeffile, NC_NOWRITE, &ncid) == NC_NOERR) {
24  printf("Loading SST DSDI coefficients from %s:\n", input->dsdicoeffile);
25 
26  if (nc_inq_dimid(ncid, "coefficient", &coeffDimID) != NC_NOERR) {
27  printf("Whoops! something is wrong reading the SST DSDI coefficient file: %s\n", input->dsdicoeffile);
28  exit(EXIT_FAILURE);
29  }
30  nc_inq_dimlen(ncid, coeffDimID, &ncoefficients);
31 
32  if (nc_inq_varid(ncid, "coefficients", &coefficientID) == NC_NOERR) {
33  nc_get_var_float(ncid, coefficientID, coef);
34  }
35  // Get DSDI threshold
36  if (nc_get_att_float(ncid, NC_GLOBAL, "dsdi_threshold", &dsdiThreshold) != NC_NOERR) {
37  printf("Whoops! something is wrong reading the SST DSDI threshold attribute from file: %s\n", input->dsdicoeffile);
38  exit(EXIT_FAILURE);
39  }
40  // Get DSDI threshold
41  if (nc_get_att_float(ncid, NC_GLOBAL, "dust_threshold", &dustAODThreshold) != NC_NOERR) {
42  printf("Did not find dust AOD threshold attribute from file: %s\n", input->dsdicoeffile);
43  printf("using default of 0.025\n");
44  }
45  nc_close(ncid);
46  // print coefficients to be used
47  printf("DSDI coefficients:");
48  for (i = 0; i < ncoefficients; i++) {
49  printf("%9.6f ", coef[i]);
50  }
51  printf("\nDSDI threshold: %f\n",dsdiThreshold);
52  printf("\nDSDI Dust AOD threshold: %f\n",dsdiThreshold);
53  } else {
54  printf("\nCannot load DSDI coefficients file: %s\n", input->dsdicoeffile);
55  exit(EXIT_FAILURE);
56  }
57  }
58  }
59 
60  float secantTheta = 1. / csenz;
61  float S0 = secantTheta - 1.;
62  dustExtinction *= secantTheta;
63 
64  dsdi = coef[0] + (coef[1] + coef[2] * S0) * (BT39 - BT12) +
65  (coef[3] + coef[4] * S0) * (BT39 - BT85) +
66  (coef[5] + coef[6] * S0) * (BT11 - BT12) +
67  (coef[7] + coef[8] * S0) * pow(BT11 - BT12, 2) +
68  (coef[9] * sqrtf(dustExtinction) + coef[10]);
69 
70  if (dustExtinction > dustAODThreshold && dsdi > dsdiThreshold) {
71 // printf("dsdi: %f dust: %f S: %f csenz: %f\n",dsdi, dustExtinction,secantTheta,csenz);
72  correction = coef[11] * dsdi + coef[12];
73  }
74 
75  return correction;
76 }
instr * input
u5 which has been done in the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT production Changes from v6 which may affect scientific the sector rotation may actually occur during one of the scans earlier than the one where it is first reported As a the b1 values are about the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT to fill pixels affected by dead subframes with a special value Output the metadata of noisy and dead subframe Dead Subframe EV and Detector Quality Flag2 Removed the function call of Fill_Dead_Detector_SI to stop interpolating SI values for dead but also for all downstream products for science test only Changes from v5 which will affect scientific to conform to MODIS requirements Removed the Mixed option from the ScanType in the code because the L1A Scan Type is never Mixed Changed for ANSI C compliance and comments correction
Definition: HISTORY.txt:256
float dust_correction(float dustExtinction, float csenz, float BT39, float BT85, float BT11, float BT12, int32_t sensorID)
Definition: sst_dsdi.c:9
int i
Definition: decode_rs.h:71
int32_t sensorID[MAXNFILES]
Definition: l2bin.cpp:97