Multiple File Input Processing

1 次查看(过去 30 天)
Hello, I need to process multiple input files in a loop and need some assistance. Here is my problem
I'm currently tasked to evaluate satellite rainfall data files (format *.grb, contains a rainfall data matrix for each geo-pixel observed by satellite - about 3000x3000). I have thousands of input files been taken for every 30 minutes interval. Here below is some example file names for one of those input files:
MSG2-SEVI-MSGMPEG-0100-0100-20070605003000.000000000Z-999804.grb
MSG2-SEVI-MSGMPEG-0100-0100-20070605010000.000000000Z-999804.grb
MSG2-SEVI-MSGMPEG-0100-0100-20070605013000.000000000Z-999804.grb
Considering first one as an example, the numbers in the middle indicates the date and time: 2007/06/05 - 00:30. And to read these kind of files (*.grb), I have a code called ReadGRIB2.m (.grb files is not directly readable on Matlab)
Rather than trying to make filenames recognized by Matlab, I just typed dir('*.grb') so matlab can read the grb files on same directory. Here is a reduced overview of my code:
Filename = dir('*.grb');
for i=1:length(Filename)
eval(['load' Filename(i).name ' .grb']);
% Decoding of *.grb file
[Data,Info]=readGRIB2(Filename);
% Presentation of Data - Creates output data wrt input filename
msg2projection(Data,Lat,Lon);
end
When I run the code, I get the following error:
??? Error using ==> load
Number of columns on line 2 of ASCII file
...\MSG2-SEVI-MSGMPEG-0100-0100-20070605003000.000000000Z-999804.grb
must be the same as previous lines.
Error in ==> MPE at 21
eval(['load ' Filename(i).name ' .grb']);
What I understand from error: I think Matlab is unable to mount the file into the ReadGRIB2 function because of being unable to recognize it first. I don't have much experience on Matlab and I would be very faithful if you can assist me.
Thanks very much in advance.

采纳的回答

Oleg Komarov
Oleg Komarov 2011-6-30
First of all you don't need to use eval for this task.
load(Filename(i).name);
Second, does the data file contain headers? How is it exactly structured the file?
Grib files are binary, so you cannot use high level import functions but you should decode them.
To import GRIB data:
In brief just erase the line with the eval from your code and if readGRIB2 is a valid decoding routine you should be fine.
  10 个评论
Al Onen
Al Onen 2011-7-3
Ah, I now got it. It works as I wanted. Thank you so much Oleg.
Oleg Komarov
Oleg Komarov 2011-7-3
If my answers were useful please accept it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Variables 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by