Skip to content

Commit

Permalink
Merge remote-tracking branch 'other/standard-product' into standard-p…
Browse files Browse the repository at this point in the history
…roduct
  • Loading branch information
shitong01 committed May 13, 2019
2 parents 929d29b + e1ddc2e commit 8066d62
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions conf/dataset_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"S1-IW_SLC_SWATH": "v1.1",
"S1-IFG": "v2.0.0",
"S1-IFG-STITCHED": "v2.0.0",
"S1-GUNW": "v2.0.1",
"S1-GUNW-MERGED": "v2.0.0",
"S1-GUNW": "v2.0.2",
"S1-GUNW-MERGED": "v2.0.2",
"S1-GUNW-MERGED-STITCHED": "v2.0.0",
"S1-VALIDATED_IFG_STACK": "v1.0",
"S1-VALIDATED_TS_STACK": "v1.0",
Expand Down
22 changes: 14 additions & 8 deletions interferogram/sentinel/create_standard_product_s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ def check_ifg_status(ifg_id):
logger.info("check_slc_status : returning False")
return False

def get_dataset_by_hash(ifg_hash):
def get_dataset_by_hash(ifg_hash, es_index="grq"):
"""Query for existence of dataset by ID."""

uu = UrlUtils()
es_url = uu.rest_url
#es_index = "{}_{}_s1-ifg".format(uu.grq_index_prefix, version)
es_index = "grq"

# query
query = {
"query":{
"bool":{
"must":[
{ "term":{"metadata.full_id_hash.raw": ifg_hash} },
{ "term":{"dataset.raw": "S1-GUNW"} }
]
}
}
Expand Down Expand Up @@ -151,7 +151,8 @@ def get_dataset_by_hash(ifg_hash):


def check_ifg_status_by_hash(new_ifg_hash):
result = get_dataset_by_hash(new_ifg_hash)
es_index="grq_*_s1-gunw"
result = get_dataset_by_hash(new_ifg_hash, es_index)
total = result['hits']['total']
logger.info("check_slc_status_by_hash : total : %s" %total)
if total>0:
Expand Down Expand Up @@ -992,11 +993,11 @@ def main():
if dem_type == "NED13-downsampled": downsample_option = "-d 33%"
else: downsample_option = ""

dem_S = dem_S - 4 if dem_S > -86 else dem_S
dem_N = dem_N + 4 if dem_N < 86 else dem_N
dem_W = dem_W - 4 if dem_W > -176 else dem_W
dem_E = dem_E + 4 if dem_E < 176 else dem_E

dem_S = dem_S - 1 if dem_S > -89 else dem_S
dem_N = dem_N + 1 if dem_N < 89 else dem_N
dem_W = dem_W - 1 if dem_W > -179 else dem_W
dem_E = dem_E + 1 if dem_E < 179 else dem_E
'''
dem_S, dem_N, dem_W, dem_E = bbox
dem_S = int(math.floor(dem_S))
Expand Down Expand Up @@ -1617,11 +1618,16 @@ def main():


#copy files to merged directory
pickle_dir = "{}/PICKLE".format(prod_dir)
fine_interferogram_xml = "fine_interferogram/IW1.xml"

met_file_merged = os.path.join(prod_dir_merged, "{}.met.json".format(ifg_id_merged))
ds_file_merged = os.path.join(prod_dir_merged, "{}.dataset.json".format(ifg_id_merged))
shutil.copy(ds_file, ds_file_merged)
shutil.copy(met_file, met_file_merged)
shutil.copytree("merged", os.path.join(prod_dir_merged, "merged"))
shutil.copytree("PICKLE", os.path.join(prod_dir_merged, "PICKLE"))
shutil.copy(fine_interferogram_xml, os.path.join(prod_dir_merged, "fine_interferogram.xml"))
#shutil.copytree(tiles_dir, os.path.join(prod_dir_merged, "tiles"))

#logger.info( json.dump(md, f, indent=2))
Expand Down
8 changes: 4 additions & 4 deletions interferogram/sentinel/ned_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def download(url_list, username, password):
return dem_files


def stitch(dem_files, downsample=None):
def stitch(bbox, dem_files, downsample=None):
"""Stitch NED1/NED13 dems."""

# unzip dem zip files
Expand All @@ -219,8 +219,8 @@ def stitch(dem_files, downsample=None):
check_call("gdalbuildvrt combinedDEM.vrt *.hgt", shell=True)
if downsample is None: outsize_opt = ""
else: outsize_opt = "-outsize {} {}".format(downsample, downsample)
check_call("gdal_translate -of ENVI {} combinedDEM.vrt stitched.dem".format(outsize_opt), shell=True)

#check_call("gdal_translate -of ENVI {} -projwin {} {} {} {} combinedDEM.vrt stitched.dem".format(outsize_opt, bbox[2], bbox[0], bbox[3], bbox[1]), shell=True)
check_call("gdalwarp combinedDEM.vrt -te {} {} {} {} -of ENVI {} stitched.dem".format( bbox[2], bbox[0], bbox[3], bbox[1], outsize_opt), shell=True)
#updte data to fill extream values with default value(-32768). First create a new dem file with the update
#check_call('gdal_calc.py -A stitched.dem --outfile=stitched_new.dem --calc="-32768*(A<-32768)+A*(A>=-32768)"', shell=True)
check_call('gdal_calc.py --format=ENVI -A stitched.dem --outfile=stitchedFix.dem --calc="A*(A>-1000)" --NoDataValue=0', shell=True)
Expand Down Expand Up @@ -290,7 +290,7 @@ def main(url_base, username, password, action, bbox, downsample):

# stitch
if action == 'stitch':
stitched_dem = stitch(dem_files, downsample)
stitched_dem = stitch(bbox, dem_files, downsample)
logger.info("stitched_dem: {}".format(stitched_dem))


Expand Down

0 comments on commit 8066d62

Please sign in to comment.