⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdi2cdf.m

📁 一个研究声多普勒计程仪很好的工具箱
💻 M
📖 第 1 页 / 共 3 页
字号:
data(fld)=fread(fid,1,'ushort');if verbose, disp(sprintf('Depth cell size %d cm',data(fld))); end% this attribute is tagged to the depth variablefld=fld+1;% blanking distance (WF)data(fld)=fread(fid,1,'ushort');if verbose, disp(sprintf('Blank after xmit distance %d cm',data(fld))); end% this attribute is tagged to the depth variablefld=fld+1;% Profiling mode (WM)data(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('Profiling mode %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','profiling_mode','LONG',1,data(fld));%cdf.profiling_mode = nclong(data(fld));fld=fld+1;
%Predicted Accuracy given in PLAN and entered by user
mexcdf('ATTPUT',cdf,'GLOBAL','pred_accuracy','FLOAT',1,pred_accuracy);
% Minimum correlation threshold (WC)data(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('Valid range for correlation %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','valid_correlation_range','LONG',2,[data(fld) 255]);%cdf.valid_correlation_range = nclong([data(fld) 0]);fld=fld+1;% number of code repetitionsdata(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('Code repetitions %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','code_repetitions','LONG',1,data(fld));%cdf.code_repetitions = nclong(data(fld));fld=fld+1;% Minimum percent good to output data (WG)data(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('Minimum and maximum percent good for output %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','minmax_percent_good','LONG',2,[data(fld) 100]);%cdf.minmax_percent_good = nclong([data(fld) 0]);fld=fld+1;% Error velocity threshold (WE)data(fld)=fread(fid,1,'ushort');if verbose, disp(sprintf('Minimum and Maximum Error Velocity values permitted %d mm/s',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','error_velocity_threshold','LONG',1,data(fld));%cdf.minmax_error_velocity = nclong([data(fld) 0]);fld=fld+1;% time between ping groups (TP)data(fld)=fread(fid,1,'uchar');fld=fld+1;data(fld)=fread(fid,1,'uchar');fld=fld+1;data(fld)=fread(fid,1,'uchar');tp=[data(fld-2),data(fld-1),data(fld)];  %added by JMCTP = str2num(sprintf('%d.%d',(tp(1)*60 + tp(2)),tp(3)));if verbose, disp(['Time between ping groups ' TP]); endmexcdf('ATTPUT',cdf,'GLOBAL','time_between_ping_groups','FLOAT',1,...	TP);%cdf.time_between_ping_groups = ncfloat(TP);fld=fld+1;% coordinate transformation (EX)data(fld)=fread(fid,1,'uchar');if verbose, 	disp(sprintf('Coordinate Transformation = %d',data(fld))); 	%b=dec2bin(data(fld));   %b=zeros(1,8); %dec2bin(data(fld));   b=dec2bin(data(fld),8);   %b(9-length(dec2bin(data(fld))):8)=dec2bin(data(fld));   %b=char(b);	transform=bin2dec(b(4:5));	if transform == 0, 		disp('	Data stored coordinates = Beam');       mexcdf('ATTPUT',cdf,'GLOBAL','transform','CHAR',4,'BEAM');      %cdf.transform = 'BEAM';	end	if transform == 1, 		disp('	Data stored coordinates = Instrument');       mexcdf('ATTPUT',cdf,'GLOBAL','transform','CHAR',4,'INST');      %cdf.transform = 'INST';	end	if transform == 2, 		disp('	Data stored coordinates = Ship');       mexcdf('ATTPUT',cdf,'GLOBAL','transform','CHAR',4,'SHIP');      %cdf.transform = 'SHIP';	end	if transform == 3, 		disp('	Data stored coordinates = Earth');       mexcdf('ATTPUT',cdf,'GLOBAL','transform','CHAR',5,'EARTH');      %cdf.transform = 'EARTH';	end%	if b(6) == '1', disp('	Tilts used in transformation'); end%	if b(7) == '1', disp('	3-beam solution used, this ensemble'); endendfld=fld+1;% Heading Alignment (EA)data(fld)=fread(fid,1,'int16');if verbose, disp(sprintf('Heading alignment %d',data(fld)./100)); endhdg_alignment = data(fld)./100;fld=fld+1;% Heading Bias (EB)data(fld)=fread(fid,1,'int16');if verbose, disp(sprintf('Heading Bias: %d deg',data(fld)./100)); endhdg_bias = data(fld)./100;fld=fld+1;% Sensor source (EZ)data(fld)=fread(fid,1,'uchar');if verbose,	disp(sprintf('Sensor Source = %d',data(fld))); 	%b=(data(fld));   b=zeros(1,8); %dec2bin(data(fld));   b(9-length(dec2bin(data(fld))):8)=dec2bin(data(fld));   b=char(b);	if b(2) == '1',		buf='Sound speed computed from ED, ES & ET';		disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end	if b(3) == '1', 		buf = 'ED taken from depth sensor';		disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end		if b(4) == '1', 		buf = 'EH taken from xducer heading sensor';		disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end		if b(5) == '1', 		buf = 'EP taken from xducer pitch sensor';			disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end		if b(6) == '1', 		buf = 'ER taken from xducer roll sensor';			disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end		if b(7) == '1', 		buf = 'ES derived from conductivity sensor';			disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end		if b(8) == '1', 		buf = 'ET taken from temperature sensor';		disp(['  ',buf]); 		mcnote(cdf,'GLOBAL',buf,notenum);			notenum=notenum+1;	end	endfld=fld+1;% Sensors availabledata(fld)=fread(fid,1,'uchar');if verbose,	disp(sprintf('Sensor Availability = %d',data(fld))); 	%b=dec2bin(data(fld));   b=zeros(1,8); %dec2bin(data(fld));   b(9-length(dec2bin(data(fld))):8)=dec2bin(data(fld));   b=char(b);	if b(3) == '1', disp('	depth sensor'); 		mcnote(cdf,'GLOBAL','depth sensor available',notenum);			notenum=notenum+1;	end		if b(4) == '1', disp('	heading sensor');  		mcnote(cdf,'GLOBAL','depth sensor available',notenum);			notenum=notenum+1;	end		if b(5) == '1', disp('	pitch sensor');  		mcnote(cdf,'GLOBAL','pitch sensor available',notenum);			notenum=notenum+1;	end		if b(6) == '1', disp('	roll sensor');  		mcnote(cdf,'GLOBAL','roll sensor available',notenum);			notenum=notenum+1;	end		if b(7) == '1', disp('	conductivity sensor');  		mcnote(cdf,'GLOBAL','conductivity sensor available',notenum);			notenum=notenum+1;	end		if b(8) == '1', disp('	temperature sensor');  		mcnote(cdf,'GLOBAL','temperature sensor available',notenum);			notenum=notenum+1;	end	endfld=fld+1;% Bin 1 distancedata(fld)=fread(fid,1,'ushort');if verbose, disp(sprintf('Distance to center of bin 1: %d cm',data(fld))); end% this is saved with the depth variablefld=fld+1;% xmit pulse lengthdata(fld)=fread(fid,1,'ushort');if verbose, disp(sprintf('Transmit pulse length %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','transmit_pulse_length','LONG',1,data(fld));%cdf.transmit_pulse_length = nclong(data(fld));mcnote(cdf,'GLOBAL','transmit_pulse_length units are cm',notenum);	notenum=notenum+1;fld=fld+1;% starting depth celldata(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('Starting water layer %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','starting_water_layer','LONG',1,data(fld));%cdf.starting_water_layer = nclong(data(fld));fld=fld+1;% ending depth celldata(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('Ending water layer %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','ending_water_layer','LONG',1,data(fld));%cdf.ending_water_layer = nclong(data(fld));fld=fld+1;% false target reject thresholddata(fld)=fread(fid,1,'uchar');if verbose, disp(sprintf('False target reject range values %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','false_target_reject_values','LONG',2,[data(fld) 255]);%cdf.false_target_reject_values = nclong([data(fld) 0]);fld=fld+1;% sparedata(fld)=fread(fid,1,'uchar');fld=fld+1;% transmit lag distancedata(fld)=fread(fid,1,'ushort');if verbose, disp(sprintf('Transmit lag distance %d',data(fld))); endmexcdf('ATTPUT',cdf,'GLOBAL','transmit_lag_distance','LONG',1,data(fld));%cdf.transmit_lag_distance = nclong(data(fld));mexcdf('ATTPUT',cdf,'GLOBAL','ADCP_serial_number','LONG',1,ADCP_serial_number);%cdf.ADCP_serial_number = nclong(ADCP_serial_number);% save the rest of the data for laterfleader = data;disp('-----------')%% ------ Set up the variables -----%% determine the number of ensembles from the file size%	and number of bytes per ensemble% there is an 8260 byte leader in every fileLEADERSIZE = 0; % original size 8260;% the checksum at the end of every ensemble record is two bytesCHECKSUMSIZE = 2;fseek(fid,0,1);	% go to end of fileinfilesize = ftell(fid)nens = ceil((infilesize-LEADERSIZE)/(nbytes+CHECKSUMSIZE));disp(sprintf('%d ensembles estimated from file size',nens))% dimensionsensid=mexcdf('DIMDEF',cdf,'ensemble','NC_UNLIMITED');%cdf('ensemble') = 0; 	% the record dimensionbinid=mexcdf('DIMDEF',cdf,'bin',nbins);%cdf('bin') = nbins;% variables% mexcdf('VARDEF',cdf,'D','FLOAT',1,[binid]);%cdf{'D'} = ncfloat('bin');mexcdf('ATTPUT',cdf,'D','units','CHAR',1,'m');%cdf{'D'}.units = 'm';mexcdf('ATTPUT',cdf,'D','long_name','CHAR',9,'DEPTH (m)');%cdf{'D'}.long_name = 'DEPTH (m)';mexcdf('ATTPUT',cdf,'D','_FillValue','FLOAT',1,1e35);% note, netcdf will not handle leading _%cdf{'D'}.FillValue = ncfloat(1e35);mexcdf('ATTPUT',cdf,'D','epic_code','LONG',1,3);%cdf{'D'}.epic_code = nclong(3);bin1=fleader(26)/100;mexcdf('ATTPUT',cdf,'D','center_first_bin','FLOAT',1,bin1);%cdf{'D'}.center_first_bin = ncfloat(fleader(26)/100);blank=fleader(12)/100;mexcdf('ATTPUT',cdf,'D','blanking_distance','FLOAT',1,blank);%cdf{'D'}.blanking_distance = ncfloat(fleader(12)/100);binsize=fleader(11)/100;mexcdf('ATTPUT',cdf,'D','bin_size','FLOAT',1,binsize);%cdf{'D'}.bin_size = ncfloat(fleader(11)/100);bincnt=nbins;mexcdf('ATTPUT',cdf,'D','bin_count','LONG',1,nbins);%cdf{'D'}.bin_count = nclong(nbins);water_depth = 0;mexcdf('ATTPUT',cdf,'D','water_depth','FLOAT',1,water_depth);%cdf{'D'}.water_depth = ncfloat(water_depth);%xducer_offset = 0;mexcdf('ATTPUT',cdf,'D','xducer_offset_from_bottom','FLOAT',1,xducer_offset);%cdf{'D'}.xducer_offset_from_bottom = ncfloat(xducer_offset);switch orientation  %Added 10-Jan-2003case 'up'    mcnote(cdf,'D','bin depths are relative to the seabed',notenum);    notenum=notenum+1;    % compute bin locations    depths = bin1:binsize:(((bincnt-1)*binsize)+bin1);    % adjust for ADCP position and save depths for later    depths = depths+xducer_offset;case 'down'     mcnote(cdf,'D','bin depths are relative to the transducer head',notenum);     notenum=notenum;    % compute bin locations    depths = bin1:binsize:(((bincnt-1)*binsize)+bin1);    depths = depths * -1;endmexcdf('VARDEF',cdf,'TIM','DOUBLE',1,0);%cdf{'TIM'} = ncdouble('ensemble');mexcdf('ATTPUT',cdf,'TIM','units','CHAR',12,'decimal days');%cdf{'TIM'}.units = 'decimal days';mexcdf('ATTPUT',cdf,'TIM','long_name','CHAR',11,'JULIAN DAYS');%cdf{'TIM'}.long_name = 'JULIAN DAYS';mexcdf('ATTPUT',cdf,'TIM','_FillValue','DOUBLE',1,1e35);%cdf{'TIM'}.FillValue = 1e35;mexcdf('ATTPUT',cdf,'TIM','epic_code','LONG',1,627);%cdf{'TIM'}.epic_code = nclong(627);mexcdf('ATTPUT',cdf,'TIM','valid_min','LONG',1,0);%cdf{'TIM'}.valid_min = nclong(0);mexcdf('ATTPUT',cdf,'TIM','slow_by','LONG',1,slow_by);mcnote(cdf,'TIM','amount of time the ADCP clock was "slow_by" is in seconds',notenum);	notenum=notenum+1;mexcdf('VARDEF',cdf,'Rec','LONG',1,0);%cdf{'Rec'} = nclong('ensemble');mexcdf('ATTPUT',cdf,'Rec','units','CHAR',6,'counts');%cdf{'Rec'}.units = 'counts';mexcdf('ATTPUT',cdf,'Rec','long_name','CHAR',7,'Records');%cdf{'Rec'}.long_name = 'Records';mexcdf('ATTPUT',cdf,'Rec','_FillValue','LONG',1,1e35);%cdf{'Rec'}.FillValue = nclong(1e35);mexcdf('ATTPUT',cdf,'Rec','epic_code','LONG',1,1207);%cdf{'Rec'}.epic_code = nclong(1207);mexcdf('ATTPUT',cdf,'Rec','valid_min','LONG',1,0);%cdf{'Rec'}.valid_min = nclong(0);%mexcdf('VARDEF',cdf,'sv','LONG',1,0);%cdf{'sv'} = nclong('ensemble');mexcdf('ATTPUT',cdf,'sv','units','CHAR',5,'m s-1');%cdf{'sv'}.units = 'm s-1';mexcdf('ATTPUT',cdf,'sv','long_name','CHAR',20,'sound velocity (m/s)');%cdf{'sv'}.long_name = 'sound velocity (m/s)';mexcdf('ATTPUT',cdf,'sv','_FillValue','LONG',1,1e35);%cdf{'sv'}.FillValue = nclong(1e35);mexcdf('ATTPUT',cdf,'sv','epic_code','LONG',1,80);%cdf{'sv'}.epic_code = nclong(80);mexcdf('ATTPUT',cdf,'sv','valid_range','LONG',2,[1400 1600]);%cdf{'sv'}.valid_range = nclong([1400 1600]);%for i=1:nbeams,	varname = [VARNAMES(VELOCITY,:),int2str(i)];   mexcdf('VARDEF',cdf,varname,'FLOAT',2,[0 1]);   %eval(['cdf{''',varname,'''} = ncfloat(''ensemble'',''bin'');'])	mexcdf('ATTPUT',cdf,varname,'units','CHAR',6,'mm s-1');   %eval(['cdf{''',varname,'''}.units = ''mm s-1'';'])	if ~transform,	% this EPIC code is for BEAM coordinates only		buf=sprintf('Beam %1i velocity, mm/s',i);		mexcdf('ATTPUT',cdf,varname,'long_name','CHAR',length(buf),buf);		%eval(['cdf{''',varname,'''}.long_name = buf;'])      mexcdf('ATTPUT',cdf,varname,'epic_code','LONG',1,1279+i);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -