Grown-ups like numbers. When you tell them about a new friend, they never ask questions about what really matters. They never ask: “What does his voice sound like?” “What games does he like best?” “Does he collect butterflies?” They ask: “How old is he?” “How many brothers does he have?” “How much does he weigh?” “How much money does his father make?” Only then do they think they know him. If you tell grown-ups, “I saw a beautiful red brick house, with geraniums at the windows and doves on the roof…,” they won’t be able to imagine such a house. You have to tell them, “I saw a house worth a hundred francs.” Then they exclaim, “What a pretty house!”
- 'The Little Prince'' by Antoine de Saint-Exupéry
Have you ever had a picture when you needed values? As scientists, we exceed the little prince's adults - we are obsessed with numbers... but lugging around and staring at an agglomeration of numbers isn't very practical - thus, graphs are used. Graphs are incredibly convenient. They allow us to compress a huge amount of information into a small space. They are ideal for first pass pattern checking and qualitative analysis. Nonetheless, we often need to go back to the quantitative side to further analyze the system. Yet sometimes, we are only provided with the plot and not the values. As such, the skill of translating a graph into a table of numbers is convenient.
For the first activity, we are tasked to digitize a handmade graph and use the pixel locations to infer the physical values of the points along the line. To recheck the values, the tabulated values will be replotted and overlaid against the original graph.
In figure 1, you can see a photograph of a plot in an old quantum mechanics book. To facilitate data collection, the picture was rotated, cropped, and grayscaled. As the lower right corner was significantly darker then the entire left side, a gradient mask was used while setting the contrast to produce a more uniform picture.
Figure 1. Original photograph |
Figure 2. Fixed image |
In GIMP, a black layer was superimposed over figure 2. Selected data points were marked by the color white pencil tool of size 1 pixel. This new layer was saved as a .tif and opened with python. Other file types were found to blur the pixels. The code used to get the pixel locations is as follows:
1 import Image
2 import numpy as np
3
4 im = Image.open(r"C:\Users\yupay\Desktop\points.tif")
5 points = np.array(im).nonzero()
6 points = np.array(points[1], 582 - points[0])
The superimposed black layer shows up as zeroes in im and the white pencil marks show up as 255(nonzero). The white pencil marks are easily grabbed in line 5.
Since the pixels are numbered (top to bottom) x (left to right) instead of the XY coordinate system's (left to right) x (bottom to top), the array of locations is rearranged in line 6. To get the physical values, we apply the following formula:
6 points = [points[0]/777.+1.,points[1]/582.*200.]
For the x values, 777 pixels corresponds to the values between 1.0 and 2.0 BeV, while 582 vertical pixels corresponds to 200 millibarns. If we arrange it into xy pairs, we get:
Table 1. Obtained physical values |
Figure 3. Recreated plot over original plot |
The same method can be applied to another simple physics experiment. Figure 4 shows a polar graph from our Physics 191 class. We were asked to throw a marble at the center of the graph. Being imperfect humans, we missed a lot. We were then asked to look for a pattern in the accuracy of our throws. I used the method discussed here to automate the measurement of marble track locations from the center. Now, it's your turn to try!
Figure 4. Marble toss experiment |
No comments:
Post a Comment