Ugly C Program to Measure Wave Height of Sequencial Raw Wave Data
One month ago, I started my master course in Kyushu University after 1 year period of research studentship, and taking new subjects which I never encounter before.
One of many interesting subject is statistical analysis of random waves. The reason that I am taking this subject is 1).basically because most of my major related subject (Naval Architect) is taught in Japanese. I can speak a little of Japanese, but I can’t read the kanji’s, yet. Poor me…!!!, and 2) because I think it might related a bit, since ship are moving on the water in the ocean and wave movement affect the movement of ship also, I guess….
Before taking this subject, I only knew that waves (lit. ocean wave), is a moving force of water that may be generated by wind or gravitational force of the moon, and have frequency and amplitude. But, actually, many terminologies exist to explain this phenomenon.
I will not take apart in explaining any of those, but any of us can find it in any text book related specifically to wave or ocean engineering. For example:
1). Leo H. Holthuijsen, Waves in Oceanic and Coastal Waters, Cambridge 2007.
2). Y. Goda, Random Seas and Design of Maritime Structure, University of Tokyo Press, Japan, 1985.
Try to relate it with my post about C programming example, here I am trying to make a simple program to calculate the wave height of some statistical data of the vertical distance between the lowest part (Trough) and the highest part (Crest) of random waves. Let me show the figure of those which taken from the lecture notes. To record the raw data of wave height, there are many ways. Of course by seeing with eyes (visual observation) is the simplest way, but that not necessarily gives us the correct measurement. Some of measurement methods are either using in situ measurement (buoy, pressure sensor) or remote sensing technique (radar, aerial photograph).
The question is, after we get the raw data of wave height recorded for a specific time and period, how to calculate it? You may find the answer in the text book by using some equation in wave theories. i.e: mean wave height, significant wave height, and so on. The raw data that we collected may for a sinusoidal graph of time and height (surface elevation), like this:
Here we must take note that, the height of the wave is not only the height that can we see by bare eyes above the water level. It also mean the height below the water surface. Interesting isn’t??? Because generally we assume the wave height is only the one above the water surface (that’s a new knowledge for me). And to measure the height of each wave profile, we can use either zero-up crossing technique or zero-down crossing technique or other advanced technique.
In the program, I will use zero-upward crossing technique, which in definition is the profile of the surface elevation between two successive points of zero-upward crossing of the elevation. Confused???Me too. Just see the figure below for more understanding. We supposed to measured the crest and trough from point A to B, and then continue the same for each wave profile.
The tricky part is that, since from point A to B we can have some data, how can we decide “this is the one called crest and this is trough”. Logically is simple, just by measuring the max and min value of the data within the range. But the application in the program may be tricky, especially for amateur like me. (How to define the crossing point??? how to measure the max and min??? and how to loop that for all the data??)….
Okay, for the program flow chart, now I am referencing to the second text book mentioned above from Y. Goda. Here is the flow chart. I made the program only to satisfy the flow in the orange boundary layer.
Also, Here is the screenshot of the text book explaining how to measure the zero-upward crossing point and how to decide its max and min value.
Finally this is the program that I made to solve that, and the output. Honestly, I was stressful but I can find enjoyment after finished making it. It may not perfect but I am still working to make it that way. Enjoy
acknowledgement : Prof. Hashimoto & Mr. Zikra, who taught the subject.








semangat