From 68389565bebeb34e2bdae1b55dd583594d5e2e4c Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Tue, 3 Dec 2019 16:54:44 +1100 Subject: [PATCH] Migrate to python 3 --- SydneyTide-python.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/SydneyTide-python.py b/SydneyTide-python.py index 5718f16..0170bbc 100644 --- a/SydneyTide-python.py +++ b/SydneyTide-python.py @@ -6,14 +6,14 @@ from pylab import * # Brett Miller 9th October 2015. # This program reads Harmonics for Fort Denison as provided by BOM on the 9th October 2015 # -# NOT FOR DISTRIBUTION -# the predictions from this code have been cross checked against some daily predictions but +# NOT FOR DISTRIBUTION +# the predictions from this code have been cross checked against some daily predictions but # not against all. # USE AT YOUR OWN CAUTION. NO GAURENTEE MADE THAT THESE PREDICTIONS ARE CORRECT. # # The x-tide method for calculating tides is:- # z(t,y,site)= MWL(site) + sum[c=1,N](nodefactor(c,y).amp(c,site).cos( speed(c).t + eqarg(c,y) - kappa(c,site) )) -# where +# where # t is the time since the beginning of the year # y is the year # site is the site of interest @@ -42,7 +42,7 @@ H=open("HARMONIC","r") l=readlinenocomm(H) numconstits=int(l) -print "Number of Constituents = ",numconstits +print("Number of Constituents = ",numconstits) # Read in the constituent speeds @@ -53,7 +53,7 @@ while i'*END*': - print "Error, expected end after eq args. Got: ",l +if l[0:5]!='*END*': + print("Error, expected end after eq args. Got: ",l) # Read in the node factors - + l=readlinenocomm(H) numyears=int(l) @@ -103,10 +103,10 @@ while i'*END*': - print "Error, expected end after node factors. Got: ",l +if l[0:5]!='*END*': + print("Error, expected end after node factors. Got: ",l) harm['sa']=[0.0410686,0.04,44.3373] harm['ssa']=[0.0821373,0.0233,140.8642] @@ -222,13 +222,13 @@ harm['MSO5']=[72.9271398,0.0001,247.7639] harm['MSK5']=[74.0251729,0.0002,189.3859] MSL=0.9952 - + # Now do the maths -start_time=datetime.datetime(2016,07,29,0,0,0) -end_time=datetime.datetime(2016,07,30,0,0,0) +start_time=datetime.datetime(2016,7,29,0,0,0) +end_time=datetime.datetime(2016,7,30,0,0,0) -time_step=datetime.timedelta(minutes=15) +time_step=datetime.timedelta(minutes=15) x=[] y=[] @@ -259,6 +259,3 @@ plt.figure() plot(x,y,c='g',label='Sample') plt.gcf().autofmt_xdate() show() - - -