Exemple #1
0
def main():
    """
    Run the update process to get new obspars, save them in the Ska
    file archive, and include new entries in the file lookup database.
    """
    opt = get_options()
    config = vars(opt)
    archive = obsid_archive.ObsArchive(config)
    archive.logger.setLevel(logging.INFO)
    archive.logger.addHandler(logging.StreamHandler())
    archive.update()
Exemple #2
0
def main():
    """
    Run the update process to get new ASP L1 telemetry, save it in the Ska
    file archive, and include it in the file lookup database.
    """
    opt = get_options()
    config = vars(opt)
    archive = obsid_archive.ObsArchive(config)
    archive.logger.setLevel(logging.INFO)
    archive.logger.addHandler(logging.StreamHandler())
    obsids = archive.update()
Exemple #3
0
def get_arch_vv(obsid, version='last'):
    """
    Given obsid and version, find archived ASP1 and obspar products and
    run V&V.  Effort is made to find the obspar that was actually used during
    creation of the ASP1 products.

    :param obsid: obsid
    :param version: 'last', 'default', or revision number of ASP1 products
    :returns: mica.vv.Obi V&V object
    """
    logger.info("Generating V&V for obsid {}".format(obsid))
    asp_l1_dirs = asp_l1_arch.get_obs_dirs(obsid)
    if asp_l1_dirs is None or version not in asp_l1_dirs:
        raise LookupError(
            "Requested version {} not in asp_l1 archive".format(version))
    l1_dir = asp_l1_dirs[version]
    # find the obspar that matches the requested aspect_1 products
    # this is in the aspect processing table
    asp_l1_proc = Ska.DBI.DBI(dbi="sqlite", server=FILES['asp1_proc_table'])
    asp_obs = asp_l1_proc.fetchall(
        "SELECT * FROM aspect_1_proc where obsid = {}".format(obsid))
    asp_proc = None
    if len(asp_obs) == 0:
        return None
    if version == 'last':
        asp_proc = asp_obs[asp_obs['aspect_1_id'] == np.max(
            asp_obs['aspect_1_id'])][0]
    if version == 'default':
        asp_proc = asp_obs[asp_obs['isdefault'] == 1][0]
    if asp_proc is None:
        asp_proc = asp_obs[asp_obs['revision'] == version][0]
    obspar_dirs = obspar_arch.get_obs_dirs(obsid)
    if obspar_dirs is None or asp_proc['obspar_version'] not in obspar_dirs:
        # try to update the obspar archive with the missing version
        config = obspar_arch.CONFIG.copy()
        config.update(dict(obsid=obsid, version=asp_proc['obspar_version']))
        oa = obsid_archive.ObsArchive(config)
        oa.logger.setLevel(logging.INFO)
        oa.logger.addHandler(logging.StreamHandler())
        oa.update()
        obspar_dirs = obspar_arch.get_obs_dirs(obsid)
    try:
        obspar_file = glob(
            os.path.join(obspar_dirs[asp_proc['obspar_version']],
                         'axaf*par*'))[0]
    except IndexError:
        raise LookupError(f"Requested version {version} not in obspar archive")
    return Obi(obspar_file, l1_dir, temproot=FILES['temp_root'])
Exemple #4
0
                        help="specific processing version to retrieve")
    parser.add_argument("--firstrun",
                        action='store_true',
                        help="for archive init., ignore revisions")
    parser.add_argument("--data-root", help="parent directory for all data")
    parser.add_argument("--temp-root", help="parent temp directory")
    parser.add_argument("--rebuild",
                        action="store_true",
                        help="Allow update to rebuild archive from obsid 1")
    opt = parser.parse_args()
    return opt


# set up an archive object with default config for use by the other
# get_* methods
archive = obsid_archive.ObsArchive(CONFIG)


def get_dir(obsid):
    """
    Get obspar directory for default/released products for an obsid.

      >>> from mica.archive import obspar
      >>> obspar.get_dir(2121)
      '/proj/sot/ska/data/mica/archive/obspar/02/02121'

    :param obsid: obsid
    :returns: directory
    :rtype: string
    """
    return archive.get_dir(obsid)