How can I load a netcdf file using Meteolab toolbox?

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?

Answers (1)

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 Comments

Dear Walter, The sample url of Iberia NCEP which is contained in MLToolbox has same format than my url.txt. Some days ago I tried use the format that you suggested (starting with newline) but I got an error message that
Input strings must have one row.
Error in loadGCM (line 155)
sd=findstr('=',urls(format,:));
Try with this url.txt . Note: your 1982 was also missing the final 'c' in the file extension.
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.

Sign in to comment.

Asked:

on 31 Aug 2015

Commented:

on 31 Aug 2015

Community Treasure Hunt

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

Start Hunting!