Beispiel #1
0
def process_loop(fname):
    """
    Thread to process satobs FourFrame FITS files in a multi-thread compatible manner
    """

    # Generate star catalog
    if not os.path.exists(fname + ".cat"):
        pix_catalog = generate_star_catalog(fname)
    else:
        pix_catalog = pixel_catalog(fname + ".cat")

    # Calibrate from reference
    calibrate_from_reference(fname, "test.fits", pix_catalog)

    # Store calibration
    store_calibration(pix_catalog, fname + ".cal")

    # Generate satellite predictions
    generate_satellite_predictions(fname)

    # Detect lines with 3D Hough transform
    ids = find_hough3d_lines(fname, nhoughmin, houghrmin)

    # Get properties
    ff = fourframe(fname)

    # Extract tracks
    if is_calibrated(ff):
        screenoutput_idents = extract_tracks(fname, trkrmin, drdtmin, drdtmax, trksig, ntrkmin, root_dir, results_dir, tle_dir)
    else:
        screenoutput_idents = None 

    # Stars available and used
    nused = np.sum(pix_catalog.flag == 1)
    nstars = pix_catalog.nstars

    # Write output
    screenoutput = "%s %10.6f %10.6f %4d/%4d %5.1f %5.1f %6.2f +- %6.2f" % (
        ff.fname, ff.crval[0], ff.crval[1], nused, nstars,
        3600.0 * ff.crres[0], 3600.0 * ff.crres[1], np.mean(
            ff.zavg), np.std(ff.zavg))

    if is_calibrated(ff):
        screenoutput = colored(screenoutput, "green")
    else:
        screenoutput = colored(screenoutput, "red")

    imgstat_output = ("%s,%.8lf,%.6f,%.6f,%.3f,%.3f,%.3f," + "%.3f,%d,%d\n") % (
        (ff.fname, ff.mjd, ff.crval[0], ff.crval[1],
            3600 * ff.crres[0], 3600 * ff.crres[1], np.mean(
                ff.zavg), np.std(ff.zavg), nstars, nused))

    # Move processed files
    shutil.move(fname, os.path.join(processed_dir, fname))
    shutil.move(fname + ".png", os.path.join(processed_dir, fname + ".png"))
    shutil.move(fname + ".id", os.path.join(processed_dir, fname + ".id"))
    shutil.move(fname + ".cat", os.path.join(processed_dir, fname + ".cat"))
    shutil.move(fname + ".cal", os.path.join(processed_dir, fname + ".cal"))

    return (screenoutput, imgstat_output, screenoutput_idents)
Beispiel #2
0
def plot_header(fname, ff, iod_line):
    # ppgplot arrays
    heat_l = np.array([0.0, 0.2, 0.4, 0.6, 1.0])
    heat_r = np.array([0.0, 0.5, 1.0, 1.0, 1.0])
    heat_g = np.array([0.0, 0.0, 0.5, 1.0, 1.0])
    heat_b = np.array([0.0, 0.0, 0.0, 0.3, 1.0])

    # Plot
    ppg.pgopen(fname)
    ppg.pgpap(0.0, 1.0)
    ppg.pgsvp(0.1, 0.95, 0.1, 0.8)

    ppg.pgsch(0.8)
    ppg.pgmtxt("T", 6.0, 0.0, 0.0,
               "UT Date: %.23s  COSPAR ID: %04d" % (ff.nfd, ff.site_id))
    if is_calibrated(ff):
        ppg.pgsci(1)
    else:
        ppg.pgsci(2)
    ppg.pgmtxt(
        "T", 4.8, 0.0, 0.0, "R.A.: %10.5f (%4.1f'') Decl.: %10.5f (%4.1f'')" %
        (ff.crval[0], 3600.0 * ff.crres[0], ff.crval[1], 3600.0 * ff.crres[1]))
    ppg.pgsci(1)
    ppg.pgmtxt("T", 3.6, 0.0, 0.0, ("FoV: %.2f\\(2218)x%.2f\\(2218) "
                                    "Scale: %.2f''x%.2f'' pix\\u-1\\d") %
               (ff.wx, ff.wy, 3600.0 * ff.sx, 3600.0 * ff.sy))
    ppg.pgmtxt(
        "T", 2.4, 0.0, 0.0, "Stat: %5.1f+-%.1f (%.1f-%.1f)" %
        (np.mean(ff.zmax), np.std(ff.zmax), ff.zmaxmin, ff.zmaxmax))
    ppg.pgmtxt("T", 0.3, 0.0, 0.0, iod_line)

    ppg.pgsch(1.0)
    ppg.pgwnad(0.0, ff.nx, 0.0, ff.ny)
    ppg.pglab("x (pix)", "y (pix)", " ")
    ppg.pgctab(heat_l, heat_r, heat_g, heat_b, 5, 1.0, 0.5)
Beispiel #3
0
        fnames = sorted(glob.glob("2*.fits"))

        # Loop over files
        for fname in fnames:
            # Generate star catalog
            pix_catalog = generate_star_catalog(fname)

            # Create reference calibration file
            if not os.path.exists("test.fits"):
                solved = generate_reference_with_anet(fname, "")

            # Calibrate astrometry
            calibrate_from_reference(fname, "test.fits", pix_catalog)

            # Redo refence if astrometry failed
            if not is_calibrated(fourframe(fname)) and pix_catalog.nstars > 10:
                print(
                    colored(
                        "Recomputing astrometric calibration for %s" % fname,
                        "yellow"))
                solved = generate_reference_with_anet(fname, "")

                # Calibrate astrometry
                calibrate_from_reference(fname, "test.fits", pix_catalog)

            # Generate satellite predictions
            generate_satellite_predictions(fname)

            # Detect lines with 3D Hough transform
            ids = find_hough3d_lines(fname)
Beispiel #4
0
                pix_catalog = generate_star_catalog(fname)

            # Calibrate from reference
            calibrate_from_reference(fname, "test.fits", pix_catalog)

            # Generate satellite predictions
            generate_satellite_predictions(fname)

            # Detect lines with 3D Hough transform
            ids = find_hough3d_lines(fname)

            # Get properties
            ff = fourframe(fname)

            # Extract tracks
            if is_calibrated(ff):
                extract_tracks(fname, trkrmin, drdtmin, trksig, ntrkmin,
                               root_dir, results_dir)

            # Stars available and used
            nused = np.sum(pix_catalog.flag == 1)
            nstars = pix_catalog.nstars

            # Write output
            output = "%s %10.6f %10.6f %4d/%4d %5.1f %5.1f %6.2f +- %6.2f" % (
                ff.fname, ff.crval[0], ff.crval[1], nused, nstars,
                3600.0 * ff.crres[0], 3600.0 * ff.crres[1], np.mean(
                    ff.zavg), np.std(ff.zavg))
            if is_calibrated(ff):
                print(colored(output, "green"))
            else: