geirs2Panic  Richard J. Mathar
Fits header keyword batch editor
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Private Member Functions | List of all members
Window Class Reference

#include <Window.h>

Collaboration diagram for Window:
Collaboration graph

Public Member Functions

 Window (char *fitsInname, int gp=0, int csiz=2048)
 
 Window (string fitsInname, int gp=0, int csiz=2048)
 
 ~Window ()
 Destructor. More...
 
void win2win (const int rotRight90, const bool flip)
 Compute the window location after splicing and optionial flip-rotation. More...
 
int sizeX () const
 The width along x in pixel units. More...
 
int sizeY () const
 The width along y in pixel units. More...
 
bool isRef (int xin, int yin) const
 Decide whether a pixel is one of the reference pixel in one of the 4 frame borders. More...
 
void blankRef (int blank)
 Fill any pixel in one of the four pixel borders (within the 4pixel limit) by the blank. More...
 
void cooGeirsWinToSplicRot (int coo[2], const int rotRight90, const bool flip)
 Convert the coordinate from fused (zero-gap) windowed to global mosaic coordinate (spliced) system. More...
 
string canonName ()
 Generate a <INSTRU>.YYYY-MM-DDTHH-MM-SS.sss.fits string name. More...
 
void rmFiles (bool verbose=false)
 Delete the file that contains the data used on construction. More...
 

Static Public Member Functions

static bool isRef (int xin, int yin, int xchipsize, int ychipsize)
 Decide whether a pixel is one of the reference pixel in one of the 4 frame borders. More...
 
static void fourPix (const string &tsiz, int coo[4], bool relwidth)
 Extract the [xl:xh,yl:yh] four parameters from the bracket. More...
 
static string trimws (const string &instring)
 Strip leading and trailing white space from a string. More...
 

Public Attributes

string iname
 Name of the input file. More...
 
int gap
 Gap (measured in pixels) between the chips of the mosaic. More...
 
int chpsz
 Size (measured in pixels) of the single chip of the mosaic. More...
 
int detsize [4]
 Size (measured in pixels) of the fused array of chips. More...
 
int trimsizeFus [4]
 Window origin and extension in the coordinate system of the fused (gapless) mosaic. More...
 
int trimsize [4]
 Window origin and extension in the coordinate system of the spliced mosaic. More...
 
FITS * ifits
 The FITS file that will be read/scanned. More...
 
valarray< float > farr
 array of pixels in floating point units. More...
 
valarray< int > iarr
 Array of pixels in 32bit integer units. More...
 
valarray< unsigned short > usarr
 Array of pixels in 16bit integer units. More...
 
valarray< unsigned short > sarr
 Array of pixels in 16bit integer units. More...
 
float pixsc
 Pixel scale in units of degrees on the sky. More...
 
long bits
 The indication of image type (integer, short, float...) More...
 
long naxes
 The indication of dimension of the image (2=flat, 3=cubes,...) More...
 

Protected Member Functions

void cooGeirsNoWin (int coo[2])
 Convert the coordinate in the fused (zero-gap) windowed coordinate system to non-windowed. More...
 
void cooToWin (int coo[2])
 Convert the coordinate in non-windowed coordinate system to windowed. More...
 
void detIdx (const int coo[2], int idx[2])
 Compute the chip number in the fused (zero-gap) global mosaic coordinate system. More...
 
void cooGeirsWinToSplic (int coo[2])
 Convert the coordinate from fused (zero-gap) windowed to global mosaic coordinate (spliced) system. More...
 
void cooGeirsWinToSplicRotWin (int coo[2], const int rotRight90, const bool flip)
 Convert the coordinate from fused (zero-gap) windowed to mosaic windowed/rotated coordinate (spliced) system. More...
 

Static Protected Member Functions

static void pixRot (int coo[2], int rotRight90, bool flip)
 Map a pixel in the input rectangular array to a pixel in the output array. More...
 

Private Member Functions

void readPix (bool verbose)
 Read the pixel data of the primary data unit (image). More...
 
void init (bool verbose)
 Scan the bare primary information in the FITS header. More...
 

Detailed Description

Since
2012-11-08
Author
Richard J. Mathar

Constructor & Destructor Documentation

Window::Window ( char *  fitsIname,
int  gp = 0,
int  csiz = 2048 
)
Parameters
[in]fitsnameThe name of the FITS file to be read.
[in]gpThe width of the gap between individual chips in the mosaic in units of pixels.
[in]csizThe dimension along each edge of each chip in pixels.
Since
2012-10-23
Author
Richard J. Mathar
Window::Window ( string  fitsIname,
int  gp = 0,
int  csiz = 2048 
)
Parameters
[in]fitsnameThe name of the FITS file to be read.
[in]gpThe width of the gap between individual chips in the mosaic in units of pixels.
[in]csizThe dimension along each edge of each chip in pixels.
Since
2012-10-23
Author
Richard J. Mathar
Window::~Window ( )

Destructor.

Member Function Documentation

void Window::win2win ( const int  rotRight90,
const bool  flip 
)

Compute the window location after splicing and optionial flip-rotation.

Parameters
[in]rotRight90Number of right-90 rotations requested.
[in]flipIf true, perform antoher right-left flip around the y-coordinate.
int Window::sizeX ( ) const

The width along x in pixel units.

Returns
The horizontal size of the window in pixels. This refers to the original orientation, not the optionally rotated or flipped one.
Since
2012-11-07
int Window::sizeY ( ) const

The width along y in pixel units.

Returns
The vertical size of the window in pixels. This refers to the original orientation, not the optionally rotated or flipped one.
Since
2012-11-07
bool Window::isRef ( int  xin,
int  yin,
int  xchipsize,
int  ychipsize 
)
static

Decide whether a pixel is one of the reference pixel in one of the 4 frame borders.

This supports elimination of the reference pixels on Hawaii2 detectors.

Parameters
[in]xinThe x coordinate in the range 0 to xchipsize-1 (inclusive) Independent of windowing, this coordinates refers to x=0 as the lower left edge coordinate of the entire mosaic.
[in]yinThe y coordinate in the range 0 to ychipsize-1 (inclusive) Independent of windowing, this coordinates refers to y=0 as the lower left edge coordinate the entire mosaic.
[in]xchipsizeThe number of pixels along x.
[in]ychipsizeThe number of pixels along y.
Returns
true if (xin,yin) lie in one of the 4-pixel white frames around the full frame.
bool Window::isRef ( int  xin,
int  yin 
) const

Decide whether a pixel is one of the reference pixel in one of the 4 frame borders.

This supports elimination of the reference pixels on Hawaii2 detectors.

Parameters
[in]xinThe x coordinate in the range 0 to xchipsize-1 (inclusive) Independent of windowing, this coordinates refers to x=0 as the lower left edge coordinate of the entire mosaic.
[in]yinThe y coordinate in the range 0 to ychipsize-1 (inclusive) Independent of windowing, this coordinates refers to y=0 as the lower left edge coordinate the entire mosaic.
Returns
true if (xin,yin) lie in one of the 4-pixel white frames around the full frame.
void Window::blankRef ( int  blank)

Fill any pixel in one of the four pixel borders (within the 4pixel limit) by the blank.

This supports elimination of the reference pixels on Hawaii2 detectors.

Parameters
[in]blankThe value to replace all reference values.
Since
2012-11-19
void Window::cooGeirsWinToSplicRot ( int  coo[2],
const int  rotRight90,
const bool  flip 
)

Convert the coordinate from fused (zero-gap) windowed to global mosaic coordinate (spliced) system.

Parameters
[in,out]coo
Since
2012-11-07
void Window::fourPix ( const string &  tsiz,
int  coo[4],
bool  relwidths 
)
static

Extract the [xl:xh,yl:yh] four parameters from the bracket.

Parameters
[in]tsizwith four integer values, colon and comma-separated. The interpretation for relwidths=true is that the value of ranges in x is from xl (inclusive) to xl+xh (exclusive) and in y from yl (inclusive) to yl+yh (exclusive). The interpretation for relwidths=false is that the value of ranges in x is from xl (inclusive) to xh (exclusive) and in y from yl (inclusive) to yh (exclusive).
[out]cooThe four coordinates xl, xh, yl, yh. If the format of the string does not provide the two brackets, two colons and comma, the values are not changed.
[in]relwidthsIf true, the 2nd pair of coordinates is interpreted as relative sizes (widths). If false, the pair is in the same absolute coordinate system as the first pair.
Since
2012-11-06
string Window::canonName ( )

Generate a <INSTRU>.YYYY-MM-DDTHH-MM-SS.sss.fits string name.

Since
2012-11-20
Author
Richard J. Mathar
string Window::trimws ( const string &  instring)
static

Strip leading and trailing white space from a string.

Parameters
[in]instringThe initial string from which nonprintable leading and trailing characters or white space (tabs, blanks) ought to be removed.
Returns
The string with leading and trailing blanks, tabs etc removed.
void Window::rmFiles ( bool  verbose = false)

Delete the file that contains the data used on construction.

Obviously, this is a risky operation and may lead to loss of data.

Parameters
[in]verboseIf true, print names of files deleted to stdout.
Since
2012-11-20
Author
Richard J. Mathar
void Window::cooGeirsNoWin ( int  coo[2])
inlineprotected

Convert the coordinate in the fused (zero-gap) windowed coordinate system to non-windowed.

Parameters
[in,out]cooOn input, the x and y coordinate in the window and fused coordinate system. On output, the x and y coordinate in the window and fused coordinate system.
void Window::cooToWin ( int  coo[2])
inlineprotected

Convert the coordinate in non-windowed coordinate system to windowed.

Parameters
[in,out]cooOn input, the x and y coordinate in the windowed spliced coordinate system. On output, the x and y coordinate in the global spliced coordinate system.
void Window::detIdx ( const int  coo[2],
int  idx[2] 
)
inlineprotected

Compute the chip number in the fused (zero-gap) global mosaic coordinate system.

Parameters
[in]coo
[out]idx
Since
2012-11-07
void Window::pixRot ( int  coo[2],
int  rotRight90,
bool  flip 
)
staticprotected

Map a pixel in the input rectangular array to a pixel in the output array.

Parameters
[in,out]coo[0] the x and [1] the y coordinate before and after the rotation. On output, the two coordinates may have picked up any of the 4 sign combinations. So this is a pure rotation on the Gaussian integer coordinate system. No shift is involved to translate the coordinates back to some sort of first quadrant.
[in]rotRight90Count of right rotations in units of 90 degrees. This value is used modulo 4, so effectively between 1 and 3. 0 has no effect, unless combined with the flip.
[in]flipRequest a flip around the y-axis. This equals sign toggling of x-coordinates after any rotation.
void Window::cooGeirsWinToSplic ( int  coo[2])
protected

Convert the coordinate from fused (zero-gap) windowed to global mosaic coordinate (spliced) system.

Parameters
[in,out]coo
Since
2012-11-07
void Window::cooGeirsWinToSplicRotWin ( int  coo[2],
const int  rotRight90,
const bool  flip 
)
protected

Convert the coordinate from fused (zero-gap) windowed to mosaic windowed/rotated coordinate (spliced) system.

Parameters
[in,out]coo
Since
2012-11-07
void Window::readPix ( bool  verbose)
private

Read the pixel data of the primary data unit (image).

Parameters
[in]verboseIf true, write some output to stdout.
Since
2012-10-18
Author
Richard J. Mathar
void Window::init ( bool  verbose)
private

Scan the bare primary information in the FITS header.

Read INSTRUME to have some input on the mosaic size. Read DETSIZE which is the preferred way to have some input on the mosaic size. Read SAVEAREA (GEIRS specific, deprecated) and TRIMSIZE to determine the window location

Author
Richard J. Mathar

Member Data Documentation

string Window::iname

Name of the input file.

The principal use is to look into the primary header for the SAVEARE (TRIMSIZE) keyword that relocates this window in the coordinate system of the mosaic of fused chips.

int Window::gap

Gap (measured in pixels) between the chips of the mosaic.

This is considered the same horizontally and vertically.

int Window::chpsz

Size (measured in pixels) of the single chip of the mosaic.

This is only considering quadratic chips (same x and y extent)

int Window::detsize[4]

Size (measured in pixels) of the fused array of chips.

This is the product of chip count and chpsz in the horizontal and vertical directions. The interpretation is that the xrange is from [0] to [1] (exclusive), the y range from [2] to [3] (exclusive) and [0]=[2]=0 with the usual 0-based C/C++/Java convention.

int Window::trimsizeFus[4]

Window origin and extension in the coordinate system of the fused (gapless) mosaic.

The four components of the array are following the same convention as detsize.

int Window::trimsize[4]

Window origin and extension in the coordinate system of the spliced mosaic.

The four components of the array are following the same convention as detsize. If some subareas of the window are located in any but the lower-left chip, the components will differ (and be larger than) the associated components in trimsizeFus.

FITS* Window::ifits

The FITS file that will be read/scanned.

valarray<float> Window::farr

array of pixels in floating point units.

Empty if this is not a floating point type.

valarray<int> Window::iarr

Array of pixels in 32bit integer units.

Empty if this is not a integer type.

valarray<unsigned short> Window::usarr

Array of pixels in 16bit integer units.

Empty if this is not a unsigned short integer type.

valarray<unsigned short> Window::sarr

Array of pixels in 16bit integer units.

Empty if this is not a short integer type.

float Window::pixsc

Pixel scale in units of degrees on the sky.

To be used to convert pixels to WCS coordinates.

long Window::bits

The indication of image type (integer, short, float...)

long Window::naxes

The indication of dimension of the image (2=flat, 3=cubes,...)