関数humanTime2sacIndex マニュアル

(The documentation of function humanTime2sacIndex)

Last Update: 2023/6/12


◆機能・用途(Purpose)

struct humanTime型構造体で表された絶対日時を SAC時系列データ内でのサンプル番号 (struct sac_timeseq型構造体のメンバdata.valueの配列要素番号) に変換する。
Convert an absolute date and time, expressed by a struct humanTime-type structure, to a sample index in a SAC time series data (i.e., an index of array of member data.value of a struct sac_timeseq-type structure).


◆形式(Format)

#include <sac/convert.h>
inline int humanTime2sacIndex
(union sacheader header,struct humanTime time_specified)


◆引数(Arguments)

header SACヘッダ。
A SAC header.
time_specified 変換したい時刻。
The time to convert.


◆戻り値(Return value)

引数headerで指定されたヘッダを持つSACデータの 先頭時刻をt0、サンプリング間隔をΔt、 引数time_specifiedが表す時刻をtとして、 t=t0+kΔtを満たす整数k。 この式を満たすkが整数でない場合はプログラムをエラー終了する。
The integer k that satisfies t=t0+kΔt, where t0 and Δt are the beginning time and sampling interval, respectively, of the SAC data that has the headers specified by argument header, and t is the time specified by argument time_specified. If the value of k that satisfies this relation is not an integer, the program finishes as an error.


◆使用例(Example)

struct sac_timeseq sacdata =read_sac_timeseq("20140102_0345_1min_100Hz.sac");
struct humanTime timevalue={2014,1,2,3,45,6.78};
int index=humanTime2sacIndex(sacdata.header,timevalue);

この例において、20140102_0345_1min_100Hz.sacは 2014/01/02 03:45:00からの1分間のSAC時系列データ(100 Hzサンプリング) であるものとする。 この場合、上の例ではindex=678となる。
Suppose that 20140102_0345_1min_100Hz.sac in this example is a SAC time series data of 100 Hz sampling that begins at 03:45:00 on January 2, 2014. Then this example gives index=678.