Pulsar data processing command language interpreter. More...

#include <Interpreter.h>

Inherits CommandParser.

Public Types

enum  Status {
  Good, Warn, Fail, TestFailed,
  CommandFailed, Undefined
}
 

Public Member Functions

 Interpreter ()
 default constructor
 
 Interpreter (int &argc, char **&argv)
 construct from command line arguments
 
 ~Interpreter ()
 destructor
 
bool evaluate (const std::string &expression)
 Evaluate a boolean expression.
 
void set (Archive *data)
 set the current Archive
 
Archiveget ()
 get the current Archive
 
bool has () const
 return true if there is a current Archive
 
void setmap (const std::string &name, Archive *data)
 set the named Archive
 
Archivegetmap (const std::string &name, bool throw_exception=true)
 get the named Archive
 
Status get_status () const
 get the status after the last command
 
void set_reply (bool f)
 set to false to disable the 'ok' reply
 
std::string get_report (const std::string &args)
 get plugin information
 
std::string load (const std::string &args)
 load an archive from disk to top of stack and optionally the map
 
std::string unload (const std::string &args)
 write an archive from either the top of the stack or the map
 
std::string push (const std::string &args)
 push a clone of the current stack top onto the stack
 
std::string pop (const std::string &args)
 pop the top of the stack
 
std::string set (const std::string &args)
 set the name of the current archive
 
std::string get (const std::string &args)
 get the named archive
 
std::string remove (const std::string &args)
 remove the named archive from the map
 
std::string clone (const std::string &args)
 clone the current archive
 
std::string convert (const std::string &args)
 convert the current archive or a named archive to a different class
 
std::string extract (const std::string &args)
 extract part of the current archive
 
std::string echo (const std::string &args)
 evaluate any expressions and print result
 
std::string edit (const std::string &args)
 edit the current archive
 
std::string system (const std::string &args)
 execute a shell command More...
 
std::string test (const std::string &args)
 test a boolean expression More...
 
std::string config (const std::string &args)
 edit the configuration parameters
 
std::string append (const std::string &args)
 append one archive to another
 
std::string freq_append (const std::string &args)
 append one archive to another in frequency direction
 
std::string shuffle (const std::string &args)
 randomly rearrange sub-integrations
 
std::string fscrunch (const std::string &args)
 frequency scrunch an archive in the stack
 
std::string tscrunch (const std::string &args)
 time scrunch an archive in the stack
 
std::string pscrunch (const std::string &args)
 poln scrunch an archive in the stack
 
std::string state (const std::string &args)
 convert the state of the data
 
std::string invint (const std::string &args)
 form the Stokes invariant interval profile
 
std::string bscrunch (const std::string &args)
 bin scrunch an archive in the stack
 
std::string fold (const std::string &args)
 fold an archive in the stack
 
std::string centre (const std::string &args)
 centre an archive in the stack
 
std::string dedisperse (const std::string &args)
 dedisperse an archive in the stack
 
std::string defaraday (const std::string &args)
 correct for faraday rotation
 
std::string weight (const std::string &args)
 weight each profile according to the named scheme
 
std::string scale (const std::string &args)
 scale each profile by the specified value
 
std::string offset (const std::string &args)
 offset each profile by the specified value
 
std::string rotate (const std::string &args)
 rotate each profile by the specified value
 
std::string dynspec (const std::string &args)
 compute dynamic spectrum of archive on stack
 
std::string correct_instrument (const std::string &args)
 correct for parallactic angle effects
 
std::string scattered_power_correct (const std::string &args)
 apply scattered power corrections
 
std::string image_correct (const std::string &args)
 apply image pulse correction
 
std::string screen_dump (const std::string &args)
 dump the raw data points to the screen
 
std::string toggle_clobber (const std::string &args)
 toggle the clober flag
 
std::string toggle_evaluate (const std::string &args)
 toggle the evaluate flag
 
void import (Extension *)
 Import the Extension.
 
void import (Extension *, const std::string &command, const std::string &help)
 Import a nested Extension.
 

Public Attributes

bool allow_infinite_frequency
 allow dedispersion or Faraday rotation correction to infinite frequency
 

Protected Member Functions

TextInterface::Parserget_interface ()
 get the interface to the current archive
 
std::vector< std::string > setup (const std::string &args, bool expand=true)
 All methods should call this method to parse the arguments. More...
 
std::string response (Status status, const std::string &text="")
 All methods should return via the response methods. More...
 
Status get_status (const Error &error)
 Converts an Error into a Status.
 
std::string response (const Error &error)
 All methods should return via the response methods.
 
template<typename T >
setup (const std::string &args)
 Parses arguments as a single instance of T.
 
template<typename T >
setup (const std::string &args, T default_value)
 Parses arguments as an optional single instance of T.
 

Protected Attributes

std::stack< Reference::To< Archive > > theStack
 the Archive stack
 
std::map< std::string, Reference::To< Archive > > theMap
 the Archive map
 
bool inplace
 operate on data "in place", otherwise make a copy
 
bool clobber
 allow the user to overwrite existing named archive
 
bool evaluation_enabled
 
bool stopwatch
 time various operations
 
bool reply
 reply to each command
 
Status status
 status flag (pass/fail)
 
std::string unload_extension
 the extension with with Archives will be unloaded
 
std::string unload_path
 the path to which Archives will be unloaded
 
Reference::To< Weightweight_policy
 The current weighting scheme.
 

Detailed Description

Pulsar data processing command language interpreter.

The Interpreter class is a command language interpreter that provides access to PSRCHIVE data processing algorithms.

The Interpreter maintains a stack and a named list (map) of Pulsar::Archive instances. Archives in the stack provide a convenient history mechanism, and Archives in the map are referenced by name, a single keyword.

All operations perform on the top of the stack. The only exceptions to this rule are the load and unload methods, which may operate directly on named archives in the map. The contents of both the stack and the map can be modified by adding Archives from file, copying Archives or subsets of Archives from other Archives in memory and finally by deleting Archives from memory. At any stage, the top of the stack or any of the Archives in the map can be saved to disk.

Commands that create copies of existing data (push, clone and extract) can accept the name of an Archive in the map as the first argument. The append command requires the name of the Archive in the map that is to be appended to the top of the stack. In all cases, the result of the operation affects the top of the stack.

Member Function Documentation

◆ response()

string Pulsar::Interpreter::response ( Status  s,
const std::string &  text = "" 
)
protected

All methods should return via the response methods.

Eventually, the Interpreter class might filter special arguments out of the list before passing the remainder along to the method.

◆ setup()

vector< string > Pulsar::Interpreter::setup ( const std::string &  args,
bool  expand = true 
)
protected

All methods should call this method to parse the arguments.

Eventually, the Interpreter class might filter special arguments out of the list before passing the remainder along to the method.

Referenced by setup().

◆ system()

string Pulsar::Interpreter::system ( const std::string &  args)

execute a shell command

If the command fails, then status is set to CommandFailed

References Error::get_message(), SystemCall::get_return_value(), SystemCall::run(), and SystemCall::set_throw().

◆ test()

string Pulsar::Interpreter::test ( const std::string &  args)

test a boolean expression

If the test evaluates to false, then status is set to TestFailed


The documentation for this class was generated from the following files:

Generated using doxygen 1.8.17