Commit 4f1cb33d authored by flechsig's avatar flechsig
Browse files

Merge branch 'uwe'

parents 511c6321 41a4a739
......@@ -443,6 +443,8 @@ record(mbbo, "$(P)$(R)Outputs")
field(TWST, "raw Phase")
field(THVL, "3")
field(THST, "unwrapped Phase")
field(FRVL, "4")
field(FRST, "alpha")
field(PINI, "YES")
}
......@@ -458,6 +460,8 @@ record(mbbi, "$(P)$(R)Outputs_RBV")
field(TWST, "raw Phase")
field(THVL, "3")
field(THST, "unwrapped Phase")
field(FRVL, "4")
field(FRST, "alpha")
field(SCAN, "I/O Intr")
}
......
......@@ -124,6 +124,7 @@ Start the ZMQ server to publish the test image
```
$ source /opt/gfa/python
$ python zmq_server.py sfb_0087.h5
$ python zmq_server.py 190315_jkuf.h5
```
Start the viewer, use Array address 2
......
// File : /afs/psi.ch/user/f/flechsig/git/WFI/src/algorithms.cpp
// Date : <11 Feb 19 10:02:46 flechsig>
// Time-stamp: <14 Mar 19 14:00:41 flechsig>
// Time-stamp: <15 Mar 19 16:57:21 flechsig>
// Author : Flechsig Uwe, uwe.flechsig&#64;psi.&#99;&#104;
#include <iostream>
......@@ -69,6 +69,38 @@ void autorange(double *data, int rows, int cols, int logscale)
cout << ", old (min, max): " << min << ", "<< max << endl;
} // autorange
void calc_alpha(double *data, int rows, int cols, struct ConfigStruct *cs)
{
int row, col, idxc;
double myR0, Dn;
// I do not use cs>R0 I calculate it from 2.18
myR0= cs->d/((cs->p2* cs->eta/cs->p1)- 1.0);
Dn= 1.0/(cs->eta * cs->eta) *cs->eta * cs->talbot_n * cs->p1 * cs->p1/ (2* 1240e-9/ cs->photon_energy);
cout << "calc_alpha: myR0 (m)= "<< myR0 << " cs->R0= " << cs->R0 << endl;
cout << "calc_alpha: Dn (m)= "<< Dn << " cs->d= " << cs->d << endl;
if (cs->direction) // rowdir
{
for (row= 0; row < rows; row++)
for (col= 0; col < cols; col++)
{
idxc= row* cols+ col;
data[idxc]*= row * cs->pixel_size/myR0 + cs->p2/(2* PI* cs->d);
}
} // end rowdir
else // coldir
{
for (row= 0; row < rows; row++)
for (col= 0; col < cols; col++)
{
idxc= row* cols+ col;
data[idxc]*= col * cs->pixel_size/myR0 + cs->p2/(2* PI* cs->d);
}
} // end coldir
} // calc_alpha
// calc a 2d forward i.e. fft(-1) -
// apply fftshift,
......@@ -247,8 +279,6 @@ void evaluf(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_out)
cols= put_in->width;
data= put_out->amp.data; // Array address= 1
// cstp->direction= COLDIR; // evaluate horizontal cuts
switch (cstp->minor) // minor calculation mode
{
case 0: // same as 5
......@@ -507,6 +537,7 @@ void eval1d(double *data, int rows, int cols, struct ConfigStruct *cs, struct Xg
data[idxc]= sqrt(pow(out[row][0], 2)+ pow(out[row][1], 2));
}
} // colloop
fftw_destroy_plan(p1);
fftw_destroy_plan(p2);
fftw_free(in);
......@@ -576,6 +607,11 @@ void eval1d(double *data, int rows, int cols, struct ConfigStruct *cs, struct Xg
put_out->dphi_wrap.copy(&put_out->amp);
unwrap_phase(put_out->amp.data, rows, cols); // call Herra
break;
case 4:
put_out->dphi_wrap.copy(&put_out->amp);
unwrap_phase(put_out->amp.data, rows, cols); // call Herra
calc_alpha(put_out->amp.data, rows, cols, cs);
break;
default:
put_out->dphi_wrap.copy(&put_out->dphi_unwrap);
unwrap_phase(put_out->dphi_unwrap.data, rows, cols);
......@@ -1010,12 +1046,14 @@ void overlay(double *data, int rows, int cols, int center, int width, double val
// read config from json? file filename hardcoded in CONFIGFILENAME
void ReadConfig(struct ConfigStruct *cs)
{
int lines= 0;
int lines= 0, ok= 0;
std::string line, key, value;
//std::string::size_type sz; // alias of size_t
char *pend;
cout << "UF ReadConfig called, filename: " << CONFIGFILENAME << endl;
cout << "****************************************************" << endl;
cout << "UF ReadConfig called, filename: " << CONFIGFILENAME << endl;
cout << "****************************************************" << endl;
// define defaults in case the configfile is not found or values not defined
cs->zeropadding= 19990101;
......@@ -1042,34 +1080,30 @@ void ReadConfig(struct ConfigStruct *cs)
{
if( std::getline(is_line, value) )
{
cout << "(key=val) (" << key << "=" << value << ")" <<endl;
if ( !strcmp("version", key.c_str())) cs->version = strtol(value.c_str(), &pend, 10);
if ( !strcmp("zeropadding", key.c_str())) cs->zeropadding = strtol(value.c_str(), &pend, 10);
if ( !strcmp("mytestdouble", key.c_str())) cs->mytestdouble= strtod(value.c_str(), &pend);
if ( !strcmp("version", key.c_str())) {cs->version = strtol(value.c_str(), &pend, 10); ok++; }
if ( !strcmp("zeropadding", key.c_str())) {cs->zeropadding = strtol(value.c_str(), &pend, 10); ok++; }
if ( !strcmp("mytestdouble", key.c_str())) {cs->mytestdouble = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("d", key.c_str())) {cs->d = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("eta", key.c_str())) {cs->eta = strtol(value.c_str(), &pend, 10); ok++; }
if ( !strcmp("p1", key.c_str())) {cs->p1 = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("p2", key.c_str())) {cs->p2 = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("photon_energy", key.c_str())) {cs->photon_energy= strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("pixel_size", key.c_str())) {cs->pixel_size = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("R0", key.c_str())) {cs->R0 = strtod(value.c_str(), &pend); ok++; }
if ( !strcmp("talbot_n", key.c_str())) {cs->talbot_n = strtol(value.c_str(), &pend, 10); ok++; }
}
}
}
//cout << "version: " << cs->version << endl;
cout << "end ReadConfig lines: " << lines << endl;
// UF json cpp did not compile- cant use it
#ifdef TEST
Json::Value root; // starts as "null"; will contain the root value after parsing
std::ifstream config_doc(CONFIGFILENAME, std::ifstream::binary);
config_doc >> root;
// for testing
std::string my_encoding = root.get("my-encoding", "UTF-32" ).asString();
cout << "my_encoding= " << my_encoding << endl;
const Json::Value my_plugins = root["my-plug-ins"];
cout << "my_plugins= " << my_plugins << endl;
for ( int index = 0; index < my_plugins.size(); ++index ) // Iterates over the sequence elements.
cout << "plugin " << index << " : " << my_plugins[index].asString() << endl;
cout << "my-indent " << root["my-indent"].get("length", 3).asInt() << endl;
cout << "my-indent " << root["my-indent"].get("use_space", true).asBool() << endl;
#endif
cout << "parse line " << lines << " >>" << line << "<<, valid: " << ok << endl; // for debugging
} // while line
cout << "version: " << cs->version << endl;
cout << "photon_energy: " << cs->photon_energy << endl;
cout << "end ReadConfig lines: " << lines << " valid: " << ok << endl;
cout << "****************************************************" << endl;
} // ReadConfig
// end algorithms.cpp
/* File : /afs/psi.ch/user/f/flechsig/git/WFI/src/algorithms.h */
/* Date : <11 Feb 19 10:03:58 flechsig> */
/* Time-stamp: <14 Mar 19 11:03:35 flechsig> */
/* Time-stamp: <15 Mar 19 16:12:13 flechsig> */
/* Author : Flechsig Uwe, uwe.flechsig&#64;psi.&#99;&#104; */
#ifndef ALGORITMS_H
......@@ -14,7 +14,8 @@
#define ROWDIR 1
#ifndef CONFIGFILENAME
#define CONFIGFILENAME "/tmp/XGI_config.conf"
#define CONFIGFILENAME "/tmp/XGI_config.conf"
// #define CONFIGFILENAME "/afs/psi.ch/user/f/flechsig/git/WFI/test/XGI_config.conf"
#endif
// configuration structure type
......@@ -30,12 +31,20 @@ struct ConfigStruct {
int width;
int zeropadding;
double mytestdouble;
double R0; // design wavefront radius of curvature in m
double d; // distance between gratings in m
double photon_energy; // in eV
double eta; // SR page 23 eta = 1 for pi/2 phase shifting grating or amplitude grating; eta=2 for pi .. grating
int talbot_n; // fractional talbot order
double p1, p2; // grating pitch in m
double pixel_size; // in m
};
// procedure prototypes
bool is_file_exist(const char *);
double linreg(int, double *, double *, double *, double *);
void autorange(double *, int, int, int);
void calc_alpha(double *, int, int, struct ConfigStruct *);
void eval1d(double *, int, int, struct ConfigStruct *, struct Xgi_out *);
void eval1d_zp(double *, int, int, struct ConfigStruct *, struct Xgi_out *);
void evalfft2d(Matrix *, struct ConfigStruct *, struct Xgi_out *);
......
clean:
rm core.*
install:
cp XGI_config.conf /tmp
\ No newline at end of file
# -*-sh-*-
# simple config file using key=val syntax and comments !! no whitespace !!
version=20190314 # the date
zeropadding=3
heinz=
mytestdouble=3.14
photon_energy=9000.0 # eV
eta=2 # pi shifting phase grating
talbot_n=11 # talbot order
p1=3.75e-6 # m
p2=2e-6 # m
pixel_size=2.86e-6 # m from Yves- not calibrated again
R0=99 # m
d=0.144 # m
drrrr=0.55 # m
# end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment