|
26 | 26 | "execution_count": null,
|
27 | 27 | "source": [
|
28 | 28 | "from sliderule import icesat2, ipysliderule, io\n",
|
29 |
| - "import time\n", |
30 | 29 | "import logging\n",
|
31 | 30 | "import numpy as np\n",
|
32 | 31 | "import matplotlib.pyplot as plt\n",
|
|
107 | 106 | "# sliderule asset and data release\n",
|
108 | 107 | "asset = SRwidgets.asset.value\n",
|
109 | 108 | "release = SRwidgets.release.value\n",
|
110 |
| - "# get sliderule submission time\n", |
111 |
| - "submission_time = time.strftime('%Y%m%d%H%M%S',time.gmtime())\n", |
112 | 109 | "\n",
|
113 | 110 | "# create an empty dataframe\n",
|
114 | 111 | "gdf = icesat2.__emptyframe()\n",
|
|
163 | 160 | "# output map of resource location\n",
|
164 | 161 | "f1, ax1 = plt.subplots(num=1, nrows=1, ncols=1, figsize=(10,6),\n",
|
165 | 162 | " subplot_kw=dict(projection=cartopy.crs.PlateCarree()))\n",
|
166 |
| - "ax1.plot(gdf.geometry.values.x,gdf.geometry.values.y,'r.',\n", |
| 163 | + "ax1.plot(gdf.geometry.x,gdf.geometry.y,'r.',\n", |
167 | 164 | " ms=1,transform=cartopy.crs.Geodetic())\n",
|
168 | 165 | "ax1.set_extent((-180,180,-90,90),crs=cartopy.crs.PlateCarree())\n",
|
169 | 166 | "# add coastlines with filled land and lakes\n",
|
|
182 | 179 | "f2, ax2 = plt.subplots(num=2, nrows=1, ncols=1, figsize=(10,6),\n",
|
183 | 180 | " subplot_kw=dict(projection=cartopy.crs.PlateCarree()))\n",
|
184 | 181 | "# create scatter plot of elevations\n",
|
185 |
| - "sc = ax2.scatter(gdf.geometry.values.x,gdf.geometry.values.y,\n", |
| 182 | + "sc = ax2.scatter(gdf.geometry.x,gdf.geometry.y,\n", |
186 | 183 | " c=gdf.h_mean,s=1,edgecolor='none',cmap=plt.cm.viridis,\n",
|
187 | 184 | " transform=cartopy.crs.PlateCarree())\n",
|
188 | 185 | "# extract latitude and longitude of polygon\n",
|
189 | 186 | "for poly in m.regions:\n",
|
190 |
| - " lon,lat = ipysliderule.coordinates(poly)\n", |
| 187 | + " lon,lat = io.from_region(poly)\n", |
191 | 188 | " ax2.plot(lon, lat, 'r', lw=1.5, transform=cartopy.crs.PlateCarree())\n",
|
192 | 189 | "# add coastlines with filled land and lakes\n",
|
193 | 190 | "ax2.add_feature(cartopy.feature.LAND, zorder=0, edgecolor='black')\n",
|
|
218 | 215 | {
|
219 | 216 | "cell_type": "markdown",
|
220 | 217 | "source": [
|
221 |
| - "#### Save GeoDataFrame to HDF5\n", |
222 |
| - "Outputs as a [pytables](https://www.pytables.org/) HDF5 which is easily read back as a Geopandas GeoDataFrame" |
| 218 | + "#### Save GeoDataFrame to output tile\n", |
| 219 | + "- [pytables HDF5](https://www.pytables.org/): easily read back as a Geopandas GeoDataFrame\n", |
| 220 | + "- [netCDF](https://www.unidata.ucar.edu/software/netcdf): interoperable with other programs" |
223 | 221 | ],
|
224 | 222 | "metadata": {}
|
225 | 223 | },
|
226 | 224 | {
|
227 | 225 | "cell_type": "code",
|
228 | 226 | "execution_count": null,
|
229 | 227 | "source": [
|
230 |
| - "args = (submission_time,release)\n", |
231 |
| - "io.to_file(gdf,\"ATL06-SR_{0}_{1}.h5\".format(*args),\n", |
232 |
| - " format='hdf', parameters=parms, regions=m.regions, verbose=True)" |
| 228 | + "display(SRwidgets.filesaver)" |
| 229 | + ], |
| 230 | + "outputs": [], |
| 231 | + "metadata": {} |
| 232 | + }, |
| 233 | + { |
| 234 | + "cell_type": "code", |
| 235 | + "execution_count": null, |
| 236 | + "source": [ |
| 237 | + "# append sliderule api version to attributes\n", |
| 238 | + "version = icesat2.get_version()\n", |
| 239 | + "parms['version'] = version['icesat2']['version']\n", |
| 240 | + "parms['commit'] = version['icesat2']['commit']\n", |
| 241 | + "# save to file in format (HDF5 or netCDF)\n", |
| 242 | + "io.to_file(gdf, SRwidgets.file,\n", |
| 243 | + " format=SRwidgets.format,\n", |
| 244 | + " driver='pytables',\n", |
| 245 | + " parameters=parms,\n", |
| 246 | + " regions=m.regions,\n", |
| 247 | + " verbose=True)" |
233 | 248 | ],
|
234 | 249 | "outputs": [],
|
235 | 250 | "metadata": {}
|
236 | 251 | },
|
237 | 252 | {
|
238 | 253 | "cell_type": "markdown",
|
239 | 254 | "source": [
|
240 |
| - "#### Read GeoDataFrame from HDF5\n", |
241 |
| - "Read the HDF5 back as a Geopandas GeoDataFrame for later use" |
| 255 | + "#### Read GeoDataFrame from input file\n", |
| 256 | + "- [pytables HDF5](https://www.pytables.org/)\n", |
| 257 | + "- [netCDF](https://www.unidata.ucar.edu/software/netcdf)" |
242 | 258 | ],
|
243 | 259 | "metadata": {}
|
244 | 260 | },
|
245 | 261 | {
|
246 | 262 | "cell_type": "code",
|
247 | 263 | "execution_count": null,
|
248 | 264 | "source": [
|
249 |
| - "args = (submission_time,release)\n", |
250 |
| - "gdf = io.from_file(\"ATL06-SR_{0}_{1}.h5\".format(*args),format='hdf')" |
| 265 | + "display(SRwidgets.fileloader)" |
| 266 | + ], |
| 267 | + "outputs": [], |
| 268 | + "metadata": {} |
| 269 | + }, |
| 270 | + { |
| 271 | + "cell_type": "code", |
| 272 | + "execution_count": null, |
| 273 | + "source": [ |
| 274 | + "# read from file in format (HDF5 or netCDF)\n", |
| 275 | + "gdf = io.from_file(SRwidgets.file,\n", |
| 276 | + " format=SRwidgets.format,\n", |
| 277 | + " driver='pytables')" |
251 | 278 | ],
|
252 | 279 | "outputs": [],
|
253 | 280 | "metadata": {}
|
|
0 commit comments