- 积分
- 736
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-9-13
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
大家好。我刚开始使用ncl,用ncl写nc文件,但是在把经纬度写到nc文件后,经纬度本来是小数后面2位数,lat:[-89.95, -89.85, ... , 89.85, 89.95]
lon:[-179.95,-179.85, ..., 179.85, 179.95]
不管我是用lat=fspan(-89.95, 89.95, 1800)
lon=fspan(-179.95, 179.95, 3600)
还是从原本的nc数据里面读取lat,lon重新写入新的nc文件中
或者从txt文件里面读取已经写好的lat,lon数据写入到nc文件中,
nc文件的经纬度数据从小数点后两位变成在小数点后多出很多位数
这个问题困扰我很多天,希望大家能帮我解决一下
- lat_1 = asciiread("filepath/lat.txt", 1800, "float")
- lon_1 = asciiread("filepath/lon.txt", 3600, "float")
- time = new(12,double,"No_FillValue")
- YYYY = tointeger(year) ;将字符转为数值
- do i = 0, ntim-1
- MM = i+1
- time(i) = cd_inv_calendar(YYYY, MM, 01, 00, 00, 00, "hours since 1985-01-01 00:00:00", 0)
- end do
- do i = 0, dimsizes(pollutant_names)-1
- emi_1 = emi_anthro_1(i,:,:,:)
- var = pollutant_names(i)
- fout_name = "PKU_" + pollutant_names(i) + "_" + year + "_anthro.nc"
- ;Remove the file if it already existed
- system("rm -f " + diro + fout_name)
-
- ;create the file:
- fout = addfile(diro + fout_name, "c")
-
- ;define some file properties:
- atts = True
- atts@title = "NetCDF file containing " + pollutant_names(i) + " anthropogenic emission dataset"
- fout@creation_date=systemfunc("date")
- fileattdef(fout, atts)
- ;define dimensions:
- dim_Names = (/"time","lat","lon"/)
- dim_Sizes = (/12, nlat, nlon/)
- dim_Unlim = (/True, False, False/)
- filedimdef(fout, dim_Names, dim_Sizes, dim_Unlim)
- ;define file variables:
- filevardef(fout, "time", "double", "time")
- filevardef(fout, "lat", "float", "lat")
- filevardef(fout, "lon", "float", "lon")
- filevardef(fout, var, "double", (/"time","lat","lon"/))
- ;define file variables attributes:
- ;;time
- tatts = True
- tatts@long_name = "Time"
- tatts@units = "hours since 1985-01-01 00:00:00"
- tatts@axis = "T"
- filevarattdef(fout, "time", tatts)
- ;;latitude
- latatts = True
- latatts@long_name = "latitude"
- latatts@units = "degree_north"
- latatts@axis = "X"
- filevarattdef(fout, "lat", latatts)
- ;;longitude
- lonatts = True
- lonatts@long_name = "longitude"
- lonatts@units = "degree_east"
- lonatts@axis = "Y"
- filevarattdef(fout, "lon", lonatts)
- ;;emission data
- emiatts = True
- emiatts@long_name = "Gridded emission desities of " + pollutant_names(i)
- emiatts@units = "kg m-2 s-1"
- filevarattdef(fout, var, emiatts)
-
- ;write out the data
- fout->lat = (/lat_1/)
- fout->lon = (/lon_1/)
- fout->time = (/time/)
- fout->$var$ = (/emi_1/)
- end do
- print("Finish the Step 5")
复制代码
|
|