def getemolt_latlon(site): """ get data from emolt_site """ urllatlon = 'http://gisweb.wh.whoi.edu:8080/dods/whoi/emolt_site?emolt_site.SITE,emolt_site.LAT_DDMM,emolt_site.LON_DDMM,emolt_site.ORIGINAL_NAME,emolt_site.BTM_DEPTH&emolt_site.SITE=' dataset = open_url(urllatlon+'"'+site+'"') print dataset var = dataset['emolt_site'] lat = list(var.LAT_DDMM) lon = list(var.LON_DDMM) original_name = list(var.ORIGINAL_NAME) bd=fth2m(list(var.BTM_DEPTH)[0]) #bd=fth2m(bd[0]) return lat[0], lon[0], original_name,bd
from matplotlib.dates import DateFormatter from numpy import mean import datetime as dt import scipy from getdata import get_dataset, getemolt_temp from pandas.core.common import save for k in range(len(site)): if site[k][0:3]=='DMF': minnumperday=10 # had to use this in DMF case since they only record every two hours numperday=12 else: minnumperday=18 numperday=24 [datet,temp,depth_i]=getemolt_temp(site,k,input_time=[dt.datetime(1880,1,1),dt.datetime(2020,1,1)], dep=[0,1000]) depth=int(fth2m(mean(depth_i)))# mean depth of instrument to be added to outputfilename for m in range(len(temp)): temp[m]=(temp[m]-32.0)/1.8 tso=Series(temp,index=datet) tsod=tso.resample('D',how=['count','mean','median','min','max','std'],loffset=timedelta(hours=-12)) tsod.ix[tsod['count']<minnumperday,['mean','median','min','max','std']] = 'NaN' #add columns for custom date format tsod['yy']=tsod.index.year tsod['mm']=tsod.index.month tsod['dd']=tsod.index.day output_fmt=['yy','mm','dd','count','mean','median','min','max','std'] tsodp=tsod.reindex(columns=output_fmt) tsodp.to_csv(outdir+site[k]+'_wtmp_da_'+str(depth)+'.csv',index=False,header=False,na_rep='NaN',float_format='%10.2f') #create a monthly mean tsom=tso.resample('m',how=['count','mean','median','min','max','std'],kind='period')