예제 #1
0
파일: msrutils.c 프로젝트: 3rdcycle/obspy
/***************************************************************************
 * msr_starttime_uc:
 *
 * Convert a btime struct of a FSDH struct of a MSRecord (the record
 * start time) into a high precision epoch time.  This time has no
 * correction(s) applied to it.
 *
 * Returns a high precision epoch time on success and HPTERROR on
 * error.
 ***************************************************************************/
hptime_t
msr_starttime_uc (MSRecord *msr)
{
  if ( ! msr )
    return HPTERROR;

  if ( ! msr->fsdh )
    return HPTERROR;
  
  return ms_btime2hptime (&msr->fsdh->start_time);
} /* End of msr_starttime_uc() */
예제 #2
0
    bool MSeedWriter::write(IntegerMSeedRecord::SharedPtr_t sampleRange)
    {
        // наполнения хедера mseed
        MSRecord* msr = msr_init(NULL);

        // общие для записей данные
        strcpy(msr->network, sampleRange->network().toLatin1().constData());
        strcpy(msr->station, sampleRange->station().toLatin1().constData());
        strcpy(msr->location, sampleRange->location().toLatin1().constData());
        strcpy(msr->channel, sampleRange->channelName().toLatin1().constData());

        msr->samprate = sampleRange->samplingRateHz();

        msr->reclen = _recordLength;
        msr->record = NULL;
        msr->encoding = _encoding;  // compression
        msr->byteorder = 1;         // big endian byte order

        BTime btime = dateTimeToBTime(sampleRange->startTime());
        msr->starttime = ms_btime2hptime(&btime);

        msr->sampletype = 'i';      // declare type to be 32-bit integers

        msr->datasamples = sampleRange->data().data();
        msr->numsamples = sampleRange->data().size();

        flag verbose = _verbose;
        _packedSamples = 0;
        _packedRecords = msr_pack(msr, &binaryStreamRecorder, _binaryStream.get(), &_packedSamples, 1, verbose);
        if (_packedRecords == -1)
        {
            return false;
        }

        msr->datasamples = NULL;
        msr_free(&msr);

        ms_log(0, "Packed %d samples into %d records\n", _packedSamples, _packedRecords);
        return true;
    }