Friday, April 12, 2013

4/10 Plotting Ting's Data, SUCCESS!!


Rather than inputting all the data by hand into Processing, is there an easier way to do it?
The answer is yes, as long as you have the data saved somewhere in your computer or on a URL. 

My project today was to find out how to tell Processing to call up data just by inserting the file name that contains the data points we want my simulation to plot. Dr. Bellis sent me a tutorial of a code called loadStrings() which I can use to input the data to my plot. After looking at the code description (http://processing.org/reference/loadStrings_.html), I knew what I needed to do to successfully put the data in. I just had to save the data that Dr. Bellis sent me, change it into a .txt file, create a folder called "data" in my simulation file, and enter loadStrigns("ams_data.txt") in the codes I have for plotting a graph. However, I did all the processes that I just mentioned, but there continued to be an error saying that it cannot find a file named ams_data.txt. I was so troubled and tried doing the same thing many times, looked up other codes and similar simulations' codes, but still failed at loading the data to my simulation. I asked Dr. Bellis for assistance and he figured out that the reason that the computer could not find the file is because I created the folder name as "data " (with a space) and not "data". This difference cannot be seen with bare eyes when one clicks on the folder. Now I know the computer treats a word and a word with space differently, that's why my ams_data.txt could not be located.

 The simplest mistake can cause a long time frustration...

After successfully stopped Processing from saying "cannot find the file named ams_data.txt", we encountered another trouble. The plot only shows one dot instead of the many dots we have on our data file. This time, because I read other people code on uploading a .txt file to Processing, I figured out what our mistake was. We had our datapoints separated with spaces, but Processing can only read datapoints that are separated by commas. Dr. Bellis rushed up (because there were only 5 mintues left before I had to leave) and sent me another ams data file, this time, commas replaced the spaces in between the numbers. After all the incidents, we finally were able to plot the data points.
Here are the results: 
Our plot
(data points from the AMS experiment lead by Samuel Ting)
Codes: http://www.sos.siena.edu/~mbellis/ew_processing/ams_data_first_try.html

Official plot with same data
Generated by the AMS team
(notice the difference between their scale and my scale for the plot)
The shape of our plot and the plot made by the AMS team are very similar, they look slightly different because they use a log scale (which I haven't figure out how to do on my simulation).

Next week, Dr. Bellis will be going to Denver for a conference, so we will not be meeting. He will send me readings to read and work to do via e-mail. :)





1 comment:

  1. Yvonne, you foray into the digital world of file names reflects your progress in your internship. You are clearly making good progress and working hard. I am impressed with your automated graph, and your problem solving skills. Keep up the great effort!

    ReplyDelete