mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
file name with frame index and detector index
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@303 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
a05631f2c3
commit
f2be1d5fd9
@ -40,8 +40,8 @@ class fileIOStatic {
|
|||||||
|
|
||||||
in case also appends the position index and the two level of scan varaibles with the specified precision
|
in case also appends the position index and the two level of scan varaibles with the specified precision
|
||||||
|
|
||||||
Filenames will be of the form: filepath/filename(_Sy_sw_px)_i
|
Filenames will be of the form: filepath/(dz_)filename(_Sy_sw_px_fv)_i
|
||||||
where y is the scan0 variable, W is the scan 1 variable, x is the position index and i is the run index
|
where z is the detector index, y is the scan0 variable, W is the scan 1 variable, x is the position index, v is the frame index and i is the run index
|
||||||
\param filepath outdir
|
\param filepath outdir
|
||||||
\param filename file root name
|
\param filename file root name
|
||||||
\param aMask action mask (scans, positions)
|
\param aMask action mask (scans, positions)
|
||||||
@ -50,20 +50,53 @@ class fileIOStatic {
|
|||||||
\param sv1 scan variable 1
|
\param sv1 scan variable 1
|
||||||
\param prec1 scan precision 1
|
\param prec1 scan precision 1
|
||||||
\param pindex position index
|
\param pindex position index
|
||||||
\param number of positions
|
\param npos number of positions
|
||||||
\param findex file index
|
\param findex file index
|
||||||
|
\param frameindex frame index
|
||||||
|
\param detindex detector id
|
||||||
\returns file name without extension
|
\returns file name without extension
|
||||||
*/
|
*/
|
||||||
static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex){ \
|
static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \
|
||||||
ostringstream osfn; \
|
ostringstream osfn; \
|
||||||
osfn << filepath << "/" << filename; \
|
osfn << filepath << "/" << filename; \
|
||||||
|
if(detindex!=-1) osfn << "_d"<< detindex; \
|
||||||
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
|
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
|
||||||
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
|
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
|
||||||
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
|
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
|
||||||
|
if(frameindex!=-1) osfn << "_f" << frameindex; \
|
||||||
osfn << "_" << findex; \
|
osfn << "_" << findex; \
|
||||||
return osfn.str(); \
|
return osfn.str(); \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** generates file prefix for receivers without file path, frame index, file index or extension
|
||||||
|
|
||||||
|
in case also appends the position index and the two level of scan varaibles with the specified precision
|
||||||
|
|
||||||
|
File prefix will be of the form: (dz_)filename(_Sy_sw_px_)
|
||||||
|
where z is the detector index, y is the scan0 variable, W is the scan 1 variable and x is the position index
|
||||||
|
\param filename file root name
|
||||||
|
\param aMask action mask (scans, positions)
|
||||||
|
\param sv0 scan variable 0
|
||||||
|
\param prec0 scan precision 0
|
||||||
|
\param sv1 scan variable 1
|
||||||
|
\param prec1 scan precision 1
|
||||||
|
\param pindex position index
|
||||||
|
\param npos number of positions
|
||||||
|
\param detindex detector id
|
||||||
|
\returns file name without extension
|
||||||
|
*/
|
||||||
|
static string createReceiverFilePrefix(char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos,int detindex=-1){ \
|
||||||
|
ostringstream osfn; \
|
||||||
|
osfn << filename; \
|
||||||
|
if(detindex!=-1) osfn << "_d"<< detindex; \
|
||||||
|
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
|
||||||
|
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
|
||||||
|
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
|
||||||
|
return osfn.str(); \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** static function that returns the file index from the file name
|
/** static function that returns the file index from the file name
|
||||||
\param fname file name
|
\param fname file name
|
||||||
\returns file index
|
\returns file index
|
||||||
@ -107,6 +140,8 @@ class fileIOStatic {
|
|||||||
} \
|
} \
|
||||||
else cout << "******************************** cannot parse file index" << endl; \
|
else cout << "******************************** cannot parse file index" << endl; \
|
||||||
uscore=s.rfind("_"); \
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \
|
||||||
p_index=i; \
|
p_index=i; \
|
||||||
s=fname.substr(0,uscore); \
|
s=fname.substr(0,uscore); \
|
||||||
@ -127,6 +162,92 @@ class fileIOStatic {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** static function that returns the variables from the file name
|
||||||
|
\param fname file name
|
||||||
|
\param index reference to index
|
||||||
|
\param f_index reference to frame index
|
||||||
|
\param p_index reference to position index
|
||||||
|
\param sv0 reference to scan variable 0
|
||||||
|
\param sv1 reference to scan variable 1
|
||||||
|
\param detindex reference to detector id
|
||||||
|
\returns file index
|
||||||
|
*/
|
||||||
|
static int getVariablesFromFileName(string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex) { \
|
||||||
|
int i; \
|
||||||
|
double f; \
|
||||||
|
string s; \
|
||||||
|
index=-1; \
|
||||||
|
p_index=-1; \
|
||||||
|
sv0=-1; \
|
||||||
|
sv1=-1; \
|
||||||
|
size_t uscore=fname.rfind("_"); \
|
||||||
|
if (uscore==string::npos) return -1; \
|
||||||
|
s=fname; \
|
||||||
|
if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \
|
||||||
|
index=i; \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
} \
|
||||||
|
else cout << "******************************** cannot parse file index" << endl; \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) { \
|
||||||
|
f_index=i; \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
} \
|
||||||
|
else cout << "******************************** cannot parse frame index" << endl; \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \
|
||||||
|
p_index=i; \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
} \
|
||||||
|
else cout << "******************************** cannot parse position index" << endl; \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \
|
||||||
|
sv1=f; \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
} \
|
||||||
|
else cout << "******************************** cannot parse scan varable 1" << endl; \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \
|
||||||
|
sv0=f; \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
} \
|
||||||
|
else cout << "******************************** cannot parse scan varable 0" << endl; \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) { \
|
||||||
|
detindex=i; \
|
||||||
|
} \
|
||||||
|
else cout << "******************************** cannot parse detector id" << endl; \
|
||||||
|
return index; \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** static function that returns the name variable from the receiver complete file name prefix
|
||||||
|
\param fname complete file name prefix
|
||||||
|
\returns file name
|
||||||
|
*/
|
||||||
|
static string getNameFromReceiverFilePrefix(string fname) { \
|
||||||
|
int i; \
|
||||||
|
double f; \
|
||||||
|
string s; \
|
||||||
|
s=fname; \
|
||||||
|
size_t uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
uscore=s.rfind("_"); \
|
||||||
|
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \
|
||||||
|
s=fname.substr(0,uscore); \
|
||||||
|
return s; \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
writes a data file
|
writes a data file
|
||||||
@ -135,7 +256,7 @@ class fileIOStatic {
|
|||||||
\param data array of data values
|
\param data array of data values
|
||||||
\param err array of arrors on the data. If NULL no errors will be written
|
\param err array of arrors on the data. If NULL no errors will be written
|
||||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
||||||
\param dataformat format of the data: can be 'i' integer or 'f' double (default)
|
\param dataformat format of the data: can be 'i' integer or 'f' double
|
||||||
\returns OK or FAIL if it could not write the file or data=NULL
|
\returns OK or FAIL if it could not write the file or data=NULL
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user