How to open Tonatiuh output .DAT files in MATLAB?

Hi, I have output files from Tonatiuh ray-tracing software but I am unable to open this file in any other software. I was wondering if there is any way to open it in MATLAB so that I can perform the analysis that I need.
Any help would be appreciate in this regard. This is a binary output file with a .DAT extension. I am unable to uplaod the file here so I am attaching a One-Drive link if anybody wants to have a look.

2 Kommentare

You have to know the format of the file. Do you know that? Otherwise it'll just be a big long string of bytes with no meaning behind them.
venu
venu am 27 Jan. 2024
The format of the file is .dat

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Jan. 2024

0 Stimmen

The binary format used to store the values is Real64 with big-endian byte ordering. The
first value stored in the file is the power per photon in watts (W). This real value
is then followed by seven-tuples of real values, one per photon . Every seven-tuple
holds the following values in the specific order given: * PhotonID * x-coordinate *
y-coordinate * z-coordinate * surface side ( 0 if is back side , 1 if is front side ) *
Previous PhotonID (0 if the photon is the first of a given ray) * Next PhotonID (0 is
the photon is the last of a given ray)
So you would fopen() the file with 'ieee-be' and you would fread() '*double* with size [7 inf] . The result would store tuples running down columns.

16 Kommentare

venu
venu am 28 Jan. 2024
Respected sir,
I am not understanding what is present in binary output file when i was extracted by using matlab code it is containing some numeric values like zeros and some numeric values please help me humble request sir
For the reference i am just attched the output what i have received
[fid, msg] = fopen(FILENAME, 'ieee-be');
if fid < 0
error('failed to open file "%s" because "%s"',, FILENAME, msg);
end
A = fread(fid, [7 inf], '*double');
fclose(fid);
Now the columns of A correspond to the seven-tuples described above.
venu
venu am 29 Jan. 2024
Bearbeitet: venu am 29 Jan. 2024
I am trying to calculate optical efficieny ,number rays receiving the absorber etc,. by using following code but i am getting error can you please help me here by i am sharing pythoncode and .dat and .txt for the reference
venu
venu am 29 Jan. 2024
Respected sir,
when i run the code i am getting the following error
please help me humbel request
FILENAME = '/MATLAB Drive/datfile/xt_1.dat';
[fid, msg] = fopen(FILENAME, 'ieee-be');
if fid < 0
error('failed to open file "%s" because "%s"',, FILENAME, msg);
end
A = fread(fid, [7 inf], '*double');
fclose(fid);
venu
venu am 29 Jan. 2024
Bearbeitet: venu am 29 Jan. 2024
RESPETED SIR
CODE IS NOT RUNNING
NOW I AM GETTING THIS ABOVE ATTACHED ERROR
The data in the file is not in the documented format. My guess is that the format is
  1. x coordinate
  2. y coordinate
  3. z coordinate
  4. previous photon ID
  5. next photon ID
FILENAME = 'sahasra_1.dat';
[fid, msg] = fopen(FILENAME, 'r', 'ieee-be');
if fid < 0
error('failed to open file "%s" because "%s"', FILENAME, msg);
end
Power_per_photon_W = fread(fid, 1, '*double');
A = fread(fid, [5 inf], '*double');
fclose(fid);
venu
venu am 30 Jan. 2024
Respected sir,
I am trying to calculate optical efficieny ,number rays receiving the absorber etc,. by using following code but i am getting error can you please help me here by i am sharing pythoncode and .dat and .txt for the reference
Can you please help me i am really very grateful to you
That is python code. We are not a python resource.
venu
venu am 30 Jan. 2024
Bearbeitet: Walter Roberson am 30 Jan. 2024
Respected sir,
Recently i have found Matlab code for calculating flux and number of rays absorbing the receiveretc.,
But i am unable to find where to give the path for .dat file and .txt file
please kindly help me I am really very very grateful to you sir Sorry for disturbance.
venu
venu am 30 Jan. 2024
Respected sir, Where to give path for.dat and .txt files
Dinfo = dir('*.dat');
Watts_per_photon = 183.19; %adjust as appropriate
[First, Second, Third] = raytrace_function(Dinfo, Watts_per_photon);
venu
venu am 31 Jan. 2024
Respected sir I am tried many ways but i am unable to figure it out where i am making mistake. I don't know weather ask this or not.can we have professional discussion on what's app chat this is my number +91908576416 its my humble request sir. Please accept.
I do not use What's App at all.
venu
venu am 1 Feb. 2024
Bearbeitet: venu am 1 Feb. 2024
Respected sir, I want to calculate optical Efficiency buy using photon mapping .dat for phd thessis your small help really create a lot of confidence in me. Can i send you google invite Link

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Benjamin Thompson
Benjamin Thompson am 27 Jan. 2024

0 Stimmen

fid = fopen('yourfilename.dat', 'r');
A = fread(fid, 'uint8=>uint8');
fclose(fid);
Then the data is in A as bytes. If you know more about the file format you can change the arguments to fread in order to make the result in A easier to use.
doc fread

2 Kommentare

venu
venu am 27 Jan. 2024
Sir can you please help me in binary files
venu
venu am 27 Jan. 2024
Sir i have tried but i am unable to extract data can you please data and send me humble request

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Chemistry finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Jan. 2024

Bearbeitet:

am 1 Feb. 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by