Add fixed iK filtering of raw files

This commit is contained in:
J.-S. Caux 2020-03-19 21:21:54 +01:00
parent 694578be19
commit 4d25d4114e
2 ha cambiato i file con 96 aggiunte e 0 eliminazioni

Vedi File

@ -0,0 +1,34 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: Filter_RAW_File_for_iK.cc
Purpose: produce a .raw file filtered for a specific iK
***********************************************************/
#include "ABACUS.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char* argv[])
{
if (argc != 3) {
cout << "Arguments needed: rawfile, iKneeded." << endl;
ABACUSerror("");
}
const char* rawfilename = argv[1];
int iKneeded = atoi(argv[2]);
Filter_RAW_File_for_iK (rawfilename, iKneeded);
return(0);
}

Vedi File

@ -0,0 +1,62 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: Filter_RAW_File_for_iK.cc
Purpose: for a given RAW file, keep only the momentum iK entries
***********************************************************/
#include "ABACUS.h"
using namespace std;
namespace ABACUS {
void Filter_RAW_File_for_iK (const char ff_file[], int iKneeded)
{
DP omega;
int iK;
DP ff;
DP dev;
string label;
ifstream infile;
infile.open(ff_file);
if (infile.fail()) ABACUSerror("The input file was not opened successfully in Sort_RAW_File. ");
stringstream outfilename;
string outfilename_string;
outfilename << ff_file << "_iK_" << iKneeded;
outfilename_string = outfilename.str();
const char* outfilename_c_str = outfilename_string.c_str();
ofstream outfile;
outfile.open(outfilename_c_str);
outfile.precision(16);
int Ndata = 0;
while ((infile.peek()) != EOF) {
infile >> omega;
infile >> iK;
infile >> ff;
infile >> dev;
infile >> label;
if (iK == iKneeded) outfile << endl << omega << "\t" << iK << "\t" << ff << "\t" << dev << "\t" << label;
}
infile.close();
outfile.close();
return;
}
} // namespace ABACUS