dem_stack_fn = sys.argv[1]

#These are annual stacks
#dem_stack_fn = '/scr/pig_stack_20160307_tworows_highcount/full_extent/new_workflow/more_testing/20021128_2050_atm_256m-DEM_20150406_1519_103001003F89B700_1030010040D68600-DEM_32m_trans_stack_730_tide_ib_mdt_geoid_removed_nocorr_offset_-3.10m_filt_DG+LVIS+ATM_2009-2016_lsq_tiltcorr_filt_nocorrinv_GLAS+SPIRIT_merge_extract/mos_year/20080101_20070701-20080630_mos-tile-0_20150101_20140701-20150630_mos-tile-0_stack_8_clip.npz'

#This was GPS site DEM test at 32 m/px
#dem_stack_fn = '/scr/pig_stack_20160307_tworows_highcount/gps_2012-2014_extent/20021204_1929_atm_32m-DEM_20150223_1531_1040010008556800_104001000855E100-DEM_32m_trans_stack_89_tide_ib_mdt_geoid_removed_nocorr_offset_-3.10m_lsq_tiltcorr_filt_nocorrinv_filt_20080101-20150601.npz'
#dem_stack_fn = '/scr/pig_stack_20160307_tworows_highcount/gps_2012-2014_extent/20021204_1929_atm_32m-DEM_20150223_1531_1040010008556800_104001000855E100-DEM_32m_trans_stack_89_tide_ib_mdt_geoid_removed_nocorr_offset_-3.10m_lsq_tiltcorr_filt_nocorrinv_filt_gpstest.npz'

#This is high-res channels extent 32 m/px
#dem_stack_fn = '/scr/pig_stack_20160307_tworows_highcount/gl_paper_extent/ian_extent/highres_mainshelf_channels/20021128_2050_atm_32m-DEM_20150223_1531_1040010008556800_104001000855E100-DEM_32m_trans_stack_210_tide_ib_mdt_geoid_removed_nocorr_offset_-3.10m_lsq_tiltcorr_filt_nocorrinv_clip_filt_20080101-20150601.npz'
#This is 64 m version
#dem_stack_fn = '/scr/pig_stack_20160307_tworows_highcount/gl_paper_extent/ian_extent/highres_mainshelf_channels/res64m/20080105_1447_SPI_09-009_PIG_SPOT_DEM_V1_40m_hae_newfltr-trans_source-DEM_20141121_1508_1020010039903900_10200100366CC300-DEM_32m_trans_stack_99.npz'

dem_dir = os.path.split(os.path.abspath(dem_stack_fn))[0]
dem_stack = malib.DEMStack(stack_fn=dem_stack_fn, save=False, med=False, trend=False, stats=True)

#vx_stack_fn = '20071101_1409_84days_20070910_0956-20071203_0925_alos_mos_Track-Pig07_vx_20140613_20140829_tsx_mos_vx_stack_16.npz'
#vx_stack_fn = os.path.join(v_dir, vx_stack_fn)
#vx_stack_fn = '/scr/pig_stack_20151201_tworows_highcount/vel/shelf_clip/20060921_1746_189days_20060521_0950-20061126_0822_alos_mos_Track-Pig06_vx_20150530_1556_22days_20150525_0356-20150605_0356_tsx_mos_track-MayJun15_vx_stack_19_clip.npz'
#vx_stack = malib.DEMStack(stack_fn=vx_stack_fn, save=False, trend=True, med=True, stats=True)
#vx_stack_fn = '/scr/pig_stack_20151201_tworows_highcount/vel_20160225_1km/shelf_clip/20060921_1746_189days_20060521_0950-20061126_0822_alos_mos_Track-Pig06_vx_20151109_1349_90days_20151014_0000-20160112_0000_ls8_mos_All_S1516_vx_stack_22_clip_LinearNDint_121_142_121day.npz'
vx_stack_fn = '/scr/pig_stack_20151201_tworows_highcount/vel_20160225_512m/20060921_1746_189days_20060521_0950-20061126_0822_alos_mos_Track-Pig06_vx_20151109_1349_90days_20151014_0000-20160112_0000_ls8_mos_All_S1516_vx_stack_22_clip_LinearNDint_237_277_121day.npz'
vx_stack = malib.DEMStack(stack_fn=vx_stack_fn, save=False, trend=False, med=False, stats=False, datestack=False)

#vy_stack_fn = '20071101_1409_84days_20070910_0956-20071203_0925_alos_mos_Track-Pig07_vy_20140613_20140829_tsx_mos_vy_stack_16.npz'
#vy_stack_fn = os.path.join(v_dir, vy_stack_fn)
#vy_stack_fn = '/scr/pig_stack_20151201_tworows_highcount/vel/shelf_clip/20060921_1746_189days_20060521_0950-20061126_0822_alos_mos_Track-Pig06_vy_20150530_1556_22days_20150525_0356-20150605_0356_tsx_mos_track-MayJun15_vy_stack_19_clip.npz'
#vy_stack = malib.DEMStack(stack_fn=vy_stack_fn, save=False, trend=True, med=True, stats=True)
#vy_stack_fn = '/scr/pig_stack_20151201_tworows_highcount/vel_20160225_1km/shelf_clip/20060921_1746_189days_20060521_0950-20061126_0822_alos_mos_Track-Pig06_vy_20151109_1349_90days_20151014_0000-20160112_0000_ls8_mos_All_S1516_vy_stack_22_clip_LinearNDint_121_142_121day.npz'
vy_stack_fn = '/scr/pig_stack_20151201_tworows_highcount/vel_20160225_512m/20060921_1746_189days_20060521_0950-20061126_0822_alos_mos_Track-Pig06_vy_20151109_1349_90days_20151014_0000-20160112_0000_ls8_mos_All_S1516_vy_stack_22_clip_LinearNDint_237_277_121day.npz'
from datetime import datetime
from copy import deepcopy

import numpy as np

from lib import iolib
from lib import malib
from lib import timelib

stack_fn = sys.argv[1]
#offset = sys.argv[2]
#This is mean offset for PIG
#Note: PIG offset is trans_reference, so DEMs are above points!
offset = -3.1

s_orig = malib.DEMStack(stack_fn=stack_fn, stats=True, trend=True)
s = deepcopy(s_orig)

idx = np.array([bool(re.search('nocorr', i)) for i in s.source])
print 'Applying %0.2f m offset to %i nocorr DEMs' % (offset,
                                                     np.nonzero(idx)[0].size)

#idx = [bool(re.search('nocorr', i)) for i in s.source]
#print 'Applying %0.2f m offset to %i nocorr DEMs' % (offset, sum(idx))

s.ma_stack[idx] += offset

out_stack_fn = os.path.splitext(
    sys.argv[1])[0] + '_nocorr_offset_%0.2fm.npz' % offset
s.stack_fn = out_stack_fn
Esempio n. 3
0
    sys.exit('Must specify input stack and mode')

mode = None
#Set this to output the inverse of the specified filter
inv = False
#Set this to output both the pass and stop
both = False

stack_fn = sys.argv[1]
mode = sys.argv[2]

#Load stack
#s = malib.DEMStack(stack_fn=stack_fn, stats=True, trend=True, med=True)
s = malib.DEMStack(stack_fn=stack_fn,
                   stats=False,
                   trend=False,
                   med=False,
                   datestack=False)

#For bed
#s = malib.DEMStack(stack_fn=stack_fn, trend=False, stats=False, datestack=False, med=False)
#Pull out Dutrieux bed
#idx = [3,]

#Use default output filename
#Note: if out_stack_fn is not specified, a new stack fn will be computed with updated min/max dt and count
out_fn = None
#out_fn = os.path.splitext(s.stack_fn)[0]+'_filt.npz'

if mode == 'pig_pre_tiltcorr':
    #Isolate DG (both stereo and mono, trans and nocorr) and altimetry
Esempio n. 4
0

def apply_tilt_map(a, gt, dx, dy, dz):
    x, y = geolib.get_xy_ma(a, gt)
    tilt = dx * x + dy * y + dz
    out = a - tilt
    return out, tilt


stack_fn = sys.argv[1]
#coeff = [-4.0853200321014337e-05,-5.1455914113714195e-06,-68.510290024182609]
coeff_fn = '/scr/pig_stack_20160307_tworows_highcount/full_extent/new_workflow/more_testing/20021128_2050_atm_256m-DEM_20150406_1519_103001003F89B700_1030010040D68600-DEM_32m_trans_stack_730_tide_ib_mdt_geoid_removed_nocorr_offset_-3.10m_filt_DG+LVIS+ATM_2009-2016_lsq_tiltcorr.csv'
if len(sys.argv) > 2:
    coeff_fn = sys.argv[2]

s = malib.DEMStack(stack_fn=stack_fn, stats=True, med=True, trend=True)
hdr = 'fn,date,date_o,tiltx,tilty,tiltz'
#stack.fn_list, stack.date_list, stack.date_list_o, tilt[:,0], tilt[:,1], tilt[:,2]
c = np.genfromtxt(coeff_fn, dtype=None, delimiter=',', names=True)
gt = s.gt

from copy import deepcopy
s_tiltcorr = deepcopy(s)
s_tiltcorr.stack_fn = os.path.splitext(stack_fn)[0] + '_lsq_tiltcorr.npz'

for n, fn in enumerate(s.fn_list):
    print n, fn
    idx = (c['fn'] == fn).nonzero()[0]
    if idx.size > 0:
        tilt = list(c[idx][0])
        print s.source[n], tilt[3:]
Esempio n. 5
0
#test = vm_stack.ma_stack[:,20:50,190:220]
#N shelf, shear margin
#test = vm_stack.ma_stack[:,133:160,101:135]

if vtype == 'vm':
    stack_fn = vm_stack_fn
elif vtype == 'vx':
    stack_fn = vx_stack_fn
elif vtype == 'vy':
    stack_fn = vy_stack_fn
elif vtype == 'dem':
    stack_fn = dem_stack_fn

stack_fn = sys.argv[1]

stack = malib.DEMStack(stack_fn=stack_fn, save=False, trend=True, med=True, stats=True)
#Get times of original obs
t = stack.date_list_o.data

if clip_to_shelfmask:
    mask_fn = '/scr/pig_dem_stack/pig_shelf_poly_shean_2011gl.shp'
    outermask_fn = '/scr/pig_stack_20151201_tworows_highcount/pig_vel_mask.shp'
    m_orig = geolib.shp2array(mask_fn, res=stack.res, extent=stack.extent)
    outermask = ~(geolib.shp2array(outermask_fn, res=stack.res, extent=stack.extent))
    m = m_orig

    #Expand shelf mask 3 km upstream for flux gates
    #Should also reduce edge artifacts
    import scipy.ndimage
    it = int(np.ceil(3000./stack.res))
    m = ~(scipy.ndimage.morphology.binary_dilation(~m, iterations=it))