You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
import os
|
|
import re
|
|
import numpy as np
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.dates as mdates
|
|
|
|
sources = [
|
|
{
|
|
'source': 'WRL',
|
|
'csv_name': 'levels.csv',
|
|
'tz': 'Etc/GMT-10'
|
|
},
|
|
{
|
|
'source': 'MHL',
|
|
'csv_name': 'OceanTide-213470.Level.csv',
|
|
'tz': 'Etc/GMT-10'
|
|
},
|
|
{
|
|
'source': 'BOM',
|
|
'csv_name': 'NSW_TP007.csv',
|
|
'tz': 'Australia/Sydney'
|
|
},
|
|
]
|
|
|
|
fig, ax = plt.subplots(1, 1, figsize=(7, 4))
|
|
|
|
for s in sources:
|
|
df = pd.read_csv(s['csv_name'], index_col=0, parse_dates=True)
|
|
try:
|
|
df = df.tz_localize(s['tz'])
|
|
except TypeError:
|
|
pass
|
|
|
|
ax.plot(df.iloc[:, 0], label=s['source']) # Predicted tide in first column
|
|
|
|
ax.legend()
|
|
ax.set_xlim('2019-11-29', '2019-12-02')
|
|
|
|
ax.set_ylabel('Predicted tide (m LAT)', labelpad=10)
|
|
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b-%d %H:%M'))
|
|
ax.xaxis.set_tick_params(rotation=45)
|
|
|
|
ax.spines['top'].set_visible(False)
|
|
ax.spines['right'].set_visible(False)
|
|
|
|
png_name = os.path.join(
|
|
os.path.dirname(__file__),
|
|
os.path.basename(__file__).replace('.py', '.png').replace('_', '-'))
|
|
plt.savefig(png_name, bbox_inches='tight', dpi=300)
|