Skip to content

Commit

Permalink
Permanent Fix for Output Files
Browse files Browse the repository at this point in the history
This is a permanent fix to an issue that happened in the previous version. Where the program asked for an output file after each and every night file entered. This defeats the purpose of this code.
  • Loading branch information
kjkoeller authored Dec 9, 2022
1 parent 8d73ad9 commit 925ad4f
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions AIJ_Night_Filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def main(c):
else:
print("You have not entered a number or the word 'Close', please try again.")
print()
get_filters(int(num))
get_nights(int(num))


def get_filters(n):
def get_nights(n):
"""
Takes a number of nights for a given filter and takes out the HJD, either A_Mag1 or T1_flux, and
error for mag or flux. Determines if the user has entered a file that contains 4 or 7 columns and correctly parses
Expand Down Expand Up @@ -122,26 +122,7 @@ def get_filters(n):
new_flux = [item for elem in total_flux for item in elem]
new_flux_err = [item for elem in total_flux_err for item in elem]

# outputs the new file to dataframe and then into a text file for use in Peranso or PHOEBE
data1 = pd.DataFrame({
"HJD": new_hjd,
"rel flux": new_flux,
"rel flux error": new_flux_err
})

data2 = pd.DataFrame({
"HJD": new_hjd,
"AMag": new_amag,
"AMag Error": new_amag_err
})

print("")
output = input("What is the file output name (WITHOUT any file extension): ")

# output both text files with a designation of magnitude or flux
data1.to_csv(output + "_magnitudes.txt", index=False, header=False, sep="\t")
data2.to_csv(output + "_flux.txt", index=False, header=False, sep="\t")
print("")
data_amount = 2
elif len(df.columns == 4):
# set parameters to lists from the file by the column header
hjd = []
Expand All @@ -165,24 +146,46 @@ def get_filters(n):
new_hjd = [item for elem in total_hjd for item in elem]
new_amag = [item for elem in total_amag for item in elem]
new_amag_err = [item for elem in total_amag_err for item in elem]
data_amount = 1
else:
print("The file you entered does not have the correct amount of columns.")
# outputs the new file to dataframe and then into a text file for use in Peranso or PHOEBE
data2 = pd.DataFrame({
"HJD": new_hjd,
"AMag": new_amag,
"AMag Error": new_amag_err
})

print("")
output = input("What is the file output name (WITHOUT any file extension): ")

# output both text files with a designation of magnitude or flux
data2.to_csv(output + "_magnitudes.txt", index=False, header=False, sep="\t")
print("")
print("Fished saving the file to the same location as this program.")
if data_amount == 1:
data2 = pd.DataFrame({
"HJD": new_hjd,
"AMag": new_amag,
"AMag Error": new_amag_err
})

print("")
output = input("What is the file output name (WITHOUT any file extension): ")

# output the text files with a designation of magnitude or flux
data2.to_csv(output + "_magnitudes.txt", index=False, header=False, sep="\t")
print("")
print("Fished saving the file to the same location as this program.")
elif data_amount == 2:
# outputs the new file to dataframe and then into a text file for use in Peranso or PHOEBE
data1 = pd.DataFrame({
"HJD": new_hjd,
"rel flux": new_flux,
"rel flux error": new_flux_err
})

data2 = pd.DataFrame({
"HJD": new_hjd,
"AMag": new_amag,
"AMag Error": new_amag_err
})

print("")
output = input("What is the file output name (WITHOUT any file extension): ")

# output both text files with a designation of magnitude or flux
data1.to_csv(output + "_magnitudes.txt", index=False, header=False, sep="\t")
data2.to_csv(output + "_flux.txt", index=False, header=False, sep="\t")
print("")


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
main(0)

0 comments on commit 925ad4f

Please sign in to comment.