Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/awk -f
- BEGIN {
- format1 = "local-maximum: %.1f %.9f\n"
- format2 = "maximum: %.1f %.9f\n"
- out1 = "local-maximum.dat"
- out2 = "maximum.dat"
- printf "" >out1
- printf "" >out2
- }
- NF {
- if (!max_y) {
- max_x = $1; max_y = $2
- }
- if (max_y < $2) {
- max_x = $1; max_y = $2
- }
- if (py && y && py < y && y > $2) {
- printf format1, x, y >out1
- }
- px = x; py = y; x = $1; y = $2
- }
- !NF {
- printf format2, max_x, max_y >out2
- max_x = max_y = "";
- px = py = x = y = "";
- }
- END {
- if (max_y) {
- printf format2, max_x, max_y >out2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement