io.db.controlnetwork — Database to Control Networks

The io.db.controlnetwork module contains logic for reading a database stored control network into a pandas dataframe.

New in version 0.1.0.

autocnet.io.db.controlnetwork.db_to_df(engine, sql='\nSELECT measures."pointid",\n        points."pointType",\n        points."apriori",\n        points."adjusted",\n        points."pointIgnore",\n        points."referenceIndex",\n        points."identifier",\n        measures."id",\n        measures."serialnumber",\n        measures."sample",\n        measures."line",\n        measures."measureType",\n        measures."imageid",\n        measures."measureIgnore",\n        measures."measureJigsawRejected",\n        measures."aprioriline",\n        measures."apriorisample"\nFROM measures\nINNER JOIN points ON measures."pointid" = points."id"\nWHERE\n    points."pointIgnore" = False AND\n    measures."measureIgnore" = FALSE AND\n    measures."measureJigsawRejected" = FALSE AND\n    measures."imageid" NOT IN\n        (SELECT measures."imageid"\n        FROM measures\n        INNER JOIN points ON measures."pointid" = points."id"\n        WHERE measures."measureIgnore" = False and measures."measureJigsawRejected" = False AND points."pointIgnore" = False\n        GROUP BY measures."imageid"\n        HAVING COUNT(DISTINCT measures."pointid")  < 3)\nORDER BY measures."pointid", measures."id";\n')[source]

Given a set of points/measures in an autocnet database, generate an ISIS compliant control network. :param path: The full path to the output network. :type path: str :param flistpath: (Optional) the path to the output filelist. By default

the outout filelist path is genrated programatically as the provided path with the extension replaced with .lis. For example, out.net would have an associated out.lis file.

Parameters

sql (str) – The sql query to execute in the database.

autocnet.io.db.controlnetwork.update_from_jigsaw(cnet, measures, connection, pointid_func=None)[source]

Updates a database fields: liner, sampler, measureJigsawRejected, samplesigma, and linesigma using an ISIS control network.

This function uses the pandas update function with overwrite=True. Therefore, this function will overwrite NaN and non-NaN entries.

In order to be efficient, this func creates an in-memory control network and then writes to the database using a string buffer and a COPY FROM call.

Note: If using this func and looking at the updates table in pgadmin, it is necessary to refresh the pgadmin table of contents for the schema.

Parameters
  • cnet (pd.DataFrame) – plio.io.io_control_network loaded dataframe

  • measures (pd.DataFrame) – of measures from a database table.

  • connection (object) – An SQLAlchemy DB connection object

  • poitid_func (callable) – A callable function that is used to split the id string in the cnet in order to extract a pointid. An autocnet written cnet will have a user specified identifier with the numeric pointid as the final element, e.g., autocnet_1. This func needs to get the numeric ID back. This callable is used to unmunge the id.