diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af637d..0fd0321 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,3 +8,5 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased](https://github.com/andrewplayer3/back_projection/compare/v0.0.0...develop) -- likely 0.0.1 +### Added +-- Added validation for gpu existance (defaults to cpu if none exists) diff --git a/back_projection/process.py b/back_projection/process.py index 7a3313c..f0c6068 100755 --- a/back_projection/process.py +++ b/back_projection/process.py @@ -4,6 +4,7 @@ import argparse import logging import os +import subprocess from pathlib import Path from zipfile import ZipFile @@ -30,9 +31,19 @@ def back_projection(granule: str, username: str, password: str, use_gpu: bool) - file.write(output_string) file.close() + gpu_exists = False + if use_gpu: + # grab gpu number, -1 if there isn't one + proc = subprocess.Popen(HOME+"/sentinel/bestgpu.sh", stdout=subprocess.PIPE, shell=True) + (bestGPU, err) = proc.communicate() + bestGPU = str(int(bestGPU.strip())) + print("GPU: ", bestGPU) + if bestGPU != "-1": + gpu_exists = True + # Run the back_projection through sentinel_cpu.py or sentinel_gpu.py VV run_backprojection = "" - if use_gpu: + if use_gpu and gpu_exists: print("RUNNING WITH GPU") print("----------------") run_backprojection = HOME + "/sentinel/sentinel_gpu.py" @@ -45,8 +56,8 @@ def back_projection(granule: str, username: str, password: str, use_gpu: bool) - print("Command: ", run_backprojection) ret = os.system(run_backprojection) - # Convert each gslc to a multiband tiff - # (band 1: complex, band 2: real, band 3: amplitude) + # create a amplitude tiff + # band 1: amplitude make_tiff = "python3 " + HOME + "/make_tiff.py " + granule + ".geo " make_tiff += "elevation.dem.rsc " + granule print(make_tiff + "_VV.tiff") @@ -60,8 +71,8 @@ def back_projection(granule: str, username: str, password: str, use_gpu: bool) - print("Command: ", run_backprojection) ret = os.system(run_backprojection) - # Convert each gslc to a multiband tiff - # (band 1: complex, band 2: real, band 3: amplitude) + # create amplitude tiff + # band 1: amplitude print(make_tiff + "_VH.tiff") ret = os.system(make_tiff + "_VH.tiff")