Unverified Commit 9b479f93 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

findfeaturessegment fixes (#5439)

* findfeaturessegment fixes

* updated changlog

* cleaned up some logging
parent 2e8de637
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ release.
- Fixed <i>noproj</i> bug where missing shapemodel-related keywords (RayTraceEngine, BulletParts, Tolerance) are dropped when the output label is created. This resulted in the Bullet collision detection engine not being used. Issue: [#5377](https://github.com/USGS-Astrogeology/ISIS3/issues/5377)
- Fixed ISIS failing to expand env variables with an "_" in them. [#5402](https://github.com/DOI-USGS/ISIS3/pull/5402)
- Fixed <i>noproj</i> bug where match cube not NULL when not specifying MATCH parameter [#5381](https://github.com/USGS-Astrogeology/ISIS3/issues/5381)
- Fixed findFeaturesSegment trying to merge networks when only 1 segmented network was successfully created [5416](https://github.com/DOI-USGS/ISIS3/issues/5416)

### Added
- Added 8 new functions to the Sensor Utility Library: Slant Distance, Target Center Distance, Right Ascension Declination, Local Solar Time, Line Resolution, Sample Resolution, Pixel Resolution, and Solar Longitude.
+26 −16
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@ import kalasiris as kisis

import subprocess
import pvl
import shutil

from glob import glob
import logging
from pathlib import Path
import logging as log
from copy import deepcopy
@@ -180,6 +180,7 @@ def generate_cnet(params, images):
            tmpdir = Path(tmpdir)
            overlapfromlist = tmpdir / "fromlist.lis"
            overlaptolist = tmpdir / "tolist.lis"

            kisis.fromlist.make([*from_images, new_params["MATCH"]], overlapfromlist)

            try:
@@ -212,7 +213,6 @@ def generate_cnet(params, images):


    if from_images:

        log.debug(f"FROMLIST: {from_images}")

        if not fromlist_path.exists():
@@ -230,6 +230,7 @@ def generate_cnet(params, images):
            log.debug(' '.join(err.cmd))
            log.debug(err.stdout)
            log.debug(err.stderr)
            return "ERROR"

        segmented_net = cnet.from_isis(new_params["ONET"])

@@ -246,7 +247,8 @@ def generate_cnet(params, images):
        
        from_originals = [image["Original"] for image in images["from"]]
        return {"onet": new_params["ONET"], "original_images": from_originals}

    else: 
        return "No Overlap"

def merge(d1, d2, k): 
    """
@@ -293,9 +295,9 @@ def findFeaturesSegment(ui):
        dictionary containing output cnet and image list
    """
    if ui.GetBoolean("debug"):
        log.basicConfig(level=logging.DEBUG)
        log.basicConfig(level=log.DEBUG)
    else: 
        log.basicConfig(level=logging.INFO)    
        log.basicConfig(level=log.INFO)    

    img_list = []
    if ui.WasEntered("From"):
@@ -311,7 +313,6 @@ def findFeaturesSegment(ui):
    else: 
        nthreads = int(multiprocessing.cpu_count())


    pool = ThreadPool(ceil(nthreads/len(img_list)))
    output = pool.map_async(segment, img_list)
    pool.close()
@@ -357,6 +358,10 @@ def findFeaturesSegment(ui):
    # merge the networks 
    onets = [o["onet"] for o in output if isinstance(o, dict)]
    log.debug(f"onets: {onets}")

    if len(onets) == 0:
        raise Exception("No Control Points Found!")

    onet_list = Path(ui.GetFileName("onet")).with_suffix(".segmented.lis")
    kisis.fromlist.make(onets, onet_list)
    
@@ -369,6 +374,7 @@ def findFeaturesSegment(ui):
    log.debug(f"merged images: {final_images}")
    kisis.fromlist.make(final_images, Path(ui.GetFileName("tolist")))
     
    if len(onets) > 1: 
        try:
            kisis.cnetmerge(clist = onet_list, onet=ui.GetFileName("onet"), networkid=ui.GetAsString("networkid"), description=f"{ui.GetString('description')}")
        except subprocess.CalledProcessError as err:
@@ -376,7 +382,11 @@ def findFeaturesSegment(ui):
            log.debug(' '.join(err.cmd))
            log.debug(err.stdout)
            log.debug(err.stderr)
    elif len(onets) == 1: 
        # Dont merge 
        shutil.copy(onets[0], ui.GetFileName("onet"))

    log.info(f"COMPLETE, wrote { ui.GetFileName("onet")}")

if __name__ == "__main__": 
    ui = astroset.init_application(sys.argv)