monopair_dates.append(datelib.date_to_fracyear(float(str(recs[i][2])[0:4]),float(str(recs[i][2])[4:6]),float(str(recs[i][2])[6:8])))

plt.figure()
for day in fracyear_cand:
  plt.plot([day,day],[-4,4],'0.7')
for day in monopair_dates:
  plt.plot([day,day],[-4,4],'r',linewidth=1.5)
for day in stereopair_dates:
  plt.plot([day,day],[-4,4],'b',linewidth=1.5)  
plt.plot([fracyear_cand[0],fracyear_cand[0]],[-4,4],'0.7',label='Potential TDM')
plt.plot([monopair_dates[0],monopair_dates[0]],[-4,4],'r',linewidth=1.5,label='WV monopair')
plt.plot([stereopair_dates[0],stereopair_dates[0]],[-4,4],'b',linewidth=1.5,label='WV stereopair')
plt.plot([fracyear_cand[0],fracyear_cand[0]],[0,0],'g',linewidth=2,label='TDM Order')
plt.plot([fracyear_cand[order_cand==1],fracyear_cand[order_cand==1]],[-4,4],'g',linewidth=2)
try:
  x,y,zb,dists = glaclib.load_flowline(glacier)
  terminus_val, terminus_time = icefronts.distance_along_flowline(x,y,dists,glacier,type='icefront')
  plt.plot(terminus_time,terminus_val/1000,'k.')
except:
  print "no terminus positions"
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
plt.gca().xaxis.set_major_formatter(x_formatter)
plt.title(glacier+'\n(total='+str(N)+', potential='+str(len(fracyear_cand))+', orbits='+str(orbits)+')')
plt.xlim([2011,2015.6]) 
plt.ylim([-4,4])
plt.ylabel('Terminus (km)')
plt.legend(loc=2)

#########
# Order #
#########
Beispiel #2
0
    xmax = 313600.0
    ymin = -2582000.0
    ymax = -2573000.0
elif glacier == 'Kanger':
    xmin = 484400.0
    xmax = 497260.0
    ymin = -2298000.0
    ymax = -2282000.0

############
# Flowline #
############

x, y, zb, dists = glaclib.load_flowline(glacier,
                                        shapefilename='flowline_flightline',
                                        filt_len=2.0e3,
                                        verticaldatum='geoid',
                                        bedsource='cresis')

############
# Get DEMs #
############

xdem, ydem, zdem, timedem, errordem = zslib.dem_grid(glacier,
                                                     xmin,
                                                     xmax,
                                                     ymin,
                                                     ymax,
                                                     years='all',
                                                     verticaldatum='geoid',
                                                     return_error=True)
Beispiel #3
0
import os
import matplotlib
import cubehelix
from mpl_toolkits.basemap import Basemap
from matplotlib.ticker import AutoMinorLocator
from matplotlib.path import Path
from matplotlib.patches import PathPatch

#############
# Load data #
#############

# Flowlines
x_H, y_H, zb_H, dists_H = glaclib.load_flowline(
    'Helheim',
    shapefilename='flowline_flightline',
    filt_len=2.0e3,
    bedsource='cresis')
x_K, y_K, zb_K, dists_K = glaclib.load_flowline(
    'Kanger',
    shapefilename='flowline_flightline',
    filt_len=2.0e3,
    bedsource='cresis')

# Get inversion dates
times_inv_K = []
times_inv_H = []
DIR = os.path.join(os.getenv("MODEL_HOME"), "Helheim/Results/INV_SSA_ModelT")
files = os.listdir(DIR)
for file in files:
    if file.endswith('taub.tif'):
Beispiel #4
0
runname = args.runname
t2 = args.t2

DIRM = os.path.join(os.getenv("MODEL_HOME"), glacier + "/3D/" + meshname + "/")
DIRO = os.path.join(DIRM + "figures/movie_" + runname)

if not (os.path.isdir(DIRM)):
    sys.exit("Mesh directory " + meshname + " does not exist for " + glacier +
             ".")

if not (os.path.isdir(DIRO)):
    os.makedirs(DIRO)

# Load flowline
print "Loading flowline..."
xflow, yflow, zb, dist = glaclib.load_flowline(glacier)

# Create grid
dx = 200
xgrid = np.arange(278000, 313000, dx)
ygrid = np.arange(-2583000, -2552000, dx)

# Points for sampling
dists_eul = np.array([-2, -5, -10, -15, -20]) * 1e3

# Get terminus position along flowline
print "Loading terminus positions..."
terminus_val, terminus_time = icefrontlib.distance_along_flowline(
    xflow, yflow, dist, glacier, datatypes=['WV', 'Landsat8', 'TSX'])

# Get data for comparison
Beispiel #5
0
# LMK, UW, 9/16/2015

import os
import numpy as np
import climlib, glaclib, icefrontlib, vellib, datelib
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.ticker import AutoMinorLocator

#################################################################################
# Get coordinates for distance D along the flowline for both Kanger and Helheim #
#################################################################################
D = 10.0e3  # m inland from average terminus position

# Helheim:
xH, yH, zbH, distsH = glaclib.load_flowline('Helheim')
ind = np.argmin(abs(distsH + D))
xptH = xH[ind]
yptH = yH[ind]
terminus_valH, terminus_timeH = icefrontlib.distance_along_flowline(
    xH, yH, distsH, 'Helheim', type='icefront')
vel_valH, vel_timeH, vel_errorH = vellib.velocity_at_eulpoints(xptH,
                                                               yptH,
                                                               'Helheim',
                                                               data='TSX')

del xH, yH, zbH, distsH, ind

# Kanger:
xK, yK, zbK, distsK = glaclib.load_flowline('Kanger')
ind = np.argmin(abs(distsK + D))
Beispiel #6
0
            linewidth=1.5)
    ax.plot(
        [xmin + 0.61 * (xmax - xmin) + 5e3, xmin + 0.61 * (xmax - xmin) + 5e3],
        [ymin + 0.80 * (ymax - ymin), ymin + 0.78 * (ymax - ymin)],
        'k',
        linewidth=1.5)
    ax.text(xmin + 0.64 * (xmax - xmin) + 5e3,
            ymin + 0.78 * (ymax - ymin),
            '5 km',
            fontsize=10)

    year, month, day = datelib.fracyear_to_date(timedem[k])
    date = '{0}{1:02d}{2:02d}'.format(year, month, int(day))
    plt.tight_layout()
    plt.subplots_adjust(top=0.99, right=0.99, left=0.01, bottom=0.01)
    plt.savefig(os.path.join(
        os.getenv("HOME"), "Bigtmp/" + glacier + "_taud_" + date + "_mag.pdf"),
                format='PDF',
                transparent=True)
    plt.close()

xf, yf, zbf, dists = glaclib.load_flowline(glacier)

taud_u_flow = np.zeros([len(dists), len(timedem)])
for k in range(0, len(timedem)):
    f = RegularGridInterpolator((y, x),
                                taud_u[:, :, k],
                                bounds_error=False,
                                fill_value=float('nan'))
    taud_u_flow[:, k] = f((yf, xf))
DIRG = os.path.join(os.getenv("MODEL_HOME"), glacier + '/Results/')
DIR_SSA_MT = DIRG + "INV_SSA_ModelT/"
DIR_SSA_CT = DIRG + "INV_SSA_ConstantT/"
DIR_FS_MT = DIRG + "INV_FS_ModelT/"
DIR_FS_CT = DIRG + "INV_FS_ConstantT/"

# Get indices where velocity is always greater than the cutoff value
x_cutoff_SSA,y_cutoff_SSA,vsurfini_cutoff_SSA,ind_cutoff_grid,ind_cutoff_SSA  = inverselib.get_velocity_cutoff(glacier,\
        velocity_cutoff=cutoff,model_dir='INV_SSA_ModelT',SSA=True,sign='over')
x_cutoff_SSA_fast,y_cutoff_SSA_fast,vsurfini_cutoff_SSA_fast,ind_cutoff_grid_fast,ind_cutoff_SSA_fast  = inverselib.get_velocity_cutoff(glacier,\
        velocity_cutoff=4000,model_dir='INV_SSA_ModelT',SSA=True,sign='over')
x_cutoff_SSA_slow,y_cutoff_SSA_slow,vsurfini_cutoff_SSA_slow,ind_cutoff_grid_slow,ind_cutoff_SSA_slow  = inverselib.get_velocity_cutoff(glacier,\
        velocity_cutoff=1000,model_dir='INV_SSA_ModelT',SSA=True,sign='under')

# Get ice front positions
xflow, yflow, zflow, dflow = glaclib.load_flowline(glacier)
term_pos, term_time = icefrontlib.distance_along_flowline(
    xflow, yflow, dflow, glacier)

# Some constants
rho_i = 917.
rho_sw = 1025.
g = 9.8

# Get runoff
ind = np.argmin(abs(dflow + 5e3))
xrac, yrac, runoff, runoff_time = climlib.racmo_at_pts(xflow[ind],
                                                       yflow[ind],
                                                       'runoff',
                                                       filt_len=14)
year_runoff, day1_runoff, day2_runoff, meltlength_runoff, total_runoff = climlib.seasonlength(
# LMK, UW, 9/16/2015

import os
import numpy as np
import climlib, glaclib, icefrontlib, vellib, datelib, coordlib
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.ticker import AutoMinorLocator

#################################################################################
# Get coordinates for distance D along the flowline for both Kanger and Helheim #
#################################################################################
D = [10.0e3]  # m inland from average terminus position

# Helheim:
xH, yH, zbH, distsH = glaclib.load_flowline('Helheim')
ind = []
for i in range(0, len(D)):
    ind.append(np.argmin(abs(distsH + D[i])))
xptH = xH[ind]
yptH = yH[ind]
terminus_valH, terminus_timeH = icefrontlib.distance_along_flowline(
    xH, yH, distsH, 'Helheim', type='icefront')
vel_valH, vel_timeH, vel_errorH = vellib.velocity_at_eulpoints(xptH,
                                                               yptH,
                                                               'Helheim',
                                                               data='TSX')

del ind

###################
                                      verticaldatum='geoid')

cutoff = 5.
floatcond = np.zeros(len(xf))
floatcond[:] = float('nan')
for i in range(0, len(xf)):
    if np.nanmin(zabovefloat[i, :]) > cutoff:
        floatcond[i] = 1  #grounded
    elif np.nanmax(zabovefloat[i, :]) < -1 * cutoff:
        floatcond[i] = -1  #floating
    elif (np.nanmax(zabovefloat[i, :]) > -1 * cutoff) or (np.nanmin(
            zabovefloat[i, :]) < cutoff):
        floatcond[i] = 0  #changing basal conditions

# Get flowline to plot some points for reference to other figures
xflow, yflow, zbflow, distflow = glaclib.load_flowline(
    glacier, shapefilename='flowline_flightline', filt_len=2.0e3)

# Get points for plotting
dists_eul = -1.0 * np.array([0, 5.0, 10.0, 15.0, 20.0])  # kilometers
coloptions = [
    'w', [182. / 255, 219. / 255, 1], 'limegreen', 'gold', [200. / 255, 0, 0]
]

# Find where points are located along flowline
ind_eul = []
for i in range(0, len(dists_eul)):
    ind_eul.append((abs(distflow - dists_eul[i] * 1e3)).argmin())

############################
# Plot spatial variability #
############################
Beispiel #10
0
file_bedrock_out = DIRM + "Inputs/roughbed.dat"
file_flowline_out = DIRM + "Inputs/flowline.dat"

#################
# Make box mesh #
#################

# Make mesh directories if mesh directories do not already exist
if not (os.path.isdir(DIRM)):
    #os.makedirs(DIRR)
    os.makedirs(DIRM)
    os.makedirs(DIRM + "Inputs")

# Flowline coordinates
x, y, zb, dists = glaclib.load_flowline(glacier,
                                        shapefilename=file_flowline_in,
                                        filt_len='none',
                                        verticaldatum='geoid')

# Surface elevations along flowline for chosen date
zs = zslib.dem_continuous_flowline(x,
                                   y,
                                   dists,
                                   glacier,
                                   date,
                                   filt_len=filt_len,
                                   verticaldatum='geoid',
                                   fillin=True)

# Terminus position for date
terminus = icefrontlib.position(
    x, y, dists, glacier,