Module: CTioga2::Data::Filters

Defined in:
lib/ctioga2/data/filters.rb

Overview

A series of commands that can be used as “filters”, as they act upon the last Dataset pushed unto the stack.

Constant Summary collapse

FiltersGroup =
CmdGroup.new('filter', "Filters",
"The commands in this group act upon the last 
dataset pushed unto the data stack: they can be viewed as filters.", 
101)
SortOperation =
Cmd.new("sort-last", nil, "--sort-last", 
          [], {}) do |plotmaker, opts|
  plotmaker.data_stack.last.sort!
end
SortFilter =
Cmd.new("sort", nil, "--sort", 
          [], {}) do |plotmaker, opts|
  plotmaker.data_stack.
    add_to_dataset_hook(Commands::Instruction.new('sort-last', [], {}))
end
TrimOperation =
Cmd.new("trim-last", nil, "--trim-last", 
          [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
  plotmaker.data_stack.last.trim!(number)
end
TrimFilter =
Cmd.new("trim", nil, "--trim", 
          [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
  ## @todo There should be a way to add commands in a type-safe
  ## way, without having to convert to string first.
  plotmaker.data_stack.
    add_to_dataset_hook(Commands::Instruction.new('trim-last', [number], {}))
end
CherryPickOperation =
Cmd.new("cherry-pick-last", nil, "--cherry-pick-last", 
          [CmdArg.new('text')], {}) do |plotmaker, formula|
  plotmaker.data_stack.last.select_formula!(formula)
end
CherryPickFilter =
Cmd.new("cherry-pick", nil, "--cherry-pick", 
          [CmdArg.new('text')], {}) do |plotmaker, formula|
  plotmaker.data_stack.
    add_to_dataset_hook(Commands::Instruction.new('cherry-pick-last', [formula], {}))
end
AVGDupModeRE =
{
  /naive|avg|average/i => :avg,
  /stddev/i => :stddev,
}
AVGDupMode =
CmdType.new('average-mode', 
                    {:type => :re_list,
                     :list => AVGDupModeRE}, "How the {command: avg-dup-last} command :\n\n * @naive@ or @average@ (the default) treats all columns (values and\n   error bars) the same way, and average everythin\n * @stddev@ ignores the original errors, and sets the new errors to the \n   standard deviation of the values\n")
AverageDupOperation =
Cmd.new("avg-dup-last", nil, "--avg-dup-last", 
          [], {'mode' => CmdArg.new('average-mode')}) do |plotmaker, opts|
  mode = opts['mode'] || :avg
  plotmaker.data_stack.last.average_duplicates!(mode)
end
AverageDupFilter =
Cmd.new("avg-dup", nil, "--avg-dup", 
          [], {}) do |plotmaker, formula|
  plotmaker.data_stack.
    add_to_dataset_hook(Commands::Instruction.new('avg-dup-last', [], {}))
end
SmoothOperation =
Cmd.new("smooth-last", nil, "--smooth-last", 
          [CmdArg.new('integer')], {}) do |plotmaker, number|
  plotmaker.data_stack.last.naive_smooth!(number)
end
SmoothFilter =
Cmd.new("smooth", nil, "--smooth", 
          [CmdArg.new('integer')], {}) do |plotmaker, nb|
  plotmaker.data_stack.
    add_to_dataset_hook(Commands::Instruction.new('smooth-last', [nb], {}))
end