Exemplo n.º 1
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 );
}
/*+++++++++++++++++++++++++ Main Program or Function +++++++++++++++*/
void SCIA_LV1C_WR_ASCII_CALOPT( const struct param_record param,
				const struct cal_options *calopt )
{
     register unsigned int nr = 0;

     char date_str[UTC_STRING_LENGTH];

     unsigned int   count[1];

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

     if ( outfl == NULL || IS_ERR_STAT_FATAL )
	  NADC_RETURN_ERROR( NADC_ERR_FILE_CRE, param.outfile );
/*
 * write ASCII dump of CAL_OPTIONS record
 */
     nadc_write_header( outfl, nr, param.infile, 
			 "Calibration Options GADS to SciaL1C" );
     nadc_write_text( outfl,++nr, "l1b_product_name", calopt->l1b_prod_name );
     if ( calopt->geo_filter != SCHAR_ZERO ) {
	  nadc_write_double( outfl, ++nr, "start_lat", 6, 
			     calopt->start_lat/1e6 );
	  nadc_write_double( outfl, ++nr, "start_lon", 6, 
			     calopt->start_lon/1e6 );
	  nadc_write_double( outfl, ++nr, "end_lat", 6, calopt->end_lat/1e6 );
	  nadc_write_double( outfl, ++nr, "end_lon", 6, calopt->end_lon/1e6 );
     } else
	  nr += 4;
     if ( calopt->time_filter != SCHAR_ZERO ) {
	  (void) MJD_2_ASCII( calopt->start_time.days, 
			      calopt->start_time.secnd,
                              calopt->start_time.musec, date_str );
          nadc_write_text( outfl, ++nr, "start_time", date_str );
	  (void) MJD_2_ASCII( calopt->stop_time.days, 
			      calopt->stop_time.secnd,
                              calopt->stop_time.musec, date_str );
          nadc_write_text( outfl, ++nr, "stop_time", date_str );

     } else
	  nr += 2;
     if ( calopt->category_filter != SCHAR_ZERO ) {
	  count[0] = 5;
          nadc_write_arr_ushort( outfl, ++nr, "category", 
                                  1, count, calopt->category );
     } else
	  nr += 1;
     if ( calopt->nadir_mds != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "nadir_mds_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "nadir_mds_flag", "FALSE" );
     if ( calopt->limb_mds != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "limb_mds_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "limb_mds_flag", "FALSE" );
     if ( calopt->occ_mds != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "occ_mds_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "occ_mds_flag", "FALSE" );
     if ( calopt->moni_mds != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "moni_mds_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "moni_mds_flag", "FALSE" );

     if ( calopt->pmd_mds != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "pmd_mds_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "pmd_mds_flag", "FALSE" );
     if ( calopt->frac_pol_mds != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "frac_pol_mds_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "frac_pol_mds_flag", "FALSE" );
     if ( calopt->slit_function != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "slit_function_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "slit_function_gads_flag", "FALSE" );
     if ( calopt->sun_mean_ref != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "sun_mean_ref_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "sun_mean_ref_gads_flag", "FALSE" );
     if ( calopt->leakage_current != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "leakage_current_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "leakage_current_gads_flag", "FALSE");
     if ( calopt->spectral_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "spectral_cal_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "spectral_cal_gads_flag", "FALSE" );
     if ( calopt->pol_sens != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "pol_sens_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "pol_sens_gads_flag", "FALSE" );
     if ( calopt->rad_sens != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "rad_sens_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "rad_sens_gads_flag", "FALSE" );
     if ( calopt->ppg_etalon != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "ppg_etalon_gads_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "ppg_etalon_gads_flag", "FALSE" );
     nadc_write_ushort( outfl,++nr, "num_nadir_clusters", calopt->num_nadir );
     nadc_write_ushort( outfl,++nr, "num_limb_clusters", calopt->num_limb );
     nadc_write_ushort( outfl,++nr, "num_occ_clusters", calopt->num_occ );
     nadc_write_ushort( outfl,++nr, "num_moni_clusters", calopt->num_moni );
     count[0] = MAX_CLUSTER;
     nadc_write_arr_schar( outfl, ++nr, "nadir_cluster_flag", 
			    1, count, calopt->nadir_cluster );
     nadc_write_arr_schar( outfl, ++nr, "limb_cluster_flag", 
			    1, count, calopt->limb_cluster );
     nadc_write_arr_schar( outfl, ++nr, "occ_cluster_flag", 
			    1, count, calopt->occ_cluster );
     nadc_write_arr_schar( outfl, ++nr, "moni_cluster_flag", 
			    1, count, calopt->moni_cluster );
     if ( calopt->mem_effect_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "mem_effect_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "mem_effect_cal_flag", "FALSE" );
     if ( calopt->leakage_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "leakage_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "leakage_cal_flag", "FALSE" );
     if ( calopt->straylight_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "straylight_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "straylight_cal_flag", "FALSE" );
     if ( calopt->ppg_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "ppg_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "ppg_cal_flag", "FALSE" );
     if ( calopt->etalon_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "etalon_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "etalon_cal_flag", "FALSE" );
     if ( calopt->wave_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "spectal_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "spectral_cal_flag", "FALSE" );
     if ( calopt->polarisation_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "polarisation_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "polarisation_cal_flag", "FALSE" );
     if ( calopt->radiance_cal != SCHAR_ZERO )
	  nadc_write_text( outfl, ++nr, "radiance_cal_flag", "TRUE" );
     else
	  nadc_write_text( outfl, ++nr, "radiance_cal_flag", "FALSE" );

     (void) fclose( outfl );
}