Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • L2SS-1914-fix_job_dispatch
  • TMSS-3170
  • TMSS-3167
  • TMSS-3161
  • TMSS-3158-Front-End-Only-Allow-Changing-Again
  • TMSS-3133
  • TMSS-3319-Fix-Templates
  • test-fix-deploy
  • TMSS-3134
  • TMSS-2872
  • defer-state
  • add-custom-monitoring-points
  • TMSS-3101-Front-End-Only
  • TMSS-984-choices
  • SDC-1400-Front-End-Only
  • TMSS-3079-PII
  • TMSS-2936
  • check-for-max-244-subbands
  • TMSS-2927---Front-End-Only-PXII
  • Before-Remove-TMSS
  • LOFAR-Release-4_4_318 protected
  • LOFAR-Release-4_4_317 protected
  • LOFAR-Release-4_4_316 protected
  • LOFAR-Release-4_4_315 protected
  • LOFAR-Release-4_4_314 protected
  • LOFAR-Release-4_4_313 protected
  • LOFAR-Release-4_4_312 protected
  • LOFAR-Release-4_4_311 protected
  • LOFAR-Release-4_4_310 protected
  • LOFAR-Release-4_4_309 protected
  • LOFAR-Release-4_4_308 protected
  • LOFAR-Release-4_4_307 protected
  • LOFAR-Release-4_4_306 protected
  • LOFAR-Release-4_4_304 protected
  • LOFAR-Release-4_4_303 protected
  • LOFAR-Release-4_4_302 protected
  • LOFAR-Release-4_4_301 protected
  • LOFAR-Release-4_4_300 protected
  • LOFAR-Release-4_4_299 protected
40 results

LofarOptions.cmake

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    createHeaders.cc 4.10 KiB
    //# createHeaders.cc: Generates all .h5/.MS files given a (OLAP) parset
    //# Copyright (C) 2012-2013  ASTRON (Netherlands Institute for Radio Astronomy)
    //# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands
    //#
    //# This file is part of the LOFAR software suite.
    //# The LOFAR software suite is free software: you can redistribute it and/or
    //# modify it under the terms of the GNU General Public License as published
    //# by the Free Software Foundation, either version 3 of the License, or
    //# (at your option) any later version.
    //#
    //# The LOFAR software suite is distributed in the hope that it will be useful,
    //# but WITHOUT ANY WARRANTY; without even the implied warranty of
    //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    //# GNU General Public License for more details.
    //#
    //# You should have received a copy of the GNU General Public License along
    //# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
    //#
    //# $Id$
    
    //# Always #include <lofar_config.h> first!
    #include <lofar_config.h>
    
    #include <cstdlib>
    #include <string>
    #include <iostream>
    #include <boost/format.hpp>
    #include <boost/lexical_cast.hpp>
    
    #include <Common/LofarLogger.h>
    #include <Common/CasaLogSink.h>
    #include <Common/Exceptions.h>
    #include <Common/Thread/Queue.h>
    #include <CoInterface/Exceptions.h>
    #include <CoInterface/OutputTypes.h>
    #include <CoInterface/Parset.h>
    #include <CoInterface/StreamableData.h>
    #include <CoInterface/SmartPtr.h>
    #include <OutputProc/Package__Version.h>
    #include "OutputThread.h"
    
    using namespace LOFAR;
    using namespace LOFAR::Cobalt;
    using namespace std;
    
    // Use a terminate handler that can produce a backtrace.
    Exception::TerminateHandler t(Exception::terminate);
    
    int main(int argc, char *argv[])
    {
      if (argc != 2) {
        cout << str(boost::format("usage: %s parset") % argv[0]) << endl;
        cout << endl;
        cout << "parset: the filename of the parset to convert (parset must have been produced by RTCP/Run/src/LOFAR/Parset.py, aka an 'OLAP parset')." << endl;
        return 1;
      }
    
    #if defined HAVE_LOG4CPLUS
      INIT_LOGGER(string(getenv("LOFARROOT") ? : ".") + "/etc/createHeaders.log_prop");
    #elif defined HAVE_LOG4CXX
      #error LOG4CXX support is broken (nonsensical?) -- please fix this code if you want to use it
      Context::initialize();
      setLevel("Global",8);
    #else
      INIT_LOGGER_WITH_SYSINFO("createHeaders");
    #endif
    
      CasaLogSink::attach();
    
      ParameterSet feedbackLTA;
    
      try {
        Parset parset(argv[1]);
        for (OutputType outputType = FIRST_OUTPUT_TYPE; outputType < LAST_OUTPUT_TYPE; outputType++) {
          const unsigned nrStreams = parset.nrStreams(outputType);
    
          for (unsigned streamNr = 0; streamNr < nrStreams; streamNr++) {
            const string logPrefix = str(boost::format("[obs %u type %u stream %3u] ") % parset.observationID() % outputType % streamNr);
    
            try {
              // a dummy queue
              Queue<SmartPtr<StreamableData> > queue;
    
              OutputThread ot(parset, outputType, streamNr, queue, queue, logPrefix, ".");
    
              // create measurement set
              ot.createMS();
    
              // wrap up
              ot.cleanUp();
    
              // obtain LTA feedback
              feedbackLTA.adoptCollection(ot.feedbackLTA());
            } catch (Exception &ex) {
              LOG_WARN_STR(logPrefix << "Could not create header: " << ex);
            } catch (exception &ex) {
              LOG_WARN_STR(logPrefix << "Could not create header: " << ex.what());
            }
          }
        }
    
        // taken from IONProc/src/Job.cc
        // Augment the LTA feedback logging
        {
          feedbackLTA.add("Observation.DataProducts.nrOfOutput_Beamformed_", str(boost::format("%u") % parset.nrStreams(BEAM_FORMED_DATA)));
          feedbackLTA.add("Observation.DataProducts.nrOfOutput_Correlated_", str(boost::format("%u") % parset.nrStreams(CORRELATED_DATA)));
    
          for (ParameterSet::const_iterator i = feedbackLTA.begin(); i != feedbackLTA.end(); ++i)
            LOG_INFO_STR("[obs " << parset.observationID() << "] LTA FEEDBACK: " << i->first << " = " << i->second);
        }  
      } catch (Exception &ex) {
        LOG_FATAL_STR("[obs unknown] Caught Exception: " << ex);
        return 1;
      }
    
      LOG_INFO_STR("[obs unknown] Program end");
      return 0;
    }