|
22 | 22 | "import h5py\n", |
23 | 23 | "import pyproj\n", |
24 | 24 | "\n", |
| 25 | + "# modules you'll need if you're downloading the data:\n", |
| 26 | + "from icepyx import icesat2data as ipd\n", |
| 27 | + "import shutil\n", |
| 28 | + "import geopandas as gpd\n", |
| 29 | + "\n", |
25 | 30 | "# run matplotlib in 'widget' mode\n", |
26 | 31 | "%matplotlib widget\n", |
27 | 32 | "%load_ext autoreload\n", |
28 | 33 | "%autoreload 2" |
29 | 34 | ] |
30 | 35 | }, |
| 36 | + { |
| 37 | + "cell_type": "code", |
| 38 | + "execution_count": null, |
| 39 | + "metadata": {}, |
| 40 | + "outputs": [], |
| 41 | + "source": [ |
| 42 | + "# Jessica's function for loading multiple data requests\n", |
| 43 | + "#define function to loop through series of requests to get data\n", |
| 44 | + "\n", |
| 45 | + "def multiple_is2_requests(earthdata_email, earthdata_uid, data_home, requests, subset, download):\n", |
| 46 | + " for req in requests:\n", |
| 47 | + " #### Download this data: (uncomment and run)\n", |
| 48 | + " region_a = ipd.Icesat2Data(req['short_name'], req['spatial_extent'], req['date_range'])\n", |
| 49 | + " if download==True:\n", |
| 50 | + " region_a.earthdata_login(earthdata_uid, earthdata_email)\n", |
| 51 | + " region_a.download_granules(data_home,subset=subset)\n", |
| 52 | + " print(region_a.dataset)\n", |
| 53 | + " print(region_a.dates)\n", |
| 54 | + " print(region_a.start_time)\n", |
| 55 | + " print(region_a.end_time)\n", |
| 56 | + " print(region_a.dataset_version)\n", |
| 57 | + " print(region_a.spatial_extent)\n", |
| 58 | + " region_a.visualize_spatial_extent()" |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "markdown", |
| 63 | + "metadata": {}, |
| 64 | + "source": [ |
| 65 | + "## A note on data\n", |
| 66 | + "Since the hackweek is over, you'll need to download some ATL03 and ATL06 yourself put it somewhere sensible. Mine is in /home/jovyan/tutorial-data, but you may need to edit this cell to match where your data ended up. The next cell contains the code to download the data from NSIDC. It takes a while to run, so if you run the cell this may be a good time to get a cup of coffee.\n" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": null, |
| 72 | + "metadata": {}, |
| 73 | + "outputs": [], |
| 74 | + "source": [ |
| 75 | + "earthdata_email='your email here'\n", |
| 76 | + "earthdata_name='your earthdata login'\n", |
| 77 | + "\n", |
| 78 | + "data_home='/home/jovyan/tutorial-data'\n", |
| 79 | + "#set DOWNLOAD to true if you're ready to download the data:\n", |
| 80 | + "download=True\n", |
| 81 | + "subset=True\n", |
| 82 | + " \n", |
| 83 | + "requests=[\n", |
| 84 | + " { 'short_name' : 'ATL06',\n", |
| 85 | + " 'spatial_extent' :[-102, -76, -98, -74.5],\n", |
| 86 | + " 'date_range' : ['2018-10-14','2020-04-01']},\n", |
| 87 | + " { 'short_name' :'ATL03',\n", |
| 88 | + " 'spatial_extent' :[-102, -76, -98, -74.5],\n", |
| 89 | + " 'date_range' : ['2018-10-14','2020-04-01']},\n", |
| 90 | + " { 'short_name' :'ATL03',\n", |
| 91 | + " 'spatial_extent' :[-102, -76, -98, -74.5],\n", |
| 92 | + " 'date_range' : ['2019-12-28', '2019-12-29']}]\n", |
| 93 | + "\n", |
| 94 | + "multiple_is2_requests(earthdata_email, earthdata_uid, data_home, requests, subset, download);\n" |
| 95 | + ] |
| 96 | + }, |
31 | 97 | { |
32 | 98 | "cell_type": "markdown", |
33 | 99 | "metadata": {}, |
|
82 | 148 | " import pointCollection as pc" |
83 | 149 | ] |
84 | 150 | }, |
85 | | - { |
86 | | - "cell_type": "code", |
87 | | - "execution_count": null, |
88 | | - "metadata": {}, |
89 | | - "outputs": [], |
90 | | - "source": [ |
91 | | - "!python3 -m pip install --user git+https://github.com/smithb/pointCollection.git" |
92 | | - ] |
93 | | - }, |
94 | 151 | { |
95 | 152 | "cell_type": "markdown", |
96 | 153 | "metadata": {}, |
|
114 | 171 | "metadata": {}, |
115 | 172 | "source": [ |
116 | 173 | "### 1.2.2 Data used\n", |
117 | | - "Data for this tutorial are stored in a shared drive, accessible to all tutorial participants. If you're getting data for yourself, you'll need to put it in a consistent place, and change this cell to match your directory." |
118 | | - ] |
119 | | - }, |
120 | | - { |
121 | | - "cell_type": "code", |
122 | | - "execution_count": 5, |
123 | | - "metadata": {}, |
124 | | - "outputs": [], |
125 | | - "source": [ |
126 | | - "data_root='/srv/tutorial-data/land_ice_applications/'" |
| 174 | + "In this tutorial, we'll use the ATL03 and ATL06 data that were downloaded in the top couple of cells. You'll have put them in the data_root directory specified in those cells, and we'll look for our mosaic background image in the same location." |
127 | 175 | ] |
128 | 176 | }, |
129 | 177 | { |
|
138 | 186 | "\n", |
139 | 187 | "https://daacdata.apps.nsidc.org/pub/DATASETS/nsidc0593_moa2009/geotiff/moa750_2009_hp1_v01.1.tif.gz\n", |
140 | 188 | "\n", |
141 | | - "[Note that if you've gotten your own version of the MOA from NSIDC, you'll need to change the path to the file later in the tutorial to match where you've stored it]" |
142 | | - ] |
143 | | - }, |
144 | | - { |
145 | | - "cell_type": "markdown", |
146 | | - "metadata": {}, |
147 | | - "source": [ |
148 | | - "#### ATL06 data\n", |
149 | | - "A set of data for the Pine Island Glacier are stored in the /PIG_ATL03 folder, under data-root folder on the Jupyter hub.\n", |
150 | | - "They cover a bounding box:\n", |
151 | | - "102 W to 98 W, 76 S to -75.4 S. " |
152 | | - ] |
153 | | - }, |
154 | | - { |
155 | | - "cell_type": "markdown", |
156 | | - "metadata": {}, |
157 | | - "source": [ |
158 | | - "#### ATL03 data\n", |
159 | | - "Two granules of ATL03 data from the same region are stored in the /PIG_ATL03 folder, under data-root folder on the Jupyter hub." |
160 | | - ] |
161 | | - }, |
162 | | - { |
163 | | - "cell_type": "markdown", |
164 | | - "metadata": {}, |
165 | | - "source": [ |
166 | | - "### If you need to run the request yourself\n", |
167 | | - "...then change the data_root variable above to somewhere on your machine, uncomment the contents of this cell, change the email and name to match your earthdata credentials, and run the cell.\n", |
168 | | - "\n", |
169 | | - "_These cells come from the data-access tutorial. Thanks to Jessica Scheick._" |
170 | | - ] |
171 | | - }, |
172 | | - { |
173 | | - "cell_type": "code", |
174 | | - "execution_count": 2, |
175 | | - "metadata": {}, |
176 | | - "outputs": [], |
177 | | - "source": [ |
178 | | - "from icepyx import icesat2data as ipd" |
179 | | - ] |
180 | | - }, |
181 | | - { |
182 | | - "cell_type": "code", |
183 | | - "execution_count": 17, |
184 | | - "metadata": {}, |
185 | | - "outputs": [], |
186 | | - "source": [ |
187 | | - "#define function to loop through series of requests to get data\n", |
188 | | - "\n", |
189 | | - "def multiple_is2_requests(earthdata_email, earthdata_uid, data_home, requests, subset, download, visualize=False):\n", |
190 | | - " for req in requests:\n", |
191 | | - " region_a = ipd.Icesat2Data(req['short_name'], req['spatial_extent'], req['date_range'])\n", |
192 | | - " if download==True:\n", |
193 | | - " region_a.earthdata_login(earthdata_uid, earthdata_email)\n", |
194 | | - " region_a.download_granules(data_home,subset=subset)\n", |
195 | | - " print(region_a.dataset)\n", |
196 | | - " print(region_a.dates)\n", |
197 | | - " print(region_a.start_time)\n", |
198 | | - " print(region_a.end_time)\n", |
199 | | - " print(region_a.dataset_version)\n", |
200 | | - " print(region_a.spatial_extent)\n", |
201 | | - " if visualize:\n", |
202 | | - " region_a.visualize_spatial_extent()" |
203 | | - ] |
204 | | - }, |
205 | | - { |
206 | | - "cell_type": "code", |
207 | | - "execution_count": 18, |
208 | | - "metadata": {}, |
209 | | - "outputs": [], |
210 | | - "source": [ |
211 | | - "earthdata_email='your email here'\n", |
212 | | - "earthdata_uid='your earthdata login'\n", |
213 | | - "\n", |
214 | | - "data_home=data_root\n", |
215 | | - "#set DOWNLOAD to true if you're ready to download the data:\n", |
216 | | - "download=False\n", |
217 | | - "subset=True\n", |
218 | | - " \n", |
219 | | - "requests=[\n", |
220 | | - " { 'short_name' : 'ATL06',\n", |
221 | | - " 'spatial_extent' :[-102, -76, -98, -74.5],\n", |
222 | | - " 'date_range' : ['2018-10-14','2020-04-01']},\n", |
223 | | - " { 'short_name' :'ATL03',\n", |
224 | | - " 'spatial_extent' :[-102, -76, -98, -74.5],\n", |
225 | | - " 'date_range' : ['2018-10-14','2020-04-01']},\n", |
226 | | - " { 'short_name' :'ATL03',\n", |
227 | | - " 'spatial_extent' :[-102, -76, -98, -74.5],\n", |
228 | | - " 'date_range' : ['2019-12-28', '2019-12-29']}]" |
229 | | - ] |
230 | | - }, |
231 | | - { |
232 | | - "cell_type": "code", |
233 | | - "execution_count": 16, |
234 | | - "metadata": {}, |
235 | | - "outputs": [ |
236 | | - { |
237 | | - "name": "stdout", |
238 | | - "output_type": "stream", |
239 | | - "text": [ |
240 | | - "ATL06\n", |
241 | | - "['2018-10-14', '2020-04-01']\n", |
242 | | - "00:00:00\n", |
243 | | - "23:59:59\n", |
244 | | - "003\n", |
245 | | - "['bounding box', [-102, -76, -98, -74.5]]\n", |
246 | | - "ATL03\n", |
247 | | - "['2018-10-14', '2020-04-01']\n", |
248 | | - "00:00:00\n", |
249 | | - "23:59:59\n", |
250 | | - "003\n", |
251 | | - "['bounding box', [-102, -76, -98, -74.5]]\n", |
252 | | - "ATL03\n", |
253 | | - "['2019-12-28', '2019-12-29']\n", |
254 | | - "00:00:00\n", |
255 | | - "23:59:59\n", |
256 | | - "003\n", |
257 | | - "['bounding box', [-102, -76, -98, -74.5]]\n" |
258 | | - ] |
259 | | - } |
260 | | - ], |
261 | | - "source": [ |
262 | | - "multiple_is2_requests(earthdata_email, earthdata_uid, data_home, requests, subset, download)" |
| 189 | + "Try downloading the linked file (you'll need to log in to Earthdata to get it), then put it in the data_root directory on your home machine." |
263 | 190 | ] |
264 | 191 | }, |
265 | 192 | { |
|
287 | 214 | "# get the bounds of the projected coordinates \n", |
288 | 215 | "XR=[np.nanmin(xy[0,:]), np.nanmax(xy[0,:])]\n", |
289 | 216 | "YR=[np.nanmin(xy[1,:]), np.nanmax(xy[1,:])]\n", |
| 217 | + "\n", |
| 218 | + "### EDIT THIS PATH TO THE MOA LOCATION IF YOU NEED TO\n", |
290 | 219 | "MOA=pc.grid.data().from_geotif(os.path.join(data_root, 'MOA','moa_2009_1km.tif'), bounds=[XR, YR])\n", |
291 | 220 | "\n", |
292 | 221 | "# show the mosaic:\n", |
|
0 commit comments