How can I load a netcdf file using Meteolab toolbox?

2 views (last 30 days)
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)

Walter Roberson
Walter Roberson on 31 Aug 2015
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
Walter Roberson
Walter Roberson on 31 Aug 2015
Try with this url.txt . Note: your 1982 was also missing the final 'c' in the file extension.
Walter Roberson
Walter Roberson on 31 Aug 2015
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.

Community Treasure Hunt

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

Start Hunting!