记录一次ncl从前端到后端出图过程:调用linux-shell执行ncl命令从nc文件出图

本文记录了一次使用NCL在Linux环境中从前端到后端生成图片的过程。前端通过ExtJS发送POST请求,后端Java Struts接收并拼接NCL命令,执行ncl脚本生成nc文件的图像。通过Runtime执行shell命令,将输出重定向到日志文件,并处理进程输出流。最后,对生成的图片进行处理并以stream形式返回给前端展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ncl出图大概长这样子:

 

数据文件:

ncl脚本:

 

;************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"    
;
; @Author Zhou
; @Date 2016-07-25
;
;************************************************
begin

;************************************************
;try to read file name from command line parameter
;************************************************
if (.not. isvar("fileName")) then      ; is fileName on command line?
      fileName = "hgt.2000.nc,hgt.2003.nc";
end if

fileArray = str_split(fileName, ",");
print(fileArray);

if (.not. isvar("filePath")) then      ; is filePath on command line?
      filePath = "./";
end if

;************************************************
; for time dimesion
;************************************************
if (.not. isvar("timeDimension")) then      ; is timeDim command line?
      timeDimension = 0;
end if
if (.not. isvar("timeDimensionStep")) then      ; is timeDim command line?
      timeDimensionStep = 5;
end if

;if (.not. isvar("level")) then      ; is levelSpace command line?
;     level = 5;
;end if


;************************************************
; for spacing
;************************************************
if (.not. isvar("levelSpace")) then      ; is levelSpace command line?
      levelSpace = 5;
end if


;************************************************
; for display rectangle
;************************************************
if (.not. isvar("rectMinLat")) then      ; is rectMinLat command line?
      rectMinLat = -90;
end if
if (.not. isvar("rectMaxLat")) then      ; is rectMaxLat command line?
      rectMaxLat = 90;
end if
if (.not. isvar("rectMinLon")) then      ; is rectMinLon command line?
      rec
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值