Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,13 @@ add_executable(testcell
target_link_libraries(testcell
cbf)

add_executable(roi_peaksearch
"${CBF__EXAMPLES}/dps_peaksearch.c"
"${CBF__EXAMPLES}/roi_peaksearch.c")
target_link_libraries(roi_peaksearch
cbf
"${libm}")

add_executable(sauter_test
"${CBF__EXAMPLES}/sauter_test.C")
target_link_libraries(sauter_test
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ $(BIN)/cbf2adscimg: $(LIB)/libcbf.a $(EXAMPLES)/cbf2adscimg.c $(EXAMPLES)/cbf2ad
$(BIN)/cbf_standardize_numbers: $(EXAMPLES)/cbf_standardize_numbers.c $(EXAMPLES)/cbf_standardize_numbers.h
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) -D_SVID_SOURCE $(INCLUDES) $(WARNINGS) \
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) -L$(LIB) -lcbf $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@

#
# changtestcompression example program
Expand Down
2 changes: 1 addition & 1 deletion Makefile_LINUX
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ $(BIN)/cbf2adscimg: $(LIB)/libcbf.a $(EXAMPLES)/cbf2adscimg.c $(EXAMPLES)/cbf2ad
$(BIN)/cbf_standardize_numbers: $(EXAMPLES)/cbf_standardize_numbers.c $(EXAMPLES)/cbf_standardize_numbers.h
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) -D_SVID_SOURCE $(INCLUDES) $(WARNINGS) \
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) -L$(LIB) -lcbf $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@

#
# changtestcompression example program
Expand Down
2 changes: 1 addition & 1 deletion Makefile_MINGW
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ $(BIN)/cbf2adscimg: $(LIB)/libcbf.a $(EXAMPLES)/cbf2adscimg.c $(EXAMPLES)/cbf2ad
$(BIN)/cbf_standardize_numbers: $(EXAMPLES)/cbf_standardize_numbers.c $(EXAMPLES)/cbf_standardize_numbers.h
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) -D_SVID_SOURCE $(INCLUDES) $(WARNINGS) \
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) -L$(LIB) -lcbf $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@

#
# changtestcompression example program
Expand Down
2 changes: 1 addition & 1 deletion Makefile_MSYS2
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ $(BIN)/cbf2adscimg: $(LIB)/libcbf.a $(EXAMPLES)/cbf2adscimg.c $(EXAMPLES)/cbf2ad
$(BIN)/cbf_standardize_numbers: $(EXAMPLES)/cbf_standardize_numbers.c $(EXAMPLES)/cbf_standardize_numbers.h
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) -D_SVID_SOURCE $(INCLUDES) $(WARNINGS) \
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) -L$(LIB) -lcbf $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@

#
# changtestcompression example program
Expand Down
2 changes: 1 addition & 1 deletion Makefile_OSX
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ $(BIN)/cbf2adscimg: $(LIB)/libcbf.a $(EXAMPLES)/cbf2adscimg.c $(EXAMPLES)/cbf2ad
$(BIN)/cbf_standardize_numbers: $(EXAMPLES)/cbf_standardize_numbers.c $(EXAMPLES)/cbf_standardize_numbers.h
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) -D_SVID_SOURCE $(INCLUDES) $(WARNINGS) \
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) -L$(LIB) -lcbf $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@

#
# changtestcompression example program
Expand Down
14 changes: 10 additions & 4 deletions examples/adscimg2cbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
#include "cbf.h"
#include "cbf_alloc.h"
#include "cbf_string.h"

/****************************************************************/
Expand Down Expand Up @@ -155,8 +156,7 @@ int main(int argc, char *argv[])
char header_bytes[6];
int numargs = argc;
int iarg;
int argtype_array[argc];
int *argtype=argtype_array;
int *argtype;
int filec;
int file_size, header_size_char, actread;
int cbf_status;
Expand All @@ -174,8 +174,7 @@ int main(int argc, char *argv[])
int *new_int_data, *old_int_data;
size_t new_int_data_size, old_int_data_size;
double thickness=0.;
const char * argval_array[argc];
const char * * argval=argval_array;
const char * * argval;
const char * roi=NULL;
const char * thickstr=NULL;
const char * polarstr=NULL;
Expand Down Expand Up @@ -232,6 +231,11 @@ int main(int argc, char *argv[])
CBF_UNUSED( cbf_status );
CBF_UNUSED( thickness );

CBF_START_ARRAY(int, argtype_array, argc);
argtype = argtype_array;
CBF_START_ARRAY(const char *, argval_array, argc);
argval = argval_array;

if(argc < 2)
{
usage();
Expand Down Expand Up @@ -641,5 +645,7 @@ int main(int argc, char *argv[])
filec--;
}
}
CBF_END_ARRAY(argval_array);
CBF_END_ARRAY(argtype_array);
exit(0);
}
4 changes: 3 additions & 1 deletion examples/cbf_standardize_numbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#include "cbf.h"
#include "cbf_alloc.h"
#include "cbf_standardize_numbers.h"
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -107,7 +108,7 @@ int main (int argc, char ** argv) {
continue;
}
if (isdigit(c) || c == '.' || c == '-' || c == '+') {
char text[lineln+1];
CBF_START_ARRAY(char, text, lineln+1);
char * endptr;
for (ii=0; ii < lineln; ii++) text[ii] = line[ii];
text[lineln] = '\0';
Expand Down Expand Up @@ -139,6 +140,7 @@ int main (int argc, char ** argv) {
spacestarted = 1;
numcomp++;
}
CBF_END_ARRAY(text);
continue;
}
if (c == ',' || (termc && c == termc)) {
Expand Down
48 changes: 28 additions & 20 deletions examples/dps_peaksearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "cbf.h"
#include "cbf_alloc.h"
#include "dps_peaksearch.h"


Expand All @@ -82,14 +84,13 @@ int xirint(double x) {
}


#if defined (__linux__)||defined(sun)
#if defined(sun)
/* Round a double to an integer */


/* Calculate sin() and cos(). */
void
sincos(x, s, c)
double x, *s, *c;
static void
sincos(double x, double *s, double *c)
{
*s = sin(x);
*c = cos(x);
Expand All @@ -100,19 +101,17 @@ double x, *s, *c;


/* Calculate sin() and cos(). */
void
sincos(x, s, c)
double x, *s, *c;
static void
sincos(double x, double *s, double *c)
{
*s = sin(x);
*c = cos(x);
}


/* Round a double to an integer */
double
rint(x)
register double x;
static double
rint(register double x)
{
if (x == (int)x)
return(x);
Expand All @@ -137,12 +136,16 @@ int fsign(double x)
*
*/

void
cmass (idata, iwidth, iheight, x, y, cm_x, cm_y, cm_nx, cm_ny)
register unsigned short *idata;
int iwidth, iheight, x, y;
double *cm_x, *cm_y;
int cm_nx, cm_ny;
static void
cmass(register unsigned short *idata,
int iwidth,
int iheight,
int x,
int y,
double *cm_x,
double *cm_y,
int cm_nx,
int cm_ny)
{
register int i, j, val;
double sum_x=0, sum_y=0, sum_z=0.0;
Expand Down Expand Up @@ -203,6 +206,9 @@ static DPS_Peak *dps_peaks = NULL;

static int ccd_image_saturation = 0;

int
sortfunc(const void *lhs, const void *rhs);

int dps_peaksearch(unsigned short *data, int nx, int ny,
int npeaks_out, double min_isigma,
int min_spacing, DPS_Peak *pptr, int min_value)
Expand All @@ -229,13 +235,11 @@ int dps_peaksearch(unsigned short *data, int nx, int ny,
int overload = 55000;
int npeaks=0;
int maxpeaks=20480;
int sortfunc();
int nover;
int nunder;
int nxfer;
DPS_Peak dps_temp;
int peakfw, peakfh;
int next_good_y[nx];
int collide;

stepx = (min_spacing+1)/2; /* Initial stepsize for scanning through the image */
Expand Down Expand Up @@ -267,6 +271,7 @@ int dps_peaksearch(unsigned short *data, int nx, int ny,
}

/* Initialize the next_good_y array to 0 */
CBF_START_ARRAY(int, next_good_y, nx);
for (i=0; i < nx; i++) next_good_y[i]= 0;

/* The next two loops go over the whole frame with stepsize
Expand Down Expand Up @@ -444,6 +449,7 @@ int dps_peaksearch(unsigned short *data, int nx, int ny,
}
}
}
CBF_END_ARRAY(next_good_y);

if (min_spacing > 0) {
for(i=0;i<npeaks;i++)
Expand Down Expand Up @@ -485,9 +491,11 @@ int dps_peaksearch(unsigned short *data, int nx, int ny,
/* Sort pixel value
*/
int
sortfunc(pk1, pk2)
DPS_Peak *pk1, *pk2;
sortfunc(const void *lhs, const void *rhs)
{
const DPS_Peak *pk1 = lhs;
const DPS_Peak *pk2 = rhs;

if (pk2->isigma > pk1->isigma)
return 1;
else
Expand Down
9 changes: 7 additions & 2 deletions examples/testhdf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <stdint.h>

#include "cbf.h"
#include "cbf_alloc.h"
#include "cbf_hdf5.h"
#include "unittest.h"

Expand Down Expand Up @@ -901,8 +902,6 @@ static testResult_t testDataset_read_write(const hid_t grp)
const int N2 = N*2;
int dataWrite0[] = {42};
int dataRead0[] = {0};
int dataWrite2[N2];
int dataRead2[N2];
const int rank = 2;
const hsize_t offset[] = {0,0};
const hsize_t offset_1[] = {1,0};
Expand All @@ -915,6 +914,9 @@ static testResult_t testDataset_read_write(const hid_t grp)
const hsize_t chunk[] = {1,N2};
TEST(H5I_GROUP==H5Iget_type(grp));

CBF_START_ARRAY(int, dataWrite2, N2);
CBF_START_ARRAY(int, dataRead2, N2);

{/* populate the data */
int i;
for (i = 0; i < N2; ++i) dataWrite2[i] = i*i;
Expand Down Expand Up @@ -1035,6 +1037,9 @@ static testResult_t testDataset_read_write(const hid_t grp)
if (CBF_SUCCESS!=error)
fprintf(stderr,"%s: Error: %s\n",__WHERE__,cbf_strerror(error));

CBF_END_ARRAY(dataRead2);
CBF_END_ARRAY(dataWrite2);

/* free the handle after using it */
cbf_H5Dfree(handle0);
cbf_H5Dfree(handle2);
Expand Down
2 changes: 1 addition & 1 deletion m4/Makefile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,7 @@ $(BIN)/cbf2adscimg: $(LIB)/libcbf.a $(EXAMPLES)/cbf2adscimg.c $(EXAMPLES)/cbf2ad
$(BIN)/cbf_standardize_numbers: $(EXAMPLES)/cbf_standardize_numbers.c $(EXAMPLES)/cbf_standardize_numbers.h
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) -D_SVID_SOURCE $(INCLUDES) $(WARNINGS) \
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@
$(EXAMPLES)/cbf_standardize_numbers.c $(SRC_FGETLN) -L$(LIB) -lcbf $(REGEX_LIBS_STATIC) $(EXTRALIBS) -o $@

#
# changtestcompression example program
Expand Down
17 changes: 12 additions & 5 deletions src/cbf_hdf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -11839,7 +11839,7 @@ _cbf_pilatusAxis2nexusAxisAttrs(h4data,units,depends_on,exsisItem,cmp)

size_t ii, rank, adim;

double oldvec[dimension];
CBF_START_ARRAY(double, oldvec, dimension);

CBF_UNUSED( adim );

Expand Down Expand Up @@ -11880,6 +11880,8 @@ _cbf_pilatusAxis2nexusAxisAttrs(h4data,units,depends_on,exsisItem,cmp)

if (cbf_H5Ivalid(attribid)) H5Aclose(attribid);

CBF_END_ARRAY(oldvec);

return errorcode;

}
Expand Down Expand Up @@ -22090,7 +22092,7 @@ _cbf_pilatusAxis2nexusAxisAttrs(h4data,units,depends_on,exsisItem,cmp)
cbf_debug_print("error: problem getting the rank of a dataset");
error |= CBF_H5ERROR;
} else if (rank > 0) {
hsize_t dims[rank];
CBF_START_ARRAY(hsize_t, dims, rank);
if (rank != H5Sget_simple_extent_dims(data_space,dims,0)) {
cbf_debug_print("error: problem getting the dimensions of a dataset");
error |= CBF_H5ERROR;
Expand All @@ -22105,8 +22107,8 @@ _cbf_pilatusAxis2nexusAxisAttrs(h4data,units,depends_on,exsisItem,cmp)
- assume that it's a uniformly spaced array of pixels in 3D space, so ignore subsequent values
- store it (and dependency chain) in the key, to be converted along with other axes
*/
hsize_t off[rank];
hsize_t cnt[rank];
CBF_START_ARRAY(hsize_t, off, rank);
CBF_START_ARRAY(hsize_t, cnt, rank);
size_t ir;
double disp2[] = {0.,0.};
double factor = 0./0.;
Expand Down Expand Up @@ -22140,7 +22142,10 @@ _cbf_pilatusAxis2nexusAxisAttrs(h4data,units,depends_on,exsisItem,cmp)
free((void*)long_name_string);
cbf_H5Afree(long_name);
}
CBF_END_ARRAY(cnt);
CBF_END_ARRAY(off);
}
CBF_END_ARRAY(dims);
} else {
cbf_debug_print("error: unsupported rank of a 'pixel_offset' field");
error |= CBF_NOTIMPLEMENTED;
Expand Down Expand Up @@ -28873,7 +28878,7 @@ CBF_CALL(CBFM_pilatusAxis2nexusAxisAttrs(h5data,token,"",axisItem,cmp_double,cmp

if (type_class==H5T_STRING) {

char element[type_size+1];
CBF_START_ARRAY(char, element, type_size+1);

size_t ii, jj;;

Expand Down Expand Up @@ -28903,6 +28908,8 @@ CBF_CALL(CBFM_pilatusAxis2nexusAxisAttrs(h5data,token,"",axisItem,cmp_double,cmp

}

CBF_END_ARRAY(element);

} else if (type_class==H5T_INTEGER){

/* Read of a single integer or an integer array of
Expand Down
Loading