ncwriteschema - assign variables and Dimensions to variables
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Ashish Uthama
le 21 Juin 2012
Clemens, you can 'accept' Johns answer if it works for you. That way we know this question is 'solved' :)
Réponse acceptée
John
le 20 Juin 2012
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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Import and Analysis dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!