Loading autocnet/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ try: with open(os.environ['autocnet_config'], 'r') as f: config = yaml.safe_load(f) except: warnings.warn('No autocnet_config environment variable set. Defaulting to an en empty configuration.') warnings.warn('No autocnet_config environment variable set. Defaulting to an empty configuration.') config = {} if 'dem' in config['spatial']: Loading autocnet/graph/network.py +12 −7 Original line number Diff line number Diff line Loading @@ -1411,7 +1411,7 @@ class NetworkCandidateGraph(CandidateGraph): mem_per_cpu=config['cluster']['processing_memory'], time=walltime, partition=config['cluster']['queue'], output=config['cluster']['cluster_log_dir']+'/slurm-%A_%a.out') output=config['cluster']['cluster_log_dir']+f'/autocnet.{function}-%j') submitter.submit(array='1-{}'.format(job_counter)) return job_counter Loading Loading @@ -1474,8 +1474,9 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE 'sample':'x', 'line':'y', 'serial': 'serialnumber'}, inplace=True) if flistpath is None: flistpath = os.path.splitext(path)[0] + '.lis' target = config['spatial'].get('target', None) cnet.to_isis(df, path) cnet.to_isis(df, path, targetname=target) cnet.write_filelist(self.files, path=flistpath) @staticmethod Loading Loading @@ -1513,7 +1514,7 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE session.commit() @classmethod def from_filelist(cls, filelist): def from_filelist(cls, filelist, clear_db=False): """ Parse a filelist to add nodes to the database. Using the information in the database, then instantiate a complete, Loading @@ -1538,6 +1539,9 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE else: warnings.warn('Unable to parse the passed filelist') if clear_db: cls.clear_db() for f in filelist: # Create the nodes in the graph. Really, this is creating the # images in the DB Loading Loading @@ -1608,7 +1612,8 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE return obj def clear_db(self, tables=None): @staticmethod def clear_db(tables=None): """ Truncate all of the database tables and reset any autoincrement columns to start with 1. Loading @@ -1627,15 +1632,15 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE tables = engine.table_names() for t in tables: session.execute(f'TRUNCATE TABLE {t} CASCADE') if t != 'spatial_ref_sys': try: session.execute(f'ALTER SEQUENCE {t}_id_seq RESTART WITH 1') except: except Exception as e: warnings.warn(f'Failed to truncate table {t}, {t} not modified') session.rollback() session.commit() session.close() def place_points_from_cnet(self, cnet): semi_major, semi_minor = config["spatial"]["semimajor_rad"], config["spatial"]["semiminor_rad"] ecef = pyproj.Proj(proj='geocent', a=semi_major, b=semi_minor) Loading autocnet/io/db/model.py +2 −1 Original line number Diff line number Diff line Loading @@ -390,10 +390,11 @@ if Session: # Trigger that watches for points that should be active/inactive # based on the point count. if not engine.dialect.has_table(engine, "points"): event.listen(Base.metadata, 'before_create', valid_point_function) event.listen(Measures.__table__, 'after_create', valid_point_trigger) event.listen(Base.metadata, 'before_create', update_point_function) event.listen(Images.__table__, 'after_create', update_point_trigger) event.listen(Points.__table__, 'after_create', update_point_trigger) event.listen(Base.metadata, 'before_create', valid_geom_function) event.listen(Images.__table__, 'after_create', valid_geom_trigger) Loading autocnet/io/db/triggers.py +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ BEGIN NEW.geom = ST_Force_2D(ST_Transform(NEW.adjusted, {})); RETURN NEW; EXCEPTION WHEN OTHERS THEN raise notice 'FAILED TO PROJECT POINT'; NEW.geom = Null; RETURN NEW; END; Loading autocnet/spatial/overlap.py +4 −3 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ INSERT INTO overlay(intersections, geom) SELECT row.intersections, row.geom FROM """ def place_points_in_overlaps(nodes, size_threshold=0.0007, distribute_points_kwargs={}): distribute_points_kwargs={}, cam_type='csm'): """ Place points in all of the overlap geometries by back-projecing using sensor models. Loading @@ -59,8 +59,9 @@ def place_points_in_overlaps(nodes, size_threshold=0.0007, overlaps = o.intersections if overlaps == None: continue overlapnodes = [nodes[id]["data"] for id in overlaps] points.extend(place_points_in_overlap(overlapnodes, o.geom, points.extend(place_points_in_overlap(overlapnodes, o.geom, cam_type=cam_type, distribute_points_kwargs=distribute_points_kwargs)) Points.bulkadd(points) Loading Loading @@ -108,7 +109,7 @@ def cluster_place_points_in_overlaps(size_threshold=0.0007, mem_per_cpu=config['cluster']['processing_memory'], time=walltime, partition=config['cluster']['queue'], output=config['cluster']['cluster_log_dir']+'/slurm-%A_%a.out') output=config['cluster']['cluster_log_dir']+'/autocnet.place_points-%j') submitter.submit(array='1-{}'.format(job_counter)) return job_counter Loading Loading
autocnet/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ try: with open(os.environ['autocnet_config'], 'r') as f: config = yaml.safe_load(f) except: warnings.warn('No autocnet_config environment variable set. Defaulting to an en empty configuration.') warnings.warn('No autocnet_config environment variable set. Defaulting to an empty configuration.') config = {} if 'dem' in config['spatial']: Loading
autocnet/graph/network.py +12 −7 Original line number Diff line number Diff line Loading @@ -1411,7 +1411,7 @@ class NetworkCandidateGraph(CandidateGraph): mem_per_cpu=config['cluster']['processing_memory'], time=walltime, partition=config['cluster']['queue'], output=config['cluster']['cluster_log_dir']+'/slurm-%A_%a.out') output=config['cluster']['cluster_log_dir']+f'/autocnet.{function}-%j') submitter.submit(array='1-{}'.format(job_counter)) return job_counter Loading Loading @@ -1474,8 +1474,9 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE 'sample':'x', 'line':'y', 'serial': 'serialnumber'}, inplace=True) if flistpath is None: flistpath = os.path.splitext(path)[0] + '.lis' target = config['spatial'].get('target', None) cnet.to_isis(df, path) cnet.to_isis(df, path, targetname=target) cnet.write_filelist(self.files, path=flistpath) @staticmethod Loading Loading @@ -1513,7 +1514,7 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE session.commit() @classmethod def from_filelist(cls, filelist): def from_filelist(cls, filelist, clear_db=False): """ Parse a filelist to add nodes to the database. Using the information in the database, then instantiate a complete, Loading @@ -1538,6 +1539,9 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE else: warnings.warn('Unable to parse the passed filelist') if clear_db: cls.clear_db() for f in filelist: # Create the nodes in the graph. Really, this is creating the # images in the DB Loading Loading @@ -1608,7 +1612,8 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE return obj def clear_db(self, tables=None): @staticmethod def clear_db(tables=None): """ Truncate all of the database tables and reset any autoincrement columns to start with 1. Loading @@ -1627,15 +1632,15 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE tables = engine.table_names() for t in tables: session.execute(f'TRUNCATE TABLE {t} CASCADE') if t != 'spatial_ref_sys': try: session.execute(f'ALTER SEQUENCE {t}_id_seq RESTART WITH 1') except: except Exception as e: warnings.warn(f'Failed to truncate table {t}, {t} not modified') session.rollback() session.commit() session.close() def place_points_from_cnet(self, cnet): semi_major, semi_minor = config["spatial"]["semimajor_rad"], config["spatial"]["semiminor_rad"] ecef = pyproj.Proj(proj='geocent', a=semi_major, b=semi_minor) Loading
autocnet/io/db/model.py +2 −1 Original line number Diff line number Diff line Loading @@ -390,10 +390,11 @@ if Session: # Trigger that watches for points that should be active/inactive # based on the point count. if not engine.dialect.has_table(engine, "points"): event.listen(Base.metadata, 'before_create', valid_point_function) event.listen(Measures.__table__, 'after_create', valid_point_trigger) event.listen(Base.metadata, 'before_create', update_point_function) event.listen(Images.__table__, 'after_create', update_point_trigger) event.listen(Points.__table__, 'after_create', update_point_trigger) event.listen(Base.metadata, 'before_create', valid_geom_function) event.listen(Images.__table__, 'after_create', valid_geom_trigger) Loading
autocnet/io/db/triggers.py +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ BEGIN NEW.geom = ST_Force_2D(ST_Transform(NEW.adjusted, {})); RETURN NEW; EXCEPTION WHEN OTHERS THEN raise notice 'FAILED TO PROJECT POINT'; NEW.geom = Null; RETURN NEW; END; Loading
autocnet/spatial/overlap.py +4 −3 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ INSERT INTO overlay(intersections, geom) SELECT row.intersections, row.geom FROM """ def place_points_in_overlaps(nodes, size_threshold=0.0007, distribute_points_kwargs={}): distribute_points_kwargs={}, cam_type='csm'): """ Place points in all of the overlap geometries by back-projecing using sensor models. Loading @@ -59,8 +59,9 @@ def place_points_in_overlaps(nodes, size_threshold=0.0007, overlaps = o.intersections if overlaps == None: continue overlapnodes = [nodes[id]["data"] for id in overlaps] points.extend(place_points_in_overlap(overlapnodes, o.geom, points.extend(place_points_in_overlap(overlapnodes, o.geom, cam_type=cam_type, distribute_points_kwargs=distribute_points_kwargs)) Points.bulkadd(points) Loading Loading @@ -108,7 +109,7 @@ def cluster_place_points_in_overlaps(size_threshold=0.0007, mem_per_cpu=config['cluster']['processing_memory'], time=walltime, partition=config['cluster']['queue'], output=config['cluster']['cluster_log_dir']+'/slurm-%A_%a.out') output=config['cluster']['cluster_log_dir']+'/autocnet.place_points-%j') submitter.submit(array='1-{}'.format(job_counter)) return job_counter Loading