|
32 | 32 | "\n",
|
33 | 33 | "The below cell is tagged as a 'paramter' cell. This enables us to overwrite the below values at runtime. There are some special values in the below cell.\n",
|
34 | 34 | "\n",
|
35 |
| - "* `input` is a special name, and it also has the `# type: stage-in` annotation. This should be a directory, and at run time it will be populated with a STAC catalog that contains files that have been staged for your algorithm to reference.\n", |
36 |
| - "* `output` is a special name, and it also has the `# type: stage-out` annotation. This should be treated as a directory to which you write ALL of your output files along with a STAC catalog that references files you would like to persist outside of the algorithm run." |
| 35 | + "* `input_stac_catalog_dir` has the `# type: stage-in` annotation. This variable tells your algorithm the name of the directory where to read inputs from. At run time it will be populated with a STAC catalog and the files it references. The application generator process will connect your variable name to the special `input` parameter in automatically generated CWL files.\n", |
| 36 | + "* `output_stac_catalog_dir` has the `# type: stage-out` annotation. This is a directory where you write ALL of your output files along with a STAC catalog that references files you would like to persist outside of the algorithm run. The application generator process will connect your variable name to the special `output` parameter in automatically generated CWL files." |
37 | 37 | ]
|
38 | 38 | },
|
39 | 39 | {
|
|
51 | 51 | },
|
52 | 52 | "outputs": [],
|
53 | 53 | "source": [
|
54 |
| - "input = 'test/stage_in/' # type: stage-in\n", |
55 |
| - "output = 'test/process_results/' # type: stage-out\n", |
| 54 | + "input_stac_catalog_dir = 'test/stage_in/' # type: stage-in\n", |
| 55 | + "output_stac_catalog_dir = 'test/process_results/' # type: stage-out\n", |
56 | 56 | "\n",
|
57 | 57 | "# Filename written to the working directory\n",
|
58 | 58 | "summary_table_filename = \"summary_table.txt\"\n",
|
|
70 | 70 | },
|
71 | 71 | {
|
72 | 72 | "cell_type": "code",
|
73 |
| - "execution_count": 8, |
| 73 | + "execution_count": 3, |
74 | 74 | "id": "62471f5d-d898-46c1-89c1-b572851db551",
|
75 | 75 | "metadata": {},
|
76 | 76 | "outputs": [
|
|
83 | 83 | }
|
84 | 84 | ],
|
85 | 85 | "source": [
|
86 |
| - "input_catalog = os.path.join(input, \"catalog.json\")\n", |
| 86 | + "input_catalog = os.path.join(input_stac_catalog_dir, \"catalog.json\")\n", |
87 | 87 | "print(\"reading {}\".format(input_catalog))"
|
88 | 88 | ]
|
89 | 89 | },
|
|
99 | 99 | },
|
100 | 100 | {
|
101 | 101 | "cell_type": "code",
|
102 |
| - "execution_count": 10, |
| 102 | + "execution_count": 4, |
103 | 103 | "id": "2eeaa5d4",
|
104 | 104 | "metadata": {},
|
105 | 105 | "outputs": [
|
|
123 | 123 | "'<table>\\n<thead>\\n<tr><th>argument_name </th><th>type </th><th>value </th></tr>\\n</thead>\\n<tbody>\\n<tr><td>example_argument_int </td><td><class 'int'> </td><td>1 </td></tr>\\n<tr><td>example_argument_float </td><td><class 'float'> </td><td>1.0 </td></tr>\\n<tr><td>example_argument_string</td><td><class 'str'> </td><td>string </td></tr>\\n<tr><td>example_argument_bool </td><td><class 'bool'> </td><td>True </td></tr>\\n<tr><td>example_argument_empty </td><td><class 'NoneType'></td><td> </td></tr>\\n</tbody>\\n</table>'"
|
124 | 124 | ]
|
125 | 125 | },
|
126 |
| - "execution_count": 10, |
| 126 | + "execution_count": 4, |
127 | 127 | "metadata": {},
|
128 | 128 | "output_type": "execute_result"
|
129 | 129 | }
|
|
158 | 158 | },
|
159 | 159 | {
|
160 | 160 | "cell_type": "code",
|
161 |
| - "execution_count": 11, |
| 161 | + "execution_count": 5, |
162 | 162 | "id": "3a09d57c",
|
163 | 163 | "metadata": {},
|
164 | 164 | "outputs": [
|
165 | 165 | {
|
166 | 166 | "data": {
|
167 | 167 | "text/plain": [
|
168 |
| - "['/Users/gangl/dev/unity/unity-OGC-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n", |
169 |
| - " '/Users/gangl/dev/unity/unity-OGC-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']" |
| 168 | + "['test/stage_in/SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n", |
| 169 | + " 'test/stage_in/SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']" |
170 | 170 | ]
|
171 | 171 | },
|
172 |
| - "execution_count": 11, |
| 172 | + "execution_count": 5, |
173 | 173 | "metadata": {},
|
174 | 174 | "output_type": "execute_result"
|
175 | 175 | }
|
|
178 | 178 | "inp_collection = Collection.from_stac(input_catalog)\n",
|
179 | 179 | "data_filenames = inp_collection.data_locations()\n",
|
180 | 180 | "\n",
|
181 |
| - "data_filenames" |
| 181 | + "# Scrub base part of path so it is not displayed in Github with a home directory prefix\n", |
| 182 | + "[ os.path.relpath(fn, os.curdir) for fn in data_filenames ]" |
182 | 183 | ]
|
183 | 184 | },
|
184 | 185 | {
|
|
193 | 194 | },
|
194 | 195 | {
|
195 | 196 | "cell_type": "code",
|
196 |
| - "execution_count": 12, |
| 197 | + "execution_count": 6, |
197 | 198 | "id": "9fbac209",
|
198 | 199 | "metadata": {},
|
199 | 200 | "outputs": [],
|
|
213 | 214 | },
|
214 | 215 | {
|
215 | 216 | "cell_type": "code",
|
216 |
| - "execution_count": 13, |
| 217 | + "execution_count": 7, |
217 | 218 | "id": "d22c8670",
|
218 | 219 | "metadata": {},
|
219 | 220 | "outputs": [],
|
|
230 | 231 | },
|
231 | 232 | {
|
232 | 233 | "cell_type": "code",
|
233 |
| - "execution_count": 14, |
| 234 | + "execution_count": 8, |
234 | 235 | "id": "3344bd15",
|
235 | 236 | "metadata": {},
|
236 | 237 | "outputs": [
|
|
251 | 252 | "'<table>\\n<thead>\\n<tr><th>product_name </th><th>product_name_type_id </th><th>shortname </th><th>product_version </th><th>date_created </th><th>time_coverage_start </th><th>time_coverage_end </th><th style=\"text-align: right;\"> geospatial_lat_mid</th><th style=\"text-align: right;\"> geospatial_lon_mid</th></tr>\\n</thead>\\n<tbody>\\n<tr><td>SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc</td><td>L1_AQ </td><td>SNDR13CHRP1</td><td>v02.48.00 </td><td>2021-04-25T05:59:08Z</td><td>2016-08-22T00:05:22Z </td><td>2016-08-22T00:11:22Z</td><td style=\"text-align: right;\"> -48.6062</td><td style=\"text-align: right;\"> 12.4563 </td></tr>\\n<tr><td>SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc</td><td>L1_AQ </td><td>SNDR13CHRP1</td><td>v02.48.00 </td><td>2021-04-25T05:59:19Z</td><td>2016-08-22T00:11:22Z </td><td>2016-08-22T00:17:22Z</td><td style=\"text-align: right;\"> -69.3979</td><td style=\"text-align: right;\"> -1.98753</td></tr>\\n</tbody>\\n</table>'"
|
252 | 253 | ]
|
253 | 254 | },
|
254 |
| - "execution_count": 14, |
| 255 | + "execution_count": 8, |
255 | 256 | "metadata": {},
|
256 | 257 | "output_type": "execute_result"
|
257 | 258 | }
|
|
263 | 264 | },
|
264 | 265 | {
|
265 | 266 | "cell_type": "code",
|
266 |
| - "execution_count": 16, |
| 267 | + "execution_count": 9, |
267 | 268 | "id": "014257f3",
|
268 | 269 | "metadata": {},
|
269 | 270 | "outputs": [],
|
270 | 271 | "source": [
|
271 | 272 | "# Write the table in text format\n",
|
272 |
| - "pathlib.Path(output).mkdir(parents=True, exist_ok=True)\n", |
273 |
| - "output_filename = os.path.join(output, summary_table_filename)\n", |
| 273 | + "pathlib.Path(output_stac_catalog_dir).mkdir(parents=True, exist_ok=True)\n", |
| 274 | + "output_filename = os.path.join(output_stac_catalog_dir, summary_table_filename)\n", |
274 | 275 | "with open(output_filename, \"w\") as summary_file:\n",
|
275 | 276 | " summary_file.write(tabulate(table_data, headers=column_names))"
|
276 | 277 | ]
|
|
285 | 286 | },
|
286 | 287 | {
|
287 | 288 | "cell_type": "code",
|
288 |
| - "execution_count": 18, |
| 289 | + "execution_count": 10, |
289 | 290 | "id": "b4aa5d3b",
|
290 | 291 | "metadata": {
|
291 | 292 | "editable": true,
|
|
303 | 304 | "dataset = Dataset(\n",
|
304 | 305 | " name=summary_table_filename, \n",
|
305 | 306 | " collection_id=out_collection.collection_id, \n",
|
306 |
| - " start_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(), \n", |
307 |
| - " end_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(),\n", |
308 |
| - " creation_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(),\n", |
| 307 | + " start_time=datetime.now(timezone.utc).isoformat(), \n", |
| 308 | + " end_time=datetime.now(timezone.utc).isoformat(),\n", |
| 309 | + " creation_time=datetime.now(timezone.utc).isoformat(),\n", |
309 | 310 | ")\n",
|
310 | 311 | "\n",
|
311 | 312 | "# Add output file(s) to the dataset\n",
|
312 | 313 | "dataset.add_data_file(DataFile(\"csv\", summary_table_filename, [\"data\"]))\n",
|
313 | 314 | "\n",
|
314 | 315 | "#when we run \"to_stac\" below, this file will be generated. this needs to be added to the stac file itself for future reference.\n",
|
315 |
| - "dataset.add_data_file(DataFile(\"json\", output + \"/\" + summary_table_filename +'.json', [\"metadata\"] ))\n", |
| 316 | + "dataset.add_data_file(DataFile(\"json\", os.path.join(output_stac_catalog_dir, summary_table_filename + '.json'), [\"metadata\"] ))\n", |
316 | 317 | "\n",
|
317 | 318 | "\n",
|
318 | 319 | "# Add the dataset to the collection\n",
|
319 | 320 | "#out_collection.add_dataset(dataset)\n",
|
320 | 321 | "out_collection._datasets.append(dataset)\n",
|
321 | 322 | "\n",
|
322 |
| - "Collection.to_stac(out_collection, output)" |
| 323 | + "Collection.to_stac(out_collection, output_stac_catalog_dir)" |
323 | 324 | ]
|
324 |
| - }, |
325 |
| - { |
326 |
| - "cell_type": "code", |
327 |
| - "execution_count": null, |
328 |
| - "id": "14f240b6-b5ea-4bf8-8764-ecf12eee6c16", |
329 |
| - "metadata": {}, |
330 |
| - "outputs": [], |
331 |
| - "source": [] |
332 | 325 | }
|
333 | 326 | ],
|
334 | 327 | "metadata": {
|
335 | 328 | "celltoolbar": "Tags",
|
336 | 329 | "kernelspec": {
|
337 |
| - "display_name": "Python 3 (ipykernel)", |
| 330 | + "display_name": "Python 3", |
338 | 331 | "language": "python",
|
339 | 332 | "name": "python3"
|
340 | 333 | },
|
|
348 | 341 | "name": "python",
|
349 | 342 | "nbconvert_exporter": "python",
|
350 | 343 | "pygments_lexer": "ipython3",
|
351 |
| - "version": "3.10.8" |
| 344 | + "version": "3.12.4" |
352 | 345 | }
|
353 | 346 | },
|
354 | 347 | "nbformat": 4,
|
|
0 commit comments