From 426399f961caebf760ab6aab4a9873366aab429c Mon Sep 17 00:00:00 2001 From: Prousselot <pierre.rousselot@ird.fr> Date: Wed, 31 Mar 2021 17:19:43 +0200 Subject: [PATCH] New netcdf convention (OceanSites) --- moored_adcp_proc/f_w_ADCP_ncOS.m | 195 +++++++++++++++++++++++++++ multi_adcp_mooring/merge_data.m | 36 +++-- template_get_adcp_data.m | 76 ++++++----- tools/f_creer_newvar2.m | 32 +++++ tools/input_GlobalAttrParameters.xls | Bin 0 -> 8704 bytes 5 files changed, 282 insertions(+), 57 deletions(-) create mode 100644 moored_adcp_proc/f_w_ADCP_ncOS.m create mode 100644 tools/f_creer_newvar2.m create mode 100644 tools/input_GlobalAttrParameters.xls diff --git a/moored_adcp_proc/f_w_ADCP_ncOS.m b/moored_adcp_proc/f_w_ADCP_ncOS.m new file mode 100644 index 0000000..d31d369 --- /dev/null +++ b/moored_adcp_proc/f_w_ADCP_ncOS.m @@ -0,0 +1,195 @@ +function f_w_ADCP_ncOS(tc_filenamin,cell_Attributes,struct_ADCP,d_fillval) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Function to write ADCP mooring current post-processed fields into NetCDF file format following OceanSites requirements. +% +% INPUTS : +% tc_filenamin : output NETCDF file name including path +% cell_Attributes : cell array containing global attribute informations needed to create NETCDF file +% (attributes read previously from xls file) +% struct_ADCP : structure array with ADCP data (U,V), dimensions (TIME,DEPTH) and mooring name +% and positions (Name of the fields are: mooringName,mooringLat,mooringLon,time,depth,u,v) +% d_fillval : numeric value to specify fill value. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Authors : Jerome LLIDO IRD/LEGOS +% Pierre Rousselot IRD/US-IMAGO +% +% Date : 26/11/2020 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% TEST INPUT ARGUMENTS %% +if nargin < 4 + error('MATLAB:notEnoughInputs',... + '\nNot enough input arguments.'); +end +if ~ischar(tc_filenamin) + error('MyComponent:incorrectType',... + '\nFirst input argument must be a char, not a %s.',class(tc_filenamin)); +end +if ~iscell(cell_Attributes) + error('MyComponent:incorrectType',... + '\nSecond input argument must be a cell, not a %s.',class(cell_Attributes)); +end +if ~isstruct(struct_ADCP) + error('MyComponent:incorrectType',... + '\nThird input argument must be a structure, not a %s.',class(struct_ADCP)); +elseif ~all(isfield(struct_ADCP,{'mooringName','mooringLat','mooringLon','time','depth','u','v'})) + error('\nCheck the field names of the structure array %s. \n Fields : time, depth, mooringLat, mooringLon, u and v required.',class(struct_ADCP)); +end +if ~isnumeric(d_fillval) + error('MyComponent:incorrectType',... + '\nLast input argument must be a numeric value, not a %s.',class(d_fillval)); +end + +%% Get start and final dates of mooring data %% +ti_startDate=julian(struct_ADCP.time(1,1)); +ti_finalDate=julian(struct_ADCP.time(length(struct_ADCP.time))); + +% Convert initial time from Julian Days (JD) beginning at 0000 hours, May 23, 1968 (as initialy created) to days numbers (JD) to be used as started at 0000 hours on January 01, 1950 %% +ti_timeJulD=struct_ADCP.time; +ti_timeJ=ones(1,numel(ti_timeJulD)) * NaN; +for it=1:numel(ti_timeJulD) + ti_timeJ(it)=days(datetime(ti_timeJulD(it)-0.5,'ConvertFrom','juliandate') - datetime(1950,1,1,0,0,0)); % -0.5 is necessary to remove 12h00 introduced by datetime function starting at noon instead of midnight as performed by julian function previously used +end +struct_ADCP.time=ti_timeJ; + +%% Find and replace NaN by FillValue in all variables %% +% Test and replace NaN (if needed) in variable dimensions (TIME, DEPTH, LATITUDE, LONGITUDE) % +if ~isempty(find(isnan(struct_ADCP.time))) + struct_ADCP.time(find(isnan(struct_ADCP.time)))=d_fillval; +end +if ~isempty(find(isnan(struct_ADCP.depth))) + struct_ADCP.time(find(isnan(struct_ADCP.depth)))=d_fillval; +end +if ~isempty(find(isnan(struct_ADCP.mooringLat))) + struct_ADCP.time(find(isnan(struct_ADCP.mooringLat)))=d_fillval; +end +if ~isempty(find(isnan(struct_ADCP.mooringLon))) + struct_ADCP.time(find(isnan(struct_ADCP.mooringLon)))=d_fillval; +end +% Find and replace NaN by FillValue in U,V ADCP fields % +struct_ADCP.u(find(isnan(struct_ADCP.u)))=d_fillval; +struct_ADCP.v(find(isnan(struct_ADCP.v)))=d_fillval; + +%% Create NetCDF file %% +ncid_ADCP = netcdf.create(tc_filenamin,'CLOBBER'); % NOCLOBBER must be used to prevent overwritting of existing file + +%% Define Dimensions %% +i_dimTime = netcdf.defDim(ncid_ADCP,'TIME',length(struct_ADCP.time)); +i_dimDepth = netcdf.defDim(ncid_ADCP,'DEPTH',length(struct_ADCP.depth)); +i_dimLat = netcdf.defDim(ncid_ADCP,'LATITUDE',length(struct_ADCP.mooringLat)); +i_dimLon = netcdf.defDim(ncid_ADCP,'LONGITUDE',length(struct_ADCP.mooringLon)); + +%% Create Netcdf Global Attributes %% + +for j=1:length(cell_Attributes) + % Test attribute's name to fill in time_coverage_start, time_coverage_end and geospatial lat_min, lat_max, lon_min and lon_max % + if strcmp(cell_Attributes{j,1},'time_coverage_start') + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'), 'time_coverage_start', [num2str(ti_startDate(1)) '-' num2str(ti_startDate(2),'%02d')... + '-' num2str(ti_startDate(3),'%02d') 'T' num2str(ti_startDate(4),'%02d') ':' num2str(ti_startDate(5),'%02d') ':' num2str(ti_startDate(6),'%02d') 'Z']); + elseif strcmp(cell_Attributes{j,1},'time_coverage_end') + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'), 'time_coverage_end', [num2str(ti_finalDate(1)) '-' num2str(ti_finalDate(2),'%02d')... + '-' num2str(ti_finalDate(3),'%02d') 'T' num2str(ti_finalDate(4),'%02d') ':' num2str(ti_finalDate(5),'%02d') ':' num2str(ti_finalDate(6),'%02d') 'Z']); + elseif strcmp(cell_Attributes{j,1},'geospatial_lat_min') + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'),'geospatial_lat_min',struct_ADCP.mooringLat); + elseif strcmp(cell_Attributes{j,1},'geospatial_lat_max') + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'),'geospatial_lat_max',struct_ADCP.mooringLat); + elseif strcmp(cell_Attributes{j,1},'geospatial_lon_min') + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'),'geospatial_lon_min',struct_ADCP.mooringLon); + elseif strcmp(cell_Attributes{j,1},'geospatial_lon_max') + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'),'geospatial_lon_max',struct_ADCP.mooringLon); + else + netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'),cell_Attributes{j,1},cell_Attributes{j,2}); + end +end % end loop j +% Add creation date +netcdf.putAtt(ncid_ADCP, netcdf.getConstant('NC_GLOBAL'), 'date_created', datestr(now, 'yyyy-mm-ddTHH:MM:SSZ')); + +%% Create Netcdf Variables & Attributes %% +% Coordinate Variables % +f_creer_newvar2(ncid_ADCP, 'TIME', 'NC_DOUBLE', i_dimTime,... + 'standard_name', 'time',... + 'units', 'days since 1950-01-01 00:00:00 UTC',... + 'axis', 'T',... + 'long_name','time of measurement',... + 'valid_min', 0.0, 'valid_max', 90000.0,... + '_FillValue', double(d_fillval),... + 'QC_indicator','good data',... + 'Processing_level','Data interpolated'); %% JLL 16/12/2020 : 'accuracy': ATTRIBUTE TO BE ADDED IF NECESSARY + +f_creer_newvar2(ncid_ADCP, 'DEPTH', 'NC_FLOAT', i_dimDepth,... + 'standard_name', 'depth',... + 'units', 'meters',... + 'positive', 'down',... + 'axis', 'Z',... + 'reference', 'sea_level',... + 'coordinate_reference_frame', 'urn:ogc:def:crs:EPSG::5831',... + '_FillValue', single(d_fillval),... + 'long_name', 'depth of measurement',... + 'valid_min', 0, 'valid_max', 12000,... + 'QC_indicator','good data',... + 'Processing_level','Data interpolated'); %% JLL 16/12/2020 : 'accuracy': ATTRIBUTE TO BE ADDED IF NECESSARY + +f_creer_newvar2(ncid_ADCP, 'LATITUDE', 'NC_FLOAT', i_dimLat,... + 'standard_name', 'latitude',... + 'units', 'degrees_north',... + 'axis', 'Y',... + 'long_name', 'latitude of measurement',... + 'reference', 'WGS84',... + 'coordinate_reference_frame', 'urn:ogc:def:crs:EPSG::4326',... + 'valid_min', -90.0, 'valid_max', 90.0,... + '_FillValue', single(d_fillval),... + 'QC_indicator','good data',... + 'Processing_level','Data interpolated'); %% JLL 16/12/2020 : 'accuracy': ATTRIBUTE TO BE ADDED IF NECESSARY + +f_creer_newvar2(ncid_ADCP, 'LONGITUDE', 'NC_FLOAT', i_dimLon,... + 'standard_name', 'longitude',... + 'units', 'degrees_east',... + 'axis', 'X',... + 'long_name', 'longitude of measurement',... + 'reference', 'WGS84',... + 'coordinate_reference_frame', 'urn:ogc:def:crs:EPSG::4326',... + 'valid_min', -180.0, 'valid_max', 180.0,... + '_FillValue', single(d_fillval),... + 'QC_indicator','good data',... + 'Processing_level','Data interpolated'); %% JLL 16/12/2020 : 'accuracy': ATTRIBUTE TO BE ADDED IF NECESSARY + +% Data Variables % +f_creer_newvar2(ncid_ADCP, 'UCUR', 'NC_FLOAT', [i_dimTime, i_dimDepth, i_dimLat, i_dimLon],... + 'standard_name', 'eastward velocity',... + 'units', 'm/s',... + '_FillValue', single(d_fillval),... + 'coordinates','TIME DEPTH LATITUDE LONGITUDE',... + 'long_name', 'eastward sea water velocity',... + 'QC_indicator','good data',... + 'processing_level','Data interpolated',... + 'valid_min' ,-12, 'valid_max', 12); %% JLL 16/12/2020 : 'accuracy': ATTRIBUTE TO BE ADDED IF NECESSARY + +f_creer_newvar2(ncid_ADCP, 'VCUR', 'NC_FLOAT', [i_dimTime, i_dimDepth, i_dimLat, i_dimLon],... + 'standard_name', 'northward velocity',... + 'units', 'm/s',... + '_FillValue', single(d_fillval),... + 'coordinates','TIME DEPTH LATITUDE LONGITUDE',... + 'long_name', 'northward sea water velocity',... + 'QC_indicator','good data',... + 'processing_level','Data interpolated',... + 'valid_min' ,-12, 'valid_max', 12); %% JLL 16/12/2020 : 'accuracy': ATTRIBUTE TO BE ADDED IF NECESSARY + +netcdf.endDef(ncid_ADCP); % End Netcdf variables definition + +%% Write/Store Dimensions and Variables in Netcdf file +netcdf.putVar(ncid_ADCP, netcdf.inqVarID(ncid_ADCP,'TIME'),struct_ADCP.time); +netcdf.putVar(ncid_ADCP, netcdf.inqVarID(ncid_ADCP,'DEPTH'),struct_ADCP.depth); +netcdf.putVar(ncid_ADCP, netcdf.inqVarID(ncid_ADCP,'LATITUDE'),struct_ADCP.mooringLat); +netcdf.putVar(ncid_ADCP, netcdf.inqVarID(ncid_ADCP,'LONGITUDE'),struct_ADCP.mooringLon); +netcdf.putVar(ncid_ADCP, netcdf.inqVarID(ncid_ADCP,'UCUR'),struct_ADCP.u); +netcdf.putVar(ncid_ADCP, netcdf.inqVarID(ncid_ADCP,'VCUR'),struct_ADCP.v); + +%% Close NetCDF file %% +netcdf.close(ncid_ADCP); + +end diff --git a/multi_adcp_mooring/merge_data.m b/multi_adcp_mooring/merge_data.m index 06d26e9..3edb4d4 100644 --- a/multi_adcp_mooring/merge_data.m +++ b/multi_adcp_mooring/merge_data.m @@ -5,14 +5,14 @@ clear all; close all; %% Variables -FileToMerge1 = 'F:\Encours\PIRATA_ADCP-MOORINGS\Convert_ADCP/ADCP_23W0N_2001_2015.nc'; %.nc file to merge with -FileToMerge2 = 'F:\Encours\PIRATA_ADCP-MOORINGS\23W\0_Final_Files/ADCP_0N23W_2015_2016_1d_up_down.nc'; %.nc file to merge +FileToMerge1 = 'M:\PIRATA-FR31\data-processing\MOUILLAGE_ADCP\10W\ADCP_10W0N_2001_2019_1d.nc'; %.nc file to merge with +FileToMerge2 = 'M:\PIRATA-FR31\data-processing\MOUILLAGE_ADCP\10W\ADCP_10W0N_2019_2019_1d.nc'; %.nc file to merge % FileToMerge3 = '/media/irdcampagnes/PIRATA/PIRATA_ADCP-MOORINGS/10W/0_Final_Files/ADCP_10W0N_2004_2005_1d.nc'; %.nc file to merge % FileToMerge1 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2013_1d.nc'; %.nc file to merge with % FileToMerge2 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2016_1d.nc'; %.nc file to merge step_subsampling = 1; % 1=daily plot_data = 1; -mooring.name = '23W0N'; +mooring.name = '10W0N'; freq = 'Variable'; % mooring.name = '0N130E'; % freq = '75'; @@ -20,8 +20,8 @@ freq = 'Variable'; %% Read first .nc file ncfile1.time = ncread(FileToMerge1,'TIME'); ncfile1.depth = ncread(FileToMerge1,'DEPTH'); -ncfile1.u = ncread(FileToMerge1,'U')'; -ncfile1.v = ncread(FileToMerge1,'V')'; +ncfile1.u = ncread(FileToMerge1,'UCUR')'; +ncfile1.v = ncread(FileToMerge1,'VCUR')'; %% Read second .nc file ncfile2.time = ncread(FileToMerge2,'TIME'); @@ -29,18 +29,13 @@ ncfile2.depth = ncread(FileToMerge2,'DEPTH'); ncfile2.u = ncread(FileToMerge2,'UCUR'); ncfile2.v = ncread(FileToMerge2,'VCUR'); -% %% Read third .nc file -% ncfile3.time = ncread(FileToMerge3,'TIME'); -% ncfile3.depth = ncread(FileToMerge3,'DEPTH'); -% ncfile3.u = ncread(FileToMerge3,'UCUR'); -% ncfile3.v = ncread(FileToMerge3,'VCUR'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Create depth matrix depth = max(vertcat(ncfile1.depth,ncfile2.depth)):ncfile1.depth(2)-ncfile1.depth(1):min(vertcat(ncfile1.depth,ncfile2.depth)); depth = fliplr(depth); max(vertcat(ncfile1.depth,ncfile2.depth)) -% min(vertcat(ncfile1.depth,ncfile2.depth)) -depth = 0:5:1000; +min(vertcat(ncfile1.depth,ncfile2.depth)) +depth = 0:5:350; %% Create time matrix time = vertcat(ncfile1.time,ncfile2.time); @@ -51,17 +46,14 @@ time = time*ones(1,length(depth)); %% Create u/v matrix for ii = 1:length(ncfile1.time) - u1(ii,:) = interp1(ncfile1.depth,ncfile1.u(ii,:),depth); - v1(ii,:) = interp1(ncfile1.depth,ncfile1.v(ii,:),depth); + u1(ii,:) = interp1(ncfile1.depth,ncfile1.u(:,ii),depth); + v1(ii,:) = interp1(ncfile1.depth,ncfile1.v(:,ii),depth); end for ii = 1:length(ncfile2.time) u2(ii,:) = interp1(ncfile2.depth,ncfile2.u(ii,:),depth); v2(ii,:) = interp1(ncfile2.depth,ncfile2.v(ii,:),depth); end -% for ii = 1:length(ncfile3.time) -% u3(ii,:) = interp1(ncfile3.depth,ncfile3.u(ii,:),depth); -% v3(ii,:) = interp1(ncfile3.depth,ncfile3.v(ii,:),depth); -% end + u = vertcat(u1,u2); v = vertcat(v1,v2); @@ -128,7 +120,7 @@ if plot_data gregtick; title({[mooring.name, ' - ' num2str(date1) ' to ' num2str(date2) ' - MERIDIONAL VELOCITY - RDI ',num2str(freq),' kHz (filtered from tide)']}); - graph_name = ['ADCP_' mooring.name '_' num2str(date1) '_' num2str(date2) '_U_V_daily']; + graph_name = ['/ADCP_' mooring.name '_' num2str(date1) '_' num2str(date2) '_U_V_daily']; set(hf,'Units','Inches'); pos = get(hf,'Position'); set(hf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)]) @@ -142,15 +134,17 @@ timed(:,5) = 0; timed(:,6) = 0; time = datenum(timed)-datenum(1950,01,01); +depth = depth(:,1); + disp('****') disp('Creating .nc file') yr_start = datestr(time(1)+datenum(1950,01,01), 'yyyy'); yr_end = datestr(time(end)+datenum(1950,01,01), 'yyyy'); -ncid = netcdf.create(['ADCP_',mooring.name,'_',num2str(yr_start),'_',num2str(yr_end),'.nc'],'NC_CLOBBER'); +ncid = netcdf.create(['/ADCP_',mooring.name,'_',num2str(yr_start),'_',num2str(yr_end),'.nc'],'NC_CLOBBER'); %create dimension -dimidz = netcdf.defDim(ncid, 'DEPTH', size(depth,2)); +dimidz = netcdf.defDim(ncid, 'DEPTH', size(depth,1)); dimidt = netcdf.defDim(ncid, 'TIME', netcdf.getConstant('NC_UNLIMITED')); %Define IDs for the dimension variables (pressure,time,latitude,...) time_ID = netcdf.defVar(ncid,'TIME','double',dimidt); diff --git a/template_get_adcp_data.m b/template_get_adcp_data.m index 5b3a890..dca5483 100644 --- a/template_get_adcp_data.m +++ b/template_get_adcp_data.m @@ -21,18 +21,21 @@ fpath_output = './0-0/'; % Cruise/mooring info cruise.name = 'PIRATA'; % cruise name -mooring.name = '0W0N'; % '0N10W' +mooring.name = '10W0N'; % '0N10W' mooring.lat = '00°00.000'; % latitude [°'] -mooring.lon = '00°00.000'; % longitude [°'] -clock_drift = 146; % [seconds] +mooring.lon = '-10°00.000'; % longitude [°'] +clock_drift = 418; % [seconds] % ADCP info -adcp.sn = 509; % ADCP serial number +adcp.sn = 24629; % ADCP serial number adcp.type = '150 khz Quartermaster'; % Type : Quartermaster, longranger adcp.direction = 'up'; % upward-looking 'up', downward-looking 'dn' adcp.instr_depth = 300; % nominal instrument depth instr = 1; % this is just for name convention and sorting of all mooring instruments +% NCFILE info +d_fillvalue = -9999; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -682,35 +685,36 @@ end %% Write netcdf file disp('****') disp('Creating .nc file') -[yr_start , ~, ~] = gregorian(inttim(1)); -[yr_end, ~, ~] = gregorian(inttim(length(inttim))); - -ncid = netcdf.create([fpath_output,'ADCP_',mooring.name,'_',num2str(yr_start),'_',num2str(yr_end),'_1d.nc'],'NC_WRITE'); - -%create dimension -dimidt = netcdf.defDim(ncid,'time',length(inttim)); -dimidz = netcdf.defDim(ncid,'depth',length(data.Z)); -%Define IDs for the dimension variables (pressure,time,latitude,...) -time_ID = netcdf.defVar(ncid,'time','double',dimidt); -depth_ID = netcdf.defVar(ncid,'depth','double',dimidz); -%Define the main variable () -u_ID = netcdf.defVar(ncid,'u','double',[dimidt dimidz]); -v_ID = netcdf.defVar(ncid,'v','double',[dimidt dimidz]); -if reply_ts == 1 - ts_ID = netcdf.defVar(ncid,'ts','double',[dimidt dimidz]); -end -%We are done defining the NetCdf -netcdf.endDef(ncid); -%Then store the dimension variables in -netcdf.putVar(ncid,time_ID,inttim); -netcdf.putVar(ncid,depth_ID,data.Z); -%Then store my main variable -netcdf.putVar(ncid,u_ID,data.uintfilt'); -netcdf.putVar(ncid,v_ID,data.vintfilt'); -if reply_ts == 1 - netcdf.putVar(ncid,ts_ID,data.tsintfilt'); -end -%We're done, close the netcdf -netcdf.close(ncid); -disp('****') -% ------------------------------------------------------------------------------------------- + +% Input parameters for NETCDF Global Attributes +tc_globAttFilename = fullfile('tools/input_GlobalAttrParameters.xls'); % JLL 2020/12 Il serait judicieux de remonter cette valeur en début du script template_get_adcp_data.m + +%% Prepare informations and variables required to create NETCDF file %% +[yr_start , ~, ~] = gregorian(data.inttim(1)); +[yr_end, ~, ~] = gregorian(data.inttim(length(data.inttim))); + +% Read inputs metadata required for NETCDF Global Attributes +[~,~,cell_ncAttributes] = xlsread(tc_globAttFilename); + +% Complete output path and filename +tc_ncFilenam_out = fullfile(fpath_output,['ADCP_',mooring.name,'_',num2str(yr_start),'_',num2str(yr_end),'_1d.nc']); + +% Assign a "4D-size" (TIME,DEPTH,LATITUDE,LONGITUDE) to the ADCP current variables : UINTFILT, VINTFILT +td_uADCP = ones(numel(data.inttim),numel(data.Z),numel(data.lat),numel(data.lon)) * d_fillvalue; +td_uADCP(:,:,1,1) = data.uintfilt'; +td_vADCP = ones(numel(data.inttim),numel(data.Z),numel(data.lat),numel(data.lon)) * d_fillvalue; +td_vADCP(:,:,1,1) = data.vintfilt'; + +% Flip for convention +data.Z = fliplr(data.Z); +td_uADCP = fliplr(td_uADCP); +td_vADCP = fliplr(td_vADCP); + +% Group general ADCP mooring informations and ADCP data to be written in NETCDF file format +struct_dataADCP = struct('mooringName', mooring.name, 'mooringLat', mooring.lat,... + 'mooringLon', mooring.lon, 'time', data.inttim, 'depth', data.Z,... + 'u', td_uADCP, 'v', td_vADCP); + +%% Write netcdf file %% +f_w_ADCP_ncOS(tc_ncFilenam_out,cell_ncAttributes,struct_dataADCP,d_fillvalue); +disp('****') \ No newline at end of file diff --git a/tools/f_creer_newvar2.m b/tools/f_creer_newvar2.m new file mode 100644 index 0000000..85f7909 --- /dev/null +++ b/tools/f_creer_newvar2.m @@ -0,0 +1,32 @@ +function f_creer_newvar2(nc,namevar,type,dimid,varargin) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Cascade Exploitation : +% ----------------------- +% +% Fonction permettant de creer une nouvelle +% Variable dans un fichier netcdf deja ouvert. +% Fonction a utiliser pour creer plusieurs variables dans un meme fichier NetCDF existant. +% +% f_creer_newvar2(filenc,namevar,type,dimvar,varargin) +% +% En entree : +% ------------- +% nc : identifiant du fichier NetCDF ou la variable doit etre creee. +% namevar : nom de la variable a creer +% type : Type de la variable +% dimid : Liste des identifiants des dimensions de la variable. +% varargin : liste(nom,valeur) des attributs de la variable a creer. ex: 'long_name','Vitessse en ms' +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% C. Kermabon - P Le Bot Avril 2009 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Definition/Creation de la variable. +id_var=netcdf.defVar(nc,namevar,type,dimid); +% Et de ses attributs. +for iatt=1:2:size(varargin,2) + netcdf.putAtt(nc,id_var,varargin{iatt},varargin{iatt+1}); +end diff --git a/tools/input_GlobalAttrParameters.xls b/tools/input_GlobalAttrParameters.xls new file mode 100644 index 0000000000000000000000000000000000000000..cfb2d651ac8495372f7006788fb79256b30dac9c GIT binary patch literal 8704 zcmeHMTZ|k>6}`O=d;ILRoi)a>O~oXBu6O;89pmhJAGTMrS+l!VB#1QWovGPvJkvdN z_xL3N8z6keQc#cxQX~|`KM~?Bg%6Oh#SapoAVjd>%Rwjt!N&##MUi4J=T!HMCq1*u z`XQuPuHCAxd+x2OTeoiAs-FJC8!N8A@{_f1Nh%$ZR=GL5NEX!L7V68Zbce_i)QR1k zot>@1s6I#^BMaO}bZx}~wjsA8bIlhbXOI^mFGl7XGcQZ(cJllfP4$7QO)M}fKK>$6 zG9(_Jfn31K&Ofb&$JBQ_pO*FUVm|U8CG%kXTNd~zTajOH|3w)D@&)bki)Fv#mN$F< zEoqS-w_Qak@;BtCr7YV;PPsY=v>F{bJvKIUVr0Ba^#?kP)bQwFm)f~o9Xz0R?^b*F ztNr`bU8jDdgJV&LD>!5hqh`s=K$pvp4Ejq`9+s7mK<X29z*H=G*XlF6Uoz!JQ!Yno z$<IxjzZzthY>*kW$jA#k#4yl8Yd{<+iYpV?2d?arwelOVX1{7AP;0l27!IZGhP$C{ zsa$4^J*GV!IK}Jo5PH8X|D9EMR?`(loXQ#e-TC3PSTp&#aQ50v{{F=;!={SUOH$R& z+haS>DNL&3Tj#*L=D@ejfiG%`bKQ+TJZ|g8t>MRS;V-t}jGmTRK0Bsc&2z={0`pus z-DaMvrWcy$L(}cE&lrDy4zpd&g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