- Removed slit 5 from amorset.c

- poldizug now sends all codes all the time
- polterwrite writes the filename again
- sanswave has been modifed to support the new second generation velocity
  selector
- sinqhttprot has been mdified to copy data to nodes, this for the second
  generation HM object
- tasscan suppressed some output
This commit is contained in:
koennecke
2009-05-15 13:24:02 +00:00
parent 5d30c7b5b9
commit caf59ef8eb
12 changed files with 225 additions and 87 deletions

View File

@ -72,6 +72,26 @@ static double sansround(double d)
}
}
/*---------------------------------------------------------------------------*/
typedef struct {
int idx;
double frac;
}MediSort;
/*---------------------------------------------------------------------------*/
static int MediCompare(const void *v1, const void *v2)
{
MediSort *m1, *m2;
m1 = (MediSort *)v1;
m2 = (MediSort *)v2;
if(m1->frac > m2->frac){
return -1;
} else if (m1->frac == m2->frac ){
return 0;
} else {
return 1;
}
}
/*---------------------------------------------------------------------------*/
int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
@ -80,9 +100,11 @@ int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData,
int iDim[2], ix, iy, pos, ival, xDetDim[2], yDetDim[2], nDetX, nDetY,
posIdx;
long totalCounts = 0;
double x, y, val, *xPos = NULL, *yPos = NULL, corrSum = .0, doubleCounts;
double x, y, val, *xPos = NULL, *yPos = NULL, corrSum = .0, doubleCounts, sumFrac;
double low, frac;
float detectorDistance;
MediSort *sortData;
if (argc < 2) {
SCWrite(pCon, "ERROR: Not enough arguments", eError);
return 0;
@ -111,7 +133,8 @@ int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData,
weights = createNXDataset(2, NX_FLOAT64, iDim);
xPos = malloc(nDetX * nDetY * sizeof(double));
yPos = malloc(nDetX * nDetY * sizeof(double));
if (dataset == NULL || weights == NULL || xPos == NULL || yPos == NULL) {
sortData = malloc(iDim[0]*iDim[1]*sizeof(MediSort));
if (dataset == NULL || weights == NULL || xPos == NULL || yPos == NULL || sortData == NULL) {
SCWrite(pCon, "ERROR: out of memory allocating temporary data",
eError);
return 0;
@ -156,18 +179,43 @@ int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData,
corrSum += dataset->u.dPtr[ix];
}
doubleCounts = (double) totalCounts;
/*
* distribute counts
*/
sumFrac = .0;
for (ix = 0; ix < 128 * 128; ix++, pos++) {
if (corrSum > .01) {
val = sansround(dataset->u.dPtr[ix] * doubleCounts / corrSum);
val = dataset->u.dPtr[ix] * doubleCounts / corrSum;
low = floor(val);
frac = val - low;
sumFrac += frac;
val = low;
sortData[ix].idx = pos;
sortData[ix].frac = frac;
} else {
val = .0;
}
setSICSDataInt(target, pos, (int) val);
}
/*
* apply median correction
*/
qsort(sortData, iDim[0]*iDim[1], sizeof(MediSort), MediCompare);
ix = 0;
while(sumFrac > .0){
pos = sortData[ix].idx;
getSICSDataInt(target,pos,&ival);
setSICSDataInt(target,pos,ival+1);
ix++;
sumFrac -= 1.;
}
dropNXDataset(dataset);
dropNXDataset(weights);
free(xPos);
free(yPos);
free(sortData);
SCSendOK(pCon);
return 1;
}