Example #1
0
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void ENVI_WR_ASCII_MPH( struct param_record param, 
			const struct mph_envi *mph )
{
     register unsigned int  nr = 0;

     FILE *outfl = CRE_ASCII_File( param.outfile, "mph" );

     if ( outfl == NULL || IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_FILE_CRE, param.outfile );
/*
 * write ASCII dump of MPH record
 */
     nadc_write_header( outfl, nr, param.infile, "Main Product Header" );
     nadc_write_text( outfl, ++nr, "PRODUCT", mph->product );
     nadc_write_text( outfl, ++nr, "PROC_STAGE", mph->proc_stage );
     nadc_write_text( outfl, ++nr, "REF_DOC", mph->ref_doc );
     nr++;    /* spare_1 */
     nadc_write_text( outfl, ++nr, "ACQUISITION_STATION", mph->acquis );
     nadc_write_text( outfl, ++nr, "PROC_CENTER", mph->proc_center );
     nadc_write_text( outfl, ++nr, "PROC_TIME", mph->proc_time );
     nadc_write_text( outfl, ++nr, "SOFTWARE_VER", mph->soft_version );
     nr++;    /* spare_2 */
     nadc_write_text( outfl, ++nr, "SENSING_START", mph->sensing_start );
     nadc_write_text( outfl, ++nr, "SENSING_STOP", mph->sensing_stop );
     nr++;    /* spare_3 */
     nadc_write_text( outfl, ++nr, "PHASE", mph->phase );
     nadc_write_short( outfl, ++nr, "CYCLE", mph->cycle );
     nadc_write_int( outfl, ++nr, "REL_ORBIT", mph->rel_orbit );
     nadc_write_int( outfl, ++nr, "ABS_ORBIT", mph->abs_orbit );
     nadc_write_text( outfl, ++nr, "STATE_VECTOR_TIME", mph->state_vector );
     nadc_write_double( outfl, ++nr, "DELTA_UT1", 3, mph->delta_ut );
     nadc_write_double( outfl, ++nr, "X_POSITION", 3, mph->x_position );
     nadc_write_double( outfl, ++nr, "Y_POSITION", 3, mph->y_position );
     nadc_write_double( outfl, ++nr, "Z_POSITION", 3, mph->z_position );
     nadc_write_double( outfl, ++nr, "X_VELOCITY", 6, mph->x_velocity );
     nadc_write_double( outfl, ++nr, "Y_VELOCITY", 6, mph->y_velocity );
     nadc_write_double( outfl, ++nr, "Z_VELOCITY", 6, mph->z_velocity );
     nr++;    /* spare_4 */
     nadc_write_text( outfl, ++nr, "VECTOR_SOURCE", mph->vector_source );
     nadc_write_text( outfl, ++nr, "UTC_SBT_TIME", mph->utc_sbt_time );
     nadc_write_uint( outfl, ++nr, "SAT_BINARY_TIME", mph->sat_binary_time );
     nadc_write_uint( outfl, ++nr, "CLOCK_STEP", mph->clock_step );
     nr++;    /* spare_5 */
     nadc_write_text( outfl, ++nr, "LEAP_UTC", mph->leap_utc );
     nadc_write_short( outfl, ++nr, "LEAP_SIGN", mph->leap_sign );
     nadc_write_text( outfl, ++nr, "LEAP_ERR", mph->leap_err );
     nr++;    /* spare_6 */
     nadc_write_text( outfl, ++nr, "PRODUCT_ERR", mph->product_err );
     nadc_write_uint( outfl, ++nr, "TOT_SIZE", mph->tot_size );
     nadc_write_uint( outfl, ++nr, "SPH_SIZE", mph->sph_size );
     nadc_write_uint( outfl, ++nr, "NUM_DSD", mph->num_dsd );
     nadc_write_uint( outfl, ++nr, "DSD_SIZE", mph->dsd_size );
     nadc_write_uint( outfl, ++nr, "NUM_DATA_SETS", mph->num_data_sets );
     nr++;    /* spare_7 */
     (void) fclose( outfl );
}
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void SCIA_OL2_WR_ASCII_SPH( struct param_record param, 
			    const struct sph_sci_ol *sph )
{
     register unsigned int  nr = 0;

     FILE *outfl = CRE_ASCII_File( param.outfile, "sph" );

     if ( outfl == NULL || IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_FILE_CRE, param.outfile );
/*
 * write ASCII dump of SPH record
 */
     nadc_write_header( outfl, nr, param.infile, 
			 "Specific Product Header of Level 2 Product" );
     nadc_write_text( outfl, ++nr, "SPH_DESCRIPTOR", sph->descriptor );
     nadc_write_short( outfl, ++nr, "STRIPLINE_CONTINUITY_INDICATOR", 
		       sph->stripline );
     nadc_write_short( outfl, ++nr, "SLICE_POSITION", sph->slice_pos );
     nadc_write_ushort( outfl, ++nr, "NUM_SLICES", sph->no_slice );
     nadc_write_text( outfl, ++nr, "START_TIME", sph->start_time );
     nadc_write_text( outfl, ++nr, "STOP_TIME", sph->stop_time );
     nadc_write_double( outfl, ++nr, "START_LAT", 6, sph->start_lat );
     nadc_write_double( outfl, ++nr, "START_LON", 6, sph->start_lon );
     nadc_write_double( outfl, ++nr, "STOP_LAT", 6, sph->stop_lat );
     nadc_write_double( outfl, ++nr, "STOP_LON", 6, sph->stop_lon );
     if ( strlen( sph->decont ) == 0 )
	  nadc_write_text( outfl, ++nr, "DECONT", sph->decont );
     else
	  ++nr;    /* spare_1 */
     nadc_write_text( outfl, ++nr, "DB_SERVER_VER", sph->dbserver );
     nadc_write_text( outfl, ++nr, "FITTING_ERROR_SUM", sph->errorsum );
/*
 * Nadir
 */
     nadc_write_ushort( outfl, ++nr, "NO_OF_NADIR_FITTING_WINDOWS", 
			 sph->no_nadir_win );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV0", sph->nadir_win_uv0 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV1", sph->nadir_win_uv1 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV2", sph->nadir_win_uv2 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV3", sph->nadir_win_uv3 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV4", sph->nadir_win_uv4 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV5", sph->nadir_win_uv5 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV6", sph->nadir_win_uv6 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV7", sph->nadir_win_uv7 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV8", sph->nadir_win_uv8 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_UV9", sph->nadir_win_uv9 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_IR0", sph->nadir_win_ir0 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_IR1", sph->nadir_win_ir1 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_IR2", sph->nadir_win_ir2 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_IR3", sph->nadir_win_ir3 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_IR4", sph->nadir_win_ir4 );
     nadc_write_text( outfl, ++nr, "NAD_FIT_WINDOW_IR5", sph->nadir_win_ir5 );
/*
 * Limb
 */
     nadc_write_ushort( outfl, ++nr, "NO_OF_LIMB_FITTING_WINDOWS", 
			 sph->no_limb_win );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_PTH", sph->limb_win_pth );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV0", sph->limb_win_uv0 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV1", sph->limb_win_uv1 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV2", sph->limb_win_uv2 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV3", sph->limb_win_uv3 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV4", sph->limb_win_uv4 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV5", sph->limb_win_uv5 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV6", sph->limb_win_uv6 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_UV7", sph->limb_win_uv7 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_IR0", sph->limb_win_ir0 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_IR1", sph->limb_win_ir1 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_IR2", sph->limb_win_ir2 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_IR3", sph->limb_win_ir3 );
     nadc_write_text( outfl, ++nr, "LIM_FIT_WINDOW_IR4", sph->limb_win_ir4 );
/*
 * Occultation
 */
     nadc_write_ushort( outfl, ++nr, "NO_OF_OCCL_FITTING_WINDOWS", 
			 sph->no_occl_win );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_PTH", sph->occl_win_pth );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV0", sph->occl_win_uv0 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV1", sph->occl_win_uv1 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV2", sph->occl_win_uv2 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV3", sph->occl_win_uv3 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV4", sph->occl_win_uv4 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV5", sph->occl_win_uv5 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV6", sph->occl_win_uv6 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_UV7", sph->occl_win_uv7 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_IR0", sph->occl_win_ir0 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_IR1", sph->occl_win_ir1 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_IR2", sph->occl_win_ir2 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_IR3", sph->occl_win_ir3 );
     nadc_write_text( outfl, ++nr, "OCC_FIT_WINDOW_IR4", sph->occl_win_ir4 );
     (void) fclose( outfl );
}
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void MERIS_WR_ASCII_SPH( struct param_record param, 
			 const struct sph_meris *sph )
{
     register unsigned int  nr = 0;

     FILE *outfl = CRE_ASCII_File( param.outfile, "sph" );

     if ( outfl == NULL || IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_FILE_CRE, param.outfile );
/*
 * write ASCII dump of SPH record
 */
     nadc_write_header( outfl, nr, param.infile, 
			 "Specific Product Header of Level 1b Product" );
     nadc_write_text( outfl, ++nr, "SPH_DESCRIPTOR", sph->descriptor );
     nadc_write_short( outfl, ++nr, "STRIPLINE_CONTINUITY_INDICATOR", 
		       sph->stripline );
     nadc_write_short( outfl, ++nr, "SLICE_POSITION", sph->slice_pos );
     nadc_write_ushort( outfl, ++nr, "NUM_SLICES", sph->num_slices );
     nadc_write_text( outfl, ++nr, "FIRST_LINE_TIME", sph->start_time );
     nadc_write_text( outfl, ++nr, "LAST_LINE_TIME", sph->stop_time );
     nadc_write_double( outfl, ++nr, "FIRST_FIRST_LAT", 
			6, sph->first_first_lat );
     nadc_write_double( outfl, ++nr, "FIRST_FIRST_LONG", 
			6, sph->first_first_lon );
     nadc_write_double( outfl, ++nr, "FIRST_MID_LAT", 6, sph->first_mid_lat );
     nadc_write_double( outfl, ++nr, "FIRST_MID_LONG", 6, sph->first_mid_lon );
     nadc_write_double( outfl, ++nr, "FIRST_LAST_LAT", 
			6, sph->first_last_lat );
     nadc_write_double( outfl, ++nr, "FIRST_LAST_LONG", 
			6, sph->first_last_lon );
     nadc_write_double( outfl, ++nr, "LAST_FIRST_LAT", 
			6, sph->last_first_lat );
     nadc_write_double( outfl, ++nr, "LAST_FIRST_LONG", 
			6, sph->last_first_lon );
     nadc_write_double( outfl, ++nr, "LAST_MID_LAT", 6, sph->last_mid_lat );
     nadc_write_double( outfl, ++nr, "LAST_MID_LONG", 6, sph->last_mid_lon );
     nadc_write_double( outfl, ++nr, "LAST_LAST_LAT", 6, sph->last_last_lat );
     nadc_write_double( outfl, ++nr, "LAST_LAST_LONG", 6, sph->last_last_lon );
     nr++;    /* spare_1 */
     nadc_write_bool( outfl, ++nr, "TRANS_ERR_FLAG", sph->trans_err );
     nadc_write_bool( outfl, ++nr, "FORMAT_ERR_FLAG", sph->format_err );
     nadc_write_bool( outfl, ++nr, "DATABASE_FLAG", sph->database );
     nadc_write_bool( outfl, ++nr, "COARSE_ERR_FLAG", sph->coarse_err );
     nadc_write_bool( outfl, ++nr, "ECMWF_TYPE", sph->ecmwf_type );
     nadc_write_ushort( outfl, ++nr, "NUM_TRANS_ERR", sph->num_trans_err );
     nadc_write_ushort( outfl, ++nr, "NUM_FORMAT_ERR", sph->num_format_err );
     nadc_write_float( outfl, ++nr, "TRANS_ERR_THRESH", 
		       6, sph->thres_trans_err );
     nadc_write_float( outfl, ++nr, "FORMAT_ERR_THRESH", 
		       6, sph->thres_format_err );
     nr++;    /* spare_2 */
     nadc_write_ushort( outfl, ++nr, "NUM_BANDS", sph->num_bands );
     nadc_write_text( outfl, ++nr, "BAND_WAVELEN", sph->band_wavelen );
     nadc_write_text( outfl, ++nr, "BANDWIDTH", sph->bandwidth );
     nadc_write_double( outfl, ++nr, "INST_FOV", 6, sph->inst_fov );
     nadc_write_bool( outfl, ++nr, "PROC_MODE", sph->proc_mode );
     nadc_write_bool( outfl, ++nr, "OFFSET_COMP", sph->offset_comp );
     nadc_write_double( outfl, ++nr, "LINE_TIME_INTERVAL", 
			6, sph->line_time_interval );
     nadc_write_ushort( outfl, ++nr, "LINE_LENGTH", sph->line_length );
     nadc_write_ushort( outfl, ++nr, "LINES_PER_TIE_PT", sph->lines_per_tie );
     nadc_write_ushort( outfl, ++nr, "SAMPLES_PER_TIE_PT", 
			sph->samples_per_tie );
     nadc_write_float( outfl, ++nr, "COLUMN_SPACING", 6, sph->column_spacing );
     nr++;    /* spare_3 */
     (void) fclose( outfl );
}
Example #4
0
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void SCIA_LV2_WR_ASCII_SPH( struct param_record param, 
			    const struct sph2_scia *sph )
{
     register unsigned int  ni, nr = 0;

     char           cbuff[MX_SZ_CBUFF];
     unsigned short ubuff[8];
     unsigned int   ndim;
     unsigned int   dims[2];

     FILE *outfl = CRE_ASCII_File( param.outfile, "sph" );

     if ( outfl == NULL || IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_FILE_CRE, param.outfile );
/*
 * write ASCII dump of SPH record
 */
     nadc_write_header( outfl, nr, param.infile, 
			 "Specific Product Header of Level 2 Product" );
     nadc_write_text( outfl, ++nr, "SPH_DESCRIPTOR", sph->descriptor );
     nadc_write_short( outfl, ++nr, "STRIPLINE_CONTINUITY_INDICATOR", 
		       sph->stripline );
     nadc_write_short( outfl, ++nr, "SLICE_POSITION", sph->slice_pos );
     nadc_write_ushort( outfl, ++nr, "NUM_SLICES", sph->no_slice );
     nadc_write_text( outfl, ++nr, "START_TIME", sph->start_time );
     nadc_write_text( outfl, ++nr, "STOP_TIME", sph->stop_time );
     nadc_write_double( outfl, ++nr, "START_LAT", 6, sph->start_lat );
     nadc_write_double( outfl, ++nr, "START_LON", 6, sph->start_lon );
     nadc_write_double( outfl, ++nr, "STOP_LAT", 6, sph->stop_lat );
     nadc_write_double( outfl, ++nr, "STOP_LON", 6, sph->stop_lon );
     ++nr;    /* spare_1 */
     nadc_write_text( outfl, ++nr, "FITTING_ERROR_SUM", sph->fit_error );
     nadc_write_ushort( outfl, ++nr, "NO_OF_DOAS_FITTING_WIN", 
			 sph->no_doas_win );
     ndim = 2;
     for ( ni = 0; ni < sph->no_doas_win; ni++ ) {
	  (void) snprintf(cbuff, MX_SZ_CBUFF, "DOAS_FITTING_WINDOW_%02u", ni);
	  ubuff[0] = sph->doas_win[ni].wv_min;
	  ubuff[1] = sph->doas_win[ni].wv_max;
	  nadc_write_arr_ushort( outfl, ++nr, cbuff, 1, &ndim, ubuff );
     }
     nr += (MAX_DOAS_FITTING_WIN - sph->no_doas_win);
     nadc_write_ushort( outfl, ++nr, "NO_OF_BIAS_FITTING_WIN", 
			 sph->no_bias_win );
     for ( ni = 0; ni < sph->no_bias_win; ni++ ) {
	  (void) snprintf(cbuff, MX_SZ_CBUFF, "BIAS_FITTING_WINDOW_%02u", ni);
	  ubuff[0] = sph->bias_win[ni].wv_min;
	  ubuff[1] = sph->bias_win[ni].wv_max;
	  if ( sph->bias_win[ni].nr_micro == 0 )
	       nadc_write_arr_ushort( outfl, ++nr, cbuff, 1, &ndim, ubuff );
	  else {
	       register unsigned int nm, nb;

	       dims[0] = 2;
	       dims[1] = sph->bias_win[ni].nr_micro+1;
	       for ( nb = 2, nm = 0; nm < sph->bias_win[ni].nr_micro; nm++ ) {
		    ubuff[nb++] = sph->bias_win[ni].micro_min[nm];
		    ubuff[nb++] = sph->bias_win[ni].micro_max[nm];
	       }
	       nadc_write_arr_ushort( outfl, ++nr, cbuff, 2, dims, ubuff );
	  }
     }
     nadc_write_ushort( outfl, ++nr, "NO_OF_DOAS_MOL",  sph->no_doas_mol );
     for ( ni = 0; ni < MAX_DOAS_SPECIES; ni++ ) {
	  (void) snprintf( cbuff, MX_SZ_CBUFF, "DOAS_MOLECULE_%02u", ni );
          nadc_write_text( outfl, ++nr, cbuff, sph->doas_mol[ni] );
     }
     nadc_write_ushort( outfl, ++nr, "NO_OF_BIAS_MOL", sph->no_bias_mol );
     for ( ni = 0; ni < sph->no_bias_mol; ni++ ) {
	  (void) snprintf( cbuff, MX_SZ_CBUFF, "BIAS_MOLECULE_%02u", ni );
          nadc_write_text( outfl, ++nr, cbuff, sph->bias_mol[ni] );
     }
     (void) fclose( outfl );
}