Intro
I want to know the vertical exaggeration of a profile. I am using this command (gmt basemap -B+n -Vi
) to get the info in the teminal which looks like this:
bash Frame.sh
basemap [INFORMATION]: Constructing the basemap
basemap [INFORMATION]: Linear projection implies x-axis distance exaggeration relative to the y-axis by a factor of -0.6
basemap [INFORMATION]: Map scale is 0.001 km per cm or 1:100.
So, the info that I want is at the end of the second line, so I using this command:
gmt basemap -B+n -Vi |& sed -n 2p | awk '{print $NF}' | gmt math STDIN ABS =
And I got this answer in the terminal:
0.6
Issue
But, when I try to create a variable with that command, but I got an error:
VE=$(gmt basemap -B+n -Vi |& sed -n 2p | awk '{print $NF}' | gmt math STDIN ABS =)
gmtmath [WARNING]: File <stdin> is empty!
Other Issue:
- Should the factor be always a positive value?
- If there isn’t Vertical exaggerations (i.e. is 1), them the 2nd line doesn’t show.
Solution
I manage to create the variable by saving the Standar Error to a file. However, I would like to know why the above failed.
gmt basemap -B+n -Vi 2> data
sed -n 2p data | awk '{print $NF}' | gmt math STDIN ABS =
VE=$(sed -n 2p data | awk '{print $NF}' | gmt math STDIN ABS =)
Full script:
gmt begin Frame png
gmt basemap -Ba -R0/10/0/3 -JX10/-3 # Make only frame
gmt basemap -B+n -Vi # Get info on the terminal
gmt basemap -B+n -Vi |& sed -n 2p | awk '{print $NF}' | gmt math STDIN ABS =
VE=$(gmt basemap -B+n -Vi |& sed -n 2p | awk '{print $NF}' | gmt math STDIN ABS =)
gmt end