Как я могу конвертировать .mat файл в файл netCDF? - PullRequest
1 голос
/ 13 января 2020

У меня есть файл .mat с этими переменными. Я загрузил его, используя команду load.

  1. широта: 129 * 1 двойная
  2. длина: 135 * 1 двойная
  3. переменная: 129 * 135 * 42369 double
  4. start_date: '1901-01-01'
  5. end_date: '2016-12-31'

Я хочу создать и экспортировать файл netCDF с широтой, долготой и ежедневным измерением времени. С переменной в качестве переменной.

TRIED

>> ncid = netcdf.create('testing.nc','NC_WRITE');
>> %Define the dimensions
dimidt = netcdf.defDim(ncid,'time',length(start_date));
dimidlat = netcdf.defDim(ncid,'latitude',length(lat));
dimidlon = netcdf.defDim(ncid,'longitude',length(Lon));
>> %Define IDs for the dimension variables (pressure,time,latitude,...)
date_ID=netcdf.defVar(ncid,'time','double',[dimidt]);
latitude_ID=netcdf.defVar(ncid,'latitude','double',[dimidlat]);
longitude_ID=netcdf.defVar(ncid,'longitude','double',[dimidlon]);
>> precip_ID = netcdf.defVar(ncid,'var','double',[dimidt dimidlat dimidlon]);
>> netcdf.endDef(ncid);
>> netcdf.putVar(ncid,date_ID,0,830788,start_date:end_date);
netcdf.putVar(ncid,latitude_ID,0,830788,Lat);
netcdf.putVar(ncid,longitude_ID,0,830788,Lon);

ОШИБКА

Error using netcdflib
The number of elements implied by the count argument (830788) does not equal the number of data elements (2).

Error in netcdf.putVar (line 88)
netcdflib(funcstr,ncid,varid,varargin{:}

OBJECTIVE

Как я могу экспортировать его в netCDF с помощью MATLAB?

...