Commit c69c54ad authored by Adam's avatar Adam

initial commit

parent de6cdf6a
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 23 15:17:21 2017
@author: AdamStoer
"""
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 5 13:34:22 2017
@author: Adam Stoer
Heat Map with Points on a Map
"""
import csv
import numpy as np
import matplotlib.pyplot as plt
from collections import defaultdict
from matplotlib.cm import plasma, jet,coolwarm
import datetime
#mission 34
columns = defaultdict(list) # each value in each column is appended to a list
mission_sci_ocr504i = str('m34_2014-06-26_view_sci_ocr504i' + ".csv")
view_sci_bb2flv2 = str('m34_2014-06-26_view_sci_bb2flsv2' + '.csv')
sci_water=str('m34_2014-06-26_view_sci_water'+'.csv')
with open('C:\\Users\\AdamStoer\\Documents\\OTN data\\' + sci_water) as file:
reader = csv.DictReader(file,delimiter=',') # read rows into a dictionary format
for row in reader:
columns['rawtime3'].append(row['unix_timestamp'])
columns['rawdepth3'].append(row['i_depth'])
columns['temp'].append(row['sci_water_temp'])
rawtime3 =columns['rawtime3']
depth3 = columns['rawdepth3'] # storage of depth
temp=columns['temp']
temp = [float(i) for i in temp]
rawtime3 = [float(i) for i in rawtime3]
with open('C:\\Users\\AdamStoer\\Documents\\OTN data\\' + mission_sci_ocr504i) as file:
reader = csv.DictReader(file,delimiter=',') # read rows into a dictionary format
for row in reader:
columns['rawtime1'].append(row['unix_timestamp'])
columns['rawdepth1'].append(row['i_depth'])
columns['irrad443'].append(row['sci_ocr504i_irrad2'])
columns['irrad555'].append(float(row['sci_ocr504i_irrad4']))
columns['pitch'].append(float(row['pitch']))
rawtime1 =columns['rawtime1']
depth1 = columns['rawdepth1'] # storage of depth
irrad443=columns['irrad443']
irrad555=columns['irrad555']
pitch=columns['pitch']
irrad443 = [float(i) for i in irrad443]
irrad555 = [float(i) for i in irrad555]
rawtime1 = [float(i) for i in rawtime1]
with open('C:\\Users\\AdamStoer\\Documents\\OTN data\\' + view_sci_bb2flv2) as file:
reader = csv.DictReader(file,delimiter=',') # read rows into a dictionary forma
for row in reader:
columns['chla'].append(row['sci_bb2flsv2_chl_scaled'])
columns['rawtime2'].append(row['unix_timestamp'])
columns['rawdepth2'].append(row['i_depth'])
rawtime2 =columns['rawtime2']
depth2 = columns['rawdepth2']
chla = columns['chla']
chla = [float(i) for i in chla]
rawtime2 = [float(i) for i in rawtime2]
def findMiddle(input_list):
middle = float(len(input_list))/2
if middle % 2 != 0:
return input_list[int(middle - .5)]
else:
return (input_list[int(middle)], input_list[int(middle-1)])
time= [datetime.datetime.fromtimestamp(int(i)).strftime('%Y-%m-%d') for i in rawtime2]
middleticktime=findMiddle(time)
time = [time[0],middleticktime,time[-1]]
writ_style = {'fontname':'Times New Roman', 'size':'15', 'color':'black', 'weight':'normal'}
def verticalprofile(variable, rawtime,depth,color,letter,typee):
fig, ax = plt.subplots(figsize=(10,5))
m=plt.scatter(rawtime, depth, c=variable, cmap=color,s=5)
#ax.fill_between(rawtime, 0, y1)
plt.title(letter, loc='left',**writ_style)
plt.xticks(np.arange(min(rawtime), max(rawtime)+1, (max(rawtime)-min(rawtime))/2),time)
#set axes specs
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_xlabel('Date',**writ_style)
ax.set_ylabel('Depth (m)',**writ_style)
ax.set_ylim(ax.get_ylim()[::-1])
#make colorbar
#get sie and extent of axes:
axpos = ax.get_position()
pos_x = axpos.x0+axpos.width + 0.01# + 0.25*axpos.width
pos_y = axpos.y0
cax_width = 0.05
cax_height = axpos.height
cax = fig.add_axes([pos_x,pos_y,cax_width,cax_height])
cbar=plt.colorbar(m, cax=cax)
ax.set_aspect('auto', adjustable=None)
for l in cbar.ax.yaxis.get_ticklabels():
l.set_family("Times New Roman")
l.set_fontsize(15)
for label in (ax.get_xticklabels() + ax.get_yticklabels()):
label.set_fontname('Times New Roman')
label.set_fontsize(15)
if typee == 'chla':
cbar.set_label('Chl a from Fluorescence ($\mathregular{mg/m^{3}}$)',**writ_style)
plt.clim(0.25,2.5)
if typee == 'irrad':
cbar.set_label('Irradiance ($\mathregular{µW/cm^{2}}$)',**writ_style)
if letter == 'A' or letter == 'B':
plt.clim(0,90)
if letter == 'C':
plt.clim(0,10)
if typee == 'temp':
cbar.set_label('Temperature (°C)',**writ_style)
plt.clim(0.0,13.0)
plt.show()
def plotpitchvsirrad(x,y,letter):
fig, ax = plt.subplots(figsize=(7,7))
fig.tight_layout(pad=2);
x = [i * 100 for i in x]
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.set_xlabel('Pitch (°)',**writ_style)
ax.set_ylabel('Irradiance ($\mathregular{µW/cm^{2}}$)',**writ_style)
for label in (ax.get_xticklabels() + ax.get_yticklabels()):
label.set_fontname('Times New Roman')
label.set_fontsize(15)
plt.title(letter, loc='left',**writ_style)
plt.scatter(x,y,color='black')
plt.show()
verticalprofile(irrad443,rawtime1,depth1,plasma,'A','irrad')
verticalprofile(irrad555,rawtime1,depth1,plasma,'B','irrad')
diffirrad=C = [(a - b) for a, b in zip(irrad555,irrad443)]
verticalprofile(diffirrad,rawtime1,depth1,plasma, 'C','irrad')
verticalprofile(chla,rawtime2,depth2,jet,'','chla')
verticalprofile(temp,rawtime3,depth3,coolwarm,'','temp')
plotpitchvsirrad(pitch,irrad443,'A')
plotpitchvsirrad(pitch,irrad555,'B')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment