Esempio n. 1
0
DATA_DIR = "/home/dunbar/Research/helheim/data/observations"
DEM_DIR = os.path.join(DATA_DIR, 'dem')
MAX_DEPTH = 30e3

# ---- Prepare Observers ----

observerpath = ['stardot1','stardot2']
observers = []
for observer in observerpath:
    path = join(DATA_DIR,observer)
    campaths =  glob.glob(join(path,"*.JSON"))
    images = [glimpse.Image(path=campath.replace(".JSON",".jpg"),cam=campath) for campath in campaths]
    images.sort(key= lambda img: img.datetime)
    datetimes = np.array([img.datetime for img in images])
    for n, delta in enumerate(np.diff(datetimes)):
        if delta <= datetime.timedelta(seconds=0):
            secs = datetime.timedelta(seconds= n%5 + 1)
            images[n+1].datetime = images[n+1].datetime + secs
    diffs = np.array([dt.total_seconds() for dt in np.diff(np.array([img.datetime for img in images]))])
    negate = diffs[diffs <= 1].astype(np.int)
    [images.pop(_) for _ in negate]

    images = images[:int(len(images)/2)]
    print("Image set {} \n".format(len(images)))
    obs = glimpse.Observer(list(np.array(images)),cache=False)
    observers.append(obs)
#-------------------------
uv = observer[1].images[0].cam.project(( 7361411.0,533528.0,180))
observer[1].images[0].cam.plot()
matplotlib.pyplot.scatter(uv[:, 0], uv[:, 1])
Esempio n. 2
0
station_datetimes = dict()
for station in stations:
    print(station)
    services = sequences[sequences.station == station].service.values
    images = cg.load_images(
        station=station, services=services, snap=snap,
        service_exif=True, anchors=False, viewdir=True, viewdir_as_anchor=True,
        file_errors=False)
    images = [img for img in images if img.anchor]
    images.sort(key=lambda x: x.datetime)
    datetimes = np.array([img.datetime for img in images])
    # Endpoints
    iranges = np.atleast_2d((0, len(images)))
    # Changes in image size
    width = [img.cam.imgsz[0] for img in images]
    cuts = [i + 1 for i in np.nonzero(np.diff(width))[0]]
    iranges = glimpse.helpers.cut_ranges(iranges, cuts)
    # Camera changes
    # HACK: Use k1 as a proxy
    k = [img.cam.k[0] for img in images]
    cuts = [i + 1 for i in np.nonzero(np.diff(k))[0]]
    iranges = glimpse.helpers.cut_ranges(iranges, cuts)
    # Gaps in coverage
    dt = np.diff(datetimes)
    cuts = [i + 1 for i in np.nonzero(dt > max_gap)[0]]
    iranges = glimpse.helpers.cut_ranges(iranges, cuts)
    # Sudden very large motions
    viewdirs = np.array([img.cam.viewdir for img in images])
    dtheta = np.diff(viewdirs, axis=0)
    pan_tilt = np.linalg.norm(dtheta[:, 0:2], axis=1)
    rotation = np.abs(dtheta[:, 2])
Esempio n. 3
0
# ---- Build DEM template ----

json = glimpse.helpers.read_json('observers.json',
    object_pairs_hook=collections.OrderedDict)
stations = set([station for x in json for station in x])
station_xy = np.vstack([f['geometry']['coordinates'][:, 0:2]
    for station, f in cg.Stations().items()
    if station in stations])
box = glimpse.helpers.bounding_box(cg.Glacier())
XY = glimpse.helpers.box_to_grid(box, step=(grid_size, grid_size),
    snap=(0, 0), mode='grid')
xy = glimpse.helpers.grid_to_points(XY)
distances = glimpse.helpers.pairwise_distance(xy, station_xy, metric='euclidean')
selected = distances.min(axis=1) < max_distance
box = glimpse.helpers.bounding_box(xy[selected]) + 0.5 * np.array([-1, -1, 1, 1]) * grid_size
shape = np.diff([box[1::2], box[0::2]], axis=1) / grid_size
dem_template = glimpse.Raster(np.ones(shape.astype(int).ravel(), dtype=bool),
    x=box[0::2], y=box[1::2][::-1])
dem_points = glimpse.helpers.grid_to_points((dem_template.X, dem_template.Y))

# ---- Select DEMs ----

dem_sigmas = {
    'aerometric': 1.5,
    'ifsar': 1.5 + 0.5, # additional time uncertainty
    'arcticdem': 3,
    'tandem': 3 # after bulk corrections
}
dem_keys = [
    ('20040618', 'aerometric'),
    ('20040707', 'aerometric'),
Esempio n. 4
0
# ---- Prepare Observers ----

observerpath = ['stardot1', 'stardot2']
observers = []
for observer in observerpath:
    path = join(DATA_DIR, observer)
    campaths = glob.glob(join(path, "*.JSON"))
    images = [
        glimpse.Image(path=campath.replace(".JSON", ".jpg"), cam=campath)
        for campath in campaths
    ]
    print("Image set {} \n".format(len(images)))
    images.sort(key=lambda img: img.datetime)
    datetimes = np.array([img.datetime for img in images])
    for n, delta in enumerate(np.diff(datetimes)):
        if delta <= datetime.timedelta(seconds=0):
            secs = datetime.timedelta(seconds=n % 5 + 1)
            images[n + 1].datetime = images[n + 1].datetime + secs
    diffs = np.array([
        dt.total_seconds()
        for dt in np.diff(np.array([img.datetime for img in images]))
    ])
    negate = diffs[diffs <= 1].astype(np.int)
    [images.pop(_) for _ in negate]

    images = images[:int(len(images) / 2)]
    obs = glimpse.Observer(list(np.array(images)), cache=False)
    observers.append(obs)

observers[1].animate(interval=100).save("stardot2animation.mp4",
Esempio n. 5
0
vy[..., lmask] = lvy

# Plot
matplotlib.pyplot.figure()
# glimpse.Raster(np.sum(bad, axis=2), template.x, template.y).plot()
glimpse.Raster(np.sum(~np.isnan(vx), axis=2) > 1, template.x,
               template.y).plot()
# matplotlib.pyplot.colorbar()
matplotlib.pyplot.plot(cg.Glacier()[:, 0], cg.Glacier()[:, 1])

# ---- Compute weights ----
# Use sum of distances to neighbors
# Saturate at 0.5 years because of seasonal variability

dts = np.column_stack(
    (np.concatenate(([datetime.timedelta(0)], np.diff(datetimes))),
     np.concatenate(
         (np.diff(datetimes), [datetime.timedelta(0)])))).sum(axis=1)
weights = np.array([dt.total_seconds() / (3600 * 24 * 365) for dt in dts])
weights[weights > 0.5] = 0.5
# Lower weights for observations before 2004
dyears = np.array([
    dt.total_seconds() / (3600 * 24 * 365)
    for dt in datetime.datetime(2004, 6, 18) - datetimes
])
weights[dyears > 0] *= (1 - dyears[dyears > 0] / max(dyears))

# ---- Compute summary statistics (cartesian) ----

w = glimpse.helpers.tile_axis(weights, vx.shape, axis=(0, 1))
vx_mean = glimpse.helpers.weighted_nanmean(vx, weights=w, axis=2)