Data stored at
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import glob
import os
import datetime
import pandas as pd
import netCDF4 as nc
from salishsea_tools.nowcast import figures
from salishsea_tools import viz_tools
%matplotlib inline
#Load NEMO grid
f = '/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc'
grid = nc.Dataset(f)
def read_IOS(filename):
"""Funtion to read IOS data in filename"""
filehandle = open(filename,'rt')
ss_depth = [] #depth
ss_sal = [] #salinity
ss_temp = [] #temperature
with filehandle as data:
headerover = False
for line in data:
if headerover:
break
word = line.split()
ss_depth.append(float(word[0]))
ss_sal.append( float(word[5]))
ss_temp.append(float(word[1]))
elif line[0:14] == "*END OF HEADER":
headerover = True
next_line = filehandle.next()
wordd = next_line.split()
for next_line in data:
ss_depth.append(float(wordd[1]))
ss_temp.append(float(wordd[2]))
ss_sal.append(float(wordd[5]))
wordd = next_line.split()
ss_depth.append(float(wordd[1]))
ss_temp.append(float(wordd[2]))
ss_sal.append(float(wordd[5]))
else:
word = line.split()
if len(word) > 1:
if word[0] == "LATITUDE" and word[1] !='2':
lat = float(word[2])+ float(word[3])/60
if word[0] == "LONGITUDE" and word[1] !='2':
lon = -(float(word[2])+ float(word[3])/60)
if word[0] == "START":
string = word[4] +' ' + word[5]
time = datetime.datetime.strptime(string,'%Y/%m/%d %H:%M:%S.%f')
return lat,lon,time,ss_depth,ss_sal,ss_temp
loop through the first directory
ios_dir = '/ocean/rich/home/SoG/ios/che/'
files = glob.glob(os.path.join(ios_dir,'*'))
files.sort(key=os.path.basename)
times = []
lats=[]
lons=[]
years = []
months = []
depths = []
sals = []
temps = []
counter = 0
for filename in files:
lat,lon,time, depth,sal, temp = read_IOS(filename)
times.append(time)
lats.append(lat)
lons.append(lon)
years.append(time.year)
months.append(time.month)
depths.append(depth)
sals.append(sal)
temps.append(temp)
counter=counter+1
#Check number of files looked at
print counter
print len(temps)
459 459
loop through the second directoy
ios_dir = '/ocean/rich/home/SoG/ios/che2/'
files = glob.glob(os.path.join(ios_dir,'*'))
files.sort(key=os.path.basename)
counter=0
for filename in files:
lat,lon,time, depth,sal, temp = read_IOS(filename)
times.append(time)
lats.append(lat)
lons.append(lon)
years.append(time.year)
months.append(time.month)
depths.append(depth)
sals.append(sal)
temps.append(temp)
counter=counter + 1
print counter
print len(files)
477 477
data = pd.DataFrame({'year': years, 'date': times, 'lat':lats, 'lon': lons,'month':months,\
'depth':depths, 'salinity': sals, 'temperature': temps})
data
date | depth | lat | lon | month | salinity | temperature | year | |
---|---|---|---|---|---|---|---|---|
0 | 1980-04-18 11:45:00 | [6.9, 17.8, 19.4, 30.4, 49.9, 74.3, 100.4, 126.3] | 48.903000 | -123.230000 | 4 | [17.7, 2.04, 0.98, -99.0, -99.0, -99.0, -99.0,... | [11.2, 26.4, 19.7, 24.7, 28.1, 26.9, 25.0, 24.9] | 1980 |
1 | 1980-06-19 22:49:00 | [5.3, 12.4, 25.2, 29.3, 49.1, 99.2, 181.3] | 49.367000 | -123.750000 | 6 | [4.0, 7.66, -99.0, -99.0, -99.0, -99.0, -99.0] | [4.3, 21.4, 26.6, 21.2, 31.4, 28.8, -99.0] | 1980 |
2 | 1981-07-03 04:10:00 | [5.4, 15.3, 15.8, 33.5, 250.5] | 49.367000 | -123.917000 | 7 | [0.74, 3.42, 0.99, -99.0, -99.0] | [0.1, 11.4, 2.0, 27.5, -99.0] | 1981 |
3 | 1982-05-20 12:12:00 | [8.8, 18.9, 30.3, 49.1, 75.1, 100.5, 101.8, 12... | 49.317000 | -123.750000 | 5 | [0.28, 0.15, -99.0, -99.0, -99.0, -99.0, -99.0... | [13.7, 24.8, 27.5, 27.5, 28.0, 27.1, 30.9, 23.... | 1982 |
4 | 1982-07-15 09:51:00 | [9.3, 20.2, 29.9, 51.7, 69.5] | 49.352000 | -123.615000 | 7 | [9.83, 0.19, -99.0, -99.0, -99.0] | [16.1, 20.8, 22.8, 22.2, 24.3] | 1982 |
5 | 1982-07-16 01:21:00 | [12.0, 21.5, 30.5, 52.3, 75.4, 98.3, 99.6, 124... | 49.250000 | -123.943000 | 7 | [5.28, 0.61, -99.0, -99.0, -99.0, -99.0, -99.0... | [6.6, 21.2, 23.5, 28.0, 26.5, 28.1, 26.1, 29.1... | 1982 |
6 | 1983-05-20 12:55:00 | [9.6, 97.9, 126.9, 138.5] | 48.893000 | -123.303000 | 5 | [0.81, 0.14, -99.0, -99.0] | [11.7, 14.6, 23.8, 23.5] | 1983 |
7 | 1996-02-26 15:38:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 48.862333 | -123.080000 | 2 | [25.0, 23.6, 26.6, 23.2, 26.7, 26.6, 23.0, 22.... | [-99.0, 29.0189, 29.3459, 29.4757, 29.5546, 29... | 1996 |
8 | 1996-02-26 16:42:00 | [8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 48.918333 | -123.179833 | 2 | [25.2, 23.9, 25.5, 25.2, 24.0, 23.5, 26.4, 23.8] | [25.0212, 28.8801, 29.0425, 29.1258, 29.5534, ... | 1996 |
9 | 1996-02-26 17:47:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 48.976167 | -123.272333 | 2 | [22.1, 25.4, 23.1, 25.6, 26.7, 22.6, 21.9, 27.... | [25.5136, 28.055, 28.7888, 29.338, 29.4314, 29... | 1996 |
10 | 1996-02-26 18:59:10 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.044000 | -123.390500 | 2 | [17.2, 25.8, 24.6, 26.5, 24.4, 25.2, 25.7, 27.... | [-99.0, 26.98, 28.4449, 29.4026, 29.4319, 29.6... | 1996 |
11 | 1996-02-26 20:14:36 | [8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0] | 49.048867 | -123.590650 | 2 | [24.9, 27.8, 25.9, 28.2, 25.4, 27.7, 27.0] | [26.3036, 28.5874, 28.7233, 28.867, 29.2233, 2... | 1996 |
12 | 1996-02-26 21:01:14 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.073200 | -123.537767 | 2 | [-99.0, 25.4, 27.2, 25.2, 24.0, 24.7, 24.3, 24... | [-99.0, 27.5501, 28.3637, 29.1868, 29.4075, 29... | 1996 |
13 | 1996-02-26 22:10:34 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.102000 | -123.485500 | 2 | [21.6, 22.7, 22.9, 26.2, 26.4, 25.4, 22.0, 24.... | [22.1691, 27.871, 28.7016, 29.3711, 29.4084, 2... | 1996 |
14 | 1996-02-26 23:21:41 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.145417 | -123.390550 | 2 | [19.2, 21.6, 22.1, 27.2, 23.5, 23.5, 26.1, 20.... | [-99.0, 27.9308, 28.9926, 29.3062, 29.3811, 29... | 1996 |
15 | 1996-02-27 11:48:00 | [6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.191167 | -123.297500 | 2 | [26.1, 24.8, 25.9, 24.4, 26.5, 25.2] | [22.6808, 28.2202, 29.1978, 29.3202, 29.4235, ... | 1996 |
16 | 1996-02-27 13:31:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.169333 | -123.556667 | 2 | [20.9, 24.0, 26.7, 28.0, 28.3, 27.7, 26.8, 29.... | [25.7472, 25.9408, -99.0, 28.8684, 29.3006, 29... | 1996 |
17 | 1996-02-27 15:00:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.210333 | -123.667833 | 2 | [24.5, 24.5, 26.9, 27.9, 28.2, 27.8, 28.5, 27.... | [26.1342, 26.1852, 27.662, 29.211, 29.3178, 29... | 1996 |
18 | 1996-02-27 16:23:00 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.221833 | -123.857000 | 2 | [27.4, 26.0, 25.5, 23.7, 28.4, 26.1, 23.9] | [27.7844, 28.2414, 28.3351, 28.6913, 29.1931, ... | 1996 |
19 | 1996-02-27 17:14:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.245333 | -123.813333 | 2 | [21.5, 23.6, 26.6, 25.4, 23.8, 22.1, 25.3, 28.... | [25.3362, 27.0176, 28.1706, 29.0893, 29.2669, ... | 1996 |
20 | 1996-02-27 18:17:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.267167 | -123.766333 | 2 | [24.6, 24.1, 27.3, 27.6, 27.7, 25.9, 28.3, 29.... | [26.0236, 26.413, 28.0926, 29.5668, 29.5091, 2... | 1996 |
21 | 1996-02-27 19:33:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.297450 | -123.707100 | 2 | [22.3, 22.9, 26.6, 25.1, 24.4, 25.9, 24.2, 28.... | [25.1702, 26.7657, 27.4616, 29.5296, 29.4566, ... | 1996 |
22 | 1996-02-27 20:42:00 | [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0,... | 49.326000 | -123.646667 | 2 | [21.2, 23.2, 25.2, 24.9, 22.5, 26.0, 17.8, 27.... | [-99.0, 25.1425, 27.8624, 28.4912, 29.4978, 29... | 1996 |
23 | 1996-02-27 21:52:00 | [9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.356000 | -123.584333 | 2 | [21.3, 21.6, 26.5, 24.2, 24.4, 25.1, 18.1, 26.... | [25.2381, 25.4384, 29.4175, 29.2994, 29.3276, ... | 1996 |
24 | 1996-02-27 22:49:00 | [5.0, 4.0, 3.0, 2.0, 1.0] | 49.375333 | -123.548333 | 2 | [22.6, 26.5, 27.5, 27.6, 27.7] | [25.1837, 28.1004, 29.1352, 29.2429, 29.386] | 1996 |
25 | 1996-06-18 04:28:00 | [15.0, 14.0, 13.0, 12.0, 11.0] | 49.192167 | -123.297000 | 6 | [2.4, 16.3, 22.5, 26.2, 24.0] | [14.355, 27.024, 28.865, 29.455, 29.806] | 1996 |
26 | 1996-06-18 05:27:00 | [26.0, 25.0, 24.0, 23.0, 22.0, 21.0, 20.0, 19.... | 49.145833 | -123.389667 | 6 | [43.5, 52.1, 57.6, 46.3, 45.8, 41.4, 41.9, -99... | [7.454, 4.971, 4.502, 4.373, 4.344, 4.39, 4.31... | 1996 |
27 | 1996-06-18 06:57:00 | [40.0, 39.0, 38.0, 37.0, 36.0, 35.0, 34.0, 33.... | 49.099900 | -123.484867 | 6 | [21.9, 35.3, 43.7, 43.4, 52.1, 53.3, 42.0, 44.... | [7.272, 5.138, 4.635, 4.468, 4.365, 4.388, 4.4... | 1996 |
28 | 1996-06-18 08:31:00 | [52.0, 51.0, 50.0, 49.0, 48.0, 47.0, 46.0, 45.... | 49.074267 | -123.537633 | 6 | [13.6, 18.9, 44.6, 46.9, 47.4, 44.9, 44.4, 43.... | [7.307, 6.269, 4.436, 4.327, 4.253, 4.395, 4.4... | 1996 |
29 | 1996-06-18 10:04:00 | [59.0, 58.0, 57.0, 56.0, 55.0, 54.0, 53.0] | 49.047833 | -123.591167 | 6 | [10.5, 24.8, 40.7, 44.7, 47.9, 49.1, 47.1] | [7.123, 6.115, 4.646, 4.525, 4.321, 4.201, 4.28] | 1996 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
906 | 2011-04-15 06:34:04 | [15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0,... | 49.401333 | -124.155667 | 4 | [16.403, 16.367, 15.573, 10.112, 2.33, 0.711, ... | [2.9, 4.2, 8.9, 19.0, 29.2, 39.1, 48.6, 74.2, ... | 2011 |
907 | 2011-04-15 14:02:03 | [16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0... | 49.318167 | -123.799667 | 4 | [17.654, 17.24, 19.28, 2.815, 0.426, 0.268, 0.... | [3.0, 4.0, 8.7, 18.7, 28.8, 39.1, 48.9, 74.5, ... | 2011 |
908 | 2011-04-15 17:28:39 | [17.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.... | 49.163167 | -123.550000 | 4 | [6.264, 11.955, 16.294, 2.546, 0.536, 0.285, 0... | [2.7, 3.3, 9.3, 18.7, 30.2, 41.1, 49.3, 73.7, ... | 2011 |
909 | 2011-04-15 22:40:31 | [16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0... | 49.029500 | -123.436667 | 4 | [17.495, 18.6, 12.316, 2.691, 0.895, 0.434, 0.... | [2.8, 4.2, 9.1, 19.1, 29.0, 38.9, 49.1, 73.2, ... | 2011 |
910 | 2011-04-17 20:17:04 | [14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, ... | 48.773833 | -123.025333 | 4 | [0.975, 1.501, 1.479, 1.8, 1.979, 1.845, 1.748... | [2.9, 4.5, 8.9, 18.9, 28.7, 39.0, 48.7, 73.6, ... | 2011 |
911 | 2011-04-18 01:04:20 | [12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.... | 48.856333 | -123.179500 | 4 | [6.4, 11.585, 2.736, 1.263, 1.226, 0.923, 0.77... | [2.8, 4.0, 9.2, 19.1, 29.4, 39.4, 49.0, 74.3, ... | 2011 |
912 | 2011-06-02 17:58:47 | [24.0, 23.0] | 49.246167 | -123.743500 | 6 | [0.797, 0.83] | [5.0, 9.4] | 2011 |
913 | 2011-04-11 14:33:06 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.640167 | -124.894000 | 4 | [8.213, 8.667, 9.357, 8.14, 3.23, 2.894, 3.239] | [3.7, 4.9, 10.1, 20.2, 32.0, 34.3, 36.9] | 2011 |
914 | 2011-04-11 16:38:07 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.597333 | -124.860000 | 4 | [6.319, 6.522, 8.008, 6.425, 5.651, 3.964, 2.249] | [3.6, 5.0, 9.8, 24.9, 39.7, 41.8, 44.4] | 2011 |
915 | 2011-04-11 19:03:47 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.569000 | -124.859833 | 4 | [5.099, 5.471, 7.6, 6.246, 2.112, 1.943, 2.034] | [3.5, 5.2, 9.9, 25.3, 43.8, 46.0, 48.5] | 2011 |
916 | 2011-04-12 00:59:11 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.542167 | -124.842833 | 4 | [4.371, 5.595, 8.692, 7.258, 1.462, 1.384, 1.523] | [3.5, 5.2, 9.8, 25.2, 45.2, 47.1, 49.8] | 2011 |
917 | 2011-04-12 14:52:20 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.517500 | -124.812333 | 4 | [4.833, 5.065, 8.679, 5.794, 1.86, 1.932, 2.096] | [3.7, 5.3, 10.2, 24.8, 42.7, 44.7, 46.8] | 2011 |
918 | 2011-04-12 16:30:42 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.483833 | -124.769833 | 4 | [5.648, 5.8, 7.365, 4.681, 2.222, 2.074, 2.174] | [3.7, 5.1, 10.0, 24.9, 49.8, 51.6, 54.1] | 2011 |
919 | 2011-04-12 18:15:06 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.472167 | -124.747167 | 4 | [4.166, 5.109, 6.922, 4.788, 3.304, 2.989, 1.294] | [3.6, 5.2, 10.0, 24.9, 36.1, 39.0, 45.2] | 2011 |
920 | 2011-04-12 20:31:22 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.462000 | -124.666000 | 4 | [6.526, 6.27, 2.93, 0.508, 1.375, 1.294, 1.173] | [3.5, 5.0, 10.3, 24.9, 52.3, 54.8, 56.3] | 2011 |
921 | 2011-04-12 22:22:04 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.663333 | -124.852167 | 4 | [4.699, 4.833, 6.146, 4.152, 0.648, 0.601, 0.617] | [3.5, 5.6, 10.3, 24.9, 48.8, 50.7, 54.1] | 2011 |
922 | 2011-04-12 23:00:59 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.649167 | -124.844667 | 4 | [4.775, 5.23, 5.517, 3.682, 1.125, 1.03, 0.654] | [3.6, 5.0, 9.8, 25.3, 51.0, 52.9, 57.0] | 2011 |
923 | 2011-04-12 23:37:12 | [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0] | 49.634667 | -124.830500 | 4 | [2.322, 2.232, 2.014, 1.316, 1.101, 0.997, 0.932] | [3.4, 4.8, 9.7, 24.9, 45.0, 47.4, 50.5] | 2011 |
924 | 2011-04-04 20:46:51 | [2.0, 1.0] | 49.113333 | -123.277167 | 4 | [0.84, 0.775] | [2.4, 2.4] | 2011 |
925 | 2011-04-04 21:22:49 | [1.0, 2.0] | 49.103333 | -123.300833 | 4 | [0.936, 0.855] | [2.7, 2.7] | 2011 |
926 | 2011-04-04 21:53:26 | [2.0, 1.0] | 49.106500 | -123.326000 | 4 | [2.517, 2.612] | [2.6, 2.6] | 2011 |
927 | 2011-04-04 22:14:45 | [1.0, 2.0] | 49.110833 | -123.349500 | 4 | [2.459, 2.562] | [2.7, 2.8] | 2011 |
928 | 2011-04-04 22:41:46 | [2.0, 1.0] | 49.117667 | -123.373167 | 4 | [2.754, 3.406] | [2.8, 2.8] | 2011 |
929 | 2011-04-04 23:06:31 | [1.0, 2.0] | 49.123667 | -123.396833 | 4 | [3.209, 2.87] | [2.5, 2.6] | 2011 |
930 | 2011-04-04 23:29:05 | [1.0, 2.0] | 49.134167 | -123.436333 | 4 | [3.136, 2.959] | [2.5, 2.7] | 2011 |
931 | 2011-04-05 00:35:58 | [2.0, 1.0] | 49.144667 | -123.476500 | 4 | [2.976, 2.976] | [2.3, 2.6] | 2011 |
932 | 2011-04-05 00:55:16 | [2.0, 1.0] | 49.155667 | -123.515500 | 4 | [3.436, 3.459] | [2.9, 3.0] | 2011 |
933 | 2011-04-05 01:21:42 | [1.0, 2.0] | 49.165167 | -123.547167 | 4 | [4.409, 3.959] | [2.7, 2.7] | 2011 |
934 | 2011-04-05 14:15:25 | [24.0, 23.0, 21.0, 22.0, 20.0, 19.0, 17.0, 18.... | 49.833667 | -124.865667 | 4 | [3.845, 4.124, 3.797, 3.749, 4.051, 4.091, 3.9... | [4.2, 4.2, 4.5, 4.6, 8.9, 8.9, 14.2, 14.2, 23.... | 2011 |
935 | 2011-04-06 14:20:39 | [24.0, 23.0, 22.0, 21.0, 19.0, 20.0, 17.0, 18.... | 49.025333 | -123.429833 | 4 | [3.617, 3.542, 3.842, 4.01, 3.417, 3.549, 1.11... | [2.9, 3.0, 4.4, 4.5, 9.4, 9.4, 13.9, 13.9, 23.... | 2011 |
936 rows × 8 columns