


Generate the required fields within Mobj for time series elevation forcing at open boundaries using the TMD (TPXO) functions. Note that TMD requires moving to the directory of the TMD toolbox. But this sould be OK. Rory O'Hara Murray, 2013-07-01


0001 % Generate the required fields within Mobj for time series elevation 0002 % forcing at open boundaries using the TMD (TPXO) functions. 0003 % 0004 % Note that TMD requires moving to the directory of the TMD toolbox. But 0005 % this sould be OK. 0006 % 0007 % Rory O'Hara Murray, 2013-07-01 0008 % 0009 function [Mobj TMD_ConList] = set_elevtide_tmd(Mobj, dates_MJD, path_to_tmd) 0010 0011 %MyTitle = 'Julian FVCOM time series for open boundary from TPXO model using TMD'; 0012 0013 % make sure an open boudary is defined 0014 if(Mobj.nObs==0) 0015 warning('cannot setup spectral open boundary, there is no open boundary in the mesh struct') 0016 return 0017 end; 0018 0019 % make sure lon and lat are defined 0020 if(not(Mobj.have_lonlat)) 0021 warning('cannot setup spectral open boundary, longitude and latitude are not defined') 0022 return 0023 end 0024 0025 %for ob=1:Mobj.nObs % loop through each open boundary 0026 ob = 1; %assume only one open bounary for the moment 0027 0028 BNid = Mobj.obc_nodes(ob,Mobj.obc_nodes(ob,:)>0); % get the ids of the nodes on the boundary 0029 lat = Mobj.lat(BNid); 0030 lon = Mobj.lon(BNid); 0031 0032 % generate 10 minute (600s) time series from TMD (TPXO) 0033 %dates = [datenum(1993,09,1) datenum(1993,12,14)]; 0034 dates = dates_MJD([1 end]) + datenum('1858-11-17 00:00:00'); 0035 time = dates(1):1/24/6:dates(2); 0036 time_MJD = time - datenum('1858-11-17 00:00:00'); 0037 model_file = 'DATA\Model_ES2008'; 0038 current_dir = pwd; 0039 cd(path_to_tmd); 0040 [eta, TMD_ConList] = tmd_tide_pred_2(model_file, time, lat, lon, 'z'); 0041 cd(current_dir); 0042 0043 %% 0044 figure('position', [360 502 879 420]) 0045 %plot(NCOF_time, NCOF_eta(:,10), '-o', OTPS_time, OTPS_eta(:,10), OTPS_time, NCOF_eta2(:,10), '-') 0046 t0 = time(1); 0047 plot(time-t0, eta) 0048 legend(gca, 'TMD (OTIS)', 4) 0049 set(gca, 'yaxislocation', 'right') 0050 xlabel('Days') 0051 ylabel('Elevation (m)') 0052 %title('September 2011') 0053 0054 %% save file in FVCOM 3 format (netCDF) 0055 %write_FVCOM_julian(BNid,time,eta,filename_out_netCDF,MyTitle, 'timeformat', 'SDN') 0056 0057 %% save time series to the Mobj structure 0058 Mobj.surfaceElevation = eta'; % Makes surfaceElevation array with size (boundary nodes, time sereis) 0059 Mobj.el_time = time_MJD; 0060 0061 return 0062 0063