本文整理汇总了C++中MJD::get_fracsec方法的典型用法代码示例。如果您正苦于以下问题:C++ MJD::get_fracsec方法的具体用法?C++ MJD::get_fracsec怎么用?C++ MJD::get_fracsec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MJD
的用法示例。
在下文中一共展示了MJD::get_fracsec方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: from_MJD
//! convert an MJD to long double
long double from_MJD (const MJD& t)
{
const long double secs_in_day = 86400.0L;
return
(long double) (t.intday()) +
(long double) (t.get_secs()) / secs_in_day +
(long double) (t.get_fracsec()) / secs_in_day;
}
示例2:
//! Return the spin frequency, given the epoch
long double Pulsar::SimplePredictor::frequency (const MJD& t) const
{
if (reference_epoch == MJD::zero)
const_cast<SimplePredictor*>(this)->reference_epoch = t;
MJD diff = t - reference_epoch;
long double seconds = diff.get_secs();
seconds += diff.get_fracsec();
long double power_of_t = 1.0;
long double result = 0;
for (unsigned i=0; i<coefs.size(); i++)
{
result += coefs[i] * (i+1) * power_of_t;
power_of_t *= seconds;
}
return result;
}
示例3: Phase
//! Return the phase, given the epoch
Pulsar::Phase Pulsar::SimplePredictor::phase (const MJD& t) const
{
if (reference_epoch == MJD::zero)
const_cast<SimplePredictor*>(this)->reference_epoch = t;
MJD diff = t - reference_epoch;
long double seconds = diff.get_secs();
seconds += diff.get_fracsec();
long double power_of_t = seconds;
long double result = 0;
for (unsigned i=0; i<coefs.size(); i++)
{
result += coefs[i] * power_of_t;
power_of_t *= seconds;
}
int64_t iphase = int64_t(result);
return Pulsar::Phase(iphase,result-iphase);
}
示例4: second
double second (const MJD& mjd)
{
return mjd.get_secs() + mjd.get_fracsec();
}
示例5: Error
//.........这里部分代码省略.........
// //////////////////////////////////////////////////////////////////////
//
// FREQ
//
if (ascii_header_set (header, "FREQ", "%lf", get_centre_frequency()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload FREQ");
// //////////////////////////////////////////////////////////////////////
//
// BW
//
if (ascii_header_set (header, "BW", "%lf", get_bandwidth()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload BW");
// //////////////////////////////////////////////////////////////////////
//
// NCHAN
//
if (ascii_header_set (header, "NCHAN", "%d", get_nchan()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload NCHAN");
// //////////////////////////////////////////////////////////////////////
//
// NPOL
//
if (ascii_header_set (header, "NPOL", "%d", get_npol()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload NPOL");
// //////////////////////////////////////////////////////////////////////
//
// NBIT
//
if (ascii_header_set (header, "NBIT", "%d", get_nbit()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload NBIT");
// //////////////////////////////////////////////////////////////////////
//
// NDIM
//
if (ascii_header_set (header, "NDIM", "%d", get_ndim()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload NDIM");
// //////////////////////////////////////////////////////////////////////
//
// STATE
//
std::string state = Signal::State2string( get_state() );
if (ascii_header_set (header, "STATE", "%s", state.c_str()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload STATE");
// //////////////////////////////////////////////////////////////////////
//
// TSAMP
//
/* IMPORTANT: TSAMP is the sampling period in microseconds */
double sampling_interval = 1e6 / get_rate();
if (ascii_header_set (header, "TSAMP", "%lf", sampling_interval)<0)
throw Error (InvalidState, "ASCIIObservation", "failed unload TSAMP");
// //////////////////////////////////////////////////////////////////////
//
// UTC_START
//
MJD epoch = get_start_time();
MJD integer_second ( epoch.intday(), epoch.get_secs(), 0.0 );
char datestr [64];
integer_second.datestr( datestr, 64, "%Y-%m-%d-%H:%M:%S" );
if (ascii_header_set (header, "UTC_START", "%s", datestr) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload UTC_START");
// //////////////////////////////////////////////////////////////////////
//
// OBS_OFFSET
//
double offset_samples = epoch.get_fracsec() * get_rate();
uint64_t offset_bytes = get_nbytes( (uint64_t)offset_samples );
if (ascii_header_set (header, "OBS_OFFSET", UI64, offset_bytes) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload OBS_OFFSET");
// //////////////////////////////////////////////////////////////////////
//
// INSTRUMENT
//
if (ascii_header_set (header, "INSTRUMENT", "%s", get_machine().c_str()) < 0)
throw Error (InvalidState, "ASCIIObservation", "failed unload INSTRUMENT");
}