geirs2Panic
Richard J. Mathar
Fits header keyword batch editor
|
#include <Window.h>
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... | |
Window::Window | ( | char * | fitsIname, |
int | gp = 0 , |
||
int | csiz = 2048 |
||
) |
[in] | fitsname | The name of the FITS file to be read. |
[in] | gp | The width of the gap between individual chips in the mosaic in units of pixels. |
[in] | csiz | The dimension along each edge of each chip in pixels. |
Window::Window | ( | string | fitsIname, |
int | gp = 0 , |
||
int | csiz = 2048 |
||
) |
[in] | fitsname | The name of the FITS file to be read. |
[in] | gp | The width of the gap between individual chips in the mosaic in units of pixels. |
[in] | csiz | The dimension along each edge of each chip in pixels. |
Window::~Window | ( | ) |
Destructor.
void Window::win2win | ( | const int | rotRight90, |
const bool | flip | ||
) |
Compute the window location after splicing and optionial flip-rotation.
[in] | rotRight90 | Number of right-90 rotations requested. |
[in] | flip | If true, perform antoher right-left flip around the y-coordinate. |
int Window::sizeX | ( | ) | const |
The width along x in pixel units.
int Window::sizeY | ( | ) | const |
The width along y in pixel units.
|
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.
[in] | xin | The 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] | yin | The 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] | xchipsize | The number of pixels along x. |
[in] | ychipsize | The number of pixels along y. |
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.
[in] | xin | The 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] | yin | The 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. |
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.
[in] | blank | The value to replace all reference values. |
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.
[in,out] | coo |
|
static |
Extract the [xl:xh,yl:yh] four parameters from the bracket.
[in] | tsiz | with 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] | coo | The 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] | relwidths | If 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. |
string Window::canonName | ( | ) |
Generate a <INSTRU>.YYYY-MM-DDTHH-MM-SS.sss.fits string name.
|
static |
Strip leading and trailing white space from a string.
[in] | instring | The initial string from which nonprintable leading and trailing characters or white space (tabs, blanks) ought to be 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.
[in] | verbose | If true, print names of files deleted to stdout. |
|
inlineprotected |
Convert the coordinate in the fused (zero-gap) windowed coordinate system to non-windowed.
[in,out] | coo | On 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. |
|
inlineprotected |
Convert the coordinate in non-windowed coordinate system to windowed.
[in,out] | coo | On 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. |
|
inlineprotected |
Compute the chip number in the fused (zero-gap) global mosaic coordinate system.
[in] | coo | |
[out] | idx |
|
staticprotected |
Map a pixel in the input rectangular array to a pixel in the output array.
[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] | rotRight90 | Count 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] | flip | Request a flip around the y-axis. This equals sign toggling of x-coordinates after any rotation. |
|
protected |
Convert the coordinate from fused (zero-gap) windowed to global mosaic coordinate (spliced) system.
[in,out] | coo |
|
protected |
Convert the coordinate from fused (zero-gap) windowed to mosaic windowed/rotated coordinate (spliced) system.
[in,out] | coo |
|
private |
Read the pixel data of the primary data unit (image).
[in] | verbose | If true, write some output to stdout. |
|
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
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,...)