예제 #1
0
        #When (x,y) = (0.5, 0.5), which is the cell boundary, value is extracted from the next cell at (1,1)
        #j_idx = [(y+0.5).astype(int), (x+0.5).astype(int)]

        vx = vx_stack_dt[j]
        vy = vy_stack_dt[j]
        vdiv = vdiv_stack_dt[j]
        
        #x_hist.append(x)
        #y_hist.append(y)
        #vdiv_hist.append(vdiv)
        x_hist[h_idx] = x
        y_hist[h_idx] = y
        #Could also just record these, then sample vdiv at later stage
        #vdiv_hist[h_idx] = vdiv[j_idx] 
        #This is bilinear interp
        vdiv_t = malib.nanfill(vdiv, scipy.ndimage.map_coordinates, [y,x], order=1, mode='nearest')
        vdiv_hist[h_idx] = vdiv_t

        #These should be interpolated at each step, not integers, use map_coordinates
        #Multiply by dt_yr, which is yr/dt, to convert to px/dt
        #vx_t = vx[j_idx]
        #vy_t = vy[j_idx]

        #Since vx and vy are continuous at each timestep, can interp
        vx_t = malib.nanfill(vx, scipy.ndimage.map_coordinates, [y,x], order=1, mode='nearest')
        vy_t = malib.nanfill(vy, scipy.ndimage.map_coordinates, [y,x], order=1, mode='nearest')

        #Note: vx_t and vy_t will have some huge bogus values
        #Should filter, but these are also handled by the clip step

        dx = vx_t * dt_yr
예제 #2
0
vmi_gp_mse_ma[:,y,x] = np.array(vmi_gp_mse.reshape((ti.size, x.shape[0])))
sigma = np.sqrt(vmi_gp_mse_ma)
"""

"""
#This fills nodata in last timestep with values from previous timestep
#Helps Savitzy-Golay filter
fill_idx = ~np.ma.getmaskarray(vmi_ma[-1]).nonzero()
temp = np.ma.array(vmi_ma[-2])
temp[fill_idx] = vmi_ma[-1][fill_idx]
vmi_ma[-1] = temp
"""

print "Running Savitzy-Golay filter"
sg_window = 5 
vmi_sg = malib.nanfill(vmi_ma, scipy.signal.savgol_filter, window_length=sg_window, polyorder=2, axis=0, mode='nearest')
#vmi_sg = malib.nanfill(vmi_ma, scipy.signal.savgol_filter, window_length=sg_window, polyorder=2, axis=0, mode='interp')

#[malib.iv(i, clim=(0,4000)) for i in vmi_ma]
#[malib.iv(vmi_ma[i] - vmi_sg[i], clim=(-100,100), cmap='RdBu') for i in range(vmi_ma.shape[0])]

#Now apply original mask
#if clip_to_shelfmask:
#    apply_mask(vmi_ma, m_orig)

#Now sample at hi-res
from scipy.ndimage.interpolation import map_coordinates
#Updated dt interval
ti_hi_dt = 20 
print "Interpolating with timestep of %0.2f days" % ti_hi_dt
#Interpolate at these points