.. highlightlang:: us .. index:: NC_SynchronizeTime .. _nc_synchronizetime: NC_SynchronizeTime ================== .. us.tag NC_SynchronizeTime ENGLISH nc.misc New5148 Changed5603 This function can be used to calculate the time offset (delay) between two data files. Example: Data files from two different data loggers that have been triggered manually. Both data files must have a time signal and a sync channel. For example: engine or vehicle speed. The time data must be measured in the same unit, i.e. seconds. The resolution in both files can be different. The time offset is calculated by a cross correlation, therefore, the sync signal should not be constant. If the calculation of the offset fails the offset can be set manually. Only the first 250000 data points are used to calculate the offset. .. function:: ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2) ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2, bMerge) ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2, bMerge, bInterpolate) ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2, bMerge, bInterpolate, bUseOffset) ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2, bMerge, bInterpolate, bUseOffset, rsOffset) ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2, bMerge, bInterpolate, bUseOffset, rsOffset, nUseTimeChannel) ssNCNewFile = NC_SynchronizeTime(ssNCFile1, ssTime1, ssSyncChannel1, ssNCFile2, ssTime2, ssSyncChannel2, oParameter) .. us.return **Return Value** Name of the NC file or an empty string, if an error occurs. .. us.params **Parameters** .. uparam:: ssNCFile1 *ssNCFile1* is the name of a NC file. .. uparam:: ssTime1 *ssTime1* is the time channel name of file 1. .. uparam:: ssSyncChannel1 *ssSyncChannel1* is the signal name of file 1. .. uparam:: ssNCFile2 *ssNCFile1* is the name of a NC file. .. uparam:: ssTime2 *ssTime1* is the time channel name of file 2. .. uparam:: ssSyncChannel2 *ssSyncChannel1* is the signal name of file 2. .. uparam:: oParameter Is an oject with the following elements: .. list-table:: :header-rows: 1 * - Element - Default Value - Description * - bMerge - TRUE (1) - If *bMerge* is TRUE (1), the channels of both files will be merge into one file. * - bInterpolate - TRUE (1) - If *bInterpolate* is TRUE (1), the channels will be interpolated onto one time base. * - bUseOffset - FALSE (0) - If *bUseOffset* is FALSE (0), the delay will be calculated. If TRUE (1) the offset can be set in the parameter *rsOffset*. * - rsOffset - No default value - Is the time offset. Is used if *bUseOffset* is TRUE (1). * - nUseTimeChannel - 0 - If *nUseTimeChannel* is set to 0 a dialog box will be displayed to select the time channel for the interpolation. If set to 1 the time channel of the first data file is used for the interpolation. If set to 2 the time channel of the second data file is used for the interpolation. * - rsXStartSync - not defined - This parameter should only be added to the object if only a section of the data should be used for the offset calculation. X-Koordinates are set so that they start with 0. * - rsXEndSync - not defined - This parameter should only be added to the object if only a section of the data should be used for the offset calculation. .. uparam:: bMerge If *bMerge* is TRUE (1), the channels of both files will be merge into one file. Default value is TRUE. .. uparam:: bInterpolate If *bInterpolate* is TRUE (1), the channels will be interpolated onto one time base. Default value is TRUE. .. uparam:: bUseOffset If *bUseOffset* is FALSE (0), the delay will be calculated. If TRUE (1) the offset can be set in the parameter *rsOffset*. Default value is 0. .. uparam:: rsOffset Is the time offset. Is used if *bUseOffset* is TRUE (1). Default value is 0. .. uparam:: nUseTimeChannel If *nUseTimeChannel* is set to 0 a dialog box will be displayed to select the time channel for the interpolation. If set to 1 the time channel of the first data file is used for the interpolation. If set to 2 the time channel of the second data file is used for the interpolation. Default value is 0. .. us.example **Example** :: bMerge = TRUE bInterpolate = TRUE bUseOffset = FALSE rsOffset = 0 nUseTimeChannel = 1; ssNC1 = auto_ImportData("c:/a.xls") ssNC2 = auto_ImportData("c:/b.xls") ssNCNew = NC_SynchronizeTime(ssNC1, "time", "speed", ... ssNC2, "time_stemp", "rpm", ... bMerge, bInterpolate, bUseOffset, rsOffset, nUseTimeChannel); if (ssNCNew == "") { // Fehler } **Example2** :: oParameter = [.]; oParameter.bMerge = TRUE; oParameter.bInterpolate = FALSE; oParameter.bUseOffset = FALSE; oParameter.rsOffset = 0; oParameter.nUseTimeChannel = 1; oParameter.rsXStartSync = 0.0; oParameter.rsXEndSync = 100.0; ssNC1 = auto_ImportData("c:/a.xls") ssNC2 = auto_ImportData("c:/b.xls") ssNCNew = NC_SynchronizeTime(ssNC1, "time", "speed", ... ssNC2, "time_stemp", "rpm", ... oParameter); if (ssNCNew == "") { // Fehler } .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - R2014.3 - New parameter *oParameter*. * - 5.14.8 - New. .. seealso:: :ref:`overview-netcdf-files`, :ref:`filemore-file-functionssynchronize-data-files`, :ref:`file-export-data`, :ref:`nc_create` :sub:`id-653736`