goesgcp 1.0.6__py3-none-any.whl → 1.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
goesgcp/main.py CHANGED
@@ -4,6 +4,7 @@ import xarray as xr
4
4
  import argparse
5
5
  import sys
6
6
  import tqdm
7
+ from distutils.util import strtobool
7
8
  from concurrent.futures import ThreadPoolExecutor
8
9
  from multiprocessing import Pool
9
10
  from google.cloud import storage
@@ -204,16 +205,16 @@ def main():
204
205
  parser.add_argument('--output', type=str, default='output/', help='Path for saving output files')
205
206
 
206
207
  # Other settings
207
- parser.add_argument('--parallel', type=bool, default=True, help='Use parallel processing')
208
+ parser.add_argument('--parallel', type=lambda x: bool(strtobool(x)), default=True, help='Use parallel processing')
208
209
  parser.add_argument('--processes', type=int, default=4, help='Number of processes for parallel execution')
209
210
  parser.add_argument('--max_attempts', type=int, default=3, help='Number of attempts to download a file')
210
211
 
211
212
  # Parse arguments
212
213
  args = parser.parse_args()
213
214
 
214
- if len(sys.argv) == 1:
215
- parser.print_help(sys.stderr)
216
- sys.exit(1)
215
+ # if len(sys.argv) == 1:
216
+ # parser.print_help(sys.stderr)
217
+ # sys.exit(1)
217
218
 
218
219
  # Set global variables
219
220
  output_path = args.output
@@ -265,26 +266,36 @@ def main():
265
266
  bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} + \
266
267
  [Elapsed:{elapsed} Remaining:<{remaining}]')
267
268
 
268
- # Download all files to a temporary directory
269
- with ThreadPoolExecutor(max_workers=args.processes) as executor:
269
+ if parallel:
270
+ # Download all files to a temporary directory
271
+ with ThreadPoolExecutor(max_workers=args.processes) as executor:
272
+ for file in recent_files:
273
+ local_path = f"tmp/{file.split('/')[-1]}"
274
+ executor.submit(download_file, (bucket_name, file, local_path))
275
+ loading_bar.update(1)
276
+ loading_bar.close()
277
+
278
+ # Process files
279
+ print(f"\nProcessing {len(recent_files)} files...")
280
+ load_bar2 = tqdm.tqdm(total=len(recent_files), ncols=100, position=0, leave=True,
281
+ bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} + \
282
+ [Elapsed:{elapsed} Remaining:<{remaining}]')
283
+
284
+
285
+ # Process files in parallel
286
+ with Pool(processes=args.processes) as pool:
287
+ for _ in pool.imap_unordered(crop_reproject, [(f"tmp/{file.split('/')[-1]}", output_path) for file in recent_files]):
288
+ load_bar2.update(1)
289
+ load_bar2.close()
290
+ else:
270
291
  for file in recent_files:
271
292
  local_path = f"tmp/{file.split('/')[-1]}"
272
- executor.submit(download_file, (bucket_name, file, local_path))
293
+ download_file((bucket_name, file, local_path))
294
+ crop_reproject((local_path, output_path))
273
295
  loading_bar.update(1)
274
- loading_bar.close()
296
+ loading_bar.close()
275
297
 
276
- # Process files
277
- print(f"\nProcessing {len(recent_files)} files...")
278
- load_bar2 = tqdm.tqdm(total=len(recent_files), ncols=100, position=0, leave=True,
279
- bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} + \
280
- [Elapsed:{elapsed} Remaining:<{remaining}]')
281
298
 
282
-
283
- # Process files in parallel
284
- with Pool(processes=args.processes) as pool:
285
- for _ in pool.imap_unordered(crop_reproject, [(f"tmp/{file.split('/')[-1]}", output_path) for file in recent_files]):
286
- load_bar2.update(1)
287
- load_bar2.close()
288
299
 
289
300
  # Remove temporary directory
290
301
  shutil.rmtree('tmp/')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: goesgcp
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: A package to download and process GOES-16/17 data
5
5
  Home-page: https://github.com/helvecioneto/goesgcp
6
6
  Author: Helvecio B. L. Neto
@@ -0,0 +1,8 @@
1
+ goesgcp/__init__.py,sha256=MigXIT7A1M9YZuH2MyjKReSziFwzbZX2boVYsLosR6s,22
2
+ goesgcp/main.py,sha256=zCrAfAjc9Vzs9-7klATCCp6hhe1w4tsu_FiMBuBAafc,10893
3
+ goesgcp-1.0.7.dist-info/LICENSE,sha256=AHeZifD4UyBZI61Ug5lETXgX3Anp_XfAvFXQqrW9AnU,1078
4
+ goesgcp-1.0.7.dist-info/METADATA,sha256=eXzz34_yexZ4zx4EmaDRrpwiHFoBtJBzJ_hnVLQD-4Q,2993
5
+ goesgcp-1.0.7.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
+ goesgcp-1.0.7.dist-info/entry_points.txt,sha256=6afMW51WnUR9VZ_xvDoiB8JQb2OFiLuzRtV6dPL__OQ,46
7
+ goesgcp-1.0.7.dist-info/top_level.txt,sha256=C-C3vipI0AwEDW9nWFkJ6D0TkcKkIYlyyM15LMskUEc,8
8
+ goesgcp-1.0.7.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- goesgcp/__init__.py,sha256=MigXIT7A1M9YZuH2MyjKReSziFwzbZX2boVYsLosR6s,22
2
- goesgcp/main.py,sha256=3cvmzeFyMh7smI3jkMnY0PUrird9i3lntkFt9c_xwZo,10462
3
- goesgcp-1.0.6.dist-info/LICENSE,sha256=AHeZifD4UyBZI61Ug5lETXgX3Anp_XfAvFXQqrW9AnU,1078
4
- goesgcp-1.0.6.dist-info/METADATA,sha256=-3huDGZYV4-ZFxmKQcU-1avXQJWPQW_RrIQ841XrlGI,2993
5
- goesgcp-1.0.6.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
- goesgcp-1.0.6.dist-info/entry_points.txt,sha256=6afMW51WnUR9VZ_xvDoiB8JQb2OFiLuzRtV6dPL__OQ,46
7
- goesgcp-1.0.6.dist-info/top_level.txt,sha256=C-C3vipI0AwEDW9nWFkJ6D0TkcKkIYlyyM15LMskUEc,8
8
- goesgcp-1.0.6.dist-info/RECORD,,