Skip to content

Commit

Permalink
set3Daxes
Browse files Browse the repository at this point in the history
  • Loading branch information
oguyon committed Aug 14, 2024
1 parent 324b6d0 commit f78633b
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ outimres="${inputMSargARRAY[3]}"
milk-all << EOF
loadfits "$immA" modesA
loadfits "$immB" modesB
set3Daxes modesB 0 0 0
linalg.sgemm .GPUdevice ${GPUindex}
linalg.sgemm .transpA 1
linalg.sgemm modesA modesB mcoeff
Expand Down
4 changes: 2 additions & 2 deletions src/COREMOD_arith/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(SOURCEFILES
image_pixunmap.c
image_set_1Dpixrange.c
image_set_2Dpix.c
image_set_axes.c
image_set_3Daxes.c
image_set_col.c
image_set_row.c
image_setzero.c
Expand Down Expand Up @@ -44,7 +44,7 @@ set(INCLUDEFILES
image_pixunmap.h
image_set_1Dpixrange.h
image_set_2Dpix.h
image_set_axes.h
image_set_3Daxes.h
image_set_col.h
image_set_row.h
image_setzero.h
Expand Down
4 changes: 2 additions & 2 deletions src/COREMOD_arith/COREMOD_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#include "image_set_1Dpixrange.h"
#include "image_set_2Dpix.h"
#include "image_set_axes.h"
#include "image_set_3Daxes.h"
#include "image_set_col.h"
#include "image_set_row.h"
#include "image_setzero.h"
Expand Down Expand Up @@ -106,7 +106,7 @@ static errno_t init_module_CLI()

CLIADDCMD_COREMOD_arith__imset_1Dpixrange();
CLIADDCMD_COREMOD_arith__imset_2Dpix();
CLIADDCMD_COREMOD_arith__imset_axes();
CLIADDCMD_COREMOD_arith__imset_3Daxes();
CLIADDCMD_COREMOD_arith__imset_col();
CLIADDCMD_COREMOD_arith__imset_row();
CLIADDCMD_COREMOD_arith__imsetzero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ static CLICMDARGDEF farg[] =

static CLICMDDATA CLIcmddata =
{
"setaxes",
"set image axes size",
"set3Daxes",
"set 3D image axes size",
CLICMD_FIELDS_DEFAULTS
};

Expand All @@ -75,7 +75,7 @@ static errno_t help_function()



errno_t image_set_axes(
errno_t image_set_3Daxes(
IMGID inimg,
uint32_t imsize0,
uint32_t imsize1,
Expand All @@ -88,28 +88,60 @@ errno_t image_set_axes(

long nelem = inimg.md->nelement;

long nelemout = imsize0;
nelemout *= imsize1;
if(imsize2 != 0)
// if size=0, adopt input size




uint32_t imsize0c = imsize0;
if(imsize0 == 0)
{
nelemout *= imsize2;
imsize0c = inimg.md->size[0];
}

if(nelemout == nelem)

uint32_t imsize1c = imsize1;
if(imsize1 == 0)
{
inimg.md->size[0] = imsize0;
inimg.md->size[1] = imsize1;
if(imsize2 == 0)
if (inimg.md->naxis < 2)
{
inimg.md->size[2] = 1;
inimg.md->naxis = 2;
// if 1D image, promote to 3D with size1 = 1
imsize1c = 1;
}
else
{
inimg.md->size[2] = imsize2;
inimg.md->naxis = 3;
imsize1c = inimg.md->size[1];
}
}

uint32_t imsize2c = imsize2;
if(imsize2 == 0)
{
if (inimg.md->naxis < 3)
{
// if 1D or 2D image, promote to 3D with size1 = 1
imsize2c = 1;
}
else
{
imsize2c = inimg.md->size[2];
}
}



long nelemout = imsize0c;
nelemout *= imsize1c;
nelemout *= imsize2c;


if(nelemout == nelem)
{
inimg.md->naxis = 3;
inimg.md->size[0] = imsize0c;
inimg.md->size[1] = imsize1c;
inimg.md->size[2] = imsize2c;
}
else
{
printf("total number of element (%ld) does not match input (%ld) - invalid sizes\n", nelemout, nelem);
Expand All @@ -130,10 +162,9 @@ static errno_t compute_function()
IMGID inimg = mkIMGID_from_name(inimname);
resolveIMGID(&inimg, ERRMODE_ABORT);


INSERT_STD_PROCINFO_COMPUTEFUNC_START
{
image_set_axes(inimg, *size0, *size1, *size2);
image_set_3Daxes(inimg, *size0, *size1, *size2);
processinfo_update_output_stream(processinfo, inimg.ID);

}
Expand All @@ -153,7 +184,7 @@ INSERT_STD_FPSCLIfunctions

// Register function in CLI
errno_t
CLIADDCMD_COREMOD_arith__imset_axes()
CLIADDCMD_COREMOD_arith__imset_3Daxes()
{
INSERT_STD_CLIREGISTERFUNC

Expand Down
13 changes: 13 additions & 0 deletions src/COREMOD_arith/image_set_3Daxes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef COREMOD_MODULE_ARITH_IMSET_3DAXES_H
#define COREMOD_MODULE_ARITH_IMSET_3DAXES_H

errno_t image_set_3Daxes(
IMGID inimg,
uint32_t size0,
uint32_t size1,
uint32_t size2
);

errno_t CLIADDCMD_COREMOD_arith__imset_3Daxes();

#endif
13 changes: 0 additions & 13 deletions src/COREMOD_arith/image_set_axes.h

This file was deleted.

0 comments on commit f78633b

Please sign in to comment.