ocssw  1.0
/disk01/web/ocssw/build/src/l1agen_czcs/hdr_2_gattr.c (r8085/r3)
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "l1czcs.h"
00003 
00004 void hdr_2_gattr( HEADER2_TYPE header2, gattr_struc *gattr )
00005 /*******************************************************************
00006 
00007    hdr_2_gattr
00008 
00009    purpose: extract and convert the CRTT header data into values needed 
00010             for the output file global attributes
00011 
00012    Returns type: void
00013 
00014    Parameters: (in calling order)
00015       Type              Name            I/O     Description
00016       ----              ----            ---     -----------
00017       HEADER2TYPE       header2          I      structure with CRTT header
00018       gattr_struc *     gattr           I/O     structure with final 
00019                                                 attributes
00020 
00021    Modification history:
00022       Programmer        Date            Description of change
00023       ----------        ----            ---------------------
00024       W. Robinson        9-Mar-2004     Original development
00025 
00026 *******************************************************************/
00027   {
00028   int i;
00029   unsigned short us;
00030  /*
00031   *  Just fill the needed values, converting when necessary
00032   */
00033   gattr->start_year = header2.starting_yr;
00034   gattr->start_day = header2.starting_day;
00035   gattr->start_msec = header2.start_msec;
00036 
00037   time_str( header2.starting_yr, header2.starting_day, header2.start_msec,
00038      gattr->start_time );
00039  /*
00040   *  get the scene center time
00041   */
00042   time_str( header2.scene_cntr_yr, header2.scene_cntr_doy, 
00043     header2.scene_cntr_msec, gattr->center_time );
00044 
00045   gattr->orbit = (unsigned short) header2.orbit;
00046   gattr->gain = header2.gain;
00047   gattr->thresh = header2.threshold;
00048   gattr->tilt = header2.tilt / 1000.;
00049 
00050   gattr->center_lat = header2.lat_cntr / 100. - 90.;
00051   us = (unsigned short) header2.long_cntr;
00052   gattr->center_lon = ( us > 18000 ) ?  us / 100. - 360. : us / 100.;
00053 
00054   gattr->pix_per_scan = 1968;
00055   gattr->scan_lines = header2.no_of_scans;
00056 
00057   /* North limit, choose among top corners
00058 printf( "long corners: fitr %d, litr %d, fitl %d, litl %d\n", header2.long_crnr_fitr, header2.long_crnr_litr, header2.long_crnr_fitl, header2.long_crnr_litl );
00059 printf( "lat corners: fitr %d, litr %d, fitl %d, litl %d\n", header2.lat_crnr_fitr, header2.lat_crnr_litr, header2.lat_crnr_fitl, header2.lat_crnr_litl );
00060   */
00061 
00062   gattr->limits[0] = ( header2.lat_crnr_litl > header2.lat_crnr_litr ) ?
00063      header2.lat_crnr_litl / 100. : header2.lat_crnr_litr / 100.;
00064  /* South */
00065   gattr->limits[1] = ( header2.lat_crnr_fitl < header2.lat_crnr_fitr ) ?
00066      header2.lat_crnr_fitl / 100. : header2.lat_crnr_fitr / 100.;
00067  /* West */
00068   gattr->limits[2] = ( header2.long_crnr_fitl < header2.long_crnr_litl )?
00069      header2.long_crnr_fitl / 100. : header2.long_crnr_litl / 100.;
00070  /* East */
00071   gattr->limits[3] = ( header2.long_crnr_fitr > header2.long_crnr_litr )?
00072      header2.long_crnr_fitr / 100. : header2.long_crnr_litr / 100.;
00073 
00074  /*
00075   * slope and intercept
00076   */
00077   for( i = 0; i < 6; i++ )
00078     {
00079     gattr->slope[i] = fixed_pt_2_floating_pt( header2.chan_line[i].slope, 24 );
00080     gattr->intercept[i] = 
00081           fixed_pt_2_floating_pt( header2.chan_line[i].intercept, 24 );
00082     }
00083  /*
00084   *  pitch, roll and yaw
00085   */
00086   gattr->roll = header2.cntr_roll / 1000.;
00087   gattr->pitch = header2.cntr_pitch / 1000.;
00088   gattr->yaw = header2.cntr_yaw / 1000.;
00089  /*
00090   *  file metric info (is any of this really used, we'll find out)
00091   */
00092   gattr->ilt_flags = header2.ilt_flags;
00093   gattr->parm_presence = header2.parameter_presence;
00094   gattr->n_miss_scans = header2.no_of_missing_scans_all;
00095   for( i = 0; i < 6; i++ )
00096     gattr->n_scan_mis_chan[i] = header2.no_of_missing_scans[i];
00097   gattr->n_hdt_sync_loss = header2.no_of_hdt_sync_losses;
00098   gattr->n_hdt_parity_err = header2.no_of_hdt_parity_errs;
00099   gattr->n_wbvt_sync_loss = header2.no_of_wbvt_sync_losses;
00100   gattr->n_wbvt_slips = header2.no_of_wbvt_bit_slips;
00101   return;
00102   }