| 查看: 692 | 回复: 6 | |||
| 当前主题已经存档。 | |||
liuzf406木虫 (著名写手)
|
[交流]
【求助】如何用matlab建立NetCDF文件
|
||
|
如何用matlab建立NetCDF文件, 我有三维的同位素数据d18O(time,lat,lon)如txt文件,如何建立NetCDF文件. data.txt site lat lon Date d18O Chicago 41.78 -87.75 1962-01-15 -18.7 Chicago 41.78 -87.75 1962-02-15 -11.6 Chicago 41.78 -87.75 1962-03-15 -11.4 Chicago 41.78 -87.75 1962-04-15 -6.6 Chicago 41.78 -87.75 1962-05-15 -1.8 Chicago 41.78 -87.75 1962-06-15 -2.7 Chicago 41.78 -87.75 1962-07-15 -5.5 Chicago 41.78 -87.75 1962-08-15 -3.8 Chicago 41.78 -87.75 1962-09-15 -2 Chicago 41.78 -87.75 1962-10-15 -5.7 Chicago 41.78 -87.75 1962-11-15 -10.7 Chicago 41.78 -87.75 1962-12-15 -15.1 Chicago 41.78 -87.75 1963-01-15 -11 Chicago 41.78 -87.75 1963-02-15 -16.7 Chicago 41.78 -87.75 1963-03-15 -5.9 Chicago 41.78 -87.75 1963-04-15 -6.2 Chicago 41.78 -87.75 1963-05-15 -1.8 Chicago 41.78 -87.75 1963-06-15 0.9 Chicago 41.78 -87.75 1963-07-15 -4.3 Chicago 41.78 -87.75 1963-08-15 -1.8 Chicago 41.78 -87.75 1963-09-15 -2.2 Chicago 41.78 -87.75 1963-10-15 -1.2 Chicago 41.78 -87.75 1963-11-15 -15.6 |
» 猜你喜欢
基金
已经有107人回复
中
已经有111人回复
地球物理学和空间物理学论文润色/翻译怎么收费?
已经有123人回复
进入ISIS后,打不开任何界面
已经有8人回复
帮山东理工大学张超副教授招调剂硕士研究生
已经有0人回复
汕头大学 - 海洋地质学 - 资源与环境 - 少量调剂名额,4月14日16点前
已经有1人回复
SCIENCE ADVANCE投稿状态咨询
已经有5人回复
所里的
木虫 (著名写手)
- 应助: 1 (幼儿园)
- 金币: 3656.3
- 散金: 17
- 红花: 2
- 帖子: 1468
- 在线: 74.9小时
- 虫号: 121259
- 注册: 2005-12-03
- 性别: GG
- 专业: 大气环境与全球气候变化
★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
xinmeng8803(金币+2):感谢回复i! 2010-03-11 09:17
小木虫(金币+0.5):给个红包,谢谢回帖交流
xinmeng8803(金币+2):感谢回复i! 2010-03-11 09:17
|
我没有做过这样的工作,我是经常读netcdf文件,在matlab里面 你可以看看netcdf帮助,其实很详细的 %An example to generate an nc file % ---------------------------- DEFINE THE FILE --------------------------- % ncquiet % No NetCDF warnings. nc = netcdf('ncexample.nc', 'clobber'); % Create NetCDF file,输入文件名. nc.description = 'NetCDF Example'; % Global attributes,基本信息. nc.author = 'Dr. Charles R. Denham'; nc.date = 'June 9, 1997'; nc('latitude') = 10; % Define dimensions,数组维数. nc('longitude') = 10; nc{'latitude'} = 'latitude'; % Define variables,定义变量. nc{'longitude'} = 'longitude'; nc{'depth'} = {'latitude', 'longitude'}; nc{'latitude'}.units = 'degrees'; % Attributes,单位信息. nc{'longitude'}.units = 'degrees'; nc{'depth'}.units = 'meters'; % ---------------------------- STORE THE DATA ---------------------------- % latitude = [0 10 20 30 40 50 60 70 80 90]; % Matlab data,变量数值. longitude = [0 20 40 60 80 100 120 140 160 180]; depth = rand(length(latitude), length(longitude)); nc{'latitude'}( = latitude; % Put all the data,对nc文件赋各变量的值.nc{'longitude'}( = longitude;nc{'depth'}( = depth;nc = close(nc); % Close the file,关闭文件. % ---------------------------- RECALL THE DATA ---------------------------%读文件 nc = netcdf('ncexample.nc', 'nowrite'); % Open NetCDF file. description = nc.description( % Global attribute.variables = var(nc); % Get variable data. for i = 1:length(variables) disp([name(variables{i}) ' =']), disp(' ') disp(variables{i}( )end nc = close(nc); % Close the file. % --------------------------------- DONE --------------------------------- % |
2楼2010-03-11 08:40:28
liuzf406
木虫 (著名写手)
- 应助: 7 (幼儿园)
- 金币: 3009.7
- 散金: 1974
- 红花: 5
- 帖子: 1041
- 在线: 1031.7小时
- 虫号: 471925
- 注册: 2007-12-03
- 性别: GG
- 专业: 自然地理学
3楼2010-03-11 08:59:43
liuzf406
木虫 (著名写手)
- 应助: 7 (幼儿园)
- 金币: 3009.7
- 散金: 1974
- 红花: 5
- 帖子: 1041
- 在线: 1031.7小时
- 虫号: 471925
- 注册: 2007-12-03
- 性别: GG
- 专业: 自然地理学
4楼2010-03-11 09:07:24
所里的
木虫 (著名写手)
- 应助: 1 (幼儿园)
- 金币: 3656.3
- 散金: 17
- 红花: 2
- 帖子: 1468
- 在线: 74.9小时
- 虫号: 121259
- 注册: 2005-12-03
- 性别: GG
- 专业: 大气环境与全球气候变化
5楼2010-03-11 11:56:56
liuzf406
木虫 (著名写手)
- 应助: 7 (幼儿园)
- 金币: 3009.7
- 散金: 1974
- 红花: 5
- 帖子: 1041
- 在线: 1031.7小时
- 虫号: 471925
- 注册: 2007-12-03
- 性别: GG
- 专业: 自然地理学
|
clear %define axis X=40.5:42.5; Y=-88.5:-86.5; T=169:372; %time period 1/1962:12/1979 %Creat netcdf file ncid = netcdf.create('Isotope.nc','NC_WRITE'); %Define the dimensions of the variables latdimID = netcdf.defDim(ncid,'lat',length(X)); londimID = netcdf.defDim(ncid,'lon',length(Y)); timedimID = netcdf.defDim(ncid,'time',length(T)); % Define a new variable named 'monthlyIso'in the file isovarid = netcdf.defVar(ncid,'monthlyIso','NC_DOUBLE',[latdimID londimID timedimID]); % Assign unit attributes netcdf.putAtt(ncid,isovarid,'units','per mil'); netcdf.endDef(ncid); netcdf.putVar(ncid,isovarid,mydata); netcdf.close(ncid); 试了试,可是不对啊. |
6楼2010-03-11 23:56:31
所里的
木虫 (著名写手)
- 应助: 1 (幼儿园)
- 金币: 3656.3
- 散金: 17
- 红花: 2
- 帖子: 1468
- 在线: 74.9小时
- 虫号: 121259
- 注册: 2005-12-03
- 性别: GG
- 专业: 大气环境与全球气候变化
7楼2010-03-12 15:40:26













回复此楼
= latitude; % Put all the data,对nc文件赋各变量的值.