Commit e3bcb904 authored by Francesco Amadori's avatar Francesco Amadori
Browse files

adjusted stare mode (hopefully)

parent 15816b03
Loading
Loading
Loading
Loading
+17 −38
Original line number Diff line number Diff line
@@ -24,55 +24,34 @@ if stare:
    single = "--single --forced_sky"
else:
    single = ""
if os.path.exists(folder_gofio + os.sep + "raw" + os.sep + night + os.sep):
    execute1 = "cd " + folder_gofio
    execute2b = "python gofioDRS.py " + night + " --flat --only_calib " + single
    execute2a = "python gofioDRS.py " + night + " --dark --only_calib " + single
    execute2c = "python gofioDRS.py " + night + " --une --only_calib " + single
    execute3 = "python gofioDRS.py --use_flat=" + str(flat) + " " + night + " " + single
    execute4 = "mkdir -p " + folder_output_complete
if os.path.exists(f"{folder_gofio}{os.sep}raw{os.sep}{night}{os.sep}"):
    execute1 = f"cd {folder_gofio}"
    execute2b = f"python gofioDRS.py {night} --flat --only_calib {single}"
    execute2a = f"python gofioDRS.py {night} --dark --only_calib {single}"
    execute2c = f"python gofioDRS.py {night} --une --only_calib {single}"
    execute3 = f"python gofioDRS.py {night} --use_flat={flat} {single}"
    execute4 = f"mkdir -p {folder_output_complete}"
    if stare:
        execute5 = (
                "cp "
                + str(Path(folder_gofio, "reduced", night, "offline")) + os.sep + "*_C_ms1d.fits "
                + folder_output_complete
                f"cp {Path(folder_gofio, 'reduced', night, 'offline')}{os.sep}*_C_ms1d.fits "
                f"{folder_output_complete}"
        )
        execute6 = (
                "echo only_C_files"
        )
    else:
        execute5 = (
            "cp "
            + str(Path(folder_gofio, "reduced", night, "offline")) + os.sep + "*_A_ms1d.fits "
            + folder_output_complete
            f"cp {Path(folder_gofio, 'reduced', night, 'offline')}{os.sep}*_A_ms1d.fits "
            f"{folder_output_complete}"
        )
        execute6 = (
            "cp "
            + str(Path(folder_gofio, "reduced", night, "offline")) + os.sep + "*_B_ms1d.fits "
            + folder_output_complete
            f"cp {Path(folder_gofio, 'reduced', night, 'offline')}{os.sep}*_B_ms1d.fits "
            f"{folder_output_complete}"
        )

    execute7 = f'cp $(ls -t {str(Path(folder_gofio, "reduced", night, "offline", "CALIB", "*UNE_ext.fits"))} | head -1) {str(Path(folder_output, night_reduce, "UNE_lines.fits"))}'

    execute = (
        execute1
        + "; "
        + execute2a
        + "; "
        + execute2b
        + "; "
        + execute2c
        + '; echo "END CALIBRATION"; '
        + execute3
        + "; "
        + execute4
        + "; "
        + execute5
        + "; "
        + execute6
        + "; "
        + execute7
    )
    execute = f'{execute1}; {execute2a}; {execute2b}; {execute2c}; echo "END CALIBRATION"; {execute3}; {execute4}; {execute5}; {execute6}; {execute7}'
    print(execute)
    os.system(execute)

@@ -89,13 +68,13 @@ if os.path.exists(folder_gofio + os.sep + "raw" + os.sep + night + os.sep):
                elem2 = copy.copy(elem)
                new_str = elem2.replace("_A_ms1d.fits", "_B_ms1d.fits")
                if new_str not in list_file_B:
                    os.system("rm -f %s" % elem)
                    os.system(f"rm -f {elem}")
        elif len(list_file_B) > len(list_file_A):
            for elem in list_file_B:
                elem2 = copy.copy(elem)
                new_str = elem2.replace("_B_ms1d.fits", "_A_ms1d.fits")
                if new_str not in list_file_A:
                    os.system("rm -f %s" % elem)
                    os.system(f"rm -f {elem}")

    #
    # # DB CONNECTION
@@ -103,4 +82,4 @@ if os.path.exists(folder_gofio + os.sep + "raw" + os.sep + night + os.sep):
    # DB.insert_target_nights(target, night_reduce, 2 * len(list_file_A), flat)
    # DB.close()
else:
    print(folder_gofio + os.sep + "raw" + os.sep + night + os.sep + "Night is not present")
    print(f"{folder_gofio}{os.sep}raw{os.sep}{night}{os.sep}Night is not present")