Unverified Commit e7261241 authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner Committed by GitHub
Browse files

Making to_isis write out sql query ordered like subpixel register (#446)

* initial commit making to_isis write out sql query ordered

* resolving merge conflicts

* cleaning copy_images
parent fe91cb73
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -433,11 +433,15 @@ def distribute_points_new(geom, nspts, ewpts, Session):
    very simplistic approximation of the shape
    of the geometry and then place some number of
    north/south and east/west points into the geometry.
    This function works best on bulky geometries, such as
    a combination of all network image footprints.

    Parameters
    ----------
    geom : shapely.geom
           A shapely geometry object
           A shapely geometry object which is a union of
           all of the image footprints in the network
           that is being grounded.

    nspts : int
            The number of points to attempt to place
+42 −35
Original line number Diff line number Diff line
@@ -1578,7 +1578,7 @@ class NetworkCandidateGraph(CandidateGraph):
                     time=walltime,
                     partition=self.config['cluster']['queue'],
                     output=self.config['cluster']['cluster_log_dir']+f'/autocnet.{function}-%j')
        submitter.submit(array='1-{}'.format(job_counter), chunksize=chunksize)
        submitter.submit(array='1-{}%24'.format(job_counter), chunksize=chunksize)
        return job_counter

    def generic_callback(self, msg):
@@ -1603,11 +1603,12 @@ class NetworkCandidateGraph(CandidateGraph):
            return

    def to_isis(self, path, flistpath=None,sql = """
SELECT points.id,
SELECT measures."pointid",
        points."pointType",
        points."apriori",
        points."adjusted",
        points."pointIgnore",
        measures."id",
        measures."serialnumber",
        measures."sample",
        measures."line",
@@ -1629,7 +1630,8 @@ WHERE
        INNER JOIN points ON measures."pointid" = points."id"
        WHERE measures."measureIgnore" = False and measures."measureJigsawRejected" = False AND points."pointIgnore" = False
        GROUP BY measures."imageid"
        HAVING COUNT(DISTINCT measures."pointid")  < 3);
        HAVING COUNT(DISTINCT measures."pointid")  < 3)
ORDER BY measures."pointid", measures."id";
"""):
        """
        Given a set of points/measures in an autocnet database, generate an ISIS
@@ -1653,6 +1655,11 @@ WHERE

        df = pd.read_sql(sql, self.engine)

        # measures.id DB column was read in to ensure the proper ordering of DF
        # so the correct measure is written as reference
        del df['id']
        df.rename(columns = {'pointid': 'id'}, inplace=True)

        #create columns in the dataframe; zeros ensure plio (/protobuf) will
        #ignore unless populated with alternate values
        df['aprioriX'] = 0
@@ -1779,15 +1786,16 @@ WHERE

        with self.session_scope() as session:
            images = session.query(Images).all()
            oldnew = []
            for obj in images:
                oldpath = obj.path
                filename = os.path.basename(oldpath)
                obj.path = os.path.join(newdir, filename)
                oldnew.append((oldpath, obj.path))

                if oldpath != obj.path:
                    # Copy the files
        [copyfile(old, new) for old, new in oldnew]
                    copyfile(oldpath, obj.path)
                    session.commit()
                else:
                    continue


    def add_from_remote_database(self, source_db_config, path,  query_string='SELECT * FROM public.images LIMIT 10'):
@@ -1848,7 +1856,6 @@ WHERE
        sourceimages = sourcesession.execute(query_string).fetchall()

        with self.session_scope() as destinationsession:
            destinationsession = self.Session()
            destinationsession.execute(Images.__table__.insert(), sourceimages)

            # Get the camera objects to manually join. Keeps the caller from