""" Compares eMOLT with FVCOM bottom temp @author: jmanning, rsignell, yacheng """ import matplotlib.pyplot as plt import netCDF4 from getdata import getemolt_latlon,getemolt_temp from conversions import dm2dd,f2c from utilities import nearxy site='BN01' [lati,loni,on]=getemolt_latlon(site) # extracts lat/lon based on site code [lati,loni]=dm2dd(lati,loni) #converts decimal-minutes to decimal degrees [obs_dt,obs_temp]=getemolt_temp(site) # extracts time series for kk in range(len(obs_temp)): obs_temp[kk]=f2c(obs_temp[kk]) # converts to Celcius # now get the model output urlfvcom = 'http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3' nc = netCDF4.Dataset(urlfvcom) nc.variables lat = nc.variables['lat'][:] lon = nc.variables['lon'][:] times = nc.variables['time'] jd = netCDF4.num2date(times[:],times.units) vname = 'temp' var = nc.variables[vname] # find nearest point to desired location and time inode = nearxy(lon,lat,loni,lati) index=netCDF4.date2index([obs_dt[0],obs_dt[-1]],times,select='nearest')#find the model time index at start & end pf obs
""" Compares eMOLT with FVCOM bottom temp @author: jmanning, rsignell, yacheng """ import matplotlib.pyplot as plt import netCDF4 from getdata import getemolt_latlon, getemolt_temp from conversions import dm2dd, f2c from utilities import nearxy site = 'BN01' [lati, loni, on] = getemolt_latlon(site) # extracts lat/lon based on site code [lati, loni] = dm2dd(lati, loni) #converts decimal-minutes to decimal degrees [obs_dt, obs_temp] = getemolt_temp(site) # extracts time series for kk in range(len(obs_temp)): obs_temp[kk] = f2c(obs_temp[kk]) # converts to Celcius # now get the model output urlfvcom = 'http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3' nc = netCDF4.Dataset(urlfvcom) nc.variables lat = nc.variables['lat'][:] lon = nc.variables['lon'][:] times = nc.variables['time'] jd = netCDF4.num2date(times[:], times.units) vname = 'temp' var = nc.variables[vname] # find nearest point to desired location and time inode = nearxy(lon, lat, loni, lati) index = netCDF4.date2index(
import matplotlib.pyplot as plt 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