爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6275|回复: 4

[图形美化] 我想在温度的垂直廓线上标记数值,请问各位大神该怎么实现?

[复制链接]

新浪微博达人勋

发表于 2017-6-7 13:26:43 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
我想在温度的垂直廓线上标记上数值,请问怎么实现?我的这个GS程序有什么问题?哪位大神帮我分析分析?'reinit'
'open E:/DATA/FNL/01/fnl0702.ctl'
'set lat 27.11'
'set lon 111.56'
'set xlopts 1 4 0.15'
'set ylopts 1 4 0.15'
'set clopts 1 4 0.15'

*打印图
'enable print E:/DATA/FNL/01/TV.gmf'


'set xlint 20'
'set ylint 20'
*层次
high=lev

t=1
*时间
while(t<=31)
high=lev
'set grid on'
'set grads off'
'set t 't
'set z 1 13'
'set ylevs 1000 975 950 925 900 850 800 750 700 650 600 550 500  '
'set zlog on '
'set cmark 3'
'set digsize 0.09'
'define T=TMPprs-273.16'   
'd T'

a=subwrd(result,4)
*提取T数值
'q dim'
c=sublin(result,4)
lev=subwrd(result,6)
*提取所在层数
'q w2xy  a   lev '
*以T数值为横坐标,层数为纵坐标转为grads中xy轴坐标
x=subwrd(result,3)
y=subwrd(result,6)
*提取xy轴坐标
'set string 2'
*设定添加的数值颜色为2
'draw string 'x' 'y' 'a''
*添加数值

'q time'
date=subwrd(result,3)
'draw title 'T' 'date
*标题

*打印
'printim E:/DATA/FNL/01/tu/TV_-'%t%'.gif white'

'print'
'c'
t=t+1
endwhile
'disable print'
;

T.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-6-7 17:01:47 | 显示全部楼层
有没有错误提示之类的?

另外我觉得你可以参考这个脚本,把draw line 改成draw string ,应该会很好用。

***************************************************************************************
* $Id: drawline.gs,v 1.17 2016/05/11 21:08:08 bguan Exp $
*
* Copyright (c) 2005-2015, Bin Guan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list
*    of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this
*    list of conditions and the following disclaimer in the documentation and/or other
*    materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
***************************************************************************************
function drawline(arg)
*
* Draw lines at specified locations.
*
if(subwrd(arg,2)='')
  usage()
  return
endif

'query gxinfo'
line3=sublin(result,3)
line4=sublin(result,4)
x1=subwrd(line3,4)
x2=subwrd(line3,6)
y1=subwrd(line4,4)
y2=subwrd(line4,6)
line5=sublin(result,5)
xaxis=subwrd(line5,3)
yaxis=subwrd(line5,6)

cnt=1
word=subwrd(arg,cnt)
while(word!='')
  axis=word
  cnt=cnt+1
  word=subwrd(arg,cnt)
  while(word!='' & word!='Lon' & word!='Lat' & word!='Lev' & word!='Val' & word!='Time')
    wcoor=word
    if(axis!='Time' & !valnum(wcoor))
      say '[drawline ERROR] <coordinate> for Lon|Lat|Lev|Val must be numeric.'
      return
    endif
    if(xaxis=axis)
      if(yaxis='Time')
        'query w2xy 'wcoor' 0000z1Jan0000'
      else
        'query w2xy 'wcoor' 0'
      endif
      xcoor=subwrd(result,3)
      'draw line 'xcoor' 'y1' 'xcoor' 'y2
    endif
    if(yaxis=axis)
      if(xaxis='Time')
        'query w2xy 0000z1Jan0000 'wcoor
      else
        'query w2xy 0 'wcoor
      endif
      ycoor=subwrd(result,6)
      'draw line 'x1' 'ycoor' 'x2' 'ycoor
    endif
    cnt=cnt+1
    word=subwrd(arg,cnt)
  endwhile
endwhile

return
***************************************************************************************
function usage()
*
* Print usage information.
*
say '  Draw lines at specified locations.'
say ''
say '  USAGE: drawline Lon|Lat|Lev|Val|Time <coordinate1> [<coordinate2>...] [Lon|Lat|Lev|Val|Time <coordinate1> [<coordinate2>...]]...'
say '    <coordinate>: world coordinate.'
say ''
say '  EXAMPLE 1: drawline Lon 180 Lat 0'
say '    Draw international date line and equator on a map.'
say ''
say '  EXAMPLE 2: drawline Val -1 0 1'
say '    Draw lines with constant value -1, 0 and 1 in a line graph.'
say ''
say '  EXAMPLE 3: drawline Time 1Jan2005'
say '    Draw a straight line marking 1 January 2005.'
say ''
say '  NOTE: proper capitalization MUST be used for key words Lon, Lat, Lev, Val and Time.'
say ''
say '  Copyright (c) 2005-2015, Bin Guan.'
return


密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-6-7 17:17:40 | 显示全部楼层
在程序里面增加了一个循环,就出来了。只是小数位太多,不知道怎么保留。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-3-20 23:50:00 | 显示全部楼层
天边的彩虹 发表于 2017-6-7 17:17
在程序里面增加了一个循环,就出来了。只是小数位太多,不知道怎么保留。

可以四舍五入。

v2=math_nint(value1*10)*0.1
'draw string 'x ' 'y ' 'v2
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-6-2 11:29:55 | 显示全部楼层
你好,请问可以贴下您出图的gs吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表