Example #1
0
def calc_ioveru_fom(config) :  
    """calculates the intersection over union figure of merit.
    This function assumes that the mask_sum raster already exists in the 
    database. Returns a floating point number from 0..1"""
    query = "SELECT viirs_calc_fom('{0}')".format(config.DBschema)
    
    # now, need to execute a query that returns a single result.
    ConnParam = vt.postgis_conn_params(config)
    conn = psycopg2.connect(ConnParam)
    # Open a cursor to perform database operations
    cur = conn.cursor()
    cur.execute(query)
    rows = cur.fetchall()

    conn.commit()
    # Close communication with the database
    cur.close()
    conn.close()
    
    return rows[0][0]
Example #2
0
def calc_ioveru_fom(config):
    """calculates the intersection over union figure of merit.
    This function assumes that the mask_sum raster already exists in the 
    database. Returns a floating point number from 0..1"""
    query = "SELECT viirs_calc_fom('{0}')".format(config.DBschema)

    # now, need to execute a query that returns a single result.
    ConnParam = vt.postgis_conn_params(config)
    conn = psycopg2.connect(ConnParam)
    # Open a cursor to perform database operations
    cur = conn.cursor()
    cur.execute(query)
    rows = cur.fetchall()

    conn.commit()
    # Close communication with the database
    cur.close()
    conn.close()

    return rows[0][0]
Example #3
0
def find_missing_zonetbl_runs(gt_schema, zone_tbl, config):
    """locates missing run_ids in the zone_tbl by comparing with the list of schemas"""
    query = """select b.runs from
      (select nspname runs from pg_namespace where nspname LIKE 'Run_%') b
      where b.runs not in (select distinct run_id from "{0}"."{1}")""".format(
        gt_schema, zone_tbl)

    # now, need to execute a query that returns multiple results.
    ConnParam = vt.postgis_conn_params(config)
    conn = psycopg2.connect(ConnParam)
    # Open a cursor to perform database operations
    cur = conn.cursor()
    cur.execute(query)
    rows = cur.fetchall()

    conn.commit()
    # Close communication with the database
    cur.close()
    conn.close()

    runs = [i[0] for i in rows]

    return runs
Example #4
0
def find_missing_zonetbl_runs(gt_schema, zone_tbl, config) : 
    """locates missing run_ids in the zone_tbl by comparing with the list of schemas"""
    query = """select b.runs from
      (select nspname runs from pg_namespace where nspname LIKE 'Run_%') b
      where b.runs not in (select distinct run_id from "{0}"."{1}")""".format(
                gt_schema, zone_tbl)

    # now, need to execute a query that returns multiple results.
    ConnParam = vt.postgis_conn_params(config)
    conn = psycopg2.connect(ConnParam)
    # Open a cursor to perform database operations
    cur = conn.cursor()
    cur.execute(query)
    rows = cur.fetchall()

    conn.commit()
    # Close communication with the database
    cur.close()
    conn.close()

    runs = [ i[0] for i in rows ] 

    return runs