Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wolfram mathematica mathematica,计算平均每小时_Wolfram Mathematica - Fatal编程技术网

Wolfram mathematica mathematica,计算平均每小时

Wolfram mathematica mathematica,计算平均每小时,wolfram-mathematica,Wolfram Mathematica,我有大量的气象数据。它按日期和时间列出。每10分钟有一个值。从600开始到1400 我想计算这两个值每小时的平均值 编号,日期1,时间1,val,编号,日期,时间,val2 谢谢 {11238, 20120530, 1300, 11290, 20120530, 1300, 141}, {11238, \ 20120530, 1310, 11290, 20120530, 1310, 223}, {11238, 20120530, 1320, \ 11290, 20120530, 1320, 2

我有大量的气象数据。它按日期和时间列出。每10分钟有一个值。从600开始到1400

我想计算这两个值每小时的平均值

编号,日期1,时间1,val,编号,日期,时间,val2

谢谢

  {11238, 20120530, 1300, 11290, 20120530, 1300, 141}, {11238, \
20120530, 1310, 11290, 20120530, 1310, 223}, {11238, 20120530, 1320, \
11290, 20120530, 1320, 201}, {11238, 20120530, 1330, 11290, 20120530, \
1330, 275}, {11238, 20120530, 1340, 11290, 20120530, 1340, 371}, \
{11238, 20120530, 1350, 11290, 20120530, 1350, 275}, {11238, \
20120530, 1400, 11290, 20120530, 1400, 238}, {11238, 20120531, 600, \
11290, 20120531, 600, 342}, {11238, 20120531, 610, 11290, 20120531, \
610, 238}, {11238, 20120531, 620, 11290, 20120531, 620, 438}, {11238, \
20120531, 630, 11290, 20120531, 630, 483}, {11238, 20120531, 640, \
11290, 20120531, 640, 498}, {11238, 20120531, 650, 11290, 20120531, \
650, 535}, {11238, 20120531, 700, 11290, 20120531, 700, 527}, {11238, \
20120531, 710, 11290, 20120531, 710, 461}, {11238, 20120531, 720, \
11290, 20120531, 720, 572}, {11238, 20120531, 730, 11290, 20120531, \
730, 624},

使用给定的数据格式:
{nr,date1,time1,val,nr date,time,val2}
,以下代码输出日期和时间以及val和val2的平均值

data = {
   {11238, 20120530, 1300, 11290, 20120530, 1300, 141},
   {11238, 20120530, 1310, 11290, 20120530, 1310, 223},
   {11238, 20120530, 1320, 11290, 20120530, 1320, 201},
   {11238, 20120530, 1330, 11290, 20120530, 1330, 275},
   {11238, 20120530, 1340, 11290, 20120530, 1340, 371},
   {11238, 20120530, 1350, 11290, 20120530, 1350, 275},
   {11238, 20120530, 1400, 11290, 20120530, 1400, 238},
   {11238, 20120531, 600, 11290, 20120531, 600, 342},
   {11238, 20120531, 610, 11290, 20120531, 610, 238},
   {11238, 20120531, 620, 11290, 20120531, 620, 438},
   {11238, 20120531, 630, 11290, 20120531, 630, 483},
   {11238, 20120531, 640, 11290, 20120531, 640, 498},
   {11238, 20120531, 650, 11290, 20120531, 650, 535},
   {11238, 20120531, 700, 11290, 20120531, 700, 527},
   {11238, 20120531, 710, 11290, 20120531, 710, 461},
   {11238, 20120531, 720, 11290, 20120531, 720, 572},
   {11238, 20120531, 730, 11290, 20120531, 730, 624}};

(* format the time data to hourly timestamps *)
times = (
     date = ToString[#2]; 
     hour = StringPadLeft[ToString@Floor[#3/100], 2, "0"];
     {date, hour}) & @@@ data;

(* join the timestamps to the data *)
datawithtimes = MapThread[Prepend, {data, times}];

(* gather the data by the timestamps *)
gathered = GatherBy[datawithtimes, First];

(* pick out the data and average *)
{StringJoin[Insert[First@#1, " ", 2], "00"],
     N@Mean[#5], N@Mean[#8]} & @@ Transpose[#] & /@ gathered

数据={11238…141},{11238…,223},};getvals[{v1,v2}]:={v1[[4]]-v2[[4]],v1[[7]]-v2[[7]};平均值[v_]:=平均值[VAL];pairs=Map[getvals,Partition[data,2,1]];avgs=N[Map[Mean,Partition[pairs,6]]]给出每个val{{{0.,-16.1667},{0.,-49.5}的前两个小时的平均值。仔细研究这方面的细节,直到你能够弄清楚它是如何工作的,并能够在将来使用它来解决问题。请查看
GatherBy
。此外,建议您考虑将数值转换为mathematica日期对象(请参见
DateObject
)。这将提供大量有用的工具。
{{20120530 1300, 11290., 247.667},
 {20120530 1400, 11290., 238.},
 {20120531 0600, 11290., 422.333},
 {20120531 0700, 11290., 546.}}