example_init_lag.html 8.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of example_init_lag</title>
  <meta name="keywords" content="example_init_lag">
  <meta name="description" content="">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">fvcom_prepro</a> &gt; example_init_lag.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>example_init_lag
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong></strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>This is a script file. </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
36
<li><a href="plot_field.html" class="code" title="function plot_field(Mobj,PlotField,varargin)">plot_field</a>	Plot the mesh, user defined field, open boundary nodes, and river points</li><li><a href="read_fvcom_bath.html" class="code" title="function [h] = read_fvcom_bath(bathfile)">read_fvcom_bath</a>	Read fvcom bathymetry file</li><li><a href="setup_metrics.html" class="code" title="function [Mobj]  = setup_metrics(Mobj)">setup_metrics</a>	Setup metrics for mesh object Mesh</li></ul>
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 clear all; close all;
0002 
0003 <span class="comment">% example script:</span>
0004 <span class="comment">% initialize the online Lagrangian tracking for Julian day (realtime) forcing</span>
0005 <span class="comment">%</span>
0006 <span class="comment">% Author(s):</span>
0007 <span class="comment">%    Geoff Cowles (University of Massachusetts Dartmouth)</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% Revision history</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%==============================================================================</span>
0012 <span class="comment">%warning off</span>
0013 type = 2;
0014 
0015 <span class="comment">% set mesh/bathymetry files</span>
0016 meshfile = <span class="string">'../Model_Maker/coos01_grd.dat'</span>;
0017 bathfile = <span class="string">'../Model_Maker/coos01_dep.dat'</span>; 
0018 lagfile  = <span class="string">'test_lag.nc'</span>;
0019 
0020 <span class="comment">% start/end time for particles</span>
0021 tbeg = greg2mjulian(2008,01,01,0,0,0); 
0022 tend = greg2mjulian(2008,02,01,0,0,0); 
0023 
0024 <span class="comment">% read in mesh and bathymetry</span>
69
0025 Mobj = read_fvcom_mesh(meshfile);
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
0026 Mobj.h = <a href="read_fvcom_bath.html" class="code" title="function [h] = read_fvcom_bath(bathfile)">read_fvcom_bath</a>(bathfile); Mobj.have_bath = true;
0027 Mobj = <a href="setup_metrics.html" class="code" title="function [Mobj]  = setup_metrics(Mobj)">setup_metrics</a>(Mobj);
0028 
0029 
0030 <span class="keyword">if</span>(type==1) <span class="comment">%initialize at all elements</span>
0031 
0032 xc   = Mobj.xc;
0033 yc   = Mobj.yc;
0034 nLag = Mobj.nElems;
0035 
0036 <span class="keyword">elseif</span>(type==2) <span class="comment">%initialize along a line of interest</span>
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 <span class="keyword">end</span>;
0044 
0045 
0046 <span class="comment">% plot to check</span>
0047 <a href="plot_field.html" class="code" title="function plot_field(Mobj,PlotField,varargin)">plot_field</a>(Mobj,Mobj.h,<span class="string">'title'</span>,<span class="string">'domain'</span>,<span class="string">'withextra'</span>,false,<span class="string">'showgrid'</span>,false); hold on;
0048 plot(xp,yp,<span class="string">'ro'</span>);
0049 
0050 
0051 <span class="comment">% dump the initial particle position file</span>
0052 nc = netcdf(lagfile,<span class="string">'clobber'</span>);
0053 nc.references = <span class="string">'http://fvcom.smast.umassd.edu'</span>;
0054 nc.source = <span class="string">'lag_init.m'</span>;
0055 nc.info = <span class="string">'debugging '</span>;
0056 
0057 
0058 
0059 
0060 
0061   
0062 <span class="comment">% dimensions</span>
0063 nc(<span class="string">'nparticles'</span>) = nLag;
0064 
0065 <span class="comment">% particle  vars</span>
0066 nc{<span class="string">'x'</span>} = ncfloat(<span class="string">'nparticles'</span>);
0067 nc{<span class="string">'x'</span>}.long_name = <span class="string">'particle x position'</span>;
0068 nc{<span class="string">'x'</span>}.units = <span class="string">'m'</span>; 
0069 
0070 nc{<span class="string">'y'</span>} = ncfloat(<span class="string">'nparticles'</span>);
0071 nc{<span class="string">'y'</span>}.long_name = <span class="string">'particle y position'</span>;
0072 nc{<span class="string">'y'</span>}.units = <span class="string">'m'</span>; 
0073 
0074 nc{<span class="string">'z'</span>} = ncfloat(<span class="string">'nparticles'</span>);
0075 nc{<span class="string">'z'</span>}.long_name = <span class="string">'particle z position'</span>;
0076 nc{<span class="string">'z'</span>}.units = <span class="string">'m'</span>; 
0077 
0078 nc{<span class="string">'pathlength'</span>} = ncfloat(<span class="string">'nparticles'</span>);
0079 nc{<span class="string">'pathlength'</span>}.long_name = <span class="string">'particle integrated path length'</span>; 
0080 nc{<span class="string">'pathlength'</span>}.units = <span class="string">'m'</span>; 
0081 
0082 nc{<span class="string">'tbeg'</span>} = ncfloat(<span class="string">'nparticles'</span>);
0083 nc{<span class="string">'tbeg'</span>}.long_name = <span class="string">'particle release time'</span>;
0084 nc{<span class="string">'tbeg'</span>}.units = <span class="string">'days since 1858-11-17 00:00:00'</span>;
0085 nc{<span class="string">'tbeg'</span>}.format = <span class="string">'modified julian day (MJD)'</span>;
0086 nc{<span class="string">'tbeg'</span>}.time_zone = <span class="string">'UTC'</span>;
0087 
0088 nc{<span class="string">'tend'</span>} = ncfloat(<span class="string">'nparticles'</span>);
0089 nc{<span class="string">'tend'</span>}.long_name = <span class="string">'particle freeze time'</span>;
0090 nc{<span class="string">'tend'</span>}.units = <span class="string">'days since 1858-11-17 00:00:00'</span>;
0091 nc{<span class="string">'tend'</span>}.format = <span class="string">'modified julian day (MJD)'</span>;
0092 nc{<span class="string">'tend'</span>}.time_zone = <span class="string">'UTC'</span>;
0093 
0094 
0095 nc{<span class="string">'group'</span>} = ncint(<span class="string">'nparticles'</span>);
0096 nc{<span class="string">'group'</span>}.long_name = <span class="string">'particle group'</span>; 
0097 nc{<span class="string">'group'</span>}.units = <span class="string">'-'</span>; 
0098 
0099 nc{<span class="string">'mark'</span>} = ncint(<span class="string">'nparticles'</span>);
0100 nc{<span class="string">'mark'</span>}.long_name = <span class="string">'particle mark'</span>; 
0101 nc{<span class="string">'mark'</span>}.units = <span class="string">'-'</span>; 
0102 
0103 <span class="comment">% dump vars</span>
0104 nc{<span class="string">'x'</span>}(:) = xp;
0105 nc{<span class="string">'y'</span>}(:) = yp;
0106 nc{<span class="string">'z'</span>}(:) = 0.0;
0107 nc{<span class="string">'tbeg'</span>}(:) = tbeg;
0108 nc{<span class="string">'tend'</span>}(:) = tend;
0109 nc{<span class="string">'group'</span>}(:) = 1;
0110 nc{<span class="string">'mark'</span>}(:) = 0;
0111 nc{<span class="string">'pathlength'</span>}(:) = 0.0;
0112 close(nc);</pre></div>
157
<hr><address>Generated on Thu 19-Mar-2015 12:20:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
158 159
</body>
</html>