IDL,将数组数据拆分为块

时间:2016-01-26 13:26:15

标签: arrays idl-programming-language

网站的新手,所以首先感谢在这里贡献的每个人,这很棒。

我也是IDL的新手,试图用它来分析一些数据。基本上,我有一组数据,我想找到一个事件的可能性。对于其中的一部分,我想将x轴数据(时间)分成均匀大小的分档,然后在每个分档中查找峰值。我理解如何在IDL中找到峰值,但还没有找到将数据拆分成相同大小的箱子的方法。

对此有任何建议将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:1)

您可能想要使用HISTOGRAM功能。以下是文档中的详细示例:

; Read the ENSO (El Nino Southern Oscillation) time series
;  and set up a time vector.
enso = READ_BINARY(FILE_WHICH('elnino.dat'), DATA_TYPE=4, ENDIAN='little')
delta = 0.25 ; years
time = FINDGEN(N_ELEMENTS(enso))*delta + 1871

; Calculate histogram of series using bins of given width.
binsize = 0.1 ; in dimensionless units of ENSO index.
h_enso = HISTOGRAM(enso, BINSIZE=binsize, LOCATIONS=binvals)

; Display times series and histogram.
winsize = 500
w = WINDOW(DIMENSIONS=[2*winsize, winsize])
series = PLOT(time, enso, $
  /CURRENT, $
  POSITION=[0.10, 0.10, 0.65, 0.90], $
  XSTYLE=3, $
  XTITLE='Time (years)', $
  YTITLE='ENSO Index', $
  TITLE='El Ni!Sn!R!U~!No - Southern Oscillation (ENSO) Index (1871-1996)')

; Add a dotted line to indicate the zero value.
zero1 = PLOT(series.xrange, [0,0], LINESTYLE='dotted', /OVERPLOT)

; Plot up the histogram using the STAIRSTEP property.
histoplot = PLOT(h_enso, binvals, $
  /CURRENT, $
  POSITION=[0.70, 0.10, 0.95, 0.90], $
  /STAIRSTEP, $
  XTITLE='Frequency', $
  TITLE='Histogram of ENSO Index Values')

; Add a dotted line to indicate the zero value.
zero2 = PLOT(histoplot.xrange, [0,0], LINESTYLE='dotted', /OVERPLOT)

这是指向文档的链接: http://www.exelisvis.com/docs/HISTOGRAM.html

此外,有关详细信息,请查看JD Smith在David Fanning页面上的帖子: http://www.idlcoyote.com/tips/histogram_tutorial.html

希望这有帮助!

相关问题