R/get_md.R

Defines functions get_md

Documented in get_md

get_md <- function(path_ecmd=NULL, path_rawdata= NULL, path_output=NULL, online, path_sa_file=NULL, path_pf_file=NULL, tlag_meth, despike_meth=c("None", "VM97", "M13"), detrend_meth=c("BA", "LD"), tilt_correction_meth=c("DR", "PF")){

dir.create(path_output, showWarnings=FALSE, recursive=TRUE)

if(online==FALSE) warning("When online=FALSE, to obtain robust estimates of planar fit coefficients and spectral correction factors, a sufficient number of raw data files is required.", call.=FALSE)
if(online==TRUE & is.null(path_sa_file)) stop("When online=TRUE, the path of the spectral assessment file (obtained from a previous run) must be specified.\nPlease provide it or set online FALSE.", call.=FALSE)
if(online==TRUE & is.null(path_pf_file)) stop("When online=TRUE, the path of the spectral assessment file (obtained from a previous run) must be specified.\nPlease provide it or set online FALSE.", call.=FALSE)

ecmd_file <- fread(path_ecmd, integer64="numeric", data.table=FALSE)
md <- ecmd_file[1,] ## prendiamo la prima riga per la costruzione dei file di progetto base


## Building dynamic metadata file for eddypro ingestion
if(md["GA_PATH"]=="closed") {
	dyn_md0 <- as.matrix(data.frame(
	"date"=paste(substr(ecmd_file[,"DATE_OF_VARIATION_EF"],1,4),substr(ecmd_file[,"DATE_OF_VARIATION_EF"],5,6), substr(ecmd_file[,"DATE_OF_VARIATION_EF"],7,8), sep="-"),
	"time"=paste(substr(ecmd_file[,"DATE_OF_VARIATION_EF"],9,10),substr(ecmd_file[,"DATE_OF_VARIATION_EF"],11,12),  sep=":"),
	"file_length"=ecmd_file[,"FILE_DURATION"],
	"acquisition_frequency"=ecmd_file[,"ACQUISITION_FREQUENCY"],
	"canopy_height"=ecmd_file[,"CANOPY_HEIGHT"],
	"master_sonic_manufacturer"=ecmd_file[,"SA_MANUFACTURER"],
	"master_sonic_model"=ecmd_file[,"SA_MODEL"],
	"master_sonic_height"=ecmd_file[,"SA_HEIGHT"],
	"master_sonic_wformat"=ecmd_file[,"SA_WIND_DATA_FORMAT"],
	"master_sonic_wref"=ecmd_file[,"SA_NORTH_ALIGNEMENT"],
	"master_sonic_north_offset"=ecmd_file[,"SA_NORTH_OFFSET"],
	"co2_irga_manufacturer"=ecmd_file[,"GA_MANUFACTURER"],
	"co2_irga_model"=ecmd_file[,"GA_MODEL"],
	"co2_irga_northward_separation"=ecmd_file[,"GA_NORTHWARD_SEPARATION"],
	"co2_irga_eastward_separation"=ecmd_file[,"GA_EASTWARD_SEPARATION"],
	"co2_irga_tube_length"=ecmd_file[,"GA_TUBE_LENGTH"],
	"co2_irga_tube_diameter"=ecmd_file[,"GA_TUBE_DIAMETER"],
	"co2_irga_flowrate"=ecmd_file[,"GA_FLOWRATE"],
	"h2o_irga_manufacturer"=ecmd_file[,"GA_MANUFACTURER"],
	"h2o_irga_model"=ecmd_file[,"GA_MODEL"],
	"h2o_irga_northward_separation"=ecmd_file[,"GA_NORTHWARD_SEPARATION"],
	"h2o_irga_eastward_separation"=ecmd_file[,"GA_EASTWARD_SEPARATION"],
	"h2o_irga_tube_length"=ecmd_file[,"GA_TUBE_LENGTH"],
	"h2o_irga_tube_diameter"=ecmd_file[,"GA_TUBE_DIAMETER"],
	"h2o_irga_flowrate"=ecmd_file[,"GA_FLOWRATE"]))
	
	dyn_md0[which(dyn_md0==":", arr.ind=TRUE)] <- "00:00"
	dyn_md <- as.data.frame(dyn_md0)
		
	write.table(dyn_md, paste0(path_output, "/", md["SITEID"],"_dynamic_metadata.txt"), quote=FALSE, row.names=FALSE, sep=",")
	}

if(md["GA_PATH"]=="open") {
	dyn_md0 <- as.matrix(data.frame(
	"date"=paste(substr(ecmd_file[,"DATE_OF_VARIATION_EF"],1,4),substr(ecmd_file[,"DATE_OF_VARIATION_EF"],5,6), substr(ecmd_file[,"DATE_OF_VARIATION_EF"],7,8), sep="-"),
	"time"=paste(substr(ecmd_file[,"DATE_OF_VARIATION_EF"],9,10),substr(ecmd_file[,"DATE_OF_VARIATION_EF"],11,12),  sep=":"), 
	"file_length"=ecmd_file[,"FILE_DURATION"],
	"acquisition_frequency"=ecmd_file[,"ACQUISITION_FREQUENCY"],
	"canopy_height"=ecmd_file[,"CANOPY_HEIGHT"],
	"master_sonic_manufacturer"=ecmd_file[,"SA_MANUFACTURER"],
	"master_sonic_model"=ecmd_file[,"SA_MODEL"],
	"master_sonic_height"=ecmd_file[,"SA_HEIGHT"],
	"master_sonic_wformat"=ecmd_file[,"SA_WIND_DATA_FORMAT"],
	"master_sonic_wref"=ecmd_file[,"SA_NORTH_ALIGNEMENT"],
	"master_sonic_north_offset"=ecmd_file[,"SA_NORTH_OFFSET"],
	"co2_irga_manufacturer"=ecmd_file[,"GA_MANUFACTURER"],
	"co2_irga_model"=ecmd_file[,"GA_MODEL"],
	"co2_irga_northward_separation"=ecmd_file[,"GA_NORTHWARD_SEPARATION"],
	"co2_irga_eastward_separation"=ecmd_file[,"GA_EASTWARD_SEPARATION"],
	"h2o_irga_manufacturer"=ecmd_file[,"GA_MANUFACTURER"],
	"h2o_irga_model"=ecmd_file[,"GA_MODEL"],
	"h2o_irga_northward_separation"=ecmd_file[,"GA_NORTHWARD_SEPARATION"],
	"h2o_irga_eastward_separation"=ecmd_file[,"GA_EASTWARD_SEPARATION"]))
	
	dyn_md0[which(dyn_md0==":", arr.ind=TRUE)] <- "00:00"
	dyn_md <- as.data.frame(dyn_md0)
	
	write.table(dyn_md, paste0(path_output, "/", md["SITEID"],"_dynamic_metadata.txt"), quote=FALSE, row.names=FALSE, sep=",")
	}


if(md["GA_PATH"]=="closed") {
	NH <- 12;
	VARIABLE_EP <- rep("ignore", NH);
	MEASURE_TYPE_EP <- rep("", NH);
	INSTRUMENT_EP <- rep("", NH);
	UNIT_EP <- rep("", NH);
	
	cat(paste(
	";GHG_METADATA",
	"\n[FileDescription]",
	sep=""),
	file=paste0(path_output, "/", md["SITEID"], ".metadata"), append=FALSE);
	
	for (h in 1:NH){	
		if (h==1)	{VARIABLE_EP[h] <- "u"; 			INSTRUMENT_EP[h] <- md["SA_MODEL"];	UNIT_EP[h] <- md["UVW_UNITS"]}
		if (h==2)	{VARIABLE_EP[h] <- "v";				INSTRUMENT_EP[h] <- md["SA_MODEL"]; UNIT_EP[h] <- md["UVW_UNITS"]}
		if (h==3)	{VARIABLE_EP[h] <- "w";	 			INSTRUMENT_EP[h] <- md["SA_MODEL"]; UNIT_EP[h] <- md["UVW_UNITS"]}
		if (h==4)	{VARIABLE_EP[h] <- "ts";		 	INSTRUMENT_EP[h] <- md["SA_MODEL"]; UNIT_EP[h] <- md["T_SONIC_UNITS"]}
		if (h==5)	{VARIABLE_EP[h] <- "co2"; 			INSTRUMENT_EP[h] <- md["GA_MODEL"]; UNIT_EP[h] <- md["CO2_UNITS"];	 MEASURE_TYPE_EP[h] <- md["CO2_measure_type"]}
		if (h==6)	{VARIABLE_EP[h] <- "h2o";			INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- md["H2O_UNITS"];	 MEASURE_TYPE_EP[h] <- md["H2O_measure_type"]}
		if (h==7)	{VARIABLE_EP[h] <- "not_numeric"; 	INSTRUMENT_EP[h] <- md["SA_MODEL"];	UNIT_EP[h] <- "dimensionless"}
		if (h==8)	{VARIABLE_EP[h] <- "diag_72"; 		INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- "dimensionless"}
		if (h==9)	{VARIABLE_EP[h] <- "cell_t";		INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- md["T_CELL_UNITS"]}
		if (h==10)	{VARIABLE_EP[h] <- "int_t_1";		INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- md["T_CELL_UNITS"]}
		if (h==11)	{VARIABLE_EP[h] <- "int_t_2";		INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- md["T_CELL_UNITS"]}
		if (h==12)	{VARIABLE_EP[h] <- "int_p";			INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- md["P_CELL_UNITS"]}
		
		cat(paste(
		"\ncol_",h,"_a_value=",
		"\ncol_",h,"_b_value=",
		"\ncol_",h,"_conversion=",
		"\ncol_",h,"_instrument=", INSTRUMENT_EP[h],
		"\ncol_",h,"_max_timelag=0.00",
		"\ncol_",h,"_max_value=",
		"\ncol_",h,"_measure_type=", MEASURE_TYPE_EP[h],
		"\ncol_",h,"_min_timelag=0.00",
		"\ncol_",h,"_min_value=",
		"\ncol_",h,"_nom_timelag=0.00",
		"\ncol_",h,"_unit_in=", UNIT_EP[h],
		"\ncol_",h,"_unit_out=",
		"\ncol_",h,"_variable=", VARIABLE_EP[h],
		sep=""),
		file=paste0(path_output, "/", md["SITEID"], ".metadata"), append=TRUE)
		}
	}

if(md["GA_PATH"]=="open") {
	NH <- 8;
	VARIABLE_EP <- rep("ignore", NH);
	MEASURE_TYPE_EP <- rep("", NH);
	INSTRUMENT_EP <- rep("", NH);
	UNIT_EP <- rep("", NH);
	
	cat(paste(
	";GHG_METADATA",
	"\n[FileDescription]",
	sep=""),
	file=paste0(path_output, "/", md["SITEID"], ".metadata"), append=FALSE);
	
	for (h in 1:NH){	
		if (h==1)	{VARIABLE_EP[h] <- "u"; 			INSTRUMENT_EP[h] <- md["SA_MODEL"];	UNIT_EP[h] <- md["UVW_UNITS"]}
		if (h==2)	{VARIABLE_EP[h] <- "v";				INSTRUMENT_EP[h] <- md["SA_MODEL"]; UNIT_EP[h] <- md["UVW_UNITS"]}
		if (h==3)	{VARIABLE_EP[h] <- "w";	 			INSTRUMENT_EP[h] <- md["SA_MODEL"]; UNIT_EP[h] <- md["UVW_UNITS"]}
		if (h==4)	{VARIABLE_EP[h] <- "ts";		 	INSTRUMENT_EP[h] <- md["SA_MODEL"]; UNIT_EP[h] <- md["T_SONIC_UNITS"]}
		if (h==5)	{VARIABLE_EP[h] <- "co2"; 			INSTRUMENT_EP[h] <- md["GA_MODEL"]; UNIT_EP[h] <- md["CO2_UNITS"];	 MEASURE_TYPE_EP[h] <- md["CO2_measure_type"]}
		if (h==6)	{VARIABLE_EP[h] <- "h2o";			INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- md["H2O_UNITS"];	 MEASURE_TYPE_EP[h] <- md["H2O_measure_type"]}
		if (h==7)	{VARIABLE_EP[h] <- "not_numeric"; 	INSTRUMENT_EP[h] <- md["SA_MODEL"];	UNIT_EP[h] <- "dimensionless"}
		if (h==8)	{VARIABLE_EP[h] <- "diag_75"; 		INSTRUMENT_EP[h] <- md["GA_MODEL"];	UNIT_EP[h] <- "dimensionless"}
		
		cat(paste(
		"\ncol_",h,"_a_value=",
		"\ncol_",h,"_b_value=",
		"\ncol_",h,"_conversion=",
		"\ncol_",h,"_instrument=", INSTRUMENT_EP[h],
		"\ncol_",h,"_max_timelag=0.00",
		"\ncol_",h,"_max_value=",
		"\ncol_",h,"_measure_type=", MEASURE_TYPE_EP[h],
		"\ncol_",h,"_min_timelag=0.00",
		"\ncol_",h,"_min_value=",
		"\ncol_",h,"_nom_timelag=0.00",
		"\ncol_",h,"_unit_in=", UNIT_EP[h],
		"\ncol_",h,"_unit_out=",
		"\ncol_",h,"_variable=", VARIABLE_EP[h],
		sep=""),
		file=paste0(path_output, "/", md["SITEID"], ".metadata"), append=TRUE)
		}
	}


cat(paste("\ndata_label=Not set",
"\nheader_rows=",md["NROW_HEADER"],
"\nseparator=",md["SEPARATOR"],
"\n",
"\n[Files]",
"\ndata_path=",
"\nenable_processing=1",## File Format
"\nend_of_line=",md["EOL"],
"\niso_format=0",
"\nsaved_native=0",
"\ntimestamp=0",
"\ntstamp_end=",ifelse(md["EXTERNAL_TIMESTAMP"]=="END",1,0),
"\n",
"\n[Instruments]",
"\ninstr_1_eastward_separation=0.00",
"\ninstr_1_height=",md["SA_HEIGHT"],
"\ninstr_1_hpath_length=1.0000",
"\ninstr_1_id=",
"\ninstr_1_manufacturer=",md["SA_MANUFACTURER"],
"\ninstr_1_model=",md["SA_MODEL"],
"\ninstr_1_north_offset=",md["SA_NORTH_OFFSET"],
"\ninstr_1_northward_separation=0.00",
"\ninstr_1_sw_version=",
"\ninstr_1_tau=0.1000",
"\ninstr_1_vertical_separation=0.00",
"\ninstr_1_vpath_length=1.0000",
"\ninstr_1_wformat=",md["SA_WIND_DATA_FORMAT"],
"\ninstr_1_wref=",md["SA_NORTH_ALIGNEMENT"],
"\ninstr_2_eastward_separation=",md["GA_EASTWARD_SEPARATION"],
"\ninstr_2_hpath_length=1.0000",
"\ninstr_2_id=",
"\ninstr_2_ko=0.008500",
"\ninstr_2_kw=0.150000",
"\ninstr_2_manufacturer=",md["GA_MANUFACTURER"],
"\ninstr_2_model=",md["GA_MODEL"],
"\ninstr_2_northward_separation=",md["GA_NORTHWARD_SEPARATION"],
"\ninstr_2_sw_version=",
"\ninstr_2_tau=0.1000",
"\ninstr_2_tube_diameter=", if(md["GA_PATH"]=="closed") md["GA_TUBE_DIAMETER"],
"\ninstr_2_tube_flowrate=", if(md["GA_PATH"]=="closed") md["GA_FLOWRATE"],
"\ninstr_2_tube_length=", if(md["GA_PATH"]=="closed") md["GA_TUBE_LENGTH"],
"\ninstr_2_vertical_separation=",md["GA_VERTICAL_SEPARATION"],
"\ninstr_2_vpath_length=1.0000",
"\n",
"\n[Project]",
"\ncreation_date=",Sys.time(),
"\nend_date=",
"\nfile_name=",md["SITEID"],".metadata",
"\nid=",
"\nini_version=3.2.0",
"\nlast_change_date=",
"\nstart_date=",
"\nsw_version=",
"\ntitle=",md["SITEID"],
"\n",
"\n[Site]",
"\naltitude=",md["ALTITUDE"],
"\ncanopy_height=",md["CANOPY_HEIGHT"],
"\ndisplacement_height=0",
"\nlatitude=",md["LATITUDE"],
"\nlongitude=",md["LONGITUDE"],
"\nroughness_length=0",
"\nsite_id=",md["SITEID"],
"\nsite_name=",md["SITEID"],
"\n",
"\n[Station]",
"\nstation_id=",md["SITEID"],
"\nstation_name=",md["SITEID"],
"\n",
"\n[Timing]",
"\nacquisition_frequency=",md["ACQUISITION_FREQUENCY"],
"\nfile_duration=",md["FILE_DURATION"],
"\npc_time_settings=local",
"\n",
sep=""), append=TRUE,
file=paste0(path_output, "/", md["SITEID"], ".metadata"))


cat(paste(
";EDDYPRO_PROCESSING",
"\n[FluxCorrection_SpectralAnalysis_General]",
"\nadd_sonic_lptf=1",
"\nex_dir=",
"\nex_file=",
"\nhorst_lens=2",### Horst and Lenshow Correction for High Freq spectral correction 1 along cross and vertical; 2 only cross and vertical
"\nsa_bin_spectra=",### THE PATH OF BINNED SPECTRA TO AVOID RECALCULATION (NOT SET)
"\nsa_ch4_g1_start=1",
"\nsa_ch4_g1_stop=12",
"\nsa_co2_g1_start=1",
"\nsa_co2_g1_stop=12",
"\nsa_end_date=",
"\nsa_end_time=",
"\nsa_file=",ifelse(online==TRUE, path_sa_file, ""),### THE PATH OF THE SPECTRAL ASSESSMENT FILE IS UPDATED BELOW
"\nsa_fmax_ch4=2.0000",
"\nsa_fmax_co2=2.0000",
"\nsa_fmax_gas4=2.0000",
"\nsa_fmax_h2o=2.0000",
"\nsa_fmin_ch4=0.0050",
"\nsa_fmin_co2=0.0050",
"\nsa_fmin_gas4=0.0050",
"\nsa_fmin_h2o=0.0050",
"\nsa_full_spectra=",
"\nsa_gas4_g1_start=1",
"\nsa_gas4_g1_stop=12",
"\nsa_hfn_ch4_fmin=1.0000",
"\nsa_hfn_co2_fmin=1.0000",
"\nsa_hfn_gas4_fmin=1.0000",
"\nsa_hfn_h2o_fmin=1.0000",
"\nsa_max_ch4=20.0000",
"\nsa_max_co2=100.0000",
"\nsa_max_gas4=20.0000",
"\nsa_max_h=1000.0000",
"\nsa_max_le=1000.0000",
"\nsa_max_ustar=5.0000",
"\nsa_min_smpl=10",
"\nsa_min_st_ch4=0.0050",
"\nsa_min_st_co2=0.5000",
"\nsa_min_st_gas4=0.0050",
"\nsa_min_st_h=5.0000",
"\nsa_min_st_le=3.0000",
"\nsa_min_st_ustar=0.0500",
"\nsa_min_un_ch4=0.0100",
"\nsa_min_un_co2=2.0000",
"\nsa_min_un_gas4=0.0100",
"\nsa_min_un_h=20.0000",
"\nsa_min_un_le=20.0000",
"\nsa_min_un_ustar=0.2000",
ifelse(online==TRUE, "\nsa_mode=0","\nsa_mode=1"), ## 0 if spectral assessment file available specified by sa_file specification above, 1 when not available (For NRT data this means switching to Moncrieff's method)
"\nsa_start_date=2000-01-01",
"\nsa_start_time=00:00",
"\nsa_subset=0",
"\nsa_use_foken_low=0",###1 Filtering flag 2 according to Foken 2004 quality policy, 0 No
"\nsa_use_foken_mid=0",###1 Filtering also flag 1 according to Foken 2004 quality policy, 0 No
"\nsa_use_vm_flags=0",###1 Filtering according to VM97 tests, 0 No
"\n",
"\n[Project]",
"\nbin_sp_avail=0",
"\nbinary_eol=-1",
"\nbinary_hnlines=-1",
"\nbinary_little_end=-1",
"\nbinary_nbytes=-1",
"\nbiom_dir=",
"\nbiom_ext=.txt",## TO SET
"\nbiom_file=",
"\nbiom_rec=0",
"\ncol_air_p=0",
"\ncol_air_t=0",
"\ncol_co2=5",
"\ncol_h2o=6",
ifelse(md["GA_PATH"]=="closed", "\ncol_diag_72=8","\ncol_diag_72=0"),
ifelse(md["GA_PATH"]=="closed", "\ncol_cell_t=9","\ncol_cell_t=0"),
ifelse(md["GA_PATH"]=="closed", "\ncol_int_t_1=10", "\ncol_int_t_1=0"),
ifelse(md["GA_PATH"]=="closed", "\ncol_int_t_2=11", "\ncol_int_t_2=0"),
ifelse(md["GA_PATH"]=="closed", "\ncol_int_p=12", "\ncol_int_p=0"),
ifelse(md["GA_PATH"]=="open", "\ncol_diag_75=8","\ncol_diag_75=0"),
"\ncol_diag_77=0",
"\ncol_ch4=0",
"\ncol_n2o=0",
"\ncol_ts=0",
"\ncreation_date=",
"\ndyn_metadata_file=", path_output, "/", md["SITEID"], "_dynamic_metadata.txt", ### PATH OF DYNAMIC METADATA 
"\nerr_label=-9999.0",
"\nfile_name=",
"\nfile_prototype=??????????yyyymmddHHMM????.csv",
"\nfile_type=1",##1 ASCII; 2 TOB1; 5 Generic Binary
"\nfiles_found=",
"\nfix_out_format=0",
"\nfoot_meth=1",
"\nfull_sp_avail=0",
"\ngas_diff=-1.00000",
"\ngas_mw=-1.0000",
"\nhf_correct_ghg_ba=1",
"\nhf_correct_ghg_zoh=1",
"\nhf_meth=4",### HIGH-FREQUENCY SPECTRAL CORRECTION METHOD: 1 Moncrieff; 2 Horst; 3 Ibrom; 4 Fratini; 5 Massmann
"\nini_version=4.4.1",
"\nlast_change_date=2017-09-13T12:40:44",
"\nlf_meth=1",
"\nmake_dataset=0",
"\nmaster_sonic=",md["SA_MODEL"],
"\nout_amflux=0",
"\nout_biomet=0",
"\nout_ghg_eu=0",
"\nout_mean_cosp=0",
"\nout_mean_spec=0",
"\nout_metadata=1",
"\nout_path=", path_output,
"\nout_rich=1",
"\npr_end_date=2017-09-13",
"\npr_end_time=11:52",
"\npr_start_date=2000-01-01",
"\npr_start_time=00:00",
"\npr_subset=0",
"\nproj_file=", path_output, "/", md["SITEID"], ".metadata",
"\nproject_id=",md["SITEID"],
"\nproject_title=",md["SITEID"],
"\nqc_meth=1",
"\nru_its_meth=2", ### add for EddyPro 7
"\nru_meth=1", ### add for EddyPro 7
"\nru_tlag_max=20.0",### add for EddyPro 7
"\nrun_fcc=0",
"\nrun_mode=0",
"\nsonic_output_rate=-1",
"\nsw_version=6.1.0",
"\ntob1_format=0",
"\nuse_biom=0",###TO DO
"\nuse_dyn_md_file=1",###SET 1 to enable dynamic metadata file uploading, 0 otherwise
"\nuse_pfile=1",
if(md["GA_PATH"]=="closed") "\nwpl_meth=0",
if(md["GA_PATH"]=="open") "\nwpl_meth=1",
"\n",
"\n[RawProcess_BiometMeasurements]",
"\nbiom_hlines=2",
"\nbiom_lwin=-1",
"\nbiom_pa=0",
"\nbiom_ppfd=-1",
"\nbiom_rg=-1",
"\nbiom_rh=-1",
"\nbiom_separator=comma",
"\nbiom_ta=0",
"\nbiom_tstamp_ref=end",
"\nbiom_use_native_header=1",
"\n",
"\n[RawProcess_DriftCorrection]",
"\ndrift_calib_date=",
"\ndrift_co2_0_dir=0",
"\ndrift_co2_0_inv=0",
"\ndrift_co2_1_dir=0",
"\ndrift_co2_1_inv=0",
"\ndrift_co2_2_dir=0",
"\ndrift_co2_2_inv=0",
"\ndrift_co2_3_dir=0",
"\ndrift_co2_3_inv=0",
"\ndrift_co2_4_dir=0",
"\ndrift_co2_4_inv=0",
"\ndrift_co2_5_dir=0",
"\ndrift_co2_5_inv=0",
"\ndrift_co2_6_dir=0",
"\ndrift_co2_6_inv=0",
"\ndrift_co2_cx=0",
"\ndrift_co2_cx_date=",
"\ndrift_co2_span=0",
"\ndrift_co2_span_2=0",
"\ndrift_co2_span_2_date=",
"\ndrift_co2_span_date=",
"\ndrift_co2_zero=0",
"\ndrift_co2_zero_date=",
"\ndrift_h2o_0_dir=0",
"\ndrift_h2o_0_inv=0",
"\ndrift_h2o_1_dir=0",
"\ndrift_h2o_1_inv=0",
"\ndrift_h2o_2_dir=0",
"\ndrift_h2o_2_inv=0",
"\ndrift_h2o_3_dir=0",
"\ndrift_h2o_3_inv=0",
"\ndrift_h2o_4_dir=0",
"\ndrift_h2o_4_inv=0",
"\ndrift_h2o_5_dir=0",
"\ndrift_h2o_5_inv=0",
"\ndrift_h2o_6_dir=0",
"\ndrift_h2o_6_inv=0",
"\ndrift_h2o_span=0",
"\ndrift_h2o_span_2=0",
"\ndrift_h2o_span_2_date=",
"\ndrift_h2o_span_date=",
"\ndrift_h2o_wx=0",
"\ndrift_h2o_wx_date=",
"\ndrift_h2o_zero=0",
"\ndrift_h2o_zero_date=",
"\ndrift_serial_number=",
"\n",
"\n[RawProcess_General]",
"\ndata_path=", path_rawdata, 
"\ndec_date=2017-09-13",
"\nmag_dec=0",
"\nrecurse=1",
"\nuse_geo_north=0",
"\nflag1_column=0",
"\nflag1_threshold=1",
"\nflag1_upper=1",
"\nflag2_column=0",
"\nflag2_threshold=-9999.0000",
"\nflag2_upper=1",
"\nflag3_column=0",
"\nflag3_threshold=-9999.0000",
"\nflag3_upper=1",
"\nflag4_column=0",
"\nflag4_threshold=-9999.0000",
"\nflag4_upper=1",
"\nflag5_column=0",
"\nflag5_threshold=-9999.0000",
"\nflag5_upper=1",
"\nflag6_column=0",
"\nflag6_threshold=-9999.0000",
"\nflag6_upper=1",
"\nflag7_column=0",
"\nflag7_threshold=-9999.0000",
"\nflag7_upper=1",
"\nflag8_column=0",
"\nflag8_threshold=-9999.0000",
"\nflag8_upper=1",
"\nflag9_column=0",
"\nflag9_threshold=-9999.0000",
"\nflag9_upper=1",
"\nflag10_column=0",
"\nflag10_threshold=-9999.0000",
"\nflag10_upper=1",
"\n",
"\n[RawProcess_ParameterSettings]",
"\naa_lim=10.0",
"\naa_max=30.0",
"\naa_min=-30.0",
"\nal_ch4_max=1000.000",
"\nal_ch4_min=0.170",
"\nal_co2_max=900.000",
"\nal_co2_min=200.000",
"\nal_h2o_max=40.000",
"\nal_h2o_min=0.000",
"\nal_n2o_max=1000.000",
"\nal_n2o_min=0.032",
"\nal_tson_max=50.0",
"\nal_tson_min=-40.0",
"\nal_u_max=30.0",
"\nal_w_max=5.0",
"\nar_bins=100",
"\nar_hf_lim=70",
"\nar_lim=7.0",
if(despike_meth=="VM97") "\ndespike_vm=0", ## 0 VM97, 1 Mauder 2013
if(despike_meth=="M13") "\ndespike_vm=1", ## 0 VM97, 1 Mauder 2013
"\ndo_extlim_dw=10",
"\ndo_hf1_lim=10.0",
"\ndo_hf2_lim=6.0",
"\nds_hf_ch4=40.00",
"\nds_hf_co2=40.00",
"\nds_hf_h2o=3.26",
"\nds_hf_n2o=40.00",
"\nds_hf_t=4.00",
"\nds_hf_uv=4.00",
"\nds_hf_var=3.00",
"\nds_hf_w=2.00",
"\nds_sf_ch4=30.00",
"\nds_sf_co2=27.00",
"\nds_sf_h2o=2.20",
"\nds_sf_n2o=30.00",
"\nds_sf_t=2.70",
"\nds_sf_uv=2.70",
"\nds_sf_var=2.00",
"\nds_sf_w=1.30",
"\nns_hf_lim=0.5",
"\nsk_hf_kumax=8.0",
"\nsk_hf_kumin=1.0",
"\nsk_hf_skmax=2.0",
"\nsk_hf_skmin=-2.0",
"\nsk_sf_kumax=5.0",
"\nsk_sf_kumin=2.0",
"\nsk_sf_skmax=1.0",
"\nsk_sf_skmin=-1.0",
"\nsr_lim_ch4=8.0",
"\nsr_lim_co2=3.5",
"\nsr_lim_h2o=3.5",
"\nsr_lim_hf=1.0",
"\nsr_lim_n2o=8.0",
"\nsr_lim_u=3.5",
"\nsr_lim_w=5.0",
"\nsr_num_spk=3",
"\ntl_def_ch4=0.0",
"\ntl_def_co2=0.0",
"\ntl_def_h2o=0.0",
"\ntl_def_n2o=0.0",
"\ntl_hf_lim=20.0",
"\ntl_sf_lim=10.0",
"\n",
"\n[RawProcess_RandomUncertainty_Settings]",
"\nru_its_meth=2",## 0 None, 1 ML94, 2 FS2001
"\nru_meth=1",## 1 Integration over the whole period
"\nru_tlag_max=20.0",
"\n",
"\n[RawProcess_Settings]",
"\navrg_len=30",
"\nbu_corr=0",
"\nbu_multi=0",
"\ncross_wind=0",
if(detrend_meth=="BA") "\ndetrend_meth=0",###0:Block Average; 1:Linear Detrending
if(detrend_meth=="LD") "\ndetrend_meth=1",###0:Block Average; 1:Linear Detrending
"\nfilter_al=1",
"\nfilter_sr=1",
"\nflow_distortion=-1",
"\nl_day_bot_gain=0.94400000",
"\nl_day_bot_offset=2.57000000",
"\nl_day_spar_gain=1.01000000",
"\nl_day_spar_offset=0.36000000",
"\nl_day_top_gain=1.00500000",
"\nl_day_top_offset=0.24000000",
"\nl_night_bot_gain=0.88300000",
"\nl_night_bot_offset=2.17000000",
"\nl_night_spar_gain=1.01000000",
"\nl_night_spar_offset=-0.17000000",
"\nl_night_top_gain=1.00800000",
"\nl_night_top_offset=-0.41000000",
"\nm_day_bot1=2.80000000",
"\nm_day_bot2=-0.06810000",
"\nm_day_bot3=0.00210000",
"\nm_day_bot4=-0.33400000",
"\nm_day_spar1=0.30000000",
"\nm_day_spar2=-0.00070000",
"\nm_day_spar3=0.00060000",
"\nm_day_spar4=-0.04400000",
"\nm_day_top1=-0.10000000",
"\nm_day_top2=-0.00440000",
"\nm_day_top3=0.00110000",
"\nm_day_top4=-0.02200000",
"\nm_night_bot1=0.50000000",
"\nm_night_bot2=-0.11600000",
"\nm_night_bot3=0.00870000",
"\nm_night_bot4=-0.20600000",
"\nm_night_spar1=-2.10000000",
"\nm_night_spar2=-0.02000000",
"\nm_night_spar3=0.00700000",
"\nm_night_spar4=0.02600000",
"\nm_night_top1=-1.70000000",
"\nm_night_top2=-0.01600000",
"\nm_night_top3=0.00510000",
"\nm_night_top4=-0.02900000",
"\nmax_lack=10",
"\nnbins=50",
"\nout_bin_og=0",
"\nout_bin_sp=1",
"\nout_full_cosp_w_ch4=0",
"\nout_full_cosp_w_co2=0",
"\nout_full_cosp_w_h2o=0",
"\nout_full_cosp_w_n2o=0",
"\nout_full_cosp_w_ts=1",
"\nout_full_cosp_w_u=0",
"\nout_full_cosp_w_v=0",
"\nout_full_sp_ch4=0",
"\nout_full_sp_co2=0",
"\nout_full_sp_h2o=0",
"\nout_full_sp_n2o=0",
"\nout_full_sp_ts=0",
"\nout_full_sp_u=0",
"\nout_full_sp_v=0",
"\nout_full_sp_w=0",
"\nout_qc_details=1",
"\nout_raw_1=0",
"\nout_raw_2=0",
"\nout_raw_3=0",
"\nout_raw_4=0",
"\nout_raw_5=0",
"\nout_raw_6=0",
"\nout_raw_7=0",
"\nout_raw_ch4=0",
"\nout_raw_co2=0",
"\nout_raw_gas4=0",
"\nout_raw_h2o=0",
"\nout_raw_p_air=0",
"\nout_raw_t_air=0",
"\nout_raw_ts=0",
"\nout_raw_u=0",
"\nout_raw_v=0",
"\nout_raw_w=0",
"\nout_st_1=0",
"\nout_st_2=0",
"\nout_st_3=0",
"\nout_st_4=0",
"\nout_st_5=0",
"\nout_st_6=0",
"\nout_st_7=0",
"\npower_of_two=1",
if(tilt_correction_meth=="DR") "\nrot_meth=1",### 1 Double Rotation, 3 Planar Fit
if(tilt_correction_meth=="PF") "\nrot_meth=3",### 1 Double Rotation, 3 Planar Fit
"\ntap_win=3",
"\ntimeconst=250.0",
"\ntlag_meth=", tlag_meth, ## 0 None; 1 Costant; 2 MaxCov with default; 3 MaxCov; 4 Autom optim (time consuming)
"\nu_offset=0",
"\nv_offset=0",
"\nw_offset=0",
"\n",
"\n[RawProcess_Tests]",##0 No, 1 Apply the test
"\ntest_aa=0",
"\ntest_al=0",
"\ntest_ar=0",
"\ntest_do=0",
"\ntest_ds=0",
"\ntest_ns=0",
"\ntest_sk=0",
if(despike_meth=="None") "\ntest_sr=0", ## SPIKE REMOVAL
if(despike_meth!="None") "\ntest_sr=1", ## SPIKE REMOVAL
"\ntest_tl=0",
"\n",
"\n[RawProcess_TiltCorrection_Settings]",
"\npf_subset=0",### 0 over the whole period, 1 over the periods identified by pf_start and pf_end below
"\npf_start_date=",### timestamp format yyyy-mm-dd
"\npf_start_time=",### timestamp format HH:MM
"\npf_end_date=",### timestamp format yyyy-mm-dd
"\npf_end_time=",### timestamp format HH:MM
"\npf_file=",ifelse(online==TRUE, path_pf_file, ""),### THE PATH OF THE SPECTRAL ASSESSMENT FILE IS UPDATED BELOW
"\npf_fix=0",
"\npf_min_num_per_sec=100",###TO CHECK WITH GERARDO
ifelse(online==TRUE, "\npf_mode=0","\npf_mode=1"), ### 0 for NRT (with pf_file specification above), 1 for LTW
"\npf_north_offset=0",
"\npf_sect_1_exclude=0",
"\npf_sect_1_width=90",
"\npf_sect_2_exclude=0",
"\npf_sect_2_width=90",
"\npf_sect_3_exclude=0",
"\npf_sect_3_width=90",
"\npf_sect_4_exclude=0",
"\npf_sect_4_width=90",
"\npf_u_min=0.5",
"\npf_w_max=1",
"\n",
"\n[RawProcess_TimelagOptimization_Settings]",
"\nto_ch4_max_lag=-1000.1",
"\nto_ch4_min_flux=0.200",
"\nto_ch4_min_lag=-1000.1",
"\nto_co2_max_lag=-1000.1",
"\nto_co2_min_flux=2.000",
"\nto_co2_min_lag=-1000.1",
"\nto_end_date=2017-09-13",
"\nto_end_time=23:59",
"\nto_file=",
"\nto_gas4_max_lag=-1000.1",
"\nto_gas4_min_flux=0.020",
"\nto_gas4_min_lag=-1000.1",
"\nto_h2o_max_lag=-1000.1",
"\nto_h2o_min_lag=-1000.1",
"\nto_h2o_nclass=10",
"\nto_le_min_flux=20.0",
"\nto_mode=1",
"\nto_pg_range=1.5",
"\nto_start_date=2000-01-01",
"\nto_start_time=00:00",
"\nto_subset=0",
"\n",
sep=""), append=FALSE,
file=paste0(path_output, "/", md["SITEID"], ".eddypro"))
}
domvit81/RFlux documentation built on Nov. 20, 2019, 8:02 a.m.