Skip to content

Commit 1ce0725

Browse files
committed
Modify to use unity-py for reading stage in input collection file.
1 parent 62675be commit 1ce0725

File tree

3 files changed

+29
-45
lines changed

3 files changed

+29
-45
lines changed

process.ipynb

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,27 @@
33
{
44
"cell_type": "code",
55
"execution_count": 1,
6-
"id": "075fe5a0",
7-
"metadata": {},
8-
"outputs": [],
9-
"source": [
10-
"import os\n",
11-
"from datetime import datetime \n",
12-
"from datetime import timezone"
13-
]
14-
},
15-
{
16-
"cell_type": "code",
17-
"execution_count": 2,
186
"id": "1251c9f4",
197
"metadata": {},
208
"outputs": [],
219
"source": [
10+
"# Application packages\n",
2211
"from tabulate import tabulate\n",
2312
"import netCDF4\n",
13+
"\n",
14+
"# stage_in packages\n",
15+
"from unity_py.resources.collection import Collection\n",
16+
"\n",
17+
"# stage_out packages\n",
18+
"import os\n",
19+
"import json\n",
20+
"from datetime import datetime, timezone\n",
2421
"from pystac import ItemCollection, Item, Asset"
2522
]
2623
},
2724
{
2825
"cell_type": "code",
29-
"execution_count": 3,
26+
"execution_count": 2,
3027
"id": "04ac7f2d",
3128
"metadata": {
3229
"tags": [
@@ -41,7 +38,7 @@
4138
"# Filename written to the working directory\n",
4239
"summary_table_filename = \"summary_table.txt\"\n",
4340
"\n",
44-
"# Examples of arbitrary arguments of different data types\n",
41+
"# Examples of optional arbitrary arguments of different data types\n",
4542
"example_argument_int = 1\n",
4643
"example_argument_float = 1.0\n",
4744
"example_argument_string = \"string\"\n",
@@ -61,7 +58,7 @@
6158
},
6259
{
6360
"cell_type": "code",
64-
"execution_count": 4,
61+
"execution_count": 3,
6562
"id": "2eeaa5d4",
6663
"metadata": {},
6764
"outputs": [
@@ -85,7 +82,7 @@
8582
"'<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>&lt;class &#x27;int&#x27;&gt; </td><td>1 </td></tr>\\n<tr><td>example_argument_float </td><td>&lt;class &#x27;float&#x27;&gt; </td><td>1.0 </td></tr>\\n<tr><td>example_argument_string</td><td>&lt;class &#x27;str&#x27;&gt; </td><td>string </td></tr>\\n<tr><td>example_argument_bool </td><td>&lt;class &#x27;bool&#x27;&gt; </td><td>True </td></tr>\\n<tr><td>example_argument_empty </td><td>&lt;class &#x27;NoneType&#x27;&gt;</td><td> </td></tr>\\n</tbody>\\n</table>'"
8683
]
8784
},
88-
"execution_count": 4,
85+
"execution_count": 3,
8986
"metadata": {},
9087
"output_type": "execute_result"
9188
}
@@ -120,29 +117,13 @@
120117
},
121118
{
122119
"cell_type": "code",
123-
"execution_count": 5,
120+
"execution_count": 4,
124121
"id": "3a09d57c",
125122
"metadata": {},
126123
"outputs": [],
127124
"source": [
128-
"import json\n",
129-
"\n",
130-
"with open(input_stac_collection, \"r\") as collection_file:\n",
131-
" collection = ItemCollection.from_dict(json.load(collection_file))"
132-
]
133-
},
134-
{
135-
"cell_type": "code",
136-
"execution_count": 6,
137-
"id": "72b03749",
138-
"metadata": {},
139-
"outputs": [],
140-
"source": [
141-
"data_filenames = []\n",
142-
"for item in collection.items:\n",
143-
" for asset_key in item.assets:\n",
144-
" asset = item.assets[asset_key]\n",
145-
" data_filenames.append(asset.href)"
125+
"inp_collection = Collection.from_stac(input_stac_collection)\n",
126+
"data_filenames = inp_collection.data_locations()"
146127
]
147128
},
148129
{
@@ -157,7 +138,7 @@
157138
},
158139
{
159140
"cell_type": "code",
160-
"execution_count": 7,
141+
"execution_count": 5,
161142
"id": "9fbac209",
162143
"metadata": {},
163144
"outputs": [],
@@ -177,7 +158,7 @@
177158
},
178159
{
179160
"cell_type": "code",
180-
"execution_count": 8,
161+
"execution_count": 6,
181162
"id": "d22c8670",
182163
"metadata": {},
183164
"outputs": [],
@@ -194,7 +175,7 @@
194175
},
195176
{
196177
"cell_type": "code",
197-
"execution_count": 9,
178+
"execution_count": 7,
198179
"id": "3344bd15",
199180
"metadata": {},
200181
"outputs": [
@@ -215,22 +196,24 @@
215196
"'<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>'"
216197
]
217198
},
218-
"execution_count": 9,
199+
"execution_count": 7,
219200
"metadata": {},
220201
"output_type": "execute_result"
221202
}
222203
],
223204
"source": [
205+
"# Output the table in html format\n",
224206
"tabulate(table_data, headers=column_names, tablefmt='html')"
225207
]
226208
},
227209
{
228210
"cell_type": "code",
229-
"execution_count": 10,
211+
"execution_count": 8,
230212
"id": "014257f3",
231213
"metadata": {},
232214
"outputs": [],
233215
"source": [
216+
"# Write the table in text format\n",
234217
"with open(summary_table_filename, \"w\") as summary_file:\n",
235218
" summary_file.write(tabulate(table_data, headers=column_names))"
236219
]
@@ -245,8 +228,8 @@
245228
},
246229
{
247230
"cell_type": "code",
248-
"execution_count": 11,
249-
"id": "b48d4ffd",
231+
"execution_count": 9,
232+
"id": "1029f88c",
250233
"metadata": {},
251234
"outputs": [],
252235
"source": [
@@ -272,8 +255,8 @@
272255
},
273256
{
274257
"cell_type": "code",
275-
"execution_count": 12,
276-
"id": "f63f5499",
258+
"execution_count": 10,
259+
"id": "504c9271",
277260
"metadata": {},
278261
"outputs": [],
279262
"source": [

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
papermill
2-
pystac
2+
git+https://github.com/unity-sds/unity-py.git@develop
33
netCDF4
44
tabulate

runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.9

0 commit comments

Comments
 (0)