mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 08:39:21 +01:00
Added f90Interface used at SLS X04SA
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@269 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
48
slsDetectorSoftware/f90Interface/externPostProcessing.cpp
Normal file
48
slsDetectorSoftware/f90Interface/externPostProcessing.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "externPostProcessing.h"
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <queue>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
int externPostProcessing::InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY)
|
||||
{
|
||||
|
||||
init_dataset(nModules,chPerMod,moduleMask,badChans,ffcoeff,fferr,tDead,angRadius,angOffset,angCentre,totalOffset,binSize,sampleX,sampleY);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int externPostProcessing::finalizeDataset(double ang[], double val[], double err[])
|
||||
{
|
||||
cout<<"Finalize Dataset"<<endl;
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
int addFrame(double data[], double *pos, double *IO, double expTime, const char *filename, int *var=0)
|
||||
{
|
||||
cout<<"Do Processing"<<endl;
|
||||
return 0;
|
||||
};
|
||||
|
||||
int calculateFlatField(int* nModules, int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[])
|
||||
{
|
||||
cout<<"Outputs Flat Field Coefficient and errors from the input data"<<endl;
|
||||
return 0;
|
||||
};
|
||||
65
slsDetectorSoftware/f90Interface/externPostProcessing.h
Normal file
65
slsDetectorSoftware/f90Interface/externPostProcessing.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef EXTERNPOSTPROCESSING_H
|
||||
#define EXTERNPOSTPROCESSING_H
|
||||
|
||||
|
||||
#include "detectorData.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "slsDetectorBase_Standalone.h"
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <queue>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void init_dataset(int *nMod, int *chPerMod, int* modMask, int *badChanMask, double *ffCoeff, double *ffErr, double *tDead, double *angRadius, double *angOffset, double *angCenter, double *totalOff, double *binSize, double * sampleX, double* sampleY);
|
||||
void finalize_dataset(double *outang, double *outval, double *outerr, int *np);
|
||||
void add_frame(double *data, double *pos, double *i0, char *fn, double *var);
|
||||
void calculate_flat_field(int *nMod, int *chPerMod, int *modMask,int *badChanMask, double *data, double *ffc, double *fferr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class externPostProcessing : public virtual slsDetectorBase1
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
externPostProcessing(){};
|
||||
virtual ~externPostProcessing(){};
|
||||
|
||||
|
||||
static int InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY);
|
||||
|
||||
|
||||
|
||||
int finalizeDataset(double ang[], double val[], double err[]);
|
||||
|
||||
int addFrame(double data[], double *pos, double *IO, double expTime, const char *filename, int *var=0);
|
||||
|
||||
int calculateFlatField(int* nModules, int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
171
slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90
Normal file
171
slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90
Normal file
@@ -0,0 +1,171 @@
|
||||
module ax
|
||||
USE,INTRINSIC :: ISO_C_BINDING
|
||||
IMPLICIT NONE
|
||||
integer(C_LONG) :: numberofmodules,totalnumberofchannels
|
||||
real(C_DOUBLE) :: numberofbins
|
||||
real(C_DOUBLE) :: bincenter(360000), binvalue(360000), binerror(360000)
|
||||
|
||||
contains
|
||||
|
||||
|
||||
subroutine initdataset(nmodules, chpmod, modulemask,badchanmask,ffcoeff,fferr,tdead,angradius,angoffset,angcenter, totaloffset, binsize, samplex, sampley) bind(c, name='init_dataset')
|
||||
IMPLICIT NONE
|
||||
integer(C_LONG), intent(IN) :: nmodules, chpmod
|
||||
integer(C_LONG), intent(IN) :: modulemask(nmodules), badchanmask(nmodules*chpmod)
|
||||
real(C_DOUBLE), intent(IN) :: ffcoeff(nmodules*chpmod), fferr(nmodules*chpmod)
|
||||
real(C_DOUBLE), intent(IN) :: tdead, totaloffset,binsize, samplex, sampley
|
||||
real(C_DOUBLE), intent(IN) :: angradius(nmodules), angoffset(nmodules), angcenter(nmodules)
|
||||
integer(C_LONG) :: i
|
||||
|
||||
print*,'init dataset'
|
||||
|
||||
numberofmodules=nmodules
|
||||
|
||||
print*,'Number of modules:'
|
||||
print*,numberofmodules
|
||||
print*,'Channels per module:'
|
||||
print*,chpmod
|
||||
|
||||
totalnumberofchannels=nmodules*chpmod
|
||||
|
||||
print*,'Total number of channels:'
|
||||
print*,totalnumberofchannels
|
||||
|
||||
|
||||
print*,'Modulemask:'
|
||||
do i=1,nmodules
|
||||
print*,i,modulemask(i)
|
||||
enddo
|
||||
|
||||
print*,'Badchannelmask:'
|
||||
do i=1,nmodules*chpmod
|
||||
print*,i,badchanmask(i)
|
||||
enddo
|
||||
|
||||
print*,'Flat field coefficients:'
|
||||
do i=1,nmodules*chpmod
|
||||
print*,i,ffcoeff(i),'+-',fferr(i)
|
||||
enddo
|
||||
|
||||
print*,'Tdead:'
|
||||
print*,tdead
|
||||
|
||||
|
||||
print*,'Angular conversion coefficients:'
|
||||
do i=1,nmodules
|
||||
print*,i,angradius(i),angoffset(i),angcenter(i)
|
||||
enddo
|
||||
|
||||
|
||||
print*,'Total offset:'
|
||||
print*,totaloffset
|
||||
|
||||
print*,'Bin size:'
|
||||
print*,binsize
|
||||
|
||||
numberofbins=360./binsize
|
||||
|
||||
|
||||
print*,'Sample displacement:'
|
||||
print*,samplex, sampley
|
||||
|
||||
end subroutine initdataset
|
||||
|
||||
|
||||
|
||||
subroutine resetdataset() bind(c, name='resetDataset')
|
||||
IMPLICIT NONE
|
||||
|
||||
print*,'reset dataset'
|
||||
|
||||
|
||||
end subroutine resetdataset
|
||||
|
||||
|
||||
subroutine finalizedataset(outang, outval, outerr, outnpoints) bind(c, name='finalize_dataset')
|
||||
IMPLICIT NONE
|
||||
integer(C_LONG), intent(OUT) :: outnpoints
|
||||
real(C_DOUBLE), intent(OUT) :: outang(*), outval(*), outerr(*)
|
||||
integer(C_LONG) :: i
|
||||
|
||||
print*,'finalize dataset'
|
||||
|
||||
outnpoints=numberofbins
|
||||
|
||||
print*,'returning points:'
|
||||
do i=1,numberofbins
|
||||
|
||||
outang(i)=i;
|
||||
outval(i)=i*100;
|
||||
outerr(i)=i*0.1
|
||||
|
||||
print*,i,outang(i),outval(i),outerr(i)
|
||||
enddo
|
||||
|
||||
end subroutine finalizedataset
|
||||
|
||||
|
||||
|
||||
subroutine addframe(data, pos, i0, fname, var) bind(c, name='add_frame')
|
||||
IMPLICIT NONE
|
||||
real(C_DOUBLE), intent(IN) :: data(totalnumberofchannels)
|
||||
real(C_DOUBLE), intent(IN) :: pos, i0, var
|
||||
character(kind=c_char), dimension(*), intent(IN) :: fname
|
||||
integer :: l
|
||||
integer :: i
|
||||
|
||||
l=0
|
||||
do
|
||||
if (fname(l+1) == C_NULL_CHAR) exit
|
||||
l = l + 1
|
||||
end do
|
||||
|
||||
|
||||
print*,'add frame'
|
||||
|
||||
print*,'Filename: '
|
||||
print*,fname(1:l)
|
||||
|
||||
print*,'Position: '
|
||||
print*,pos
|
||||
|
||||
print*,'I0: '
|
||||
print*,i0
|
||||
|
||||
print*,'Var: '
|
||||
print*,var
|
||||
|
||||
print*,'Data: '
|
||||
print*,data
|
||||
|
||||
|
||||
end subroutine addframe
|
||||
|
||||
|
||||
|
||||
subroutine calculateflatfield(nmodules, chpmod, modulemask, badchanmask,data, ffcoeff,fferr) bind(c, name='calculate_flat_field')
|
||||
|
||||
IMPLICIT NONE
|
||||
integer(C_LONG), intent(IN) :: nmodules, chpmod
|
||||
integer(C_LONG), intent(IN) :: modulemask(nmodules), badchanmask(nmodules*chpmod)
|
||||
real(C_DOUBLE), intent(IN) :: data(nmodules*chpmod)
|
||||
real(C_DOUBLE), intent(OUT) :: ffcoeff(*),fferr(*)
|
||||
integer(C_LONG) :: i
|
||||
|
||||
real(C_DOUBLE) :: ave;
|
||||
|
||||
print*,'calculate flat field'
|
||||
|
||||
do i=1,nmodules*chpmod
|
||||
ffcoeff(i)=data(i)*10.
|
||||
fferr(i)=i
|
||||
print*,i,data(i), ffcoeff(i),fferr(i)
|
||||
enddo
|
||||
|
||||
|
||||
|
||||
|
||||
end subroutine calculateflatfield
|
||||
|
||||
|
||||
end module ax
|
||||
Reference in New Issue
Block a user