Skip to content
Snippets Groups Projects

add gas, gash for JET and fix cdf2mat for ASTRA cdf file as well

Merged Olivier Sauter requested to merge fix_jetgas_cdf2mat into master
2 files
+ 61
21
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 56
21
@@ -47,16 +47,31 @@ for i=1:length(coordnames_sorted)
matcdf.coords(i).index_allvarnames = strmatch(matcdf.coords(i).name,allvarnames,'exact');
matcdf.coords(i).index_varnames_sorted = strmatch(matcdf.coords(i).name,varnames_sorted,'exact');
matcdf.coords(i).varid = allvarids(matcdf.coords(i).index_allvarnames);
if strcmp(allinfo.Variables(matcdf.coords(i).index_allvarnames).Datatype,'single')
matcdf.coords(i).data = netcdf.getVar(funnetcdf,matcdf.coords(i).varid,'double');
if ~isempty(matcdf.coords(i).index_allvarnames)
if strcmp(allinfo.Variables(matcdf.coords(i).index_allvarnames).Datatype,'single')
matcdf.coords(i).data = netcdf.getVar(funnetcdf,matcdf.coords(i).varid,'double');
else
matcdf.coords(i).data = netcdf.getVar(funnetcdf,matcdf.coords(i).varid);
end
for ij=1:length(fields_variables_to_copy)
matcdf.coords(i).(fields_variables_to_copy{ij}) = allinfo.Variables(matcdf.coords(i).index_allvarnames).(fields_variables_to_copy{ij});
end
for jj=1:numel(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes)
if strcmp(lower(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes(jj).Name),'units')
matcdf.coords(i).units = strtrim(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes(jj).Value);
end
if strcmp(lower(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes(jj).Name),'long_name')
matcdf.coords(i).long_name = strtrim(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes(jj).Value);
end
end
else
matcdf.coords(i).data = netcdf.getVar(funnetcdf,matcdf.coords(i).varid);
end
for ij=1:length(fields_variables_to_copy)
matcdf.coords(i).(fields_variables_to_copy{ij}) = allinfo.Variables(matcdf.coords(i).index_allvarnames).(fields_variables_to_copy{ij});
matcdf.coords(i).data = [];
for ij=1:length(fields_variables_to_copy)
matcdf.coords(i).(fields_variables_to_copy{ij}) = [];
end
matcdf.coords(i).units = '';
matcdf.coords(i).long_name = [matcdf.coords(i).name ' empty'];
end
matcdf.coords(i).units = strtrim(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes(1).Value);
matcdf.coords(i).long_name = strtrim(allinfo.Variables(matcdf.coords(i).index_allvarnames).Attributes(2).Value);
matcdf.coords(i).label = [matcdf.coords(i).name ' ' num2str(matcdf.coords(i).Size) ': ' matcdf.coords(i).long_name];
cdf2mat_out.coords.(matcdf.coords(i).name) = matcdf.coords(i);
end
@@ -65,16 +80,31 @@ for i=1:length(varnames_sorted)
matcdf.vars(i).name = varnames_sorted{i};
matcdf.vars(i).index_allvarnames = strmatch(matcdf.vars(i).name,allvarnames,'exact');
matcdf.vars(i).varid = allvarids(matcdf.vars(i).index_allvarnames);
if strcmp(allinfo.Variables(matcdf.vars(i).index_allvarnames).Datatype,'single')
matcdf.vars(i).data = netcdf.getVar(funnetcdf,matcdf.vars(i).varid,'double');
if ~isempty(matcdf.vars(i).index_allvarnames)
if strcmp(allinfo.Variables(matcdf.vars(i).index_allvarnames).Datatype,'single')
matcdf.vars(i).data = netcdf.getVar(funnetcdf,matcdf.vars(i).varid,'double');
else
matcdf.vars(i).data = netcdf.getVar(funnetcdf,matcdf.vars(i).varid);
end
for ij=1:length(fields_variables_to_copy)
matcdf.vars(i).(fields_variables_to_copy{ij}) = allinfo.Variables(matcdf.vars(i).index_allvarnames).(fields_variables_to_copy{ij});
end
for jj=1:numel(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes)
if strcmp(lower(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes(jj).Name),'units')
matcdf.vars(i).units = strtrim(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes(jj).Value);
end
if strcmp(lower(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes(jj).Name),'long_name')
matcdf.vars(i).long_name = strtrim(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes(jj).Value);
end
end
else
matcdf.vars(i).data = netcdf.getVar(funnetcdf,matcdf.vars(i).varid);
end
for ij=1:length(fields_variables_to_copy)
matcdf.vars(i).(fields_variables_to_copy{ij}) = allinfo.Variables(matcdf.vars(i).index_allvarnames).(fields_variables_to_copy{ij});
matcdf.vars(i).data = [];
for ij=1:length(fields_variables_to_copy)
matcdf.vars(i).(fields_variables_to_copy{ij}) = [];
end
matcdf.vars(i).units = '';
matcdf.vars(i).long_name = [matcdf.vars(i).name ' empty'];
end
matcdf.vars(i).units = strtrim(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes(1).Value);
matcdf.vars(i).long_name = strtrim(allinfo.Variables(matcdf.vars(i).index_allvarnames).Attributes(2).Value);
matcdf.vars(i).label = matcdf.vars(i).name;
for j=1:length(matcdf.vars(i).Dimensions)
ij = strmatch(matcdf.vars(i).Dimensions(j).Name,coordnames_sorted,'exact');
@@ -93,13 +123,18 @@ for i=1:length(varnames_sorted)
matcdf.vars(i).label = [matcdf.vars(i).label ': ' matcdf.vars(i).long_name ' [' matcdf.vars(i).units ']'];
cdf2mat_out.allvars.(matcdf.vars(i).name) = matcdf.vars(i);
end
top_attr_names = {allinfo.Attributes(:).Name};
ij = strmatch('shot',top_attr_names,'exact');
cdf2mat_out.shot = allinfo.Attributes(ij).Value;
if ~isempty(allinfo.Attributes)
top_attr_names = {allinfo.Attributes(:).Name};
ij = strmatch('shot',top_attr_names,'exact');
cdf2mat_out.shot = allinfo.Attributes(ij).Value;
else
cdf2mat_out.shot = NaN;
end
cdf2mat_out.fname = pfname;
cdf2mat_out.id = pfname(length(pfname)-11:length(pfname)-4);
[a1,a2,a3]=fileparts(pfname);
cdf2mat_out.id = a2;
netcdf.close(funnetcdf);
netcdf.close(funnetcdf);
clear matcdf
return
Loading