8 int const number_of_scans,
10 MODFILE *
const geo_file,
210 } dimensions[dimcount] = {
231 static uint8 ui8value[][3]={
239 static uint16 ui16value[][3]={
240 {(uint16)0, (uint16)1},
242 {(uint16)0, (uint16)1400},
245 static uint32 ui32value[][3]={
254 static int16 i16value[][3]={
262 static float32 r32value[][3]={
263 {(float32)-180.0, (float32)180.0, (float32)
LONG_FVALUE},
264 {(float32)(-90.0), (float32)(90.0), (float32)
LAT_FVALUE},
265 {(float32)(-1.0), (float32)(1.0)},
270 static float64 r64value[][2]={
271 {(float64)-7200000.0, (float64)7200000.0},
272 {(float64)-7600.0, (float64)7600.0},
273 {(float64)0.0, (float64)16384.0},
274 {(float64)0.0, (float64)1.5},
275 {(float64)-1.0, (float64)1.0}
278 static int8 i8value[3]={(int8)-127, (int8)127,
HIRES_FVALUE};
284 enum dimtype dims[3];
285 char data_type[DATATYPELENMAX];
286 unsigned char not_swath;
292 void const *fillvalue;
293 void const *scale_val;
313 vecdim}, R64, 1,
"meters", r64value[0]},
315 vecdim}, R64, 1,
"meters per second",
319 vecdim}, R64, 1,
NULL, r64value[4]},
321 vecdim}, R64, 1,
"radians"},
323 vecdim}, R32, 1,
NULL, r32value[2]},
339 {
RANGE,
SCAN_GRP, 0, {none}, UI16, 0,
"meters", ui16value[1],
353 r32value[3], &r32value[3][2]},
355 ui32value[0], &ui32value[0][2]},
357 ui32value[1], &ui32value[0][2]},
370 const float32 temp_limits[EQN_TYPES][2] = { {50.0, 118.0},
371 {-22.0, 87.0}, {-23.0, 87.0}};
372 float32 fill_temp[1];
373 const int eqn_type[6] = {TA07, TP02, TP01, TP01, TP02, TP02};
374 const char *temp_units[] = {
"Kelvin ",
"Celsius",
"Celsius",
375 "Celsius",
"Celsius",
"Celsius"};
398 long int dim_sizes[3];
399 PGSt_SMF_status ret_val = PGS_S_SUCCESS;
400 int i, obj, dim, temp;
401 int num_objs = (
int)(
sizeof SDS_object /
sizeof SDS_object[0]);
402 int32 vdata_id, status_32;
404 char msgbuf[PGS_SMF_MAX_MSGBUF_SIZE] =
"";
405 char filefunc[] = __FILE__
", GEO_initialize_product";
409 fill_values ==
NULL || geo_file ==
NULL || swfid ==
FAIL ||
411 sprintf(msgbuf,
"geo_file = %p, number_of_scans = %d, swfid = %ld\n"
412 "fill_values = %p, GEO_param = %p", (
void *)geo_file,
413 number_of_scans, (
long)swfid, (
void *)fill_values,
423 vdata_id = VSattach((int32)geo_file->hdf_id, _HDF_VDATA,
"w");
424 if (vdata_id ==
FAIL) {
430 if (status_32 != SUCCEED) {
435 for (temp = 0; temp <
NUM_TEMPS; temp++) {
436 status_n = VSfdefine(vdata_id, temperature_field[temp],
438 if (status_n != SUCCEED) {
444 status_n = VSsetfields(vdata_id, TEMPERATURE_FIELDS);
445 if (status_n != SUCCEED) {
451 if (VSsetattr(vdata_id, _HDF_VDATA, MFILL_VALUE,
DFNT_FLOAT32, 1,
452 fill_temp) != SUCCEED) {
458 for (temp = 0; temp <
NUM_TEMPS; temp++) {
459 if (VSsetattr(vdata_id, temp, MUNITS, DFNT_CHAR, 7,
460 temp_units[temp]) != SUCCEED) {
462 temp, MUNITS, temp_units[temp]);
466 if (VSsetattr(vdata_id, temp, MDATA_RANGE,
DFNT_FLOAT32, 2,
467 temp_limits[eqn_type[temp]]) != SUCCEED) {
475 status_32 = VSdetach(vdata_id);
476 if (status_32 != SUCCEED) {
481 if (number_of_scans == 0)
482 return PGS_S_SUCCESS;
484 dimensions[nscans].value = (long)number_of_scans;
485 SDS_object[25].scale_val = &GEO_param->
angle_scale;
486 SDS_object[26].scale_val = &GEO_param->
angle_scale;
487 SDS_object[27].scale_val = &GEO_param->
range_scale;
488 SDS_object[28].scale_val = &GEO_param->
angle_scale;
489 SDS_object[29].scale_val = &GEO_param->
angle_scale;
490 SDS_object[37].scale_val = &GEO_param->
hires_scale;
491 SDS_object[38].scale_val = &GEO_param->
hires_scale;
492 SDS_object[39].scale_val = &GEO_param->
hires_scale;
493 SDS_object[0].fillvalue = &fill_values->
scan_number;
498 SDS_object[8].fillvalue = &fill_values->
mirr_side;
501 SDS_object[11].fillvalue = &fill_values->
moon_vector;
504 SDS_object[14].fillvalue = &fill_values->
orb_pos;
505 SDS_object[15].fillvalue = &fill_values->
orb_vel;
506 SDS_object[16].fillvalue = &fill_values->
T_inst2ECR;
508 SDS_object[18].fillvalue = &fill_values->
sun_ref;
509 SDS_object[20].fillvalue = &fill_values->
impulse_enc;
516 modsmf(
MODIS_E_GEO,
"GEO_create_swath()", filefunc);
525 for (obj=0; obj<num_objs; obj++) {
527 if ( SDS_object[obj].not_swath )
529 memset (dim_sizes, 0,
sizeof(dim_sizes));
531 dim_sizes[
i] = dimensions[SDS_object[obj].dims[
i]].
value;
533 if (createMODISarray(geo_file, SDS_object[obj].
name,
534 SDS_object[obj].
group, SDS_object[obj].data_type,
535 SDS_object[obj].
rank, dim_sizes) != MAPIOK) {
536 sprintf(msgbuf,
"createMODISarray(\"%s\",\n \"%s\", \"%s\")", geo_file->filename,
537 SDS_object[obj].name, SDS_object[obj].data_type);
542 for (dim=0; dim<(
int)SDS_object[obj].
rank; dim++){
543 if (putMODISdimname(geo_file, SDS_object[obj].
name,
544 SDS_object[obj].
group, (
long)dim,
545 dimensions[SDS_object[obj].dims[dim]].
name) != MAPIOK){
546 sprintf(msgbuf,
"putMODISdimname(\"%s\",\n \"%s\", \"%s\", \"%s\")",
547 geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
548 dimensions[SDS_object[obj].dims[dim]].name);
556 if ((SDS_object[obj].
units) && putMODISarinfo(geo_file,
557 SDS_object[obj].
name, SDS_object[obj].
group, MUNITS, TXT,
558 (
long)strlen(SDS_object[obj].
units), SDS_object[obj].
units) != MAPIOK){
560 "putMODISarinfo(\"%s\",\n \"%s\", \"%s\", \"%s\", \"%s\")",
561 geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
562 MUNITS, SDS_object[obj].units);
567 if ((SDS_object[obj].
range) && putMODISarinfo(geo_file,
568 SDS_object[obj].
name, SDS_object[obj].
group, MDATA_RANGE,
569 SDS_object[obj].data_type, 2
L, SDS_object[obj].
range) != MAPIOK) {
570 sprintf(msgbuf,
"putMODISarinfo(\"%s\",\n \"%s\", \"%s\", \"%s\", \"%s\")",
571 geo_file->filename, SDS_object[obj].name,
572 SDS_object[obj].group, MDATA_RANGE, SDS_object[obj].data_type);
577 if (SDS_object[obj].fillvalue) {
578 dim_sizes[0] = dim_sizes[1] = dim_sizes[2] = 1;
579 if (putMODISarinfo(geo_file, SDS_object[obj].
name,
580 SDS_object[obj].
group, MFILL_VALUE, SDS_object[obj].data_type, 1
L,
581 SDS_object[obj].fillvalue) != MAPIOK) {
582 sprintf(msgbuf,
"putMODISarinfo(\"%s\",\n \"%s\", \"%s\", \"%s\", \"%s\")",
583 geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
584 MFILL_VALUE, SDS_object[obj].data_type);
590 if ((SDS_object[obj].scale_val) && putMODISarinfo(geo_file,
591 SDS_object[obj].
name, SDS_object[obj].
group, MSLOPE, R64, 1
L,
592 SDS_object[obj].scale_val) != MAPIOK) {
593 sprintf(msgbuf,
"putMODISarinfo(\"%s\"\n\"%s\", \"%s\", \"%s\", \"%s\")",
594 geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
595 MSLOPE, SDS_object[obj].data_type);
601 for (obj=0; obj<(
int)(
sizeof element /
sizeof element[0]); obj++) {
603 element[obj].
name, UI32, 1
L, &element[obj].
value) != MAPIOK)
605 sprintf(msgbuf,
"putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
606 geo_file->filename,
ATTIT_ANG, element[obj].name);
611 element[obj].
name, UI32, 1
L, &element[obj].
value) != MAPIOK)
613 sprintf(msgbuf,
"putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
614 geo_file->filename,
THERMCORR, element[obj].name);
620 for (obj=0; obj<(
int)(
sizeof(quality_attr)/
sizeof(quality_attr[0])); obj++)
623 quality_attr[obj].
name, UI32, 1
L, &quality_attr[obj].
value) != MAPIOK)
625 sprintf(msgbuf,
"putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
626 geo_file->filename,
ATT_QUALITY, quality_attr[obj].name);
632 quality_attr[obj].
name, UI32, 1
L, &quality_attr[obj].
value) != MAPIOK)
634 sprintf(msgbuf,
"putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
635 geo_file->filename,
EPH_QUALITY, quality_attr[obj].name);