How can I load a netcdf file using Meteolab toolbox?

1 回表示 (過去 30 日間)
Szabó-Takács Beáta
Szabó-Takács Beáta 2015 年 8 月 31 日
コメント済み: Walter Roberson 2015 年 8 月 31 日
I would like load my netcdf file from ModelData directory in MLToolbox by the following way:
dmn=readDomain('c:\Users\Beata\Documents\MATLAB\MLToolbox_R2013\ModelData\CNRM');
date=datenum('01-Jan-1961'):datenum('31-Dec-1990');
path=['c:\Users\Beata\Documents\MATLAB\MLToolbox_R2013\ModelData\CNRM\url.txt'];
[patterns,dmn]=loadGCM(dmn,path,'dates',date,'anHour','Analysis','ds',0);
But I got the following error message:
SWITCH expression must be a scalar or string constant.
Error in loadGCM (line 160)
switch lower(format)
I do not understand what I made wrong. I attached the url, table and domain files. The domain file is originaly of course .cfg file but I attached in .txt file. Could someone help me how can I fix this error?

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 8 月 31 日
Your url.txt file is not formatted properly. At the moment it starts like
#!Version=2#!Colums=Year, Var, Level, Url#!format=netcdf1961, TP, 0, ./nc/CNRM_1961-1990_pr_power.nc1962, ...
each of the #! needs to start a new line, so it needs to look like
#!Version=2
#!Colums=Year, Var, Level, Url
#!format=netcdf1961, TP, 0, ./nc/CNRM_1961-1990_pr_power.nc1962, TP, 0, ./nc/CNRM_1961-1990_pr_power.nc1963, TP, 0, ....
  3 件のコメント
Walter Roberson
Walter Roberson 2015 年 8 月 31 日
Try with this url.txt . Note: your 1982 was also missing the final 'c' in the file extension.
Walter Roberson
Walter Roberson 2015 年 8 月 31 日
You can find a copy of Iberia_NCEP/url.txt at the link. If you look at it, it clearly uses multiple lines, not running everything together in one line.
I suspect you opened the file in Notepad, an old MS Windows application that expects lines to be terminated with carriage return followed by newline, whereas the file is in Unix format which does not use carriage return. With Notepad, everything would have appeared to be on one line.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by