Perl: the Markov chain saw PerlMonks

Ocean tides in Perl

 on Oct 31, 2011 at 19:37 UTC Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!
I am looking for a way to get the ocean tides using Perl. Has anyone done or would know if its possible using Perl.
Thanks for the info!

Replies are listed 'Best First'.
Re: Ocean tides in Perl
by BrowserUk (Pope) on Oct 31, 2011 at 20:00 UTC

Two possibilities:

1. Calculate them.

There is a worked example, in MATLAB, on the wikipedia page of the guy that worked out how to do it: Arthur_Thomas_Doodson. It should be relatively easy to adapt it to perl, though you need sets of values for each place you want to make predictions for. These are probably available on line somewhere.

For example, the UK Hydrological Office makes 7 days worth of predictions available for 100s of points around the world for free.

There are almost certainly other sites that do similar.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Ocean tides in Perl
by GrandFather (Sage) on Oct 31, 2011 at 23:56 UTC

In general tide calculations are horribly complicated because they are not only influenced by obvious things like the phase of the moon, but also by the topography of the sea floor in the "local" area. For accurate tide predictions for a specific location you need to obtain coefficients for the set of significant parameters used in a tidal model (maybe 30-60 of them!). The parameters are generally calculated from tide data collected over a longish period (19 years) for the location of interest! See Theory_of_tides#Tidal_constituents for a discussion of some of these parameters.

Writing a Perl module to perform the required calculations would not be particularly hard, but the result is likely to be slow. Obtaining the coefficients is likely to be a harder problem than writing the code to perform the calculation.

True laziness is hard work
In general tide calculations are horribly complicated

YES, this is what make a project like this so dificult and thus so "sexy". A very unusual problem here in the monastery.

but also by the topography of the sea floor in the "local" area

yep ...and don't forget the barometric pressure. The local parameters are important.

A lot of parameters should be in any of the modules managing time/localtime, other groups in modules belonging to Math and Astro categories, and a fourth set should be calculated for the specific area and probably need to be measured in the field. If I could make a wish I will add also a plotting method at the end, (maybe Graphics::Timeline or something equivalent).

Writing a Perl module to perform the required calculations would not be particularly hard

I agree

but the result is likely to be slow

Well this is an advice that I will take seriously. Can I abuse of your time and knowledge and ask you to explore this a little more GrandFather?, do you honestly think that this would be a major obstacle to do this in Perl? (instead i.e. C). Generally speaking of course, how this problem could be avoided? (i.e not choosing a time-module know for being slow etc...)

Well, I have about 500 lines of C that uses a 37 coefficient set to perform tide prediction calculations but it's not code I can release to the public domain (I don't have ownership of it) and I'm not sure I could legally derive a Perl equivalent from it. However, it's pretty much solid calculation so the equivalent Perl wouldn't be a heck of a lot smaller. You can gauge from that the size of the coding task. Oh, and I don't know how compatible that set of parameters may be with publicly available tide parameter sets so the whole thing could be a complete waste of time in any case.

To be of any practical use a tide calculation module would need to use a set of parameters for which data is publicly available. It's about 10 years since I worked on any of this stuff so maybe things are different now, but then the data was considered valuable and was hard to come by. Because of the potential difficulty in getting data I'd think there would be little call for such a module in CPAN. My involvement in such calculations has long since passed so I have no particular current interest in creating such a module.

True laziness is hard work
Re: Ocean tides in Perl
by moritz (Cardinal) on Oct 31, 2011 at 20:04 UTC

Just look at Tide calculation on Wikipedia, you can implement that in Perl (if that's what you want; if not, please elaborate).

Re: Ocean tides in Perl
by pvaldes (Chaplain) on Oct 31, 2011 at 20:54 UTC

mmmh, you really have my interest, please elaborate the idea. Of course is possible and you'll probably want:

```use strict; use warnings;

use Astro::MoonPhase;
use Math::Trig; # you will need the cosine function

# print cos X ; # where X in radians;

my \$date = time();
my @dataphase = phase(\$date);

print "Distance to the Moon at this day: ", \$dataphase[3], " Km";
Re: Ocean tides in Perl
by Anonymous Monk on Oct 31, 2011 at 19:41 UTC

I am looking for a way to get the ocean tides using Perl.

No, sea and bits do not mix

Has anyone done or would know if its possible using Perl.

If you can build a tide machine, you can talk to it with perl

Create A New User
Node Status?
node history
Node Type: perlquestion [id://934951]
Approved by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2017-08-18 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (306 votes). Check out past polls.

Notices?