libatomprobe
Library for Atom Probe Tomography (APT) computation
dataFiles.h
Go to the documentation of this file.
1 /*
2  * dataFiles.h : atom probe data file loading header
3  * Copyright (C) 2014 Daniel Haley
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef ATOMPROBE_FILES_H
20 #define ATOMPROBE_FILES_H
21 #include <vector>
22 #include <atomic>
23 //Include for C99 fixed-width data types
24 #include <inttypes.h>
25 
27 
28 namespace AtomProbe {
29 
30 using std::vector;
31 
32 //Enum for error codes for epos reader
33 //Error strings can be extracted using RECORDREAD_ERR_STRINGS[enum value]
34 enum
35 {
43 };
44 extern const char *RECORDREAD_ERR_STRINGS[];
45 
46 inline const char *getRecordReadErrString(unsigned int errCode) { return RECORDREAD_ERR_STRINGS[errCode];};
47 
48 
49 enum
50 {
58 };
59 
60 enum
61 {
65 };
66 
67 typedef struct ATO_ENTRY
68 {
69  float x,y,z;//Nominally in Angstrom
70  float mass; //Nominally in Da/e
71  //Ignore cluster-id as redundant, can be re-computed quickly
72  float approxPulse;
73  float voltage; //standing voltage, in V
74  float tof; //Time of flight in us. May or may not be corrected from raw
75  float detectorX,detectorY; //In cm
76  float pulseVoltage;
77 } ATO_ENTRY;
78 
80 extern const char *ATO_ERR_STRINGS[];
81 
82 inline const char *getAtoErrString(unsigned int errCode) { return ATO_ERR_STRINGS[errCode];};
83 
85 
100 unsigned int loadPosFile(std::vector<IonHit> &posIons, const char *posFile);
101 
102 
104 
109 unsigned int loadPosFile(std::vector<IonHit> &posIons,
110  const char *posFile, unsigned int nSamplesMax);
111 
112 
113 //Convert the error code returned from loadPosFile into a human-readable message
114 const char *getPosFileErrString(unsigned int errMesg);
115 
117 
121 unsigned int savePosFile(const std::vector<Point3D> &points, float mass, const char *name,bool append=false);
122 
124 unsigned int savePosFile(const std::vector<IonHit> &data, const char *name,bool append=false);
125 
127 
131 unsigned int saveTapsimBin(const std::vector<IonHit> &posIons,std::ostream &f);
133 
135 unsigned int saveTapsimBin(const std::vector<IonHit> &posIons, const char *filename);
136 
138 
144 size_t loadEposFile(std::vector<EPOS_ENTRY> &outData,const char *filename );
145 
147 
161 size_t chunkLoadEposFile(std::vector<EPOS_ENTRY> &outData, const char *filename,
162  unsigned int chunkSize, unsigned int chunkOffset, unsigned int &nEntriesLeft);
163 
164 
166 
178 unsigned int loadTextData(const char *cpFilename,
179  std::vector<std::vector<float> > &dataVec,std::vector<std::string> &headerVec,
180  const char *delim="\t,", bool allowNan=true,bool allowConvFails=false,unsigned int headerCount=-1);
181 
183 enum
184 {
207 };
208 
209 extern const char *OPS_ENUM_ERRSTRINGS[];
210 
213 {
215  float x,y;
217  float tof;
218 };
219 
222 {
226  float voltage;
228  float pulseVolt;
230  //For some reason, OPS files seem to have duplicate beta data
231  float beta;
232 };
233 
235 /* See 10.1063/1.2709758 for the details of the correction paramters.
236 */
238 {
240  float flightPath;
242  float alpha;
244  float beta;
246  float tZero;
250  unsigned int detectorChannels;
251 };
252 
255 {
259  std::vector<::std::vector<SINGLE_HIT> > eventData;
261  std::vector<VOLTAGE_DATA> voltageData;
263  std::vector<unsigned long long> eventPulseNumber;
264 };
265 
267 
275 unsigned int readPosapOps(const char *file,
276  THREEDAP_EXPERIMENT &data,
277  unsigned int &badLine, unsigned int &progress,
278  std::atomic<bool> &wantAbort,
279  unsigned int nDelayLines=2,bool strictMode=false);
280 
282 
294 unsigned int loadATOFile(const char *fileName,
295  std::vector<ATO_ENTRY> &ions, unsigned int forceEndian=0);
296 }
297 
298 
299 #endif
const char * RECORDREAD_ERR_STRINGS[]
Definition: dataFiles.cpp:82
float flightPath
The flight path to the virtual (or real) projected tip image.
Definition: dataFiles.h:240
Definition: dataFiles.h:67
float voltage
Standing Voltage applied to specimen (V)
Definition: dataFiles.h:226
const char * OPS_ENUM_ERRSTRINGS[]
Definition: dataFiles.cpp:776
float approxPulse
Definition: dataFiles.h:72
const char * getPosFileErrString(unsigned int errMesg)
Definition: dataFiles.cpp:238
float pulseVoltage
Definition: dataFiles.h:76
unsigned int loadATOFile(const char *fileName, std::vector< ATO_ENTRY > &ions, unsigned int forceEndian=0)
Load a LAWATAP "ATO" file.
Definition: dataFiles.cpp:1212
Data structure that contains the experiment information present in a 3Dap file.
Definition: dataFiles.h:254
float detectorY
Definition: dataFiles.h:75
unsigned int saveTapsimBin(const std::vector< IonHit > &posIons, std::ostream &f)
Write a tapsim file from a vector of IonHits.
Definition: dataFiles.cpp:667
const char * ATO_ERR_STRINGS[]
Human readable error messages for use with ATO reader return values.
Definition: dataFiles.cpp:73
THREEDAP_DATA params
Experiment parameters.
Definition: dataFiles.h:257
float pulseVolt
Pulse voltage applied to specimen (V)
Definition: dataFiles.h:228
size_t loadEposFile(std::vector< EPOS_ENTRY > &outData, const char *filename)
Load an entire "EPOS" File.
Definition: dataFiles.cpp:756
unsigned int loadTextData(const char *cpFilename, std::vector< std::vector< float > > &dataVec, std::vector< std::string > &headerVec, const char *delim="\", bool allowNan=true, bool allowConvFails=false, unsigned int headerCount=-1)
Load a CSV, TSV or similar text file. Assumes "C" Locale for input (ie "." as decimal separator)...
Definition: dataFiles.cpp:1504
unsigned int detectorChannels
The number of channels on the detector.
Definition: dataFiles.h:250
float y
Definition: dataFiles.h:69
unsigned int savePosFile(const std::vector< Point3D > &points, float mass, const char *name, bool append=false)
Save a vector of Point3Ds into a pos file, using a fixed mass, return nonzero on error.
Definition: dataFiles.cpp:499
float mass
Definition: dataFiles.h:70
std::vector< VOLTAGE_DATA > voltageData
Voltage information.
Definition: dataFiles.h:261
unsigned int readPosapOps(const char *file, THREEDAP_EXPERIMENT &data, unsigned int &badLine, unsigned int &progress, std::atomic< bool > &wantAbort, unsigned int nDelayLines=2, bool strictMode=false)
Function to read POSAP "OPS" files.
Definition: dataFiles.cpp:805
std::vector<::std::vector< SINGLE_HIT > > eventData
vector of event vectors. Each interior event vector describes a group of hits on one pulse ...
Definition: dataFiles.h:259
unsigned int loadPosFile(std::vector< IonHit > &posIons, const char *posFile)
Load a pos file directly into a single ion list.
Definition: dataFiles.cpp:256
float tZero
Time offset for pulse, in nanoseconds.
Definition: dataFiles.h:246
float detectorRadius
The size of the detector, in mm.
Definition: dataFiles.h:248
float alpha
Pulse coupling coefficient (1 of 2)
Definition: dataFiles.h:242
float beta
Pulse coupling coefficient (2 of 2)
Definition: dataFiles.h:244
float tof
Definition: dataFiles.h:74
float tof
Reported time of flight.
Definition: dataFiles.h:217
float voltage
Definition: dataFiles.h:73
struct AtomProbe::ATO_ENTRY ATO_ENTRY
float detectorX
Definition: dataFiles.h:75
Single 3DAP hit event.
Definition: dataFiles.h:212
float beta
Coupling coefficient to specimen.
Definition: dataFiles.h:231
float x
Definition: dataFiles.h:69
experimental setup data
Definition: dataFiles.h:237
unsigned int progress
Definition: kd-example.cpp:26
size_t nextHitGroupOffset
FIXME: Document me.
Definition: dataFiles.h:224
std::vector< unsigned long long > eventPulseNumber
The pulse number associated with an event group.
Definition: dataFiles.h:263
const char * getRecordReadErrString(unsigned int errCode)
Definition: dataFiles.h:46
float z
Definition: dataFiles.h:69
const char * getAtoErrString(unsigned int errCode)
Definition: dataFiles.h:82
Voltage data structure – these updates occur periodically during the experiment. ...
Definition: dataFiles.h:221
size_t chunkLoadEposFile(std::vector< EPOS_ENTRY > &outData, const char *filename, unsigned int chunkSize, unsigned int chunkOffset, unsigned int &nEntriesLeft)
Load an "EPOS" file, with a maximum chunk size.
Definition: dataFiles.cpp:765