Unpacking netcdf files to spreadsheet failure
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to unpack a rather large netcdf file. The dimensions are 12 columns and 2168927 rows. Obviously this is way too large for a single variable or spreadsheet. I don't really need to data, just about 25% of it. I only need the rows with negative latitudes (column 2 of 12) My thoughts were to unpack the entire thing into 2 or 3 spreadsheets and then just extract the data I need manually. I can unpack the data, but I can't seem to parse it into spreadsheets correctly. I can create the two sheets and have data fill in the sheets, but not the right data. Instead of filling in the data from certain xlRange that I create, it creates the first 1000000 rows from the file and all of the columns in both sheets. Both sheets wind up being the same.
Column headers are: 'Date' 'Latitude' 'Longitude' 'Start_Depth' 'Stop_Depth' 'Midpoint_Depth' 'Density' 'Error' 'Elevation' 'SDOS_Flag' 'Method' 'Citation'
Can anyone tell me what I am doing wrong?
Below is my practice code where I am trying to separate out only 20 lines of the spreadsheet into different sheets.
ncid = netcdf.open('SUMup_datasets_july2018_density.nc','NC_NOWRITE');
%[dimname, dimlen] = netcdf.inqDim(ncid,0)
varname0 = netcdf.inqVar(ncid,0);
varid = netcdf.inqVarID(ncid,varname0);
data0 = netcdf.getVar(ncid,varid);
varname1 = netcdf.inqVar(ncid,1);
varid = netcdf.inqVarID(ncid,varname1);
data1 = netcdf.getVar(ncid,varid);
...
varname11 = netcdf.inqVar(ncid,11);
varid = netcdf.inqVarID(ncid,varname11);
data11 = netcdf.getVar(ncid,varid);
xlRange = 'A1:L20';
xlRange2 = 'A21:L50';
newData = [data0, data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11]; % to append the new column with existing data.
xlswrite('SUMup_datasets_july2018_density.xlsx', newData,'Sheet1',xlRange); % to write new data into excel sheet.
col_header={varname0,varname1,varname2,varname3, varname4, varname5, varname6, varname7, varname8, varname9, varname10, varname11}; %Row cell array (for column labels)
xlswrite('SUMup_datasets_july2018_density.xlsx',col_header,'Sheet1'); %Write column header
xlswrite('SUMup_datasets_july2018_density.xlsx', newData,'Sheet2',xlRange2); % to write new data into excel sheet.
col_header={varname0,varname1,varname2,varname3, varname4, varname5, varname6, varname7, varname8, varname9, varname10, varname11}; %Row cell array (for column labels)
xlswrite('SUMup_datasets_july2018_density.xlsx',col_header,'Sheet2'); %Write column header
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!