|
143 | 143 | "outputs": [],
|
144 | 144 | "source": [
|
145 | 145 | "# Read raster\n",
|
146 |
| - "single_glacier_raster = xr.open_zarr(\"../data/raster_data/single_glacier_itslive.zarr\", decode_coords=\"all\")\n", |
| 146 | + "single_glacier_raster = xr.open_zarr(\n", |
| 147 | + " \"../data/raster_data/single_glacier_itslive.zarr\", decode_coords=\"all\", chunks=None\n", |
| 148 | + ")\n", |
147 | 149 | "# Read vector\n",
|
148 | 150 | "single_glacier_vector = gpd.read_file(\"../data/vector_data/single_glacier_vec.json\")"
|
149 | 151 | ]
|
150 | 152 | },
|
151 | 153 | {
|
152 |
| - "cell_type": "code", |
153 |
| - "execution_count": null, |
| 154 | + "cell_type": "markdown", |
154 | 155 | "metadata": {},
|
155 |
| - "outputs": [], |
156 | 156 | "source": [
|
157 |
| - "# Take a look at raster data object\n", |
158 |
| - "single_glacier_raster" |
| 157 | + "We can also drop variables we won't be using:" |
159 | 158 | ]
|
160 | 159 | },
|
161 | 160 | {
|
|
164 | 163 | "metadata": {},
|
165 | 164 | "outputs": [],
|
166 | 165 | "source": [
|
167 |
| - "single_glacier_raster.nbytes / 1e9" |
| 166 | + "vars_to_keep = [\n", |
| 167 | + " \"v\",\n", |
| 168 | + " \"vx\",\n", |
| 169 | + " \"vy\",\n", |
| 170 | + " \"v_error\",\n", |
| 171 | + " \"vy_error\",\n", |
| 172 | + " \"vx_error\",\n", |
| 173 | + " \"acquisition_date_img1\",\n", |
| 174 | + " \"acquisition_date_img2\",\n", |
| 175 | + " \"satellite_img1\",\n", |
| 176 | + " \"satellite_img2\",\n", |
| 177 | + "]\n", |
| 178 | + "single_glacier_raster = single_glacier_raster[vars_to_keep]" |
168 | 179 | ]
|
169 | 180 | },
|
170 | 181 | {
|
|
173 | 184 | "metadata": {},
|
174 | 185 | "outputs": [],
|
175 | 186 | "source": [
|
176 |
| - "np.unique(single_glacier_raster.satellite_img1)" |
| 187 | + "# Take a look at raster data object\n", |
| 188 | + "single_glacier_raster" |
177 | 189 | ]
|
178 | 190 | },
|
179 | 191 | {
|
|
182 | 194 | "metadata": {},
|
183 | 195 | "outputs": [],
|
184 | 196 | "source": [
|
185 |
| - "np.unique(single_glacier_raster.satellite_img2)" |
| 197 | + "single_glacier_raster.nbytes / 1e9" |
186 | 198 | ]
|
187 | 199 | },
|
188 | 200 | {
|
189 |
| - "cell_type": "markdown", |
| 201 | + "cell_type": "code", |
| 202 | + "execution_count": null, |
190 | 203 | "metadata": {},
|
| 204 | + "outputs": [], |
191 | 205 | "source": [
|
192 |
| - "The above code cells show us that this dataset contains observations from Sentinel 1 & 2 and Landsat 4,5,6,7,8 & 9 satellite sensors. The dataset is 3.3 GB. \n", |
193 |
| - "\n", |
194 |
| - "Next, we want to perform computations that require us to load this object into memory. To do this, we use the [dask .compute()](https://docs.dask.org/en/stable/generated/dask.dataframe.DataFrame.compute.html) method, which turns a 'lazy' object into an in-memory object. If you try to run compute on too large of an object, your computer may run out of RAM and the kernel being used in this python session will die (if this happens, click 'restart kernel' from the kernel drop down menu above). " |
| 206 | + "np.unique(single_glacier_raster.satellite_img1)" |
195 | 207 | ]
|
196 | 208 | },
|
197 | 209 | {
|
|
200 | 212 | "metadata": {},
|
201 | 213 | "outputs": [],
|
202 | 214 | "source": [
|
203 |
| - "single_glacier_raster = single_glacier_raster.compute()" |
| 215 | + "np.unique(single_glacier_raster.satellite_img2)" |
204 | 216 | ]
|
205 | 217 | },
|
206 | 218 | {
|
207 | 219 | "cell_type": "markdown",
|
208 | 220 | "metadata": {},
|
209 | 221 | "source": [
|
210 |
| - "Now, if you expand the data object to look at the variables, you will see that they no long hold `dask.array` objects." |
| 222 | + "The above code cells show us that this dataset contains observations from Sentinel 1 & 2 and Landsat 4,5,6,7,8 & 9 satellite sensors. The dataset is 1.1 GB. " |
211 | 223 | ]
|
212 | 224 | },
|
213 | 225 | {
|
|
1326 | 1338 | "metadata": {
|
1327 | 1339 | "celltoolbar": "Tags",
|
1328 | 1340 | "kernelspec": {
|
1329 |
| - "display_name": "geospatial_datacube_book_env", |
| 1341 | + "display_name": "Python 3 (ipykernel)", |
1330 | 1342 | "language": "python",
|
1331 | 1343 | "name": "python3"
|
1332 | 1344 | },
|
|
0 commit comments