NetCDFファイルがあります。このファイルには、数か月にわたる世界中の総降水量を表すデータが含まれています(したがって、3次元配列に格納されています)。私は最初に、XConvとncdumpの両方で、データが適切であり、データが形成された方法であることを確認しました。すべてが賢明に見えます-値は非常に小さい(〜10 ^ -10-これはモデルデータであり、事実上ゼロを表すため、これは理にかなっています)から約5x10^-3まで変化します。
IDLまたはMatLabでこのデータを処理しようとすると、問題が発生します。これらのプログラムで生成された配列は、-4x10 ^ 4などの巨大な負の数でいっぱいで、5000などの場合によっては巨大な正の数があります。奇妙なことに、緯度と経度(特定の場所)に関するMatLabのデータのプロットを見ると時間)、降雨のパターンは賢明に見えますが、値は完全に間違っています。
IDLでは、ファイルを読み込んでテキストファイルに書き込むため、非常に基本的なテキストファイルを使用するソフトウェアで処理できます。これが私が使用しているコードです:
PRO nao_heaps
address = '/Users/levyadmin/Downloads/'
file_base = 'output'
ncid = ncdf_open(address + file_base + '.nc')
MONTHS=['january','february','march','april','may','june','july','august','september','october','november','december']
varid_field = ncdf_varid(ncid, "tp")
varid_lon = ncdf_varid(ncid, "longitude")
varid_lat = ncdf_varid(ncid, "latitude")
varid_time = ncdf_varid(ncid, "time")
ncdf_varget,ncid, varid_field, total_precip
ncdf_varget,ncid, varid_lat, lats
ncdf_varget,ncid, varid_lon, lons
ncdf_varget,ncid, varid_time, time
ncdf_close,ncid
lats = reform(lats)
lons = reform(lons)
time = reform(time)
total_precip = reform(total_precip)
total_precip = total_precip*1000. ;put in mm
noLats=(size(lats))(1)
noLons=(size(lons))(1)
noMonths=(size(time))(1)
; the data may not be an integer number of years (otherwise we could make this next loop cleaner)
av_precip=fltarr(noLons,noLats,12)
for month=0, 11 do begin
year = 0
while ( (year*12) + month lt noMonths ) do begin
av_precip(*,*,month) = av_precip(*,*,month) + total_precip(*,*, (year*12)+month )
year++
endwhile
av_precip(*,*,month) = av_precip(*,*,month)/year
endfor
fname = address + file_base + '.dat'
OPENW,1,fname
PRINTF,1,'longitude'
PRINTF,1,lons
PRINTF,1,'latitude'
PRINTF,1,lats
for month=0,11 do begin
PRINTF,1,MONTHS(month)
PRINTF,1,av_precip(*,*,month)
endfor
CLOSE,1
END
なぜ私がMatLabとIDLでそのような奇妙な値を取得しているのか、誰かが何か考えを持っていますか?!