The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Import Multiple ASCII Files, Average, and Plot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

christos_e

6 Posts

Posted - 08/22/2022 :  4:09:31 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2021b
Operating System: Windows 10

Hi,

I have run some molecular dynamics simulations and generated data in the form of .dat files. I have attached one of my .dat files as an example. What I would like to be able to do is automate the processing and plotting of these files.

Specifically, in my simulations, each setup is run 3 times generating different results. For example, for a simulation at temperature 27 C, this is run 3 times. Then, I generate 3 .dat files for that setup for each characteristic I am interested in. For example, the RMSD. I want to automate the import process of these .dat files to keep the first column (time stamps) the same for all 3, then average the results in the second column of each .dat file (characteristic of interest, like RMSD) and create a standard line plot.

I would also like the ability to plot multiple averages on the same plot for the same characteristic. For example, I may run simulations at 28 C and 29 C, and I want to compare the average RMSDs at the various temperatures.

I found this tutorial https://www.originlab.com/doc/Tutorials/Import-Multi-Clone about importing a .dat file, generating a plot, and repeating it on other .dat files. But I cannot find any information about selecting multiple .dat files, averaging their result, and then plotting them. I really appreciate any help on solving this!

https://my.originlab.com/ftp/forum_and_kbase/Images/RMSD.dat

Christos E

snowli

USA
1397 Posts

Posted - 08/22/2022 :  4:43:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Here is what u can do:
1. Choose Data: Import from File: Multiple ASCII to select 3 data files.
2. In ImpASC dialog, set Mult-File (except 1st file) import mode to Start New Sheets.
3. Click OK. This will import all 3 data into same book.
4. Choose Analysis: mathematics: Average Multiple Curves...
5. Set recalculation mode to auto. Click > next to Input node and choose Select Columns to select all columns in the book. Click OK
--> U will get an Average result sheet.
6. Highlight data here to plot graph.
Right click the last sheet in workbook and choose Add Graph as Sheet.
--> It will embed graph window to same book so everything is in same book.

7. Now u can choose File: Save Workbook as Analysis Template to save an OGWU file.

8. Then choose File: Batch Processing, load the saved template file.
Choose Files in File List. It should be multiple of 3.
Set Result Sheet to be None and click OK.

--> It should import each 3 data into one book and create corresponding average curves and plots.

9. Since now u have average curves sheets, u can highlight average cuves into one graph. E.g. with one of the average curves sheet active, don't select anything and choose Plot menu. It will open Plot Setup dialog for u to pick multiple average sheets to plot goether.

Thanks, Snow




Go to Top of Page

snowli

USA
1397 Posts

Posted - 08/22/2022 :  5:04:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
BTW, if all your X (Time) are the same for all data, no matter 27 C, 28C or 29C.

U can use the same import way to import all data into same worksheet and remember to set partial import from 2nd file on.

This way u will get 1 X and 9 Y columns.
Then u can use Worksheet: Reduce Columns... to merge every 3 columns into 1 column, starting from 2nd column on.

This way, u will get 1X and 3 average Ys.
Highlight all and plot.

Thanks, Snow
Go to Top of Page

christos_e

6 Posts

Posted - 08/23/2022 :  05:28:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Snow,

Thank you so much for your help. I followed the steps in your first post, and everything works!

In terms of your second reply, do you mean that in step 1 I should just select the 9 .dat files from the beginning? The time stamps are the same in all the files. However, this method would require me to have all the data already generated for each scenario, correct?

Is the first method the fastest way to add additional data to an existing plot? For example, if I have the data from 27C, 28C, and 29C and plotted the averages on the same plot, what is the fastest way to then add the averages from 30C, 31C, etc. when those data have been calculated? I assume the best way is to do the batch processing step for each new scenario and add the data to the plot with the multiple averages.

Thank you again!!

Christos E
Go to Top of Page

snowli

USA
1397 Posts

Posted - 08/23/2022 :  09:13:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Christos,

Yes, for 2nd methods (reduce columns), u don't have to have all files ready either.
E.g. first import 3 files of 27 C, by choosing
1st File Import Mode: Replace Existing.
Multi-File IMport Mode: Start New Columns.
Partial Import from 2nd file on.
From: 2.
This way 1 X 3 Y imported into one sheet.

When Reducing Columns. Set output to be New Sheet.
Set Recalculation Mode to Auto.
....
This way, the reduced result will be put to a new sheet.

Then with imported data sheet active, do multiple ascii import again.
But this time
1st File Import Mode: Start New Columns.
Multi-File IMport Mode: Start New Columns.
Partial Import from All.
From: 2.
This way, Y data from other temperatores will be appended as new columns in same sheet without X data.
And the Reduced Columns sheet will update to get new averages.
U can plot from the reduced column sheet.


Unless u have 6, 9, ... files, u don't have to use batch process.
For each 3 files, u can choose File: Recent Book: to load your saved template (OGWU) file.
With 1st sheet active, choose Multiple ASCII import to import 3 files.
It will update average results.

Then add data to graph. U can watch this FAQ of how to add data to existing plot.
https://www.originlab.com/doc/Quick-Help/Add-Data-to-Layer

Thanks, Snow
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000