36 #include "Cpeak_interpBiLin.h"
52 std::string class_name, m_peak_name, m_peak_type;
53 std::vector<std::string> m_infos;
55 const char* m_paramPath;
62 m_peak_name = peak_name;
63 class_name=
"Cpeak_factory";
65 m_infos.push_back(
"max");
66 m_infos.push_back(
"interpP");
67 m_infos.push_back(
"interpG");
68 m_infos.push_back(
"interpBiLin");
69 m_infos.push_back(
"barycenter");
87 std::cerr<<class_name<<
"::"<<__func__<<
": error: serial type="<<type<<
" is unknown\n"<<std::flush;
94 pPeak->m_verbose = m_verbose;
100 Cpeak<T>* create(std::string type_name)
103 std::cerr<<class_name<<
"::"<<__func__<<
"(\""<<type_name<<
"\")\n"<<std::flush;
105 if(type_name==m_infos[0])
return create(0);
106 else if(type_name==m_infos[1])
return create(1);
107 else if(type_name==m_infos[2])
return create(2);
108 else if(type_name==m_infos[3])
return create(3);
109 else if(type_name==m_infos[4])
return create(4);
112 std::cerr<<class_name<<
"::"<<__func__<<
": error: grab type="<<type_name<<
" not handled.\n"<<std::flush;
117 Cpeak<T>* create(CParameterNetCDF ¶mFile)
121 std::string attribute;
122 std::string peak_type=
"type";
123 load_attribute(paramFile, peak_type, attribute);
125 if (m_peak_type !=
"none")
127 attribute = m_peak_type;
130 m_peak_type = attribute;
132 return create(attribute);
136 Cpeak<T>* create(
int argc,
char *argv[])
140 commandLine(argc,argv);
146 if(m_paramPath!=
"true")
150 NcFile file(m_paramPath,NcFile::ReadOnly);
151 if(m_verbose){std::cout<<
" --correlator file : "<<m_paramPath<<
"\n";}
154 CParameterNetCDF paramFile;
155 if ( error = paramFile.setFile(&file) !=1 )
157 std::cerr<<
"Error while loading"<<m_paramPath<<
" parameter file"<<std::endl;
162 ppeak = create(paramFile);
164 if (ppeak == NULL){
return NULL;}
172 std::cout<<
" --mesh option : Command line\n";
173 std::cout<<
" --building!!\n";
184 template<
typename Tatt>
185 int load_attribute(CParameterNetCDF ¶mFile, std::string &attribute_name, Tatt &attribute)
189 int error = paramFile.loadAttribute(attribute_name,attribute, &m_peak_name);
195 bool is_parameter_file(NcFile &file)
199 pVar = file.get_var(m_peak_name.c_str());
201 return ((pVar->num_dims())==0);
205 void commandLine(
int argc,
char *argv[])
209 m_paramPath = cimg_option(
"-p",
"./parameters.nc",
"parameter, mesh or true");
211 m_verbose = cimg_option(
"-v",
false,0);
215 printf(
"Mode Verbose\n");
216 printf(
"%s : %s\n",class_name.c_str(),m_paramPath);
221 void stringSplit(std::string manyString, std::vector<std::string> value)
225 char *split=(
char*)(
" ,;");
227 cstr =
new char [manyString.size()+1];
228 strcpy(cstr,manyString.c_str());
229 ptr=strtok(cstr,split);
232 value.push_back(ptr);
233 ptr=strtok(NULL,split);
242 printf(
"\nclass %s\n",class_name.c_str());
243 for (
int i=0; i<m_infos.size(); i++)
246 printf(
"\t(%i) mode : %s\n",i,m_infos[i].c_str());
Definition: Cpeak_interpG.h:42
Definition: Cpeak_interpP.h:42
This class localizes the most important peak within an image, removes it and provide peak statistics...
Definition: Cpeak.h:47
Definition: Cpeak_factory.h:46
Definition: Cpeak_max.h:41
Definition: Cpeak_barycenter.h:43
Definition: Cpeak_interpBiLin.h:43