Home > fvcom_prepro > example_init_lag.m

example_init_lag

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 clear all; close all;
0002 
0003 % example script:
0004 % initialize the online Lagrangian tracking for Julian day (realtime) forcing
0005 %
0006 % Author(s):
0007 %    Geoff Cowles (University of Massachusetts Dartmouth)
0008 %
0009 % Revision history
0010 %
0011 %==============================================================================
0012 %warning off
0013 type = 2;
0014 
0015 % set mesh/bathymetry files
0016 meshfile = '../Model_Maker/coos01_grd.dat';
0017 bathfile = '../Model_Maker/coos01_dep.dat'; 
0018 lagfile  = 'test_lag.nc';
0019 
0020 % start/end time for particles
0021 tbeg = greg2mjulian(2008,01,01,0,0,0); 
0022 tend = greg2mjulian(2008,02,01,0,0,0); 
0023 
0024 % read in mesh and bathymetry
0025 Mobj = read_fvcom_mesh(meshfile);
0026 Mobj.h = read_fvcom_bath(bathfile); Mobj.have_bath = true;
0027 Mobj = setup_metrics(Mobj);
0028 
0029 
0030 if(type==1) %initialize at all elements
0031 
0032 xc   = Mobj.xc;
0033 yc   = Mobj.yc;
0034 nLag = Mobj.nElems;
0035 
0036 elseif(type==2) %initialize along a line of interest
0037 nLag = 10;  
0038 p1 = [1.188363e6,194497];
0039 p2 = [1.188548e6,194996];
0040 xp = p1(1):(p2(1)-p1(1))/(nLag-1):p2(1);
0041 yp = p1(2):(p2(2)-p1(2))/(nLag-1):p2(2);
0042 
0043 end;
0044 
0045 
0046 % plot to check
0047 plot_field(Mobj,Mobj.h,'title','domain','withextra',false,'showgrid',false); hold on;
0048 plot(xp,yp,'ro');
0049 
0050 
0051 % dump the initial particle position file
0052 nc = netcdf(lagfile,'clobber');
0053 nc.references = 'http://fvcom.smast.umassd.edu';
0054 nc.source = 'lag_init.m';
0055 nc.info = 'debugging ';
0056 
0057 
0058 
0059 
0060 
0061   
0062 % dimensions
0063 nc('nparticles') = nLag;
0064 
0065 % particle  vars
0066 nc{'x'} = ncfloat('nparticles');
0067 nc{'x'}.long_name = 'particle x position';
0068 nc{'x'}.units = 'm'; 
0069 
0070 nc{'y'} = ncfloat('nparticles');
0071 nc{'y'}.long_name = 'particle y position';
0072 nc{'y'}.units = 'm'; 
0073 
0074 nc{'z'} = ncfloat('nparticles');
0075 nc{'z'}.long_name = 'particle z position';
0076 nc{'z'}.units = 'm'; 
0077 
0078 nc{'pathlength'} = ncfloat('nparticles');
0079 nc{'pathlength'}.long_name = 'particle integrated path length'; 
0080 nc{'pathlength'}.units = 'm'; 
0081 
0082 nc{'tbeg'} = ncfloat('nparticles');
0083 nc{'tbeg'}.long_name = 'particle release time';
0084 nc{'tbeg'}.units = 'days since 1858-11-17 00:00:00';
0085 nc{'tbeg'}.format = 'modified julian day (MJD)';
0086 nc{'tbeg'}.time_zone = 'UTC';
0087 
0088 nc{'tend'} = ncfloat('nparticles');
0089 nc{'tend'}.long_name = 'particle freeze time';
0090 nc{'tend'}.units = 'days since 1858-11-17 00:00:00';
0091 nc{'tend'}.format = 'modified julian day (MJD)';
0092 nc{'tend'}.time_zone = 'UTC';
0093 
0094 
0095 nc{'group'} = ncint('nparticles');
0096 nc{'group'}.long_name = 'particle group'; 
0097 nc{'group'}.units = '-'; 
0098 
0099 nc{'mark'} = ncint('nparticles');
0100 nc{'mark'}.long_name = 'particle mark'; 
0101 nc{'mark'}.units = '-'; 
0102 
0103 % dump vars
0104 nc{'x'}(:) = xp;
0105 nc{'y'}(:) = yp;
0106 nc{'z'}(:) = 0.0;
0107 nc{'tbeg'}(:) = tbeg;
0108 nc{'tend'}(:) = tend;
0109 nc{'group'}(:) = 1;
0110 nc{'mark'}(:) = 0;
0111 nc{'pathlength'}(:) = 0.0;
0112 close(nc);

Generated on Thu 19-Mar-2015 12:20:56 by m2html © 2005