0001 function init_lag(Mobj, timerange, type, file)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 subname = 'init_lag';
0043
0044 global ftbverbose;
0045 if ftbverbose
0046 fprintf('\nbegin : %s \n', subname)
0047 end
0048
0049 tbeg = timerange(1);
0050 tend = timerange(2);
0051
0052 if type == 1
0053 xp = Mobj.xc;
0054 yp = Mobj.yc;
0055 nLag = Mobj.nElems;
0056 elseif type == 2
0057 nLag = 10;
0058 p1 = [1.188363e6,194497];
0059 p2 = [1.188548e6,194996];
0060 xp = p1(1):(p2(1)-p1(1))/(nLag-1):p2(1);
0061 yp = p1(2):(p2(2)-p1(2))/(nLag-1):p2(2);
0062 elseif isvector(type)
0063 end
0064
0065
0066 nc = netcdf.create(file, 'clobber');
0067 netcdf.putAtt(nc, netcdf.getConstant('NC_GLOBAL'), 'references', 'http://fvcom.smast.umassd.edu, http://pml.ac.uk')
0068 netcdf.putAtt(nc, netcdf.getConstant('NC_GLOBAL'), 'source', 'init_lag.m')
0069 netcdf.putAtt(nc, netcdf.getConstant('NC_GLOBAL'), 'info', 'debugging')
0070 netcdf.putAtt(nc, netcdf.getConstant('NC_GLOBAL'), 'history', sprintf('File created with %s from the MATLAB fvcom-toolbox', subname))
0071
0072
0073 nlag_dimid = netcdf.defDim(nc, 'nparticles', nLag);
0074
0075
0076 x_varid = netcdf.defVar(nc, 'x', 'NC_FLOAT', nlag_dimid);
0077 netcdf.putAtt(nc, x_varid, 'long_name', 'particle x position');
0078 netcdf.putAtt(nc, x_varid, 'units', 'm');
0079
0080 y_varid = netcdf.defVar(nc, 'particle y position', 'NC_FLOAT', nlag_dimid);
0081 netcdf.putAtt(nc, y_varid, 'long_name', 'particle y position');
0082 netcdf.putAtt(nc, y_varid, 'units', 'm');
0083
0084 z_varid = netcdf.defVar(nc, 'particle z position', 'NC_FLOAT', nlag_dimid);
0085 netcdf.putAtt(nc, z_varid, 'long_name', 'particle z position');
0086 netcdf.putAtt(nc, z_varid, 'units', 'm');
0087
0088 pathlength_varid = netcdf.defVar(nc, 'pathlength', 'NC_FLOAT', nlag_dimid);
0089 netcdf.putAtt(nc, pathlength_varid, 'long_name', 'particle integrated path length');
0090 netcdf.putAtt(nc, pathlength_varid, 'units', 'm');
0091
0092 tbeg_varid = netcdf.defVar(nc, 'tbeg', 'NC_FLOAT', nlag_dimid);
0093 netcdf.putAtt(nc, tbeg_varid, 'long_name', 'particle release time');
0094 netcdf.putAtt(nc, tbeg_varid, 'units', 'days since 1858-11-17 00:00:00');
0095 netcdf.putAtt(nc, tbeg_varid, 'format', 'modified julian day (MJD)');
0096 netcdf.putAtt(nc, tbeg_varid, 'time_zone', 'UTC');
0097
0098 tend_varid = netcdf.defVar(nc, 'tbeg', 'NC_FLOAT', nlag_dimid);
0099 netcdf.putAtt(nc, tend_varid, 'long_name', 'particle freeze time');
0100 netcdf.putAtt(nc, tend_varid, 'units', 'days since 1858-11-17 00:00:00');
0101 netcdf.putAtt(nc, tend_varid, 'format', 'modified julian day (MJD)');
0102 netcdf.putAtt(nc, tend_varid, 'time_zone', 'UTC');
0103
0104 group_varid = netdf.defVar(nc, 'group', 'NC_INT', nlag_dimid);
0105 netcdf.putAtt(nc, group_varid, 'long_name', 'particle group');
0106 netcdf.putAtt(nc, group_varid, 'units', '-');
0107
0108 mark_varid = netdf.defVar(nc, 'mark', 'NC_INT', nlag_dimid);
0109 netcdf.putAtt(nc, mark_varid, 'long_name', 'particle mark');
0110 netcdf.putAtt(nc, mark_varid, 'units', '-');
0111
0112
0113 netcdf.endDef(nc);
0114
0115
0116 netcdf.putVar(nc, x_varid, xp);
0117 netcdf.putVar(nc, y_varid, yp);
0118 netcdf.putVar(nc, z_varid, zp);
0119 netcdf.putVar(nc, tbeg_varid, tbeg);
0120 netcdf.putVar(nc, tend_varid, tend);
0121 netcdf.putVar(nc, group_varid, 1);
0122 netcdf.putVar(nc, mark_varid, 0);
0123 netcdf.putVar(nc, pathlength_varid, 0);
0124
0125
0126 netcdf.close(nc);
0127
0128 if ftbverbose; fprintf('end : %s\n', subname); end