Пример #1
0
void dsp::TimeDivide::set_start_time (MJD _start_time)
{
  if (start_time == _start_time)
    return;

  if (Operation::verbose)
    cerr << "dsp::TimeDivide::set_start_time start_time=" 
         << _start_time.printall() << endl;

  start_time = _start_time;
  start_phase = Pulsar::Phase::zero;
  is_valid = false;

  if( reference_epoch != MJD::zero )
  {
    if (Operation::verbose)
      cerr << "dsp::TimeDivide::set_start_time set to reference_epoch=" 
           << reference_epoch.printall() << endl;

    start_time = reference_epoch;
  }
  else if( division_seconds && division_seconds == unsigned(division_seconds) )
  {
    unsigned integer_seconds = unsigned(division_seconds);
    unsigned seconds = start_time.get_secs();
    unsigned divisions = seconds / integer_seconds;
    start_time = MJD (start_time.intday(), divisions * integer_seconds, 0.0);

    if (Operation::verbose)
      cerr << "dsp::TimeDivide::set_start_time rounded start_time=" 
           << _start_time.printall() << endl;
  }
}
Пример #2
0
std::string dsp::FilenameEpoch::get_filename (const PhaseSeries* data)
{
  MJD epoch = data->get_start_time();

  if (Observation::verbose)
    cerr << "dsp::FilenameEpoch::get_filename epoch=" 
         << epoch.printall() << endl;

  if (integer_seconds)
  {
    // ensure that the epoch is rounded up into the current division
    epoch = data->get_mid_time (false);

    DEBUG("dsp::FilenameEpoch::get_filename mid_time=" << epoch.printall());

    unsigned seconds = epoch.get_secs();
    unsigned divisions = seconds / integer_seconds;
    epoch = MJD (epoch.intday(), divisions * integer_seconds, 0.0);

    if (Observation::verbose)
      cerr << "dsp::FilenameEpoch::get_filename division_start=" 
           << epoch.printall() << endl;
  }

  vector<char> fname (FILENAME_MAX);
  char* filename = &fname[0];

  if (!epoch.datestr( filename, FILENAME_MAX, datestr_pattern.c_str() ))
    throw Error (FailedSys, "dsp::PhaseSeriesUnloader::get_filename",
       "error MJD::datestr(" + datestr_pattern + ")");

  if (report_unload)
    cerr << "unloading " << tostring(data->get_integration_length(),2)
	 << " seconds: " << filename << endl;

  return filename;
}
Пример #3
0
//! Seek to a sample close to the specified MJD
void dsp::Input::seek(MJD mjd)
{
  int misplacement = 0;

  if (mjd+1.0/get_info()->get_rate() < get_info()->get_start_time())
    misplacement = -1;

  if (mjd-1.0/get_info()->get_rate() > get_info()->get_end_time())
    misplacement = 1;

  double seek_seconds = (mjd-get_info()->get_start_time()).in_seconds();

  if (misplacement)
  {
    string msg = "The given MJD (" + mjd.printall() + ") is ";
    if (misplacement < 0)
      msg += "before the start time";
    else
      msg += "after the end time";
    msg += "of the input data "
           "(" + get_info()->get_start_time().printall() + "); "
           "difference is %lf seconds";

    throw Error (InvalidParam, "dsp::Input::seek", msg.c_str(), seek_seconds);
  }
 
  double seek_samples = seek_seconds*get_info()->get_rate();
  uint64_t actual_seek = 0;

  if( seek_samples<0.0 )
    actual_seek = 0;
  else if( uint64_t(seek_samples) > get_info()->get_ndat() )
    actual_seek = get_info()->get_ndat();
  else
    actual_seek = uint64_t(seek_samples);

  if( verbose )
    fprintf(stderr,"dsp::Input::seek(MJD) will seek %f = "UI64" samples\n",
	    seek_samples, actual_seek);

  seek( actual_seek, SEEK_SET );
}