depth=pd.Series(secondData['depth'],index=tf_index1) temp=pd.Series(secondData['temp'],index=tf_index1) lon=pd.Series(secondData['lon'],index=tf_index1) lat=pd.Series(secondData['lat'],index=tf_index1) inde=pd.Series(secondData['index'],index=tf_index1) indx=[] for i in tf_index: if obsturtle_id[i]==118905: #this turtle is same turtle with 4-second turtle indx.append(i) obsLon, obsLat = obsData['LON'][indx], obsData['LAT'][indx] obsTime = pd.Series(np_datetime(obsData['END_DATE'][indx]), index=indx) obsTemp = pd.Series(str2ndlist(obsData['TEMP_VALS'][indx]), index=indx) obsDepth = pd.Series(str2ndlist(obsData['TEMP_DBAR'][indx]), index=indx) modTemp = pd.Series(obsData['modTempByDepth'],index=indx) for i in indx: modTemp[i]=str2list(modTemp[i],bracket=True) INDX=[] for j in tf_index1: if i==inde[j]: INDX.append(j) #find indices which are in same area fig=plt.figure() ax=fig.add_subplot(111) ax.plot(temp[INDX],depth[INDX],'ro-', label='raw',linewidth=1) ax.plot(modTemp[i],obsDepth[i],'go--' ,label='roms',linewidth=3) ax.plot(obsTemp[i],obsDepth[i],'bo--', label='telemetered',linewidth=3) ax.set_xlim([0, 30]) ax.set_ylim([max(obsDepth[i])+3, -1]) ax.set_xlabel('Temp', fontsize=10) ax.set_ylabel('Depth', fontsize=10) plt.xticks(fontsize=10) plt.yticks(fontsize=10)
r = 10 # the obs position that has shipboard position within (r) kilometers might be considered as good data. day = 3 # the obs time that has shipboard time within (day) days might be considered as good data. obsData=pd.read_csv('ctdWithModTempByDepth.csv',index_col=0) tf_index=np.where(obsData['TF'].notnull())[0] obslat = pd.Series(obsData['LAT'][tf_index],index=tf_index) obslon = pd.Series(obsData['LON'][tf_index],index=tf_index) obstime = pd.Series(np_datetime(obsData['END_DATE'][tf_index]),index=tf_index) obsDepth=pd.Series(str2ndlist(obsData['TEMP_DBAR'][tf_index]),index=tf_index) obstemp=pd.Series(str2ndlist(obsData['TEMP_VALS'][tf_index]),index=tf_index) modtemp=pd.Series(str2ndlist(obsData['modTempByDepth'][tf_index],bracket=True),index=tf_index) obsData1=pd.read_csv('ctd_FVcom_temp.csv') #this ctd`s FVCOM temperature tf_index_FVCOM=np.where(obsData1['modtempBYdepth'].notnull())[0] modtemp_FVCOM=pd.Series(obsData1['modtempBYdepth'],index=tf_index_FVCOM) for i in tf_index_FVCOM: modtemp_FVCOM[i]=str2list(modtemp_FVCOM[i],bracket=True) obsData2=pd.read_csv('ctd_withHYCOMtemp.csv') #this ctd`s HYCOM temperature tf_index_HYCOM=np.where(obsData2['modtemp_HYCOM'].notnull())[0] modtemp_HYCOM=pd.Series(obsData2['modtemp_HYCOM'],index=tf_index_HYCOM) for i in tf_index_HYCOM: modtemp_HYCOM[i]=str2list(modtemp_HYCOM[i],bracket=True) shipData=pd.read_csv('ship06-08_MODELtemp.csv',index_col=0) shiplat=pd.Series(shipData['LAT'],index=shipData.index) shiplon=pd.Series(shipData['LON'],index=shipData.index) shiptime=pd.Series(shipData['time'],index=shipData.index) shipdepth=pd.Series(str2ndlist(shipData['depth'],bracket=True),index=shipData.index) shiptemp=pd.Series(str2ndlist(shipData['temperature'],bracket=True),index=shipData.index) MODtemp=pd.Series(str2ndlist(shipData['modTempByDepth'],bracket=True),index=shipData.index) for i in range(len(shiptime)): shiptime[i]=datetime.strptime(shiptime[i], "%Y-%m-%d %H:%M:%S") # change str to datatime
temp = pd.Series(secondData['temp'], index=tf_index1) lon = pd.Series(secondData['lon'], index=tf_index1) lat = pd.Series(secondData['lat'], index=tf_index1) inde = pd.Series(secondData['index'], index=tf_index1) indx = [] for i in tf_index: if obsturtle_id[ i] == 118905: #this turtle is same turtle with 4-second turtle indx.append(i) obsLon, obsLat = obsData['LON'][indx], obsData['LAT'][indx] obsTime = pd.Series(np_datetime(obsData['END_DATE'][indx]), index=indx) obsTemp = pd.Series(str2ndlist(obsData['TEMP_VALS'][indx]), index=indx) obsDepth = pd.Series(str2ndlist(obsData['TEMP_DBAR'][indx]), index=indx) modTemp = pd.Series(obsData['modTempByDepth'], index=indx) for i in indx: modTemp[i] = str2list(modTemp[i], bracket=True) INDX = [] for j in tf_index1: if i == inde[j]: INDX.append(j) #find indices which are in same area fig = plt.figure() ax = fig.add_subplot(111) ax.plot(temp[INDX], depth[INDX], 'ro-', label='raw', linewidth=1) ax.plot(modTemp[i], obsDepth[i], 'go--', label='roms', linewidth=3) ax.plot(obsTemp[i], obsDepth[i], 'bo--', label='telemetered', linewidth=3) ax.set_xlim([0, 30]) ax.set_ylim([max(obsDepth[i]) + 3, -1]) ax.set_xlabel('Temp', fontsize=10) ax.set_ylabel('Depth', fontsize=10) plt.xticks(fontsize=10) plt.yticks(fontsize=10)
import matplotlib.pyplot as plt from matplotlib import path from turtleModule import mon_alpha2num, np_datetime, str2list from watertempModule import water_roms ###########################main code################################################# ctddata = pd.read_csv('ctdWithModTempByDepth.csv') shallow = ctddata.ix[17] # 17, 19, 22 deep = ctddata.ix[13469] # 18914 shallowtime = np_datetime(shallow['END_DATE']) shallowtemp = [float(temp) for temp in shallow['TEMP_VALS'].split(',')] #modelobj = water_roms() #modelurl = modelobj.get_url(shallowtime, shallowtime+timedelta(hours=1)) depth = [int(dep) for dep in shallow['TEMP_DBAR'].split(',')] modeltemp = str2list(shallow['modTempByDepth'], bracket=True) ''' modeltemp = [] for dep in depth: print dep modeltemp.append(modelobj.watertemp(shallow['LON'], shallow['LAT'], dep, shallowtime, modelurl)) ''' deeptime = np_datetime(deep['END_DATE']) deeptemp = [float(temp) for temp in deep['TEMP_VALS'].split(',')] #modelobj2 = water_roms() #modelurl2 = modelobj2.get_url(deeptime, deeptime+timedelta(hours=1)) depth2 = [int(dep) for dep in deep['TEMP_DBAR'].split(',')] ''' modeltemp2 = [] print 'start deep'
tf_index = np.where(obsData['TF'].notnull())[0] obslat = pd.Series(obsData['LAT'][tf_index], index=tf_index) obslon = pd.Series(obsData['LON'][tf_index], index=tf_index) obstime = pd.Series(np_datetime(obsData['END_DATE'][tf_index]), index=tf_index) obsDepth = pd.Series(str2ndlist(obsData['TEMP_DBAR'][tf_index]), index=tf_index) obstemp = pd.Series(str2ndlist(obsData['TEMP_VALS'][tf_index]), index=tf_index) modtemp = pd.Series(str2ndlist(obsData['modTempByDepth'][tf_index], bracket=True), index=tf_index) obsData1 = pd.read_csv('ctd_FVcom_temp.csv') #this ctd`s FVCOM temperature tf_index_FVCOM = np.where(obsData1['modtempBYdepth'].notnull())[0] modtemp_FVCOM = pd.Series(obsData1['modtempBYdepth'], index=tf_index_FVCOM) for i in tf_index_FVCOM: modtemp_FVCOM[i] = str2list(modtemp_FVCOM[i], bracket=True) obsData2 = pd.read_csv('ctd_withHYCOMtemp.csv') #this ctd`s HYCOM temperature tf_index_HYCOM = np.where(obsData2['modtemp_HYCOM'].notnull())[0] modtemp_HYCOM = pd.Series(obsData2['modtemp_HYCOM'], index=tf_index_HYCOM) for i in tf_index_HYCOM: modtemp_HYCOM[i] = str2list(modtemp_HYCOM[i], bracket=True) shipData = pd.read_csv('ship06-08_MODELtemp.csv', index_col=0) shiplat = pd.Series(shipData['LAT'], index=shipData.index) shiplon = pd.Series(shipData['LON'], index=shipData.index) shiptime = pd.Series(shipData['time'], index=shipData.index) shipdepth = pd.Series(str2ndlist(shipData['depth'], bracket=True), index=shipData.index) shiptemp = pd.Series(str2ndlist(shipData['temperature'], bracket=True), index=shipData.index) MODtemp = pd.Series(str2ndlist(shipData['modTempByDepth'], bracket=True),