- 积分
- 849
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-3-15
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 channam 于 2020-6-10 17:23 编辑
我想输出内蒙古自治区范围内能见度小于2km的数据到文本csv,包括经纬度位置和能见度值,请问大家有什么好的建议吗?
现在可以做到输出全部范围的数据,或者指定经纬度范围,或者某经纬度位置的数据,这些都是在读入数据的时指定的, 比如: t = fin->VIS_P0_L1_GLL0(:,{40.80},{111.55}),但省份范围都是不规则的,该怎么指定范围呢?
筛选能见度小于2km数据的循环感觉写的也不咋对,实在不擅长编程啊,请大家帮忙指点一下咯~
参考官网例子的脚本
;----------------------------------------------------------------------
; write_csv_2.ncl
;
; Concepts illustrated:
; - Writing a CSV file with a header using write_table
;----------------------------------------------------------------------
; This example reads three 3D arrays off a NetCDF file and writes
; the contents to a CSV file with a header that contains the
; long_name and units of each field.
;----------------------------------------------------------------------
begin
;--- file to read in.
filename = "./dat/xxx.GRB2"
fin = addfile(filename,"r")
;---Pick 3D arrays to write to CSV file
t = fin->VIS_P0_L1_GLL0(:,:,:)
t = t*0.001
; Read the 1D coordinate arrays, conform them to 3D,
; then convert to 1D so we can write them to CSV
; file along with data.
dims = dimsizes(t)
time1d = ndtooned(conform_dims(dims,t&forecast_time0,0))
lat1d = ndtooned(conform_dims(dims,t&lat_0, 1))
lon1d = ndtooned(conform_dims(dims,t&lon_0, 2))
;---Construct header line
field_names = (/ t&forecast_time0@long_name + " [" + t&forecast_time0@units + "]", \
t&lat_0@long_name + " [" + t&lat_0@units + "]", \
t&lon_0@long_name + " [" + t&lon_0@units + "]", \
t@long_name + " [" + t@units + "]"/)
header = [/str_join(field_names,",")/]
;---Write header to CSV file.
csv_filename = "vis_050620.csv"
system("rm -rf " + csv_filename)
write_table(csv_filename, "w", header, "%s")
;---Convert 3D arrays to 1D for writing to CSV file
t1d = ndtooned(t)
;-------这里企图写一个循环输出能见度小于2km的数据------;;
; do i=1,284501
; if((t1d(i).gt.0).and.(t1d(i).le.2)) then
; t11d =t1d(i)
; lat11d =lat1d(i)
; lon11d =lon1d(i)
; end if
; end do
;------------------------------------------------------------------------;
;---Write data to file
alist = [/time1d,lat1d,lon1d,t1d/]
format = "%g,%g,%g,%g"
write_table(csv_filename, "a", alist, format)
end
|
-
-
|