NCL绘图:将输出的PNG文件保存到当前目录
load '$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl'
begin a = addfile('geo_em.d01.nc','r') ; Open a file
type = 'png'
output_dir = './' ; 设置输出文件的当前目录
output_file = output_dir + 'plt_geo_1.png' ; 设置输出文件的路径和名称
wks = gsn_open_wks(type,output_file) ; 使用输出文件的路径和名称定义wks变量
ter = a->HGT_M(0,:,:)
res = True ; Create plot resource variable
res@cnFillOn = True ; Enable filled contours
res@gsnSpreadColors = True ; Use color spread across the entire color map
plot = gsn_contour(wks,ter,res) ; Create plot
end
在此示例中,将输出文件设置为当前目录中的'plt_geo_1.png'。如果要将输出文件保存到不同的目录中,可以修改output_dir变量的值为所需的目录路径。
原文地址: https://www.cveoy.top/t/topic/o8b9 著作权归作者所有。请勿转载和采集!