TPXO to ROMS EXPRESS (tide extraction software)

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

TPXO to ROMS EXPRESS (tide extraction software)

#1 Post by johnluick » Wed Dec 14, 2011 9:55 pm

I have attached my matlab script for extracting the tidal harmonics from the TPXO 7.2 netcdf files and creating a forcing file for ROMS. I've put everything required (I hope) in the zip file. It also does some plots to check the results. My goal, in writing it, was to simplify the process provided in the ROMS repository of software.

If you find a bug please let me know here in this forum so I can fix it.
TPXOextraction.zip
(11.63 KiB) Downloaded 832 times

yang
Posts: 56
Joined: Mon Sep 25, 2006 2:37 pm
Location: Institue of oceanology ,Chinese acedemy of scinece

Re: TPXO to ROMS EXPRESS (tide extraction software)

#2 Post by yang » Thu Dec 15, 2011 12:47 am

I have download the files, but the .zip file can not be unzipped correctly. Can you give me the .m files ?

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#3 Post by johnluick » Thu Dec 15, 2011 10:11 am

The problem is with your unzipping software. Here is a link to an evaluation version of WinZip that does work:
http://download.cnet.com/WinZip/3000-22 ... 03164.html
There is plenty of other free compression software. Yes, I tried WinRAR and it failed.
Or you can go to my rather dusty and moth-eaten website www.austides.com where I chose to put the unzipped scripts. While you're there, feel free to ask Professor Loeb a question.

yang
Posts: 56
Joined: Mon Sep 25, 2006 2:37 pm
Location: Institue of oceanology ,Chinese acedemy of scinece

Re: TPXO to ROMS EXPRESS (tide extraction software)

#4 Post by yang » Fri Dec 16, 2011 12:41 am

Thanks. Now, it works.

User avatar
patrickm
Posts: 24
Joined: Fri Apr 30, 2004 6:41 pm
Location: IRD, FRANCE
Contact:

Re: TPXO to ROMS EXPRESS (tide extraction software)

#5 Post by patrickm » Fri Dec 16, 2011 9:46 am

For information, the romstools package (provided with the agrif version of roms) also has a tidal toolbox (in matlab) that processes TPXO for ROMS. It is called make_tides ...

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#6 Post by johnluick » Sat Dec 17, 2011 3:33 am

I'm glad you mentioned this Patrick. I used to use make_tides and am indebted to it's authors - thank you! The main reason I wrote this was (as I recall) at the time, at least, make_tides required the use of a tidal database (provided with ROMS_Tools) derived from TPXO 6.x, rather than directly using the database OSU provides (which by then was TPXO 7.x, which I wanted to use). Also, I have tried to make this script simpler and more straightforward (not sure if I succeeded). Of course, both scripts will work for both the AGRIF and Rutgers versions.

User avatar
patrickm
Posts: 24
Joined: Fri Apr 30, 2004 6:41 pm
Location: IRD, FRANCE
Contact:

Re: TPXO to ROMS EXPRESS (tide extraction software)

#7 Post by patrickm » Sat Dec 17, 2011 12:05 pm

Hi John, make_tides now reads TPXO7 but we will look at your routines. The management and corrections of tidal phase and amplitude needed in the case of real time forcing is not straightforward. If you simplified some of the treatment processes, that would be interesting to us as well. We may want to converge at some point. cheers ... Patrick

chilequan
Posts: 2
Joined: Sat Nov 19, 2011 4:34 pm
Location: Ocean University of China

Re: TPXO to ROMS EXPRESS (tide extraction software)

#8 Post by chilequan » Thu Dec 22, 2011 3:08 am

I think I find a bug. Line 74 and line 80 in file "interpTPXO.m" may lead to mistakes when we get more than one i,j value from
"[j,i]=find(dr==(min(min(dr(VARinterp~=0)))));".

I use "VARinterp(ff(n))=VARinterp(j(1),i(1));" to fix it, but I'm not sure whether it is right.(I don't read scripts carefully for my final exam coming....)

====================appendix==========================
err by matlab:

??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> interpTPXO at 80
VARinterp(ff(n))=VARinterp(j,i);

Error in ==> extractTPXOtides at 120
ur=interpTPXO('URe',ROMSnames(k),TPXOfile_vel,TPXOfile_grid,lonR,latR,maskR
--------------------------
then I found in line 73:
K>> [j,i]

ans =

76 28
76 30


And thank you for you scripts. I think its an easy way to create the tide file for ROMS

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#9 Post by johnluick » Thu Dec 22, 2011 9:09 pm

Hi Chilequan,

thanks for your interest. I'm unable to reproduce this error, and to tell the truth, I can't see how it could arise (since min(min.. only seems to return a single value even there are two equal minimums), but your solution appears reasonable. If you like, when your exams are finished, we can discuss this offline (my email address is on the website mentioned above). Good luck with them.

John

chilequan
Posts: 2
Joined: Sat Nov 19, 2011 4:34 pm
Location: Ocean University of China

Re: TPXO to ROMS EXPRESS (tide extraction software)

#10 Post by chilequan » Fri Dec 23, 2011 2:30 am

It's true that min(min(....)) can only return a single value. But the codes are

"[j,i]=find(dr==min(min(dr(VARinterp~=0)))));", and

"find(dr=='some value')" may return more than one result.
=================================================
Here is an easy example:

>> a=[1 2;1 4];
[i,j]=find(a==min(min(a)));
[i,j]

ans =

1 1
2 1

elhunter
Posts: 9
Joined: Mon Dec 11, 2006 6:13 pm
Location: IMCS

Re: TPXO to ROMS EXPRESS (tide extraction software)

#11 Post by elhunter » Tue Jan 03, 2012 2:55 pm

Hi John,


I was testing out your tidal extraction script today, to see how it compares with the scripts I posted on wikiroms (which are fairly cumbersome).

I came across a minor issue that some others might run into.

>> extractTPXOtides
'Extracting ' 'MM' ' amplitudes'

Error using &
Matrix dimensions must agree.

Error in interpTPXO (line 76)
ff=find (mask==1 & VARinterp==0); %ff: wet points that were not assigned 0

Error in extractTPXOtides (line 97)
zr=interpTPXO('hRe',ROMSnames(k),TPXOfile_elev,TPXOfile_grid,lonR,latR,maskR);




It turns the the problem was the range of longitude values. My grid is -180 to 180 and the TPXO7.2 grid is 0 to 360. The interpolation in interpTPXO does not check for this.


I added a lon=mod(lon,360) in interpTPXO.m.


Thanks,
Eli Hunter
Institute for Marine and Coastal Sciences

elhunter
Posts: 9
Joined: Mon Dec 11, 2006 6:13 pm
Location: IMCS

Re: TPXO to ROMS EXPRESS (tide extraction software)

#12 Post by elhunter » Tue Jan 03, 2012 3:35 pm

Hi there,

So I ran into another issue when running the extraction script. It has to do with writing the output tidal forcing file.

>> extractTPXOtides
'Extracting ' 'K1' ' amplitudes'

'Extracting ' 'K1' ' u components'

'Extracting ' 'K1' ' v components'

'Extracting ' 'M2' ' amplitudes'

'Extracting ' 'M2' ' u components'

'Extracting ' 'M2' ' v components'

Error using snc_get_varput_indexing (line 43)
Expected START to be one of these types:

double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64

Instead its type was char.

Error in nc_varput_tmw (line 12)
[start,count,stride] =
snc_get_varput_indexing(ndims,info.Size,size(data),varargin{:});

Error in nc_varput (line 53)
nc_varput_tmw(ncfile,varname,data,varargin{:});

Error in extractTPXOtides (line 213)
nc_varput(ROMS_frc_file,'tide_period',ROMSperiods,'PRESERVE_FVD')


The call to nc_varput has a 'PRESERVE_FVD' input variable, which is not the correct usage in recent SNCTOOLS distributions. This spot is reserved for start,count,stride. PRESERVE_FVD should be set as a preference, i.e. setpref('SNCTOOLS','PRESERVE_FVD',1).

In the extractTPXOtides.m file, there is a comment:

%"PRESERVE_FVD" suppresses the permute that nc_varput_tmw would do.
%start/count/stride has been disabled in nc_varput_tmw.

Is that the case? I think it's generally not good practice to alter a toolbox your software uses.


Eli

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#13 Post by johnluick » Tue Jan 03, 2012 9:42 pm

Eli,

thanks for pointing these things out. I haven't updated snctools in a long time and clearly it is time to do that.

I think that the Marchesiello/Penven/Gambon team will be revising make_tides soon, and perhaps now also you will be making your tide software extraction software simpler to use. When one or both of those things happens, I think it would be best for people to use one of them, so I will get the forum moderator to remove my stuff from here.

I do hope you guys take up my suggestion for adding the 2D velocities to the forcing file, so that in future they can replace ellipses (for simplicity).

Cheers

John

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#14 Post by johnluick » Tue Oct 08, 2013 4:03 am

The tide extraction software (TPXO2ROMS.m) I wrote and posted here last year has been updated. It requires at least R2012a but now uses the native Matlab netcdf interface instead of snctools. It also has improved interpolation (offers a choice between TriscatteredInterp.m and scatteredInterpolant.m/griddedInterpolant.m). Most of the improvements are due to Charles James. It is also faster as it makes use of the fact that both of those schemes are now capable of handling complex numbers.
Actually there is nothing wrong with otps2roms.m which is in the "repository" but I think this is simpler - at least, it does not require unix extract_HC executable.

Added 17 October:
Please see below for new version. This version was saving transports, not velocities.
Last edited by johnluick on Thu Oct 17, 2013 2:58 am, edited 1 time in total.

yang
Posts: 56
Joined: Mon Sep 25, 2006 2:37 pm
Location: Institue of oceanology ,Chinese acedemy of scinece

Re: TPXO to ROMS EXPRESS (tide extraction software)

#15 Post by yang » Wed Oct 09, 2013 1:45 pm

I think that there is something wrong. For example, when i use this code to get tide, the Cmax is often larger than 100.[imgh=][/imgh]
Last edited by yang on Fri Nov 08, 2013 12:31 am, edited 2 times in total.

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#16 Post by johnluick » Wed Oct 09, 2013 8:40 pm

Please pause Matlab right after the line:
TPXO=readTPXOdata(TPXOfile_elev,TPXOfile_vel,TPXOfile_grid,lonR,latR);
Then enter:

zz=squeeze(TPXO.h.z(:,:,8));
contourf(abs(zz))
colorbar

This will show if the values you are reading in are in correct units etc. What I get are numbers which are typical open ocean M2 amplitudes (0.1 - 0.3). Let me know and I can take it from there.

I should clarify something in my previous email. When I said "there's nothing wrong with otps2roms.m..." what I was trying to say was that in general I think people should use the matlab scripts from the repository (like otps2roms.m) unless they have some specific reason for not doing so. They are more thoroughly tested and keeps everyone on the same page.

One good thing about what Charles did in modifying TPXO2ROMS.m is he substituted in the new way Matlab requires you to interpolate. It is quite a good algorithm and soon TriScatteredInterp will be "deprecated" or whatever they call it.

John

yang
Posts: 56
Joined: Mon Sep 25, 2006 2:37 pm
Location: Institue of oceanology ,Chinese acedemy of scinece

Re: TPXO to ROMS EXPRESS (tide extraction software)

#17 Post by yang » Thu Oct 10, 2013 12:51 am

OK, the attached map is corresponding to the following code.
TPXO=readTPXOdata(TPXOfile_elev,TPXOfile_vel,TPXOfile_grid,lonR,latR);
zz=squeeze(TPXO.h.z(:,:,8));
contourf(abs(zz))
colorbar
Last edited by yang on Fri Nov 08, 2013 12:30 am, edited 3 times in total.

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#18 Post by johnluick » Thu Oct 10, 2013 12:56 am

Looks good. Before I go further, what version of Matlab are you using? Must be R2012 or later.

yang
Posts: 56
Joined: Mon Sep 25, 2006 2:37 pm
Location: Institue of oceanology ,Chinese acedemy of scinece

Re: TPXO to ROMS EXPRESS (tide extraction software)

#19 Post by yang » Thu Oct 10, 2013 5:40 am

Matlab-2012b

The tide data i used is from ftp://ftp.oce.orst.edu/dist/tides/Globa ... tcdf.tar.Z
Last edited by yang on Fri Oct 18, 2013 6:02 am, edited 1 time in total.

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#20 Post by johnluick » Thu Oct 10, 2013 7:22 am

Please send your next response to john.luick@austides.com, so we can go offline and thereby not annoy everyone with a troubleshooting exercise. Also, in your email, can you confirm that you are not plotting phase (rather than amplitude) in that first plot you sent?

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#21 Post by johnluick » Thu Oct 17, 2013 3:04 am

This version (3.1) should be used. The one I put up a couple of weeks ago saved transports instead of velocities (my apologies). I also made a number of lesser changes which noted are at the start of the function.

23 October note - the new Matlab/netcdf interface commands ncread, nccreate and ncwrite reverse the array order automatically. You need to be really careful. I have replaced the TPXO2ROMS and have uploaded a new TPXO2ROMS.zip which I believe to be CF-compliant, and ROMS did not complain.

As an example, you read in an array which ncdump said was A(eta_rho,xi_rho). Your array in Matlab will look like A(xi_rho,eta_rho). Then for the netcdf output file you define vardims={'xi_rho',L,'eta_rho',M}, which nccreate reverses in the netcdf output file, so that after you write with ncwrite, which reverses the array on output, you finally ncdump the result, and see B(eta_rho,xi_rho)!

Personally, I plan to go back to snctools, to preserve my sanity, but will leave TPXO2ROMS this way so that people won't need snctools to use TPXO2ROMS. The above was tested on R2012a on a Windows PC. I can't test on linux because ours only has R2010.
Attachments
TPXO2ROMS.zip
(8.01 KiB) Downloaded 287 times

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#22 Post by johnluick » Mon Oct 28, 2013 1:42 am

A week or two ago I posted an update of TPXO2ROMS and some comments about the new Matlab netcdf interface commands ncread, ncwrite, etc.
Since I did so by editing a previous post, there was no notification sent out (as far as I know).
TPXO2ROMS users are advised to download this update.
I would be interested if anyone else has had similar experience with ncread etc.

yang
Posts: 56
Joined: Mon Sep 25, 2006 2:37 pm
Location: Institue of oceanology ,Chinese acedemy of scinece

Re: TPXO to ROMS EXPRESS (tide extraction software)

#23 Post by yang » Tue Oct 29, 2013 6:55 am

Good work. very nice!
It works well, now.

geo_ytwin
Posts: 6
Joined: Tue Apr 13, 2010 4:16 pm
Location: South China Sea Institute of Oceanology, CAS

Re: TPXO to ROMS EXPRESS (tide extraction software)

#24 Post by geo_ytwin » Thu Nov 07, 2013 5:54 pm

Hi,
Is there any way to consider specific tidal u and v components for rotating rectangular grid?

User avatar
kate
Posts: 3808
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: TPXO to ROMS EXPRESS (tide extraction software)

#25 Post by kate » Thu Nov 07, 2013 6:16 pm

Huh? ROMS will want the tidal velocities to be rotated to its grid, according to the "angle" variable.

geo_ytwin
Posts: 6
Joined: Tue Apr 13, 2010 4:16 pm
Location: South China Sea Institute of Oceanology, CAS

Re: TPXO to ROMS EXPRESS (tide extraction software)

#26 Post by geo_ytwin » Fri Nov 08, 2013 3:15 am

Yes, Kate.
So how can I rotate the tidal u and v (for example from TPXO data) to get tidal velocities that are perpendicular to the roms grid? The roms needs tidal current ellipses as the input information for tidal currents. I am confused how to rotate the tidal current ellipses.

User avatar
jivica
Posts: 139
Joined: Mon May 05, 2003 2:41 pm
Location: The University of Western Australia, Perth, Australia

Re: TPXO to ROMS EXPRESS (tide extraction software)

#27 Post by jivica » Fri Nov 08, 2013 7:56 am

I think tidal ellipses, to be more precise inclination, is not rotated to the ROMS grid within forcing file. It is rotated during applying BC see angler(i,j) in the last line of code, in Nonlinear/set_tides.F:

Code: Select all

# if defined UV_TIDES
!
!-----------------------------------------------------------------------
!  Add tidal currents (m/s) to 2D momentum climatologies.
!-----------------------------------------------------------------------
!
      Utide(:,:)=0.0_r8
      Vtide(:,:)=0.0_r8
      cff=2.0_r8*pi*(time(ng)-tide_start*day2sec)
      DO itide=1,NTC
        IF (Tperiod(itide).gt.0.0_r8) THEN
          omega=cff/Tperiod(itide)
          DO j=MIN(JstrR,Jstr-1),JendR
            DO i=MIN(IstrR,Istr-1),IendR
              angle=UV_Tangle(i,j,itide)-angler(i,j)
What it important to know is that tidal information (in terms of adding effect to the bry) is needed only along the active boundary cells, NOT AT THE WHOLE grid(!!). But ROMS is reading in a standard way forcing file and needs that info, but you can make trick and fill whole domain with zeros (if you do not know tides or do not want to extract them, ie big grid) and than only replace those along boundaries (+ 1 cell inside if needed for gradients)..... At the same time you can see how to optimize the code not to compute expensive trigonometrical functions etc along ALL POINTS, instead along only BRY stripes....

Cheers,
Ivica

User avatar
kate
Posts: 3808
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: TPXO to ROMS EXPRESS (tide extraction software)

#28 Post by kate » Fri Nov 08, 2013 8:31 pm

Thanks, Ivica. It's been years since I looked at this. Find a tool once and forget about it.

As for the other question, there are fields for which one might need to rotate to the ROMS grid. The rotation angle is called "angle" in the grid file and it is a matter of applying simple trigonometry. I guess I would assume readers here would have that knowledge already, but there's an example in uv_rotate.F in the ROMS source. Plus of course the code Ivica has pointed out.

geo_ytwin
Posts: 6
Joined: Tue Apr 13, 2010 4:16 pm
Location: South China Sea Institute of Oceanology, CAS

Re: TPXO to ROMS EXPRESS (tide extraction software)

#29 Post by geo_ytwin » Wed Nov 13, 2013 2:48 am

Thanks, Ivica and Kate.
Your replay make me clear for preparing tidal forcing file.

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#30 Post by johnluick » Thu Nov 21, 2013 12:47 am

TPXO2ROMS_v4pt0.zip
(8.79 KiB) Downloaded 352 times
This new version of TPXO2ROMS (TPXO2ROMSv4pt0) reads from the new TPXO 8 atlas. The most important harmonics in TPXO8 are at 1/30 degree resolution (as opposed to 1/4 degree for version 7.2 and earlier). There are other improvements in TPXO 8 as well (see http://volkov.oce.orst.edu/tides/tpxo8_atlas.html). You need to download the netcdf files (there are now two per harmonic plus the new grid). Four of the harmonics (MM, MF, MS4, MN4) are at 1/6 degree. I am not sure my interpolation scheme is working properly for them - you can try it for your area and let us all know - it is also possible there are some flaws on the database. I will update the software once this is established.

thomas.roc
Posts: 34
Joined: Tue Oct 28, 2008 3:19 pm
Location: IT Power

Re: TPXO to ROMS EXPRESS (tide extraction software)

#31 Post by thomas.roc » Fri Dec 05, 2014 12:56 am

Dear all,

I realize this thread is rather old but I noticed this odd line in TPXO2ROMS_v4pt1.m:
line 253: ncwrite(fnOut,'tide_Vphase',vamp)

Should not it be "ncwrite(fnOut,'tide_Vphase',vpha)" rather?

BTW, if some could direct me to a python package permitting similar functionality (i.e. creating tidal forcing file from TPXO dataset) it would be greatly appreciated.

Best,

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#32 Post by johnluick » Fri Dec 05, 2014 1:06 am

You are quite right of course. Thanks for pointing this out.
I do not know of any python script for this.
John

d.kobashi
Posts: 63
Joined: Tue Sep 28, 2010 11:59 pm
Location: Texas A&M University

Re: TPXO to ROMS EXPRESS (tide extraction software)

#33 Post by d.kobashi » Fri Dec 05, 2014 8:00 pm

I don't think a python tool equivalent to the John's one exists. I searched for it before because I switched to Python.

There are few python tools on tidal analysis as far as I know. I found the following.
http://sourceforge.net/projects/tappy/

You can possibly write python scripts to create ROMS tidal forcing based on the tool.
I don't have enough energy to do that and the John's tool works fine by me (Thanks, John!).

Or there could be tools to convert Matlab codes to Python? something like f2py (fortran to python) I wonder.

Cheers,

DJ Kobashi

thomas.roc
Posts: 34
Joined: Tue Oct 28, 2008 3:19 pm
Location: IT Power

Re: TPXO to ROMS EXPRESS (tide extraction software)

#34 Post by thomas.roc » Tue Dec 09, 2014 4:31 am

Thank you all,

Here is an early christmas present, a python translation of John's tpxo8_to_roms package.
I've started testing it...so far, so good.

Enjoy

-T-
Attachments
tpxo8_to_roms_python.zip
(8.31 KiB) Downloaded 238 times

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#35 Post by johnluick » Tue Dec 09, 2014 5:15 am

I look forward to trying this myself!
Thanks Thomas.
John

fagundesmo
Posts: 46
Joined: Wed Dec 03, 2014 1:46 am
Location: University of Georgia

Re: TPXO to ROMS EXPRESS (tide extraction software)

#36 Post by fagundesmo » Sun Aug 02, 2015 1:29 pm

Dear all,

I am trying TPX02ROMS version 3.2 to generate tides input to my area. However, I have had some issues while using it. These are the errors I am getting:


'Extracting ' 'M2' ' amplitudes'

'Extracting ' 'M2' ' u components'

Error using scatteredInterpolant
The input points must be a double array.

Error in TPXO2ROMS>interpTPXO (line 351)
F=scatteredInterpolant(x(m),y(m),z(m),'nearest');

Error in TPXO2ROMS (line 105)
ei=interpTPXO(TPXO.U,ROMSnames{k},lonR,latR,maskR);

Error in TPXO2ROMS_script (line 20)
TPXO2ROMS(t0,fnIn,fnOut,ndays)
[/b]


Since, I have used MATLAB for a couple weeks I do not know how I should proceed to fix these errors. I would appreciate if someone helped me.

Cheers,

fagundesmo
Posts: 46
Joined: Wed Dec 03, 2014 1:46 am
Location: University of Georgia

Re: TPXO to ROMS EXPRESS (tide extraction software)

#37 Post by fagundesmo » Sun Aug 02, 2015 3:59 pm

I think I did it. Could all confirm whether I changed right or not? I added the following lines:

xx=double(x(:,:));
yy=double(y(:,:));
zz=double(z(:,:));
F=scatteredInterpolant(xx(m),yy(m),zz(m),'nearest');
z=F(xx,yy);
F=griddedInterpolant(xx',yy',zz');

User avatar
CharlesJames
Posts: 34
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#38 Post by CharlesJames » Tue Aug 04, 2015 5:21 am

There may be a couple of issues here, the first is that scatteredInterpolant only takes datatype double (real or complex) so your solution will avoid that error.

But there may still be a problem with your u_tpxo72.nc file - the version of that file that I have has the variables URe and UIm (the variables you are reading at this step) both with datatype "double" so they shouldn't be triggering this problem. I don't know if there are different versions of this file or perhaps someone is saving space by converting the variables to single precision? The latest version of TPXO2ROMS (4.1) uses the TPXO8 netCDF files which might work better for you. In any case if the program runs OK with your fix I'd still have a close look at the resulting forcing file just to make sure it looks the way you expect.

fagundesmo
Posts: 46
Joined: Wed Dec 03, 2014 1:46 am
Location: University of Georgia

Re: TPXO to ROMS EXPRESS (tide extraction software)

#39 Post by fagundesmo » Wed Aug 05, 2015 11:17 am

CharlesJames wrote:There may be a couple of issues here, the first is that scatteredInterpolant only takes datatype double (real or complex) so your solution will avoid that error.

But there may still be a problem with your u_tpxo72.nc file - the version of that file that I have has the variables URe and UIm (the variables you are reading at this step) both with datatype "double" so they shouldn't be triggering this problem. I don't know if there are different versions of this file or perhaps someone is saving space by converting the variables to single precision? The latest version of TPXO2ROMS (4.1) uses the TPXO8 netCDF files which might work better for you. In any case if the program runs OK with your fix I'd still have a close look at the resulting forcing file just to make sure it looks the way you expect.

Hmm..., I downloaded tpxo72.nc from this website http://volkov.oce.orst.edu/tides/tpxo8_atlas.html that I took as reference from "tidal forcing topic" at wiki ROMS. About my output when I added those lines worked properly. However, some variables were not right maybe that's why I didn't understand what was wrong. I will try TPXO2ROMS (4.1) out instead.
Let's say I wanted to run TPXO2ROMS_v4pt0.m to my experiment that had a length of 30 years and my reference time I set to start at 1900-01-01. How should I set my t0 and lengthSim in this case?

Thanks in advance

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#40 Post by johnluick » Thu Aug 06, 2015 9:35 pm

I'm overseas at the moment but I will answer as best I can from memory.

TPXO2ROMS 4.x is designed to run with TPXO 8.1 not TPXO 7.x.. You should download 8.1.
I believe you cannot accurately simulate tides for more than one year with ROMS because it doesn't allow the nodal factors (f and u) to vary over time. Someone correct me if I'm wrong there. The worst offender, O1, will be out by probably 5 to 8 degrees at times, and O1 amplitude out by up to 15 to 20%.

You can do one-year segments and use perfect restarts with new values of t0 and TIDE_START (set them to the same mid-year time). You would also have to change the start time (variable name DATE_START? I forget. It is the one right before TIDE_START in ocean.in).

Or you can forget about using perfect restarts... let's say your tides spin up in 5 days. You can do 370 day simulations starting 5 days before the start of each year then ignore the first five days of simulation. This is what I would do.

But the point is, as far as I know ROMS doesn't allow the harmonics to change in time (over lunar nodal cycle) so you have to use some finagle if you want to really accurately model tides even over one month let alone one year. It would be easy enough to modify the code in ROMS. It should input constants (exactly as from TPXO or other model), not phases at some specific time (as it currently does), and then compute f and u as a function of time, compute the "equation of time", etc... And it definitely should not use the ellipse velocities (which is also does), which are a total waste of computing time and more importantly add unnecessary confusion.

John

johnluick
Posts: 98
Joined: Mon Jun 20, 2005 3:46 pm
Location: South Australian Research and Development Institute

Re: TPXO to ROMS EXPRESS (tide extraction software)

#41 Post by johnluick » Fri Oct 11, 2019 10:45 pm

I have updated the TPXO2ROMS Matlab software for creating a ROMS tidal input file from the TPXO tide database. It is now called TPXO2ROMS_v5pt1. Version 5.1 downloads the latest global tidal inversion (TPXO9) from Oregon State University. You will need permission from the authors (Lana Erofeeva and Gary Egbert) to download the TPXO9 netcdf files.

TPXO2ROMS v5.1 had a lot of changes due to the fact that TPXO9 includes harmonic 2N2. Matlab variables cannot begin with a number (like, 2) and I had previously referred to the different harmonics as struct variables by name, e.g. harmonic.M2, harmonic.K1, etc. Also, the TPXO9 data is organised differently from previous versions (much improved).

This new code worked correctly in extensive checking and testing, but I haven't actually run a ROMS model using the result. If anyone has a problem please let me know asap.

TPXO2ROMS v 5.1 can be freely downloaded from https://austides.com/downloads/

With great thanks to Lana and Gary for their fantastic product and continued updates.

Post Reply