FITS Image Sections, with Binning and Filtering

The rows in a FITS binary table must be binned before being displayed as an image. By default, JS9 uses a bin factor of 1 to extract the central 2048 x 2048 section of the data for display. This default is controlled by the JS9.globalOpts.table object properties, which can be set in your js9Prefs.js file.

Also by default, the central 2048 x 2048 section of a FITS image is displayed at bin 1. This default is controlled by the JS9.globalOpts.image object properties, which can be set in your js9Prefs.js file.

The Bin/Filter/Section plugin allows you to extract sections from FITS binary tables and images, with options to choose the image center, image dimensions, and bin factor. For tables, the plugin also allows you to filter rows of the table by means of arithmetic and boolean operations on the table columns.

The Bin/Filter/Section plugin works with both FITS representation files and with ordinary in-memory FITS files. If the displayed FITS file is a representation file (i.e., it has a parent file, a JS9 helper is connected, etc.), the plugin will ask the JS9 helper to extract the image section from the parent. Otherwise, it extracts the section from the in-memory FITS file. This behavior is meant to be transparent to the user.

When extracting an image section, you can set one or more of the following options:

For example, if a table has FITS (tlmin, tlmax) dimensions 4096 x 4096, then:

Specifying 0,0 for the center will cause the section to be extracted from the center of the image.

Although the binning parameter is usually input as an real value, there are other options available:

Note that the JS9.globalOpts.binMode property specifies the default action for whether the binned pixels are summed together (if binMode is "s") or averaged (if binMode is "a"). This action is overridden by the last two bin directives listed above or by the mode input option.

Table filtering allows you to select rows from an FITS binary table (e.g., an X-ray event list) by checking each row against an expression involving the columns in the table. When a table is filtered, only valid rows satisfying these expressions are used to make the image.

A filter expression consists of an arithmetic or logical operation involving one or more column values from a table. Columns can be compared to other columns or to numeric constants. Standard JavaScript math functions can be applied to columns. JavaScript (or C) semantics are used when constructing expressions, with the usual precedence and associativity rules holding sway:

  Operator                                Associativity
  --------                                -------------
  ()                                      left to right
  !  (bitwise not) - (unary minus)        right to left
  *  /                                    left to right
  +  -                                    left to right
  < <= > >=                               left to right
  == !=                                   left to right
  &  (bitwise and)                        left to right
  ^  (bitwise exclusive or)               left to right
  |  (bitwise inclusive or)               left to right
  && (logical and)                        left to right
  || (logical or)                         left to right
  =                                       right to left
For example, if energy and pha are columns in a table, then the following are valid expressions:
  pha > 1
  energy == pha
  pha > 1 && energy ≤ 2
  max(pha,energy)≥2.5

NB: when using cfitsio (the default, instead of the deprecated fitsy.js), table filtering follows cfitsio conventions, which is documented here.

Once the desired parameters have been set, pressing the Run button will filter, bin and display the data.