diff --git a/plugins/milk-extra-src/linalgebra/MVMextractModes.c b/plugins/milk-extra-src/linalgebra/MVMextractModes.c index b5480dd1..df901779 100644 --- a/plugins/milk-extra-src/linalgebra/MVMextractModes.c +++ b/plugins/milk-extra-src/linalgebra/MVMextractModes.c @@ -323,14 +323,15 @@ static errno_t compute_function() // CONNECT TO MASK STREAM int use_mask = 0; //flag indicating that the mask is being used uint32_t mask_npix = 0; //The number of 1 pixels in the mask - uint32_t * mask_idx = NULL; //Array holding the indices of the 1 pixels - float * masked_pix = NULL; //Array to hold the pixel values + uint32_t *mask_idx = NULL; //Array holding the indices of the 1 pixels + float *masked_pix = NULL; //Array to hold the pixel values IMGID imgmask = mkIMGID_from_name(inmasksname); if(resolveIMGID(&imgmask, ERRMODE_WARN) != -1) { printf("Mask stream size : %u %u\n", imgmask.md->size[0], imgmask.md->size[1]); - if(imgmask.md->size[0] == imgin.md->size[0] && imgmask.md->size[1] == imgin.md->size[1]) + if(imgmask.md->size[0] == imgin.md->size[0] + && imgmask.md->size[1] == imgin.md->size[1]) { use_mask = 1; } @@ -344,7 +345,7 @@ static errno_t compute_function() // if(use_mask) { - for(long n=0; n < imgmask.md->size[0]*imgmask.md->size[1]; ++n) + for(long n = 0; n < imgmask.md->size[0]*imgmask.md->size[1]; ++n) { if(imgmask.im->array.F[n] == 1) { @@ -352,10 +353,10 @@ static errno_t compute_function() } } - mask_idx = (uint32_t *) malloc( mask_npix * sizeof(long)); - masked_pix = (float *) malloc( mask_npix * sizeof(float)); + mask_idx = (uint32_t *) malloc(mask_npix * sizeof(long)); + masked_pix = (float *) malloc(mask_npix * sizeof(float)); long nn = 0; - for(long n=0; n < imgmask.md->size[0]*imgmask.md->size[1]; ++n) + for(long n = 0; n < imgmask.md->size[0]*imgmask.md->size[1]; ++n) { if(imgmask.im->array.F[n] == 1) { @@ -364,13 +365,15 @@ static errno_t compute_function() } } - printf("Mask has : %u pixels (%f%%)\n", mask_npix, (100.0*mask_npix)/(imgmask.md->size[0]*imgmask.md->size[1])); + printf("Mask has : %u pixels (%f%%)\n", mask_npix, + (100.0 * mask_npix) / (imgmask.md->size[0]*imgmask.md->size[1])); } else { //Just use full image - mask_npix = imgin.md->size[0]*imgin.md->size[1]; - printf("No mask using : %u pixels (%f%%)\n", mask_npix, (100.0*mask_npix)/(imgin.md->size[0]*imgin.md->size[1])); + mask_npix = imgin.md->size[0] * imgin.md->size[1]; + printf("No mask using : %u pixels (%f%%)\n", mask_npix, + (100.0 * mask_npix) / (imgin.md->size[0]*imgin.md->size[1])); } @@ -424,7 +427,12 @@ static errno_t compute_function() IMGID imgmodes = mkIMGID_from_name(immodes); resolveIMGID(&imgmodes, ERRMODE_ABORT); - + // Could this be IMGIDcompare? + if(imgmodes.md->datatype != _DATATYPE_FLOAT) + { + PRINT_ERROR("Cannot operate with modes other than FP32!!!s"); + abort(); + } printf("Modes stream size : %u %u\n", imgmodes.md->size[0], @@ -551,7 +559,7 @@ static errno_t compute_function() IMGID imgout = stream_connect_create_2Df32(outcoeff, arraytmp[0], arraytmp[1]); // Local working copy of output - float *outarray = (float*) malloc(sizeof(float) * arraytmp[0] * arraytmp[1]); + float *outarray = (float *) malloc(sizeof(float) * arraytmp[0] * arraytmp[1]); @@ -638,22 +646,25 @@ static errno_t compute_function() fflush(stdout); long matsz; - float * modesmat; + float *modesmat; if(use_mask) { //reformat the matrix using the mask matsz = mask_npix * NBmodes; - modesmat = (float *) malloc(sizeof(float)*mask_npix * data.image[IDmodes].md->size[2]); + modesmat = (float *) malloc(sizeof(float) * mask_npix * + data.image[IDmodes].md->size[2]); uint32_t nrows = data.image[IDmodes].md->size[2]; - uint32_t ncols = data.image[IDmodes].md->size[0]*data.image[IDmodes].md->size[1]; + uint32_t ncols = data.image[IDmodes].md->size[0] * + data.image[IDmodes].md->size[1]; for(uint32_t rr = 0; rr < nrows; ++rr) { for(uint32_t cc = 0; cc < mask_npix; ++cc) { - modesmat[rr*mask_npix + cc] = data.image[IDmodes].array.F[rr*ncols + mask_idx[cc]]; + modesmat[rr * mask_npix + cc] = data.image[IDmodes].array.F[rr * ncols + + mask_idx[cc]]; } } } @@ -964,17 +975,18 @@ static errno_t compute_function() } - float * imginfloatptr = NULL; + float *imginfloatptr = NULL; - if( imgin.md->datatype == _DATATYPE_FLOAT ) + if(imgin.md->datatype == _DATATYPE_FLOAT) { imginfloatptr = imgin.im->array.F; printf("INPUT type = FLOAT - no type conversion required\n"); } else { - imginfloatptr = (float*) malloc(sizeof(float) * imgin.md->size[0] * imgin.md->size[1] ); + imginfloatptr = (float *) malloc(sizeof(float) * imgin.md->size[0] * + imgin.md->size[1]); printf("INPUT not float -> type conversion to float enabled\n"); } @@ -1014,72 +1026,72 @@ static errno_t compute_function() - if( imgin.md->datatype != _DATATYPE_FLOAT ) + if(imgin.md->datatype != _DATATYPE_FLOAT) { imginfloatptr = imgin.im->array.F; // type conversion (if needed) - switch (imgin.md->datatype ) + switch(imgin.md->datatype) { case _DATATYPE_DOUBLE: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.D[ii]; } break; case _DATATYPE_UINT8: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.UI8[ii]; } break; case _DATATYPE_INT8: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.SI8[ii]; } break; case _DATATYPE_UINT16: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.UI16[ii]; } break; case _DATATYPE_INT16: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.SI16[ii]; } break; case _DATATYPE_UINT32: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.UI32[ii]; } break; case _DATATYPE_INT32: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.SI32[ii]; } break; case _DATATYPE_UINT64: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.UI64[ii]; } break; case _DATATYPE_INT64: - for(int ii=0; iisize[0] * imgin.md->size[1]; ii++) + for(int ii = 0; ii < imgin.md->size[0] * imgin.md->size[1]; ii++) { imginfloatptr[ii] = (float) imgin.im->array.SI64[ii]; } @@ -1322,7 +1334,7 @@ static errno_t compute_function() free(modevalarrayref); - if( imgin.md->datatype != _DATATYPE_FLOAT ) + if(imgin.md->datatype != _DATATYPE_FLOAT) { free(imginfloatptr); } diff --git a/src/COREMOD_memory/fps_list.c b/src/COREMOD_memory/fps_list.c index 3bba9c8f..bcf25d8a 100644 --- a/src/COREMOD_memory/fps_list.c +++ b/src/COREMOD_memory/fps_list.c @@ -91,8 +91,7 @@ errno_t fps_list() if(strstr(de->d_name, ".fps.shm") != NULL) { char fpsname[100]; - int slen = strlen(de->d_name); - int slen1 = slen - strlen(".fps.shm"); + int slen1 = 100 - strlen(".fps.shm"); strncpy(fpsname, de->d_name, slen1); fpsname[slen1] = '\0'; diff --git a/src/COREMOD_memory/logshmim.c b/src/COREMOD_memory/logshmim.c index b0a2ecb3..7f72eae8 100644 --- a/src/COREMOD_memory/logshmim.c +++ b/src/COREMOD_memory/logshmim.c @@ -566,9 +566,19 @@ static errno_t compute_function() IMGID inimg = mkIMGID_from_name(streamname); resolveIMGID(&inimg, ERRMODE_ABORT); + if(inimg.md->naxis == 3) + { + PRINT_ERROR("streamFITSlog with 3D data is NOT supported"); + } + uint32_t xsize = inimg.md->size[0]; uint32_t ysize = inimg.md->size[1]; + if(inimg.md->naxis == 1) + { + ysize = 1; // For 1D data, it's likely size[1] is initialized to 0, which will cause trouble. + } uint32_t zsize = (*cubesize); + uint8_t datatype = inimg.md->datatype; diff --git a/src/COREMOD_memory/stream_pixmapdecode.c b/src/COREMOD_memory/stream_pixmapdecode.c index c9efbba9..e96dc2c3 100644 --- a/src/COREMOD_memory/stream_pixmapdecode.c +++ b/src/COREMOD_memory/stream_pixmapdecode.c @@ -346,7 +346,7 @@ imageID COREMOD_MEMORY_PixMapDecode_U( while(loopOK == 1) { loopOK = processinfo_loopstep(processinfo); - printf("cnt0: %ld; loopOK %d\n", data.image[IDin].md[0].cnt0, loopOK); + //printf("cnt0: %ld; loopOK %d\n", data.image[IDin].md[0].cnt0, loopOK); fflush(stdout); if(data.image[IDin].md[0].sem == 0) @@ -435,12 +435,12 @@ imageID COREMOD_MEMORY_PixMapDecode_U( if(slice == NBslice - 1) { - COREMOD_MEMORY_image_set_sempost_byID(IDout, -1); - data.image[IDout].md[0].cnt0++; + processinfo_update_output_stream(processinfo, IDout); } data.image[IDout].md[0].cnt1 = slice; + // Whatever hacks these are to manage slicey business? semval = ImageStreamIO_semvalue(data.image + IDout, 2); if(semval < SEMAPHORE_MAXVAL) {