Esempio n. 1
0
        plt.text(x=1,
                 y=23,
                 s=r'$\mathregular{R^2}$=' + str(round(r_squared[j], 3)),
                 fontsize=15)
        if j == 0:
            plt.title('%s' % tp, fontsize=FONTSIZE)
    plt.savefig('obsVSmodel_%s.png' % tp, dpi=200)
    return r_squared


####################################roms#######################################
FONTSIZE = 25
obs = pd.read_csv('ctdWithModTempByDepth.csv')
tf_index = np.where(obs['TF'].notnull())[0]
obsdepth = pd.Series(obs['MAX_DBAR'][tf_index], index=tf_index)
obstemp = pd.Series(bottom_value(obs['TEMP_VALS'][tf_index]), index=tf_index)
obsdata_roms = pd.DataFrame({
    'depth': obsdepth,
    'temp': obstemp
}).sort_index(by='depth')
Temp_roms = pd.Series(str2ndlist(
    obs['modTempByDepth'][obsdata_roms['temp'].index], bracket=True),
                      index=obsdata_roms['temp'].index)
temp_roms = []
for i in obsdata_roms['temp'].index:
    if Temp_roms[i][-1] > 100:  #get rid of some bad data
        temp_roms.append(obsdata_roms['temp'][i])
    else:
        temp_roms.append(Temp_roms[i][-1])
temp_roms = pd.Series(temp_roms, index=obsdata_roms['temp'].index)
index_roms = index_by_depth(obsdata_roms['depth'], 50)
    plt.plot(x, x, 'r-', linewidth=2)
    plt.plot(x2, y2, 'y-', linewidth=2)
    # plt.title('R-squard: %.4f' % r_squared, fontsize=FONTSIZE)
    plt.savefig('obsVSmodelDeepestBottom2.png',dpi=200)
    return ax1, ax2, r_squared
#############################MAIN CODE###########################################
FONTSIZE = 25
# obs = pd.read_csv('ctd_extract_TF.csv')
obs = pd.read_csv('ctd_good.csv')
tf_index = np.where(obs['TF'].notnull())[0]
obslat, obslon = obs['LAT'][tf_index].values, obs['LON'][tf_index].values
obstime = np_datetime(obs['END_DATE'][tf_index])
# obsdepth = mean_value(obs['TEMP_DBAR'][tf_index])
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, 8, 24)
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'].values, url)
temp = pd.Series(temp, index = obsdata['temp'].index)

index = index_by_depth(obsdata['depth'], 50)
# colors = utilities.uniquecolors(10)
tp='all'
    return ax1, ax2, r_squared


#############################MAIN CODE###########################################
FONTSIZE = 14
# obs = pd.read_csv('ctd_extract_TF.csv')
obs = pd.read_csv('ctdWithModTempByDepth.csv')
obstime1 = np_datetime(obs['END_DATE'])
tf_index = np.where((obs['TF'].notnull())
                    & (obstime1 >= datetime(2009, 10, 11, 2, 0)))[0]
obslat, obslon = obs['LAT'][tf_index].values, obs['LON'][tf_index].values
obstime = np_datetime(obs['END_DATE'][tf_index])
# obsdepth = mean_value(obs['TEMP_DBAR'][tf_index])
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)
        plt.xticks(fontsize=20)
        plt.yticks(fontsize=20)
        plt.plot(x, x, 'r-', linewidth=2)
        plt.plot(x2, y2, 'y-', linewidth=2)
        plt.text(x=1,y=27,s=text[j],fontsize=15)
        plt.text(x=1,y=23,s=r'$\mathregular{R^2}$='+str(round(r_squared[j],3)),fontsize=15)
        if j==0:
            plt.title('%s'%tp,fontsize=FONTSIZE)
    plt.savefig('obsVSmodel_%s.png'%tp,dpi=200)
    return r_squared
####################################roms#######################################
FONTSIZE = 25
obs = pd.read_csv('ctdWithModTempByDepth.csv')
tf_index = np.where(obs['TF'].notnull())[0]
obsdepth = pd.Series(obs['MAX_DBAR'][tf_index],index=tf_index)
obstemp = pd.Series(bottom_value(obs['TEMP_VALS'][tf_index]),index=tf_index)
obsdata_roms= pd.DataFrame({'depth':obsdepth, 'temp':obstemp}).sort_index(by='depth')
Temp_roms=pd.Series(str2ndlist(obs['modTempByDepth'][obsdata_roms['temp'].index],bracket=True),index=obsdata_roms['temp'].index)
temp_roms=[]
for i in obsdata_roms['temp'].index:
    if Temp_roms[i][-1]>100:   #get rid of some bad data
        temp_roms.append(obsdata_roms['temp'][i])
    else:
        temp_roms.append(Temp_roms[i][-1])
temp_roms=pd.Series(temp_roms,index=obsdata_roms['temp'].index)
index_roms=index_by_depth(obsdata_roms['depth'], 50)
###################################fvcom#######################################
obs = pd.read_csv('ctdWithdepthofbottom_fvcom.csv')
tf_index = np.where(obs['in FVcom range'].notnull())[0]
obsdepth = pd.Series(obs['MAX_DBAR'][tf_index],index=tf_index)
obstemp = pd.Series(bottom_value(obs['TEMP_VALS'][tf_index]),index=tf_index)