I want to use either native GMT commands or awk or similar, to read an output file from another program from the beginning as a character string and search for the word CHAIN, then read (and convert the values to numbers) until I hit the word CHAIN again. I need to convert paired values (they are time and temperature) from rows into columns. I’m going to be generating plots in GMT and using this newly created file as plot input.
See truncated example of text file requiring extraction, below (just a single line). The file is over 100,000 lines so this may not be efficient. I need to ignore the “100000 100000 1” after the word CHAIN and then grab the -633 (likelihood), and the time-temperature values in the row and convert to columns
The 100001 is the iteration #, the negative values are likelihood and posterior probabilities, and then the 5 indicates that there are 5 time and temperature point pairs, with those points then listed. Not sure of the best way to grapple this but each of these records needs to be plotted together as a path; i.e. 1690.7 (time) and 399.0 (temp.) is point one, 1660.5 and 334.5 is point two, etc. then the -633.67 value will be used for the entire assembled path as a value for color in a color ramp during plotting when combining all paths. I’m not sure if there is a way to plot rows rather than columns within GMT, but if so this may be easier that way.
This file has text before and after the line I quoted. Would this work for 10000 records in a file? and I need it to ignore all other text. I was trying the use the word “CHAIN” as a way to starting reading the file…
As soon as I hit CHAIN I need to keep reading for 10k lines and then I will hit CHAIN again and it should terminate there and save everything to a file for GMT to read in. Here is an example of the output plot I need to create
I see. This will require more programming to parse that file. Best to do in your favorite programming language, especially if there are more than one block of CHAIN … CHAIN sections. Might be a lot simple to do in C or Python than in shell scripts, for instance.