Get info of Vertical exaggeration of a profile

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

Not sure, maybe how bash works. But, I remember you needing VE for various things. Mostly for labelling, yes? I wonder if we can find a slicker solution to getting VE in GMT but it does depend on what you plan to use it for. Is it always as part of a title or label string ?

I wonder if we can find a slicker solution to getting VE in GMT but it does depend on what you plan to use it for.

Yes, well. With GMT it is possible to get the VE via basemap -Vi. It also can be done trouogh maths as in animation 14

VE=$(gmt math -Q $KM $H MUL $W DIV $DepthMax DIV = --FORMAT_FLOAT_OUT=%.2g)

It was also the idea to make a new module (Vertical exaggeration for Profiles · Issue #4367 · GenericMappingTools/gmt · GitHub)

On the link are the two ways I want to use VE:

  1. labeling
  2. to calculate how the angles are deformed.