hg.c
ABSTRACT: Simple operations on data structures for histograms (HG),
points (PT), and pgplot states (PGSTATE).
Everything is public.
DESCRIPTION:
Make a new HG
RETURN VALUES:
Pointer to an HG
SIGNATURE:
HG *shHgNew(
void /* void */
)
DESCRIPTION:
Sets the name of the HG
RETURN VALUES:
SH_SUCCESS if successfull
SIGNATURE:
RET_CODE shHgNameSet(
HG* hg, /* the hg to name */
char* name /* what to name it */
)
DESCRIPTION:
Returns the name of an HG
RETURN VALUES:
Char pointer to name of HG or NULL if Error
SIGNATURE:
char *shHgNameGet(
HG* hg /* hg with unknown name */
)
DESCRIPTION:
Define a HG; labels, limits, and number of bins
RETURN VALUES:
SH_SUCCESS or HG_ERROR
SIGNATURE:
RET_CODE shHgDefine(
HG *hg, /* hg to be defined */
char *xLabel, /* label for x data */
char *yLabel, /* label for y data */
char *name, /* name of the new hg */
double minimum, /* minimum value */
double maximum, /* maximum value */
unsigned int nbin /* number of bins to create */
)
DESCRIPTION:
Set all the contents and errors to zero in a HG
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shHgClear (
HG *hg /* the HG to be worked upon */
)
DESCRIPTION:
Increment one bin of a HG.
Add weight to the bin that value falls in
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shHgFill (
HG *hg, /* the HG to be worked upon */
double value, /* the value that determines the bin */
double weight /* the amount of increase */
)
DESCRIPTION:
Return the mean of a HG
RETURN VALUES:
Mean as a double
SIGNATURE:
double shHgMean(
HG *hg /* the HG to be worked upon */
)
DESCRIPTION:
Return the sigma of a HG
RETURN VALUES:
Returns the sigma as a double
SIGNATURE:
double shHgSigma(
HG *hg /* the HG to be worked upon */
)
DESCRIPTION:
Short printout of a HG; mostly for debugging
RETURN VALUES:
HG_OK
SIGNATURE:
RET_CODE shHgPrint(
HG *hg /* the HG to be worked upon */
)
DESCRIPTION:
Return a HG that is hg1 and hg2 operating on each other. Set
operation to "+", "m", "*", "/". "m" (not "-") is subtraction.
RETURN VALUES:
A pointer to a HG containing the result of the input hg's
SIGNATURE:
HG *shHgOper(
HG *hg1, /* the first HG to be worked upon */
char *operation, /* what to do to the two HGs */
HG *hg2 /* the other HG to be worked upon */
)
DESCRIPTION:
Delete a HG
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shHgDel(
HG *hg /* the HG to be worked upon */
)
DESCRIPTION:
Make a new PGSTATE
RETURN VALUES:
A pointer to the new PGSTATE
SIGNATURE:
PGSTATE *shPgstateNew(
void /* void */
)
DESCRIPTION:
Set everything in a PGSTATE to a good default value
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstateDefault(
PGSTATE *pgstate /* the PGSTATE to be worked upon */
)
DESCRIPTION:
Simple dump of a PGSTATE
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstatePrint(
PGSTATE *pgstate /* the PGSTATE to be worked upon */
)
DESCRIPTION:
Make the plot show up in the "next" window
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstateNextWindow(
PGSTATE *pgstate /* the PGSTATE to be worked upon */
)
DESCRIPTION:
Delete a PGSTATE
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstateDel(
PGSTATE *pgstate /* the PGSTATE to be worked upon */
)
DESCRIPTION:
Open a PGSTATE (xwindow or pgplot.ps file, for example)
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstateOpen(
PGSTATE *pgstate /* the PGSTATE to be worked upon */
)
DESCRIPTION:
Put the title on the page.
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstateTitle(
PGSTATE *pgstate /* the PGSTATE to be worked upon */
)
DESCRIPTION:
Plot a HG
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shHgPlot(
PGSTATE *pgstate, /* the PGSTATE to plot the HG on */
HG *hg, /* the HG to be plotted */
double xminIn, /* min value for x */
double xmaxIn, /* max value for x */
double yminIn, /* min value for y */
double ymaxIn, /* max value for y */
int xyOptMask /* XMINOPT | XMAXOPT, etc., to use above
values, not calculated ones */
)
DESCRIPTION:
Close a PGSTATE
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPgstateClose(
PGSTATE *pgstate /* the PGSTATE to be closed */
)
DESCRIPTION:
Put the pixel values of a REGION in a HG
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shHgReg(
HG *hg, /* the HG to be worked upon */
REGION *reg, /* the region whose values will be used */
int maskBits /* exclude pixels with matches to this mask */
)
DESCRIPTION:
Make a new point
RETURN VALUES:
New pt
SIGNATURE:
PT * shPtNew(
void /* void */
)
DESCRIPTION:
Define the values of a PT
RETURN VALUES:
SH_SUCCESS if successfull
SIGNATURE:
RET_CODE shPtDefine(
PT *pt, /* pt to work on */
float row, /* row value */
float col, /* column value */
float radius /* radius value */
)
DESCRIPTION:
Simple dump of a PT
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPtPrint(
PT *pt /* unknown point */
)
DESCRIPTION:
Delete a point
RETURN VALUES:
SH_SUCCESS
SIGNATURE:
RET_CODE shPtDel(
PT *pt /* pt to delete */
)
DESCRIPTION:
Create a chain by selecting from a plot (HG or V) in X
RETURN VALUES:
SH_SUCCESS if successfull
SIGNATURE:
RET_CODE shChainFromPlot(
PGSTATE *pgstate, /* what plot? */
CHAIN *outputChain, /* destination chain */
CHAIN *inputChain, /* source chain */
VECTOR *vMask /* mask */
)
DESCRIPTION:
Create an array of points by selecting from a plot (HG or V) in X
RETURN VALUES:
SH_SUCCESS if successful, vIndex containing index of points in vX, vY
SIGNATURE:
RET_CODE shVIndexFromPlot(
PGSTATE *pgstate, /* what plot? */
VECTOR *vIndex,
VECTOR *vX,
VECTOR *vY,
VECTOR *vMask /* mask */
)
DESCRIPTION:
Create an array of points by selecting from an HG
RETURN VALUES:
SH_SUCCESS if successful, vIndex containing index of points in vX
SIGNATURE:
RET_CODE shVIndexFromHg(
PGSTATE *pgstate, /* what plot? */
VECTOR *vIndex,
VECTOR *vX,
VECTOR *vMask /* mask */
)
DESCRIPTION:
Get a PT from a histogram bin; min or max value
RETURN VALUES:
SH_SUCCESS, point in pt
SIGNATURE:
RET_CODE shPtBin(
HG *hg, /* hg to copy from */
PT *pt, /* pt to get */
char *minORmax /* min or max value */
)
DESCRIPTION:
Return the thing on the chain closest to the picked point
RETURN VALUES:
void, point returned in pt
SIGNATURE:
void *shGetClosestFromChain(
CHAIN *inputChain, /* chain to use */
VECTOR *vMask, /* what part? */
PT *pt, /* point to return */
char *xName, /* name of x value */
char *yName /* name of y value */
)
DESCRIPTION:
Return the thing on the vector closest to the picked point
RETURN VALUES:
index of closest point in vectors as int, or -1 if error.
SIGNATURE:
int shGetClosestFromVectors(
VECTOR *vX, /* x vector to use */
VECTOR *vY, /* y vector to use */
VECTOR *vMask, /* what part? */
PT *pt /* point to return */
)
DESCRIPTION:
Return coordinate of points picked from pgstate X window.
Left button picks closest point.
Middle button picks first and second corner of rectangle.
Right button cancels operation.
RETURN VALUES:
number telling what button, or 0
SIGNATURE:
int shGetCoord(
PGSTATE *pgstate, /* what plot */
PT *pt1, /* first button point */
PT *pt2 /* second button point */
)
DESCRIPTION:
Plot row and col values in a chain in saoDisplay window
RETURN VALUES:
SH_SUCCESS if successfull
SIGNATURE:
RET_CODE shChainToSao(ClientData clientData, /* window info */
CHAIN *tchain, /* chain to plot */
char *rowName, /* name of row */
char *colName, /* name of column */
char *radiusName /* name of radius */
)
DESCRIPTION:
Add noise to a regions; simple poisson model.
RETURN VALUES:
0 as int
SIGNATURE:
int shRegFluctuateAsSqrt(
REGION *regPtr, /* the region */
double gain /* the gain in electrons per ADU */
)
DESCRIPTION:
Append the elements in the plot that are included in the box
bounded by the two points.
RETURN VALUES:
Number of winners (??) or 0 upon error
SIGNATURE:
unsigned int shAppendIncludedElementsToChain(
CHAIN *outputChain, /* output chain */
CHAIN *inputChain, /* input chain */
VECTOR *vMask, /* mask on chains */
PT *pt1, /* point 1 */
PT *pt2, /* point 2 */
char *xName, /* name of x */
char *yName /* name of y */
)
DESCRIPTION:
Append the elements in the plot that are included in the box
bounded by the two points.
RETURN VALUES:
Number of winners (??) or 0 upon error
SIGNATURE:
unsigned int shGetIncludedFromVectors(
VECTOR *vIndex, /* output vector */
VECTOR *vX, /* input vector */
VECTOR *vY, /* input vector */
VECTOR *vMask, /* mask on vectors */
PT *pt1, /* point 1 */
PT *pt2 /* point 2 */
)
DESCRIPTION:
Append the elements in the plot that are included in the bin
bounded by the two points.
RETURN VALUES:
Number of winners (??) or 0 upon error
SIGNATURE:
unsigned int shGetIncludedFromVector(
VECTOR *vIndex, /* output vector */
VECTOR *vX, /* input vector */
VECTOR *vMask, /* mask on vX */
PT *pt1, /* point 1 */
PT *pt2 /* point 2 */
)