<jupyter_start><jupyter_text>Velocity Data Download Script for Validation Working Script to pull large velocity datasets and later compare to ICESAT2-derived velocitiesICESat-2 hackweek  June 15, 2020  <NAME>  Import necessary modules<jupyter_code>import os
import requests
import zipfile
import numpy as np
import pandas as pd
import geopandas as gpd
import pyproj
import scipy, sys, os, pyproj, glob
import matplotlib.pyplot as plt
from shapely.geometry import Point, Polygon
# run matplotlib in 'widget' mode
%matplotlib widget
%load_ext autoreload
%autoreload 2
#! cd ..; [ -d pointCollection ] || git clone https://www.github.com/smithB/pointCollection.git
sys.path.append(os.path.join(os.getcwd(), '..'))

#!python3 -m pip install --user git+https://github.com/tsutterley/pointCollection.git@pip
import pointCollection as pc
#stuck here, not sure how to import point collection 

#Magic function to enable interactive plotting (zoom/pan) in Jupyter notebook
#If running locally, this would be `%matplotlib notebook`, but since we're using Juptyerlab, we use widget
%matplotlib widget
#%matplotlib inline
#Set up directories and spatial extent
data_root='/srv/shared/surface_velocity/'
#spatial_extent = np.array([-102, -76, -98, -74.5])
spatial_extent = np.array([-65, -86, -55, -81])
lat=spatial_extent[[1, 3, 3, 1, 1]]
lon=spatial_extent[[2, 2, 0, 0, 2]]
print(lat)
print(lon)
# project the coordinates to Antarctic polar stereographic
xy=np.array(pyproj.Proj(3031)(lon, lat))
# get the bounds of the projected coordinates 
XR=[np.nanmin(xy[0,:]), np.nanmax(xy[0,:])]
YR=[np.nanmin(xy[1,:]), np.nanmax(xy[1,:])]
#Load Data
Measures_vel=pc.grid.data().from_geotif(os.path.join(data_root,'FIS_Velocity','Measures2_FIS_Vel.tif'), bounds=[XR, YR])
Measures_vx=pc.grid.data().from_geotif(os.path.join(data_root,'FIS_Velocity','Measures2_FIS_Vx.tif'), bounds=[XR, YR])
Measures_vy=pc.grid.data().from_geotif(os.path.join(data_root,'FIS_Velocity','Measures2_FIS_Vy.tif'), bounds=[XR, YR])


# show the velocity map:
plt.figure()
Measures_vel.show(cmap='viridis', clim=[0, 1000])
plt.plot(xy[0,:], xy[1,:])
plt.title('Measures2 Velocity Map')<jupyter_output>[-86 -81 -81 -86 -86]
[-55 -55 -65 -65 -55]
{'fraction_non_alphanumeric': 0.14402544298046344, 'fraction_numerical': 0.03498409813721036, 'mean_word_length': 5.9904761904761905, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '262147', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 868, 'n_tokens_neox': 797, 'n_words': 210, 'path': 'contributors/rodrigo_gomez/Test_lynn.ipynb', 'repo_name': 'tedmaksym/surface_velocity', 'size': '2211'}