Merged RELEASE-1_1 back into trunk.
r1836 | ffr | 2007-04-06 19:10:02 +1000 (Fri, 06 Apr 2007) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
79ac59740f
commit
e7324b8335
193
nxscript.c
193
nxscript.c
@@ -915,6 +915,196 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
|
||||
free(data);
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
/* ANSTO MOD1 START */
|
||||
/**\brief Calculates polar angles on a 2D grid for cylindrical detectors.
|
||||
*
|
||||
* param dradius detector radius
|
||||
* param angsep angular separation between detector columns in radians
|
||||
* param active_height_mm of a detector in mm
|
||||
* param det_rot_rad detector rotation in radians
|
||||
* param row_zero vertical pixel at beam centre.
|
||||
* param ROI_row_offset horizontal pixel offset of ROI
|
||||
* param col_zero horizontal pixel at beam centre for detector rotation of zero.
|
||||
* param ROI_col_offset vertical pixel offset of ROI
|
||||
* param rownum number of detector rows
|
||||
* param colnum number of detector columns
|
||||
*
|
||||
* Detector pixel layout uses display coordinates viewed from the sample.
|
||||
* ie If you stand at the sample and face the detector the (0,0) is at the
|
||||
* left.
|
||||
*/
|
||||
float *G_TwoThetaArr=NULL;
|
||||
void polar_angle(int folding, int dim, double dradius, double angsep, double active_height_mm, double det_rot_rad, double row_zero, double ROI_row_offset, double col_zero, double ROI_col_offset, double pixelrownum, double pixelcolnum) {
|
||||
|
||||
int row,col;
|
||||
double rowsep, height, alpha, pang;
|
||||
double rowstart, rowend, rownum, colnum, pixelrow, pixelcol;
|
||||
|
||||
if (folding == 1) {
|
||||
rownum = pixelrownum;
|
||||
colnum = pixelcolnum;
|
||||
} else {
|
||||
rownum = pixelrownum/2;
|
||||
colnum = pixelcolnum*2;
|
||||
}
|
||||
|
||||
if (G_TwoThetaArr != NULL)
|
||||
free(G_TwoThetaArr);
|
||||
|
||||
G_TwoThetaArr = (float *)malloc(rownum*colnum*sizeof(float));
|
||||
|
||||
|
||||
rowsep = active_height_mm/(rownum-1);
|
||||
|
||||
if (dim==1) {
|
||||
rowstart = rownum/2;
|
||||
rowend = rownum/2;
|
||||
} else {
|
||||
rowstart = 0;
|
||||
rowend = rownum;
|
||||
}
|
||||
for (row=rowstart; row < rowend; row++) {
|
||||
height=(row_zero - ROI_row_offset - row)*rowsep;
|
||||
for (col=0; col < colnum; col++) {
|
||||
alpha = (col_zero - ROI_col_offset - col)*angsep + det_rot_rad;
|
||||
pang = acos(dradius * cos(alpha)/sqrt(dradius*dradius+ height*height));
|
||||
if (folding == 1) {
|
||||
G_TwoThetaArr[(int)(row*colnum+col)]=pang;
|
||||
} else {
|
||||
if (col%2==0) {
|
||||
pixelrow = row + rownum;
|
||||
pixelcol = col/2;
|
||||
} else {
|
||||
pixelrow = (rownum - 1) - row;
|
||||
pixelcol = (col-1)/2;
|
||||
}
|
||||
G_TwoThetaArr[(int)(pixelrow*pixelcolnum+pixelcol)]=pang;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void putPolarArray(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
int status, written=0;
|
||||
int start[NX_MAXRANK], size[NX_MAXRANK];
|
||||
char buffer[256];
|
||||
Tcl_Interp *tcl = NULL;
|
||||
|
||||
int folding, dim;
|
||||
double angsep, det_rot_rad, active_height_mm, rowsep;
|
||||
double row_zero, ROI_row_offset, col_zero, ROI_col_offset, dradius;
|
||||
double rownum, colnum;
|
||||
|
||||
if(argc < 11){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to array",
|
||||
eError);
|
||||
return;
|
||||
}
|
||||
tcl = InterpGetTcl(pSics);
|
||||
assert(tcl != NULL);
|
||||
|
||||
|
||||
status = listToArray(pSics,argv[3],start);
|
||||
if(status != TCL_OK){
|
||||
SCWrite(pCon,"ERROR: failed to convert start value list", eError);
|
||||
return;
|
||||
}
|
||||
|
||||
status = listToArray(pSics,argv[4],size);
|
||||
if(status != TCL_OK){
|
||||
SCWrite(pCon,"ERROR: failed to convert size value list", eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetInt(tcl,argv[5],&folding);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to int",argv[5]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetInt(tcl,argv[6],&dim);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to int",argv[6]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[7],&dradius);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[7]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[8],&angsep);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[8]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[9],&active_height_mm);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[9]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[10],&det_rot_rad);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[10]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[11],&row_zero);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[11]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[12],&ROI_row_offset);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[12]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[13],&col_zero);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[13]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[14],&ROI_col_offset);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[14]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[15],&rownum);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[15]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
status = Tcl_GetDouble(tcl,argv[16],&colnum);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to double",argv[16]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
polar_angle(folding, dim, dradius, angsep, active_height_mm, det_rot_rad, row_zero, ROI_row_offset, col_zero, ROI_col_offset, rownum, colnum);
|
||||
|
||||
// status = NXDputalias(self->fileHandle, self->dictHandle,argv[2],G_TwoThetaArr);
|
||||
status = NXDopenalias(self->fileHandle, self->dictHandle,argv[2]);
|
||||
status = NXputslab(self->fileHandle, G_TwoThetaArr, start, size);
|
||||
if(status == NX_OK){
|
||||
written = 1;
|
||||
}
|
||||
NXopenpath(self->fileHandle,"/");
|
||||
if(written != 1){
|
||||
sprintf(buffer,"ERROR: failed to write array");
|
||||
SCWrite(pCon,buffer,eError);
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
/* ANSTO MOD1 END */
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void putIntArray(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
@@ -1128,6 +1318,9 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
}else if(strcmp(argv[1],"putintarray") == 0){
|
||||
/*================*/
|
||||
putIntArray(pCon,pSics,self,argc,argv);
|
||||
}else if(strcmp(argv[1],"putpolararray") == 0){
|
||||
/*================*/
|
||||
putPolarArray(pCon,pSics,self,argc,argv);
|
||||
}else if(strcmp(argv[1],"putglobal") == 0){
|
||||
/*===============*/
|
||||
putGlobal(pCon,pSics,self,argc,argv);
|
||||
|
||||
Reference in New Issue
Block a user