30 #include <HdfEosDef.h> 44 const char *fieldname,
61 status =
MtkReadL1B2Fid(fid, gridname, fieldname, region, databuf, mapinfo);
84 const char *fieldname,
110 double sun_distance_au_squared;
129 strncpy(fieldstr, fieldname,
MAXSTR);
130 fieldarr[0] = fieldstr;
134 if ((sp = strchr(fieldstr,
' ')) != NULL) {
139 while (*sp !=
'\0') {
140 *sp = (char)tolower((
int)*sp);
143 }
else if ((sp = strchr(fieldstr,
'\0')) != NULL) {
153 if (strncmp(fieldarr[1],
"radiance",
MAXSTR) == 0) {
158 strncat(field, fieldarr[0],
MAXSTR);
159 strncat(field,
" ",
MAXSTR);
160 strncat(field,
"Radiance/RDQI",
MAXSTR);
162 status =
MtkReadRawFid(fid, gridname, field, region, &radrdqi, &map);
173 fill_value.
data.
u16[0][0] -= 4;
182 for (l = 0; l < buf.
nline; l++) {
183 for (s = 0; s < buf.
nsample; s++) {
186 scale_factor.
data.
d[0][0]);
188 buf.
data.
f[l][s] = 0.0;
197 }
else if (strncmp(fieldarr[1],
"scaled radiance",
MAXSTR) == 0 ||
198 strncmp(fieldarr[1],
"dn",
MAXSTR) == 0) {
203 strncat(field, fieldarr[0],
MAXSTR);
204 strncat(field,
" ",
MAXSTR);
205 strncat(field,
"Radiance/RDQI",
MAXSTR);
207 status =
MtkReadRawFid(fid, gridname, field, region, &buf, &map);
218 fill_value.
data.
u16[0][0] -= 4;
220 for (l = 0; l < buf.
nline; l++) {
221 for (s = 0; s < buf.
nsample; s++) {
232 }
else if (strncmp(fieldarr[1],
"rdqi",
MAXSTR) == 0) {
237 strncat(field, fieldarr[0],
MAXSTR);
238 strncat(field,
" ",
MAXSTR);
239 strncat(field,
"Radiance/RDQI",
MAXSTR);
241 status =
MtkReadRawFid(fid, gridname, field, region, &radrdqi, &map);
248 for (l = 0; l < buf.
nline; l++) {
249 for (s = 0; s < buf.
nsample; s++) {
256 }
else if (strncmp(fieldarr[1],
"equivalent reflectance",
MAXSTR) == 0) {
261 strncat(field, fieldarr[0],
MAXSTR);
262 strncat(field,
" ",
MAXSTR);
263 strncat(field,
"Radiance/RDQI",
MAXSTR);
265 status =
MtkReadRawFid(fid, gridname, field, region, &radrdqi, &map);
276 fill_value.
data.
u16[0][0] -= 4;
293 sun_distance_au_squared = sun_distance_au.
data.
d[0][0] *
294 sun_distance_au.
data.
d[0][0];
296 for (l = 0; l < buf.
nline; l++) {
297 for (s = 0; s < buf.
nsample; s++) {
300 ((radrdqi.
data.
u16[l][s] >> 2) *
301 scale_factor.
data.
d[0][0]) /
302 solar_irradiance.
data.
f[0][0]);
304 buf.
data.
f[l][s] = 0.0;
315 }
else if (strncmp(fieldarr[1],
"brf",
MAXSTR) == 0) {
320 strncat(field, fieldarr[0],
MAXSTR);
321 strncat(field,
" ",
MAXSTR);
322 strncat(field,
"Radiance/RDQI",
MAXSTR);
324 status =
MtkReadRawFid(fid, gridname, field, region, &radrdqi, &map);
335 fill_value.
data.
u16[0][0] -= 4;
338 strncat(grid,
"BRF Conversion Factors",
MAXSTR);
340 strncat(field, fieldarr[0],
MAXSTR);
341 strncat(field,
"ConversionFactor",
MAXSTR);
343 status =
MtkReadRawFid(fid, grid, field, region, &conv_factor, &tmpmap);
355 for (l = 0; l < buf.
nline; l++) {
356 for (s = 0; s < buf.
nsample; s++) {
358 conv_factor.
data.
f[l/lf][s/sf] > 0.0) {
360 scale_factor.
data.
d[0][0] *
361 conv_factor.
data.
f[l/lf][s/sf]);
363 buf.
data.
f[l][s] = 0.0;
377 status =
MtkReadRawFid(fid, gridname, fieldname, region, &buf, &map);
MTKt_status MtkDataBufferAllocate(int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer *databuf)
Allocate Data Buffer.
MTKt_status MtkReadL1B2(const char *filename, const char *gridname, const char *fieldname, MTKt_Region region, MTKt_DataBuffer *databuf, MTKt_MapInfo *mapinfo)
Reads, unpacks and unscales any L1B2 grid/field from a MISR L1B2 product file.
#define MTKT_MAPINFO_INIT
#define MTK_ERR_CODE_JUMP(code)
2-dimensional Data Buffer
#define MTKT_DATABUFFER_INIT
MTKt_status MtkFillValueGetFid(int32 fid, const char *gridname, const char *fieldname, MTKt_DataBuffer *fillbuf)
Version of MtkFillValueGet that takes an HDF-EOS file ID rather than a filename.
MTKt_status MtkDataBufferFree(MTKt_DataBuffer *databuf)
Free data buffer.
MTKt_status MtkGridAttrGetFid(int32 fid, const char *gridname, const char *attrname, MTKt_DataBuffer *attrbuf)
Version of MtkFileGridAttrGet that takes an HDF-EOS file ID rather than a filename.
MTKt_status MtkReadL1B2Fid(int32 fid, const char *gridname, const char *fieldname, MTKt_Region region, MTKt_DataBuffer *databuf, MTKt_MapInfo *mapinfo)
Version of MtkReadL1B2 that takes an HDF-EOS file identifier rather than a filename. MISR L1B2 product file.
MTKt_status MtkReadRawFid(int32 fid, const char *gridname, const char *fieldname, MTKt_Region region, MTKt_DataBuffer *databuf, MTKt_MapInfo *mapinfo)
Version of MtkReadRaw that takes an HDF-EOS file identifier rather than a filename.
#define MTK_ERR_COND_JUMP(code)
int32 GDopen(char *, intn)
MTKt_status MtkFileTypeFid(int32 Fid, MTKt_FileType *filetype)
Version of MtkFileType that takes an HDF-EOS file identifier rather than a filename.