Reading dst and plt files

https://www.dacm-logiciels.fr/tracewin
Post Reply
United States of Americawtam
Skilled
Skilled
Posts: 111
Joined: Mon 7 Dec 2020 06:17
Location: Boston
Country:
United States of America (us)
United States of America

Reading dst and plt files

Post by United States of Americawtam »

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
User avatar
FranceDidier
Administrator
Administrator
Posts: 976
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: Reading dst and plt files

Post by FranceDidier »

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);
United States of AmericaAbhishek
Initiated
Initiated
Posts: 46
Joined: Sun 12 Dec 2021 00:44
Country:
United States of America (us)
United States of America

Re: Reading dst and plt files

Post by United States of AmericaAbhishek »

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
User avatar
FranceDidier
Administrator
Administrator
Posts: 976
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: Reading dst and plt files

Post by FranceDidier »

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
United States of AmericaAbhishek
Initiated
Initiated
Posts: 46
Joined: Sun 12 Dec 2021 00:44
Country:
United States of America (us)
United States of America

Re: Reading dst and plt files

Post by United States of AmericaAbhishek »

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
Attachments
dst and plt reader.zip
(1.55 KiB) Downloaded 200 times
User avatar
FranceDidier
Administrator
Administrator
Posts: 976
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: Reading dst and plt files

Post by FranceDidier »

Dear Abhishek,

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

Regards,

Didier
Norwayyngvelevinsen
Initiated
Initiated
Posts: 34
Joined: Fri 5 Mar 2021 10:40
Location: ESS, Sweden
Country:
Norway (no)
Norway

Re: Reading dst and plt files

Post by Norwayyngvelevinsen »

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?
User avatar
FranceDidier
Administrator
Administrator
Posts: 976
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: Reading dst and plt files

Post by FranceDidier »

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
United States of AmericaAbhishek
Initiated
Initiated
Posts: 46
Joined: Sun 12 Dec 2021 00:44
Country:
United States of America (us)
United States of America

Re: Reading dst and plt files

Post by United States of AmericaAbhishek »

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
Post Reply