ncwriteschema - assign variables and Dimensions to variables
1 回表示 (過去 30 日間)
古いコメントを表示
I really need help with netCDF Schemas.
I would like to export data and therefor create a netCDF-Schema.
This works:
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'rows';
mySchema.Dimensions(1).Length = length([1 2 3 4 5 6 7]');
mySchema.Dimensions(1).Name = 'columns';
mySchema.Dimensions(1).Length = 1;
ncwriteSchema('Testfile',mySchema)
But when trying to add Variables and try to assign Dimensions to the Variables i get an error:
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'rows';
mySchema.Dimensions(1).Length = 7;
mySchema.Dimensions(1).Name = 'columns';
mySchema.Dimensions(1).Length = 1;
mySchema.Variables(1).Name = 'r0';
mySchema.Variables(1).Dimensions = {'rows' 'columns'};
mySchema.Variables(1).Datatype = 'float'
ncwriteschema('Testfile',mySchema)
ERROR:
Attempt to reference field of non-structure array.
Error in internal.matlab.imagesci.nc/writeDimensionSchema (line 1483)
dimNames = {schema.Name};
Error in internal.matlab.imagesci.nc/writeVariableSchema (line 1582)
this.writeDimensionSchema(...
Error in internal.matlab.imagesci.nc/writeGroupSchema (line 1676)
this.writeVariableSchema(schema.Variables, schema.Name);
Error in internal.matlab.imagesci.nc/writeSchema (line 490)
this.writeGroupSchema(schema);
Error in ncwriteschema (line 91)
ncObj.writeSchema(schemastruct);
QUESTION:
I really need help to add the Variables correctly to the netCDF Schema. I hope you guys know an answer.
I think it has something to do with this line:
mySchema.Variables(1).Dimensions = {'rows' 'columns'};
PS: I searched for solutions in MATLAB help and google yet.
2 件のコメント
Ashish Uthama
2012 年 6 月 21 日
Clemens, you can 'accept' Johns answer if it works for you. That way we know this question is 'solved' :)
採用された回答
John
2012 年 6 月 20 日
The specification for the variable dimensions should be the same as in the dimensions themselves, i.e. just listing the dimension names isn't enough. Rewrite as
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'rows';
mySchema.Dimensions(1).Length = 7;
mySchema.Dimensions(2).Name = 'columns';
mySchema.Dimensions(2).Length = 1;
mySchema.Variables(1).Name = 'r0';
mySchema.Variables(1).Dimensions(1) = mySchema.Dimensions(1); % rows
mySchema.Variables(1).Dimensions(2) = mySchema.Dimensions(2); % cols
mySchema.Variables(1).Datatype = 'single';
ncwriteschema(ncfile,mySchema)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!