<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_astrometric_catalog(imglist, **pars):
 """Generates a catalog of all sources from an existing astrometric catalog are in or near the FOVs of the images in the input list. Parameters imglist : list List of one or more calibrated fits images that will be used for catalog generation. Returns ======= ref_table : object Astropy Table object of the catalog """

    # generate catalog
    temp_pars = pars.copy()
    if pars['output'] == True:
        pars['output'] = 'ref_cat.ecsv'
    else:
        pars['output'] = None
    out_catalog = amutils.create_astrometric_catalog(imglist,**pars)
    pars = temp_pars.copy()
    #if the catalog has contents, write the catalog to ascii text file
    if len(out_catalog) > 0 and pars['output']:
        catalog_filename = "refcatalog.cat"
        out_catalog.write(catalog_filename, format="ascii.fast_commented_header")
        log.info("Wrote reference catalog {}.".format(catalog_filename))

    return(out_catalog)