Page 1 of 1

Reading dst and plt files

Posted: Wed 1 Dec 2021 05:27
by wtam
Dear Didier,

Would you mind sharing any scripts that read .dst and .plt binary files, as described on p.38 of the user's manual?

Best regards,
Wai-Ming

Re: Reading dst and plt files

Posted: Wed 1 Dec 2021 16:45
by Didier
Dear Wai-Ming

I don't get script but 'C' code source, like following to write dst file.

Regards,

Didier

Code: Select all

char cc1=125,cc2=100;
FILE *f

f=fopen(dst_file,"wb");
fwrite(&cc1,sizeof(char),1,f);
fwrite(&cc2,sizeof(char),1,f);
fwrite(&nbr_part,sizeof(int),1,f); // number of particles
fwrite(&Ibeam,sizeof(double),1,f); // bema current (mA)
fwrite(&Freq,sizeof(double),1,f);  // Bunch frequency (MHz)
fwrite(&cc1,sizeof(char),1,f);

for (int i=0;i<nbr_part;i++) {
  fwrite(&Part[i].x,sizeof(double),1,f);  // (cm)
  fwrite(&Part[i].xp,sizeof(double),1,f); // (rad)
  fwrite(&Part[i].y,sizeof(double),1,f);  // (cm)
  fwrite(&Part[i].yp,sizeof(double),1,f); // (rad)
  fwrite(&Part[i].p,sizeof(double),1,f);  // (rad)
  fwrite(&Part[i].w,sizeof(double),1,f);  // MeV
}
fwrite(&Mo,sizeof(double),1,f); // particle mass (MeV)
fclose(f);

Re: Reading dst and plt files

Posted: Mon 13 Dec 2021 08:28
by Abhishek
Dear Didier and Wai-Ming,
I have posted some MATLAB scripts for TraceWin to read .dat file on my webpage with following link,

https://apathakacceleratophysics.zyrosite.com/page-2

I too have a script that can read .plt file. Please let me know if that's needed and I will be happy to help.

With Regards
Abhidhek Pathak

Re: Reading dst and plt files

Posted: Mon 13 Dec 2021 10:21
by Didier
Dear Abhishek,

Thank a lot to share with us. But most of your links are password protected and moreover I don't see any concerning the reading of plt.

Regards,

Didier

Re: Reading dst and plt files

Posted: Mon 13 Dec 2021 10:40
by Abhishek
Dear Didier,
My apologies for the inconvenience caused. Here I am attaching the Matlab scripts reading the .dst and .plt file in a .zip format. The scripts that are attached may require some variable changes like particle number or file name but the architecture remain the same.

Thank you

With Regards
Abhishek Pathak

Re: Reading dst and plt files

Posted: Mon 13 Dec 2021 10:51
by Didier
Dear Abhishek,

Thank you, I am sure it will be very useful for many.

Regards,

Didier

Re: Reading dst and plt files

Posted: Thu 10 Feb 2022 14:17
by yngvelevinsen
Hi Didier,

On this topic, we have a script for reading the plt files in Python, but I was recently made aware that we are not able to read the files with compression. Looking in the manual I do not see how this compression is done. I was wondering therefore if you could provide a similar code snippet to show how you do it?

Re: Reading dst and plt files

Posted: Fri 11 Feb 2022 10:50
by Didier
Dear Abhishek,

I have upgraded the documentation to explain the first 2 levels of compression (page 39), the third and last is not relevant.

Regards,

Didier

Re: Reading dst and plt files

Posted: Fri 4 Mar 2022 17:50
by Abhishek
Dear Didier,
Thank you very much for updating the documentation. I am sure it will be very helpful for all TraceWin users.

With Regards
Abhishek Pathak