I’m sure I’m doing something silly. I am putting time stamps (-U) on my plots, and want to change the colour from black to something else. So I do this:
Yeah. We’ve got cartesian coordinates: (t, P) (t=time, P=pressure) and we need to transform these onto the barograph charts coordinate system where the time grid lines are curved. The reason for this is that the barograph has a stylus on the end of an arm which will traces out the pressure on a rotating drum.
Actually, all the seismologists here will be familiar with the concept!
Most meteorological data nowadays are digital, so people just plot time series on Cartesian maps. But there are still a few analogue instruments being maintained by volunteers. And people like the look of the old instruments and charts.
The code snippet I sent was just the plotting part of a longer ksh script. The coordinates of the green lines are computed and transformed into the chart coordinates, and saved in the files called chart.txt and labels.txt
Yep, I know them from either meteorological instruments as well as seismographs. Very cool plots and refreshing in these times of xy plots all so similar.
It would be fun to make GMT.jl plotting function that creates them (but time is so short).
The coordinate transformation is simple. I use awk (why use these new-fandangled languages when something from the 70s will do?):
function barocoords {
#
# Convert date in format t,p,... to x,y,... on the barograph chart.
#
# Input data are provided on stdin and transformed data written to stdout.
#
# Arguments
#
# $1: length of chart (cm) Default: 63
# $2: height of chart (cm) Default: 15
# $3: mimimum pressure (hPa) Default: 950
# $4: maximum pressure (hPa) Default: 1050
# $5: minimum time (s since 1970-01-01T00:00:00) Default: 7 days ago
# $6: maximum time (s since 1970-01-01T00:00:00) Default: Now
# $7: length of barograph arm (cm) Default: 25
awk -v plen="${1:-63}" -v phgt="${2:-15}" -v pmin="${3:-950}" \
-v pmax="${4:-1050}" -v tmin="${5:-$(($(gdate -u +%s)-604800))}" \
-v tmax="${6:-$(gdate -u +%s)}" -v arm="${7:-25}" '
{
t = $1;
p = $2;
pmid = (pmin + pmax)/2;
y = phgt*(p - pmid)/(pmax - pmin);
d = arm - sqrt(4*arm^2 - 4*y^2)/2;
x = plen*(t - tmin)/(tmax - tmin) + d;
printf("%f\t%f\t", x, y);
for (ii=3; ii<=NF; ii++) printf("%s\t", $ii);
printf("\n");
}'
}
Sure, awk is a king for all of us, but Julia simplicity (when it’s not complicated) is also a breeze. If you could attach the zip with chart.txt & data.txt I could give it a try.
chart.txt and labels.txt are generated on the fly. I guess if one doesn’t change the chart size etc they could be static files. data.txt is simply a time series with two columns: time in the first column and pressure in the second.
I’ve attached the complete script which does the plotting. Doing a seismograph chart would be a bit more complex. A barograph chart just covers one circuit of the drum, and then the paper is changed. An old style seismograph does many circuits.plot_baro.zip (2.6 KB)
Here are the things I see that you can affect regarding the timestamp:
You can change the font used but not its size or color via FONT_LOGO
You can change the white color of the box via PAGE_RGB but that changes the entire page color
You can change the specific formatting of the time stamp via FORMAT_TIME_STAMP
You can change the default placement of the time stamp via MAP_LOGO_POS
You can change the color of the box beneath the GMT glyph via MAP_DEFAULT_PEN but that is entirely overprinted by the black/white glyph anyway
Basically, we never intended for users to change attributes related to the time stamp. For instance, the width is carefully set to match what is needed for that font size (and explicitly for Helvetica), it is not computed to fit whatever text ends up being set.
Thanks. I’ll just add any additional stuff like time stamps using gmt text. I kind of like the -U because it also puts in a subtle advertisement for GMT
My thought when setting up the minimal theme was that the GMT logo/timestamp is a bit like a brand and I didn’t want to mess with it by using a different font for FONT_LOGO even in the new theme.
Setting a font size would mean overprinting the box, etc. Its size is not determined from the size of the text (well ,it is hard wired based on the default size of the text and not meant to be changed.