#
# Analysis command descriptions:
#   menu label/description
#   file templates for this command (* for all files)
#   "menu" (add to menu) |"bind" (bind to key)
#   analysis command line
#

hmenu Funtools

# 1D histogram params for a table
param thist
column entry    "Enter column name to histogram" pi "(histo)"
bins   entry    "Enter [min:max:]bins" 0 "('0' for default number of bins)"
bwidth  checkbox  "Use bin width instead of number of bins?"    0
norm   checkbox "Normalize by bin size?"                       0
end

# 1D histogram params for an image
param ihist
bins  entry "Enter [min:max:]bins" 0 "('0' for default number of bins)"
end

# Light Curve params
param ltc
bins  entry    "Enter [min:max:]bins" 0 "('0' for default number of bins)"
bwidth checkbox "Use bin width instead of number of bins?"    0
norm  checkbox "Normalize by time?"                          0
end

# funcen
param   funcen
niter   entry    "Number of iterations"		5
tol	entry	 "Pixel tolerance distance"	1
disp    checkbox "Display refined region(s)?"	1
ftype	checkbox "Use image filtering?"		0    "(default: event filter)"
end

help Funtools Overview

Funtools Tasks in DS9

The tasks in this section of the Analysis menu utilize the Funtools
programs 'funcnts', 'funhist', and 'funcen':

1. Radial Profile Plot: run funcnts and pass results through funcnts.plot.
Both source and background regions can be specified.

2. Histogram Plot: run funhist on any column of a binary table and
pass results through funhist.plot

3. Light Curve Plot: run funhist on 'time' column of a binary table
and pass results through funhist.plot

4. Energy Spectrum Plot: run funhist on 'pi' column of a binary table
and pass results through funhist.plot

5. Counts in Regions: run funcnts and display textual output.
Both source and background regions can be specified.

6. Refine Positions for Binary Tables: run funcen (binary tables only)
and display textual output. The input region(s) can be replaced by the
refined regions.

7. Column Histogram: run funhist on any column of a binary table and
display textual output.

8. Image Histogram: run funhist on image data and display textual output.

All of these tasks work off the original disk-based FITS file. The
funcnts-based tasks (radial profile, counts in regions) present their
results using WCS units, if the appropriate info is present in the
FITS header.

For situations where a disk file is not available (e.g., image data
generated by a program and sent to DS9's 'fits' XPA access point),
alternate versions of the radial profile and counts in regions tasks
are offered that work from DS9's internal image data. In these two
cases, results are presented in pixels. Aside from the units, the
results should be identical to the file-based results.

For more sophisticated analysis, please consider using the underlying
Funtools tasks directly. These are documented at:

http://hea-www.harvard.edu/saord/funtools/programs.html

endhelp

Radial Profile Plot (annulus regions; options: none)
*
menu
PRE funds9 funcnts_plot "$xpa" "$filename" "$regions(source,,)" "$regions(background,,)" POST | $plot(stdin)

Histogram Plot (any column; options: column name, number of bins)
*
menu
$param(thist); PRE funds9 funhist_plot "$xpa" "$filename[$regions]" "$norm $bwidth" "$column" "$bins" POST | $plot(stdin)

Light Curve Plot ("time" column; options: number of bins)
*
menu
$param(ltc); PRE funds9 funhist_plot "$xpa" "$filename[$regions]" "$norm $bwidth" time "$bins" POST | $plot(stdin)

Energy Spectrum Plot ("pi" column; options: none)
*
menu
PRE funds9 funhist_plot "$xpa" "$filename[$regions]" "0 0" "pi" "$bins" POST | $plot(stdin)

Counts in Regions (any regions; options: none)
*
menu
PRE funds9 funcnts "$xpa" "$filename" "$regions(source,,)" "$regions(background,,)" POST | $text

Refine Positions for Binary Tables (options: niter, tol, display, filtertype)
*
menu
$param(funcen); PRE funds9 funcen "$xpa" "$filename" "$regions(source,,)" $niter $tol $disp $ftype POST | $text

Column Histogram (any column; options: colname, <min:max:>bins)
*
menu
$param(thist); PRE funds9 funhist "$xpa"  "$filename[$regions]" "$norm $bwidth" "$column" "$bins" POST | $text

Image Histogram (options: <min:max:>bins)
*
menu
$param(ihist); $data | PRE funhist "stdin[$regions]" xy "$bins" POST | $text

---

Radial Profile Plot in Pixels using DS9's Internal Image Data (annulus regions)
*
menu
$data | PRE funcnts -rpG stdin "$regions(source,,)" "$regions(background,,)" |  funcnts.plot -file "$filename" ds9 POST | $plot(stdin)

Counts in Regions in Pixels using DS9's Internal Image Data (any regions)
*
menu
$data | PRE funcnts -rp stdin "$regions(source,,)" "$regions(background,,)" POST | $text

---

end
