How would you go about computing tidally averaged parameters from the netCDF history files? For example, I have halfhour outputs from an estuary model that was forced with a semidiurnal tide (12hour, to prevent aliasing). I'd like to find tidallyaveraged velocities and tracer concentrations.
Do I need to be concerned with variations in the vertical grid cell size when computing the averages? Can I interpolate to a constant zelevation and then do a lowpass filter on the data? Are there any other methods?
Tidal filtering of output files

 Posts: 20
 Joined: Fri Oct 20, 2006 3:34 pm
 Location: VIMS
J.Paul,
Judging from this Ticket,
https://www.myroms.org/projects/src/ticket/115
it looks like the best way to remove the tide would be to rerun your simulation with these new detiding options.
But if you are stuck with your existing 1/2 hour history files, you could certainly analyze your output with a serious tidal package like t_tide, or for your simple application with just 12 hour forcing, a simple mfile like my "tidefit.m". I haven't used it for a while, but give it a whirl and let me know how you make out. It might rely on stuff from the RPSstuff package at seamat. http://stellwagen.er.usgs.gov/models/share/tidefit.m
Regarding whether you have to first interpolate to a fixed level, that depends on what you are trying to compare it to.
Rich
Judging from this Ticket,
https://www.myroms.org/projects/src/ticket/115
it looks like the best way to remove the tide would be to rerun your simulation with these new detiding options.
But if you are stuck with your existing 1/2 hour history files, you could certainly analyze your output with a serious tidal package like t_tide, or for your simple application with just 12 hour forcing, a simple mfile like my "tidefit.m". I haven't used it for a while, but give it a whirl and let me know how you make out. It might rely on stuff from the RPSstuff package at seamat. http://stellwagen.er.usgs.gov/models/share/tidefit.m
Regarding whether you have to first interpolate to a fixed level, that depends on what you are trying to compare it to.
Rich
If you are only forcing your model with a single harmonic, M2 as your post indicates, then all you need to do is activate AVERAGES and set Navg in ocean.in to give you a 12.42 hour averaging interval (Navg=3600*12.42/DT). The "tidallyaveraged" output will be in the averages netcdf file. If you set Ndia the same, you will get "tidallyaveraged" diagnostics also.
You can then average the averages to get more stable estimates, after perhaps first rejecting some initial entries if there appear to be some transients before approaching a tidally repeating solution. Quadratic terms will be saved in the averages file if you activate that option.
In my experience, you don't need to be concerned about the time averaging of the coordinate system for most variables. However, if you want to obtain an exact balance of meaneddy decompositions, then you do. The averages quadratic option will also write terms like "Huon" which include the levelbylevel "Hz" (layer thickness) in the average. The vertical integral of these is just the vertical sum (the dz is included) and it will include the effect of time varying layer thickness, which in tidal simulations is quite likelly correlated with u and zeta, so contributes to the mean.
The only other thing to be concerned about is that the average calculation is effectively a simple boxcar filter, and therefore has some nasty sidelobes if you are using it to detide the model.
The recently added tidal fit option, which we would welcome users to test more fully, performs an evolving least squares fit to all harmonics. This would be a more robust way to compute harmonics of your solution. It is subject to the same constraints as any tidal fitting exercise in that you have to let the model run long enough for the separation of harmonics to be distinct (e.g. at least 30 days to separate M2 and S2, or longer with more harmonics).
You can then average the averages to get more stable estimates, after perhaps first rejecting some initial entries if there appear to be some transients before approaching a tidally repeating solution. Quadratic terms will be saved in the averages file if you activate that option.
In my experience, you don't need to be concerned about the time averaging of the coordinate system for most variables. However, if you want to obtain an exact balance of meaneddy decompositions, then you do. The averages quadratic option will also write terms like "Huon" which include the levelbylevel "Hz" (layer thickness) in the average. The vertical integral of these is just the vertical sum (the dz is included) and it will include the effect of time varying layer thickness, which in tidal simulations is quite likelly correlated with u and zeta, so contributes to the mean.
The only other thing to be concerned about is that the average calculation is effectively a simple boxcar filter, and therefore has some nasty sidelobes if you are using it to detide the model.
The recently added tidal fit option, which we would welcome users to test more fully, performs an evolving least squares fit to all harmonics. This would be a more robust way to compute harmonics of your solution. It is subject to the same constraints as any tidal fitting exercise in that you have to let the model run long enough for the separation of harmonics to be distinct (e.g. at least 30 days to separate M2 and S2, or longer with more harmonics).
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 089018521, USA. ph: 6096300559 jwilkin@rutgers.edu
71 Dudley Rd, New Brunswick, NJ 089018521, USA. ph: 6096300559 jwilkin@rutgers.edu

 Posts: 20
 Joined: Fri Oct 20, 2006 3:34 pm
 Location: VIMS
Thanks for the information. I think I'll try using the AVERAGES files. This is an estuary, so I'm forcing the freesurface at the open boundary and not using the SSH_TIDES or UV_TIDES options, which means I can't use the DETIDE option unless I change my setup, right?
Also, what variables are in the DIAGNOSTICS file? Briefly looking at varinfo.dat, it seems that the terms from the momentum and tracer conservation equations are placed here. The ocean.in file seems to indicate that they're timeaveraged over NDIA steps. Is this right? There could be more information on the ROMS wiki about these DIAGNOSTICS options.
J.Paul
Also, what variables are in the DIAGNOSTICS file? Briefly looking at varinfo.dat, it seems that the terms from the momentum and tracer conservation equations are placed here. The ocean.in file seems to indicate that they're timeaveraged over NDIA steps. Is this right? There could be more information on the ROMS wiki about these DIAGNOSTICS options.
J.Paul