diff --git a/AIJ_Night_Filters.py b/AIJ_Night_Filters.py index 6c9c4ec..2b72c09 100644 --- a/AIJ_Night_Filters.py +++ b/AIJ_Night_Filters.py @@ -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 @@ -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 = [] @@ -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)