obsdepth = obs['MAX_DBAR'][tf_index].values
# obstemp = mean_value(obs['TEMP_VALS'][tf_index])
obstemp = bottom_value(obs['TEMP_VALS'][tf_index])
obsdata = pd.DataFrame({
    'depth': obsdepth,
    'temp': obstemp,
    'lon': obslon,
    'lat': obslat,
    'time': obstime
}).sort_index(by='depth')

starttime = datetime(
    2009, 10, 11, 2, 0
)  # altough our starttime is(2009, 8, 24),but the roms time start on 2009,10,11
endtime = datetime(2013, 12, 13)
tempobj = wtm.water_roms()
url = tempobj.get_url(starttime, endtime)
# temp = tempobj.watertemp(obslon, obslat, obsdepth, obstime, url)
temp = tempobj.watertemp(obsdata['lon'].values, obsdata['lat'].values,
                         obsdata['depth'].values, obsdata['time'], url)
temp = pd.Series(temp, index=obsdata['temp'].index)

index = index_by_depth(obsdata['depth'], 50)
# colors = utilities.uniquecolors(10)
tp = 'all'
if tp == 'all':
    x1, y1 = temp, obsdata['temp']
    ax1, ax2, r_squared = show2pic(x1, y1, FONTSIZE)
    ax1.set_title('Bottom Temperature(R-squared=%.2f)' % r_squared,
                  fontsize=FONTSIZE)
    ax2.set_title('Bottom Temperature(R-squared=%.2f)' % r_squared,
예제 #2
0
def nearest_point_index2(lon, lat, lons, lats):
    d = dist(lon, lat, lons, lats)
    min_dist = np.min(d)
    index = np.where(d == min_dist)
    return index


obsData = pd.read_csv('ctd_extract_good.csv', index_col=0)
obsLon = obsData['LON']
obsLat = obsData['LAT']

starttime = datetime(
    2013, 07, 10
)  # starttime and endtime can be any time that included by model, we just want a url to get "lon_rho", "lat_rho", "h", "s_rho" in model.
endtime = starttime + timedelta(hours=1)
tempObj = wtm.water_roms()
url = tempObj.get_url(starttime, endtime)
modData = netCDF4.Dataset(url)
modLons = modData.variables['lon_rho'][:]
modLats = modData.variables['lat_rho'][:]
s_rho = modData.variables['s_rho'][:]
h = modData.variables['h'][:]
indexNotNull = obsLon[
    obsLon.isnull() ==
    False].index  # some obslat and obslon of point are empty, get rid of them.
# or this line can be the indices of TF which is less.
# indexTF = np.where(obsData['TF'].notnull())[0]

loc = []
for i in indexNotNull:
    ind = []
예제 #3
0
import watertempModule as wtm  
############################################################################################
obsData = pd.read_csv('ctdWithModTempByDepth.csv') 
tf_index = np.where(obsData['TF'].notnull())[0]
modTemp = pd.Series(str2ndlist(obsData['modTempByDepth'][tf_index],bracket=True), index=tf_index) # if str has '[' and ']', bracket should be True
indx=[]
for j in tf_index:
    if modTemp[j][-1]<100:
        indx.append(j)
obs=obsData.ix[indx]
obs=obs.drop(['Unnamed: 0','Unnamed: 0.1'],axis=1)
obs.to_csv('ctdwithoutbad_roms.csv')
###############################################################################
starttime = datetime(2013,07,10) # starttime and endtime can be any time that included by model, we just want a url to get "lon_rho", "lat_rho","h"in model.
endtime = starttime + timedelta(hours=1)
tempObj = wtm.water_roms()
url = tempObj.get_url(starttime, endtime)
modData = netCDF4.Dataset(url)
modLons = modData.variables['lon_rho'][:]
modLats = modData.variables['lat_rho'][:]
moddepth = modData.variables['h'][:]

modNearestIndex = pd.Series(str2ndlist(obsData['modNearestIndex'][indx], bracket=True), index=indx) # if str has '[' and ']', bracket should be True

newH=[]
for i in indx:
    m, n = int(modNearestIndex[i][0]), int(modNearestIndex[i][1])
    newH.append(moddepth[m][n])
obs['depth_bottom']=pd.Series(newH,index=indx)
obs.to_csv('ctdWithdepthofbottom_roms.csv')
#obs=obs.drop(['Unnamed: 0','Unnamed: 0.1'],axis=1)