Getting numerical values from grdmath to use in pstext

Hi
I want to perform simple operations on grd files (like computing statistical properties, mean, variance…).
I understand that I can easily compute all that from grdmath
(e.g., grdmath file.grd MEAN = vmean), but I do not understand how
I can then write the value of vmean on my figures using pstext (vmean is a grd file of uniform value vmean, not the numerical value vmean).
Looks like a question that should already have been asked but I can’t find the answer.
Cheers

grdmath always outputs grids. But for mean and std see also grdinfo

It is a good question with not great answers. yes, numerous grdmath operators results in a single value that is then replicated onto the output grid. Many of us, like you, need that number from time to time. While it would be easy for us to simply print that single value on output instead of writing a grid, this is not so great for external tools calling that module since they expect to receive a memory reference to a grid. Suddenly throwing in a constant will mess them up. THe situation in gmtmath is a bit different. Here we hvae the -S modifier to limit output to just one (say, the first or last record) and that way you can call an operator that gives a single repeated result but then request one row. This does not change the output type of gmtmath (still a table), just the number of records. Here are options for your needs

If the operator you need exists in gmt math, do gmt grd2xyz yourgrid -o2 | gmt math STDIN -Sf operator = singlevalue.txt
Otherwise, just do gmt grd2xyz -o2 theresult.grd | head -1 > singlevalue.txt

I will see if I can think of a solution to the general issue without breaking anything.