当前位置: 首页>>代码示例>>C++>>正文


C++ MJD::datestr方法代码示例

本文整理汇总了C++中MJD::datestr方法的典型用法代码示例。如果您正苦于以下问题:C++ MJD::datestr方法的具体用法?C++ MJD::datestr怎么用?C++ MJD::datestr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MJD的用法示例。


在下文中一共展示了MJD::datestr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DEBUG

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;
}
开发者ID:UCBerkeleySETI,项目名称:dspsr,代码行数:37,代码来源:PhaseSeriesUnloader.C

示例2: main

int main (int argc, char ** argv) try
{
  bool phase_periastron = false;
  bool longitude_periastron = false;
  bool longitude_ascending = false;

  MJD mjd;
  double duration = 0.0;

  char site = '7';
  double freq = 1400.0;

  int gotc = 0;
  while ((gotc = getopt(argc, argv, "hd:f:m:s:pPaA")) != -1)
  {
    switch (gotc)
    {
    case 'h':
      usage ();
      return 0;

    case 'd':
      duration = atof (optarg);
      break;

    case 'f':
      freq = atof (optarg);
      break;

    case 'm':
      mjd = MJD(optarg);
      break;

    case 's':
      site = optarg[0];
      break;

    case 'p':
      phase_periastron = true;
      break;

    case 'P':
      longitude_periastron = true;
      break;

    case 'A':
      longitude_ascending = true;
      break;

    }
  }

  if (optind >= argc)
  {
    cerr << "Please provide tempo parameter file" << endl;
    return -1;
  }

  if (mjd == 0.0)
  {
    time_t temp = time(NULL);
    struct tm date = *gmtime(&temp);
    fprintf (stderr, "\nUsing current date/time: %s\n", asctime(&date));
    mjd = MJD (date);
  }

  psrephem eph (argv[optind]);

  double epoch = mjd.in_days();

  if (duration)
  {
    unsigned nsteps = 100;
    for (unsigned i=0; i<nsteps; i++)
    {
      double hours = (duration * i) / nsteps;
      double seconds = hours * 3600.0;

      MJD t = mjd + seconds;

      cout << hours << " " << t.datestr("%H:%M:%S") << " "
	   << get_binlng_asc (t.in_days(), eph, freq, site) << endl;
    }
    return 0;
  }

  cout << "================================================" << endl;

  if ( phase_periastron )
    cout << "Binary phase (wrt periastron) = " 
	 << get_binphs_peri (epoch, eph, freq, site)*360.0 << " deg" << endl;
  
  if ( longitude_periastron )
    cout << "Longitude wrt periastron = " 
	 << get_binlng_peri (epoch, eph, freq, site) << " deg" << endl;
  
  if ( longitude_ascending )
    cout << "Longitude wrt ascending node = "
	 << get_binlng_asc (epoch, eph, freq, site) << " deg" << endl;
  
//.........这里部分代码省略.........
开发者ID:SkyTian13,项目名称:psrchive,代码行数:101,代码来源:ephorb.C

示例3: Error


//.........这里部分代码省略.........
    break;
  }

  cerr << "WAPP nbit=" << get_info()->get_nbit() << endl;

  // ////////////////////////////////////////////////////////////////////
  //
  // start_time
  //

  /* built by WAPP from yyyymmdd */  
  string utc = head->obs_date;  utc += "-";

  /* UT seconds after midnight (start on 1-sec tick) [hh:mm:ss] */
  utc += head->start_time;

#if WVS_FIXES_STR2TM

  struct tm time;

  /* the str2tm function has been deprecated in favour of the standard C strptime */
  if (str2tm (&time, utc.c_str()) < 0)
    throw Error (InvalidState, "dsp::WAPPFile::open_file",
		 "Could not parse UTC from " + utc);

  MJD mjd (time);

#else

  // copied from WAPPArchive

  struct tm obs_date_greg;
  struct WAPP_HEADER* hdr = head;

  int rv = sscanf(hdr->obs_date, "%4d%2d%2d", 
      &obs_date_greg.tm_year, &obs_date_greg.tm_mon,
      &obs_date_greg.tm_mday);
  obs_date_greg.tm_year -= 1900;
  obs_date_greg.tm_mon -= 1;
  if (rv!=3) 
    throw Error (InvalidState, "dsp::WAPPFile::open_file",
        "Error converting obs_date string (rv=%d, obs_date=%s)", 
        rv, hdr->obs_date);
  rv = sscanf(hdr->start_time, "%2d:%2d:%2d", 
      &obs_date_greg.tm_hour, &obs_date_greg.tm_min, 
      &obs_date_greg.tm_sec);
  if (rv!=3) 
    throw Error (InvalidState, "dsp::WAPPFile::open_file",
        "Error converting start_time string (rv=%d, start_time=%s)", 
        rv, hdr->start_time);

  MJD mjd (obs_date_greg); 

#endif

  char buff[64];
  cerr << "UTC=" << utc << " MJD=" << mjd << " -> "
       << mjd.datestr (buff, 64, "%Y-%m-%d %H:%M:%S") << endl;

  // from sigproc-2.4
  /* for data between April 17 and May 8 inclusive, the start times are
     off by 0.5 days due to the ntp daemon not running... fix here.
     this also occured on May 17! hopefully will not happen again... */
  if ( ((mjd.intday() >= 52016) && (mjd.intday() <= 52039)) 
       || (mjd.intday() == 52046.0)) {
    cerr << "WARNING: MJD start time off by 0.5 days! fixed..." << endl;
    MJD half_day (0.5);
    mjd -= half_day;
  }

  get_info()->set_start_time (mjd);

  // ////////////////////////////////////////////////////////////////////
  //
  // rate
  //
  /* actual sample time (us) i.e. requested+dead time */
  double tsamp_us = head->wapp_time;

  // from sigproc-2.4
  tsamp_us += wappcorrect( mjd.in_days() );

  get_info()->set_rate ( 1e6 / tsamp_us );

  // ////////////////////////////////////////////////////////////////////
  //
  // telscope code
  //
  get_info()->set_telescope ("Arecibo");  // assume Arecibo

  string prefix="wapp";
  get_info()->set_machine("WAPP");	

  header_bytes = lseek(fd,0,SEEK_CUR);

  cerr << "header bytes=" << header_bytes << endl;

  set_total_samples();

}
开发者ID:UCBerkeleySETI,项目名称:dspsr,代码行数:101,代码来源:WAPPFile.C


注:本文中的MJD::datestr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。