Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Ocean tides in Perl

by GrandFather (Sage)
on Oct 31, 2011 at 23:56 UTC ( #934995=note: print w/replies, xml ) Need Help??

in reply to Ocean tides in Perl

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

Replies are listed 'Best First'.
Re^2: Ocean tides in Perl
by pvaldes (Chaplain) on Nov 01, 2011 at 10:18 UTC
    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

        About 20+ years ago, I wrote a small basic program for a Yacht Club. The data was available from a US government agency for a specific geographic location. The Yacht Club knew that their location was 1 hour 22 minutes behind the tide for that specific geographic location. With that information the program produced a chart something like the following for the entire year:

        Tides for ____________________ starting with November 1, 2011. Day High Tide Height Sunrise Moon Time % Moon /Low Time Feet Sunset Visible Tu 1 High 3:41 AM 3.0 7:43 AM Rise 1:23 PM 31 1 Low 11:14 AM 0.2 6:47 PM 1 High 5:57 PM 2.2 1 Low 11:06 PM 1.1

        The only calculations the program made was to adjust the 'Tide Time'. For perl to do this the script would be trivial.

        From this discussion, it sounds like I needed to account for a lot more. Isn't tide predicting mostly an approximation?

        "Well done is better than well said." - Benjamin Franklin

        I can understand the reasons of any monk to be reluctant to show any code that is the result of many hours of hard work and I'm sure that the other monks think the same; in any case your reply sheds a lot of light on the subject and I think it points the OP in the right direction. In short, excelent advice, very illustrative to me, thank you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://934995]
[LanX]: hippo: I'm telling him constantly to upgrade to postgress...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-03-19 09:34 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (238 votes). Check out past polls.