Skip to content

Commit

Permalink
some cleaning and spec norm func
Browse files Browse the repository at this point in the history
  • Loading branch information
jw-lin committed Oct 19, 2023
1 parent e6b81d4 commit 28eb9bf
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 174 deletions.
22 changes: 22 additions & 0 deletions AOloopControl/examples/scexao-NIRPL-conf/scripts/normspectra
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# add column_sum function to fpsCTRL

source ./scripts/fps-utility

# name of function to setup
fname="norm_spectra"

# add to fpsCTRL, start tmux, start conf, turn on procinfo
setupfps "${fname}"

# procinfo specific stuff
sendFPScmd "setval ${fname}-${CACAO_LOOPNUMBER}.procinfo.triggermode 3"
sendFPScmd "setval ${fname}-${CACAO_LOOPNUMBER}.procinfo.loopcntMax -1"
sendFPScmd "setval ${fname}-${CACAO_LOOPNUMBER}.procinfo.triggersname aol${CACAO_LOOPNUMBER}_imWFS2"

# setting input and output streams
sendFPScmd "setval ${fname}-${CACAO_LOOPNUMBER}.wfsin aol${CACAO_LOOPNUMBER}_imWFS2"
sendFPScmd "setval ${fname}-${CACAO_LOOPNUMBER}.wfsout aol6_imWFS2_norm"

sendFPScmd "confwupdate ${fname}-${CACAO_LOOPNUMBER}"
6 changes: 2 additions & 4 deletions AOloopControl_IOtools/AOloopControl_IOtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
#include "WFScamsim.h"
#include "WFSmap.h"
#include "ao188_preprocessor.h"
#include "pl_trace_renorm.h"
#include "pl_column_sum.h"
#include "extract_spectra.h"
#include "norm_spectra.h"



Expand All @@ -60,9 +59,8 @@ static errno_t init_module_CLI()
CLIADDCMD_AOloopControl_IOtools__WFSmap();
CLIADDCMD_AOloopControl_IOtools__findspots();
CLIADDCMD_AOloopControl_IOtools__AO188Preproc();
CLIADDCMD_AOloopControl_IOtools__PLtracerenorm();
CLIADDCMD_AOloopControl_IOtools__PLcolumnsum();
CLIADDCMD_AOloopControl_IOtools__extractspectra();
CLIADDCMD_AOloopControl_IOtools__normspectra();

// add atexit functions here
// atexit((void*) myfunc);
Expand Down
6 changes: 2 additions & 4 deletions AOloopControl_IOtools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ set(SOURCEFILES
${SRCNAME}.h
acquireWFSim.c
ao188_preprocessor.c
pl_trace_renorm.c
pl_column_sum.c
findspots.c
WFScamsim.c
WFSmap.c
extract_spectra.c
norm_spectra.c
)

set(INCLUDEFILES
${SRCNAME}.h
AOloopControl_IOtools.h
acquireWFSim.h
ao188_preprocessor.h
pl_trace_renorm.h
pl_column_sum.h
findspots.h
WFScamsim.h
WFSmap.h
extract_spectra.h
norm_spectra.h
)


Expand Down
2 changes: 1 addition & 1 deletion AOloopControl_IOtools/extract_spectra.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static errno_t compute_function()
INSERT_STD_FPSCLIfunctions

// Register function in CLI
errno_t CLIADDCMD_AOloopControl_IOtools__extractspectra()
errno_t CLIADDCMD_AOloopControl_IOtools__normpectra()
{

CLIcmddata.FPS_customCONFsetup = customCONFsetup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* @file pl_trace_renorm.c
* @brief acquire and normalize spectra of 3-port PL
* @file norm_spectra.c
* @brief normalize spectra
*
*
*
*/

#include <math.h>
#include "CommandLineInterface/CLIcore.h"
#include "COREMOD_tools/COREMOD_tools.h"

// Local variables pointers
static char *input_shm_name; // input shared memory
Expand All @@ -16,8 +17,8 @@ static long fpi_inputshmname;
static char *output_shm_name; // output shared memory
static long fpi_outputshmname;

static int64_t *compWFSnormalize; // spec norm toggle (lifted this from acquireWFSim.c heh)
static long fpi_compWFSnormalize;
static int64_t *compWFSnormalize; // toggle for normalization
static long fpi_compWFSnormalize;

static CLICMDARGDEF farg[] =
{
Expand All @@ -30,6 +31,15 @@ static CLICMDARGDEF farg[] =
(void **) &input_shm_name,
&fpi_inputshmname
},
{
CLIARG_ONOFF,
".comp.WFSnormalize",
"normalize spectral traces",
"1",
CLIARG_HIDDEN_DEFAULT,
(void **) &compWFSnormalize,
&fpi_compWFSnormalize
},
{
CLIARG_STR,
".wfsout",
Expand All @@ -39,15 +49,6 @@ static CLICMDARGDEF farg[] =
(void **) &output_shm_name,
&fpi_outputshmname
},
{
CLIARG_ONOFF,
".comp.WFSnormalize",
"normalize WFS frames",
"1",
CLIARG_HIDDEN_DEFAULT,
(void **) &compWFSnormalize,
&fpi_compWFSnormalize
},
};

// Optional custom configuration setup.
Expand All @@ -73,7 +74,7 @@ static errno_t customCONFcheck()

static CLICMDDATA CLIcmddata =
{
"spectra_renorm", "normalize spectral traces", CLICMD_FIELDS_DEFAULTS
"norm_spectra", "normalize spectra", CLICMD_FIELDS_DEFAULTS
};


Expand All @@ -93,17 +94,15 @@ static errno_t compute_function()

uint32_t sizeoutx = wfsin.size[0];
uint32_t sizeouty = wfsin.size[1];
uint32_t sizeout = sizeoutx * sizeouty;

// Create output
// trying to copy shape of wfsin. Assume a structure 3 rows x N columns, N goes along wavelength
// Create output, same size as input
IMGID wfsout;
wfsout =
stream_connect_create_2D(output_shm_name, sizeoutx, sizeouty, _DATATYPE_FLOAT);
stream_connect_create_2D(output_shm_name,sizeoutx,sizeouty,_DATATYPE_FLOAT);

// This is the while(True) {
//INSERT_STD_PROCINFO_COMPUTEFUNC_INIT
INSERT_STD_PROCINFO_COMPUTEFUNC_START
INSERT_STD_PROCINFO_COMPUTEFUNC_INIT
INSERT_STD_PROCINFO_COMPUTEFUNC_LOOPSTART
{
// JON YOU GET TO WORK HERE
if(data.fpsptr->parray[fpi_compWFSnormalize].fpflag & FPFLAG_ONOFF) {
Expand All @@ -112,10 +111,17 @@ static errno_t compute_function()
double tot = 0.0;
int i;
for (i = 0; i < sizeoutx; i++) {
tot += wfsin.im->array.F[i*sizeouty+j];
tot += wfsin.im->array.F[j*sizeoutx + i];
}
double normval;
if (tot <= 0){
normval = 0;
}
else {
normval = 1/tot;
}
for (i = 0; i < sizeoutx; i++) {
wfsout.im->array.F[i*sizeouty+j] = wfsin.im->array.F[i*sizeouty+j]/tot;
wfsout.im->array.F[j*sizeoutx + i] = wfsin.im->array.F[j*sizeoutx + i]*normval;
}
}
}
Expand All @@ -124,7 +130,7 @@ static errno_t compute_function()
wfsin.im->array.F,
sizeof(float) * sizeout);
}

// Done and post downstream.
processinfo_update_output_stream(processinfo, wfsout.ID);
}
Expand All @@ -139,7 +145,7 @@ static errno_t compute_function()
INSERT_STD_FPSCLIfunctions

// Register function in CLI
errno_t CLIADDCMD_AOloopControl_IOtools__PLtracerenorm()
errno_t CLIADDCMD_AOloopControl_IOtools__normspectra()
{

CLIcmddata.FPS_customCONFsetup = customCONFsetup;
Expand Down
6 changes: 6 additions & 0 deletions AOloopControl_IOtools/norm_spectra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef AOLOOPCONTROL_IOTOOLS_NORMSPECTRA_H
#define AOLOOPCONTROL_IOTOOLS_NORMSPECTRA_H

errno_t CLIADDCMD_AOloopControl_IOtools__normspectra();

#endif
129 changes: 0 additions & 129 deletions AOloopControl_IOtools/pl_column_sum.c

This file was deleted.

6 changes: 0 additions & 6 deletions AOloopControl_IOtools/pl_column_sum.h

This file was deleted.

6 changes: 0 additions & 6 deletions AOloopControl_IOtools/pl_trace_renorm.h

This file was deleted.

0 comments on commit 28eb9bf

Please sign in to comment.