03-26-2020 10:40 AM
@RavensFan wrote:
How do you evaluate (inputfile >> E1 >> C1) and
outputfile << E2 << " "<< C2 << endl;
My understanding is that >> and << mean right and left shifts. But that doesn't make sense in the context those operators were used in the program.
std::ostream overloads these operators for file I/O. It's basically move it into the file or out of the file.
The "outputfile << E2 << " " << C2 << endl;" gives something like a string constructed by appending all the elements (effectively from right to left).
Technically they produce a stringstream and take a stringstream as arguments, so it's something like outfile << (E2 << ( " " << ( C2 << std::endl; ) ) ); where each bracket pair produces a valid input to the next leftmost element. See http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/ if you care to read more. Or just use LabVIEW and happily forget about it all 🙂
03-26-2020 10:45 AM - edited 03-26-2020 10:48 AM
Here's my "best effort" attempt at your code.
But I don't get exactly the same values as yours for the first case, and not at all for the most recent input/output pair.
The 11 spaces is a little problematic reading the file - it seems a bit arbitrary (although of course it can be handled, it's a little strange).
Is it some sort of tab -> space issue with some editor?
Edit: looking at your recently uploaded .C file I think probably I'll get the same results as you for the first page if I change the "B" value - in your original code you gave 1.0006, but in your .c file you have 1.00027. I'm guessing that might be enough (at least in the first case).
03-26-2020 10:56 AM - edited 03-26-2020 11:05 AM
Yes, looks mostly like some kind of resampling assuming a slight nonlinearity in the x-scale.
Even if I assume linear scales and double the Y, I get pretty close. (maybe within noise!?)
So all you probably need to add are a few nonlinear tweaks based on your values.
03-26-2020 12:57 PM
@cbutcher wrote:
....... Or just use LabVIEW and happily forget about it all 🙂
I like that answer.
That << usage in this case seems like some arcane syntax where there is are much more commonly used methods to get the same end result.
03-26-2020 07:22 PM
Actually, there is no constant algorithm for this calculation.
What I want to do is make a re-binning process for the energy axes (column 1), to compress it from around 1 keV interval to be 2 keV or more interval. the goal of this process is to increase the results statics because the measurement time is too short and with the current conditions the noise of the spectrum will be so high.
this is my idea and I already use it before in my work.
but I get the general ideas from the attached paper. you will find it clear on page 2.
for your information, I modified this idea to be the code that I shared with you.
about the distances between the column, it is not so important. I can control it easy or change it to "," or deny interval. or we can change the input file to be .xls file in 2 columns.
03-26-2020 07:32 PM
your current LabVIEW version is later than mien, can you please share it again with me! .. i am used LabVIEW 2018
03-26-2020 07:52 PM
03-26-2020 08:15 PM
It is a very smart idea, I will modify it to match the expected results.
really great effort 😊