OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
emeta_api.c
Go to the documentation of this file.
1 #include "emeta_api.h" /* EMETA structure and routines */
2 
3 static EMETA emeta; /* Enhanced metadata structure */
4 
5 int emeta_init( /* Returns num bands in EMETA */
6  char *emeta_filename ) /* Enhanced metadata file name */
7 {
8  /* Read the enhanced metadata file */
9  if ( emeta_read( &emeta, emeta_filename ) != SUCCESS )
10  {
11  IAS_LOG_ERROR("Reading the enhanced metadata file %s.", emeta_filename);
12  return(0);
13  }
14 
15  return(emeta.num_band);
16 }
17 
19  int eband, /* Input band index */
20  EMETA_FRAME *frame ) /* Output image frame info */
21 {
22 
23  if ( eband > emeta.num_band-1 )
24  {
25  IAS_LOG_ERROR("Invalid band requested");
26  return(ERROR);
27  }
28 
29  /* Establish the output image file frame */
30  frame->band = emeta.band_emeta[eband].band;
31  frame->nlines = emeta.band_emeta[eband].l1t_lines;
32  frame->nsamps = emeta.band_emeta[eband].l1t_samps;
33  frame->code = emeta.projection.code;
34  frame->zone = emeta.projection.zone;
35  frame->pixsize = emeta.band_emeta[eband].pixsize;
36  frame->ul_x = emeta.projection.corners.upleft.x;
37  frame->ul_y = emeta.projection.corners.upleft.y;
38 
39  return(SUCCESS);
40 }
41 
43  int in_line, /* L1T line coordinate */
44  int in_samp, /* L1T sample coordinate */
45  int in_band, /* Spectral band number */
46  short *sat_zn, /* Satellite zenith angle */
47  short *sat_az, /* Satellite azimuth angle */
48  short *sun_zn, /* Solar zenith angle */
49  short *sun_az ) /* Solar azimuth angle */
50 {
51  double l1t_line; /* Float line coordinate */
52  double l1t_samp; /* Float sample coordinate */
53  double satang[2]; /* Satellite viewing angles */
54  double sunang[2]; /* Solar viewing angles */
55  double r2d; /* Radian to degree conversion */
56  int eband; /* Band index */
57  int band; /* Band number */
58  int status; /* Status return flag */
59 
60  /* Initialize conversion factor from radians to hundredths of degrees */
61  r2d = 4500.0 / atan(1.0);
62  status = ERROR;
63 
64  /* Process the angles for each band */
65  for ( eband=0; eband<emeta.num_band; eband++ )
66  {
67  band = emeta.band_emeta[eband].band;
68  if ( band != in_band ) continue;
69  status = SUCCESS;
70 
71  /* Calculate the angles for the current line/sample */
72  l1t_line = (double)in_line;
73  l1t_samp = (double)in_samp;
74 
75  /* Calculate the viewing geometry using the RPC method */
76  status = emeta_angles_rpc( l1t_line, l1t_samp, &emeta, band, satang, sunang );
77  if ( status != SUCCESS ) IAS_LOG_ERROR("Evaluating angles in band %d.", band);
78 
79  /* Quantize the satellite angles */
80  *sat_zn = (short)floor( r2d*satang[0] + 0.5 );
81  *sat_az = (short)floor( r2d*satang[1] + 0.5 );
82  /* Quantize the solar angles */
83  *sun_zn = (short)floor( r2d*sunang[0] + 0.5 );
84  *sun_az = (short)floor( r2d*sunang[1] + 0.5 );
85  }
86 
87  /* Return status */
88  return( status );
89 }
90 
92 {
93  /* Free the ephemeris structure */
94  emeta_free_ephemeris( &emeta );
95 
96  return;
97 }
#define SUCCESS
Definition: ObpgReadGrid.h:15
#define IAS_LOG_ERROR(format,...)
Definition: ias_logging.h:96
int status
Definition: l1_czcs_hdf.c:32
void emeta_free_ephemeris(EMETA *emeta)
Definition: emeta.c:51
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
int num_band
Definition: emeta.h:107
int emeta_read(EMETA *emeta, const char *emeta_filename)
Definition: emeta_exploit.c:21
int l1t_samps
Definition: emeta.h:84
subroutine satang(pi, rad, tilt, roll, pitch, yaw, xlon, ylat, senz, sena)
Definition: satang.f:3
double pixsize
Definition: emeta_exploit.h:27
int l1t_lines
Definition: emeta.h:83
EMETA_BAND band_emeta[IAS_MAX_NBANDS]
Definition: emeta.h:108
Definition: emeta.h:102
void emeta_close()
Definition: emeta_api.c:91
integer, parameter double
int emeta_angles_rpc(double l1t_line, double l1t_samp, EMETA *emeta, int band, double *satang, double *sunang)
int emeta_init(char *emeta_filename)
Definition: emeta_api.c:5
EMETA_SCENE_PROJ projection
Definition: emeta.h:106
IAS_DBL_XY upleft
int emeta_get_frame(int eband, EMETA_FRAME *frame)
Definition: emeta_api.c:18
struct IAS_CORNERS corners
Definition: emeta.h:75
double pixsize
Definition: emeta.h:87
int emeta_calc(int in_line, int in_samp, int in_band, short *sat_zn, short *sat_az, short *sun_zn, short *sun_az)
Definition: emeta_api.c:42
#define ERROR
Definition: ancil.h:24
int band
Definition: emeta.h:81