diff --git a/SERI-QC_with_QCFIT/dataFiles/blankQA0 b/SERI-QC_with_QCFIT/dataFiles/blankQA0 new file mode 100644 index 0000000..d10b58c --- /dev/null +++ b/SERI-QC_with_QCFIT/dataFiles/blankQA0 @@ -0,0 +1,29 @@ + Site Identifier: + --- Latitude: + --- Longitude: + --- Elevation: + --- Time Zone: + + ---Low Airmass-- ---Med Airmass-- --High Airmass-- + -MAX- -LFT RGT- -MAX- -LFT RGT- -MAX- -LFT RGT- + KN KT S P S P KN KT S P S P KN KT S P S P + +JAN: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +FEB: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +MAR: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +APR: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +MAY: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +JUN: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +JUL: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +AUG: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +SEP: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +OCT: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +NOV: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 +DEC: 00-000 0-00 0-00; 00-000 0-00 0-00; 00-000 0-00 0-00 + +DEFAULT CONFIGURATION +Integration (minutes): +Data Folder: +Plane: +3-Component Filter: +Comments: diff --git a/SERI-QC_with_QCFIT/forms.py b/SERI-QC_with_QCFIT/forms.py index 9b8608e..bcf1eff 100644 --- a/SERI-QC_with_QCFIT/forms.py +++ b/SERI-QC_with_QCFIT/forms.py @@ -31,20 +31,40 @@ def close(): def getPath(format): root = tk.Tk() - root.withdraw() + root.title("Select Input File") + root.resizable(False, False) + + # Keep a small visible host window centered so macOS places the file dialog correctly. + root.update_idletasks() + screen_width = root.winfo_screenwidth() + screen_height = root.winfo_screenheight() + dialog_width = 360 + dialog_height = 120 + center_x = int((screen_width - dialog_width) / 2) + center_y = int((screen_height - dialog_height) / 2) + root.geometry(f"{dialog_width}x{dialog_height}+{center_x}+{center_y}") + tk.Label(root, text="Opening file browser...", padx=20, pady=20).pack() + + # Bring host to the front before opening the native dialog. + root.lift() + root.attributes('-topmost', True) root.update() - if format == "qc0": - path = tkinter.filedialog.askopenfilename(parent=root, initialdir="/", title='Upload QC0 file', - filetypes=(("QC0 files", "*.QC0"), ("all files", "*.*"))) + root.attributes('-topmost', False) + + path = "" + if format == "qa0": + path = tkinter.filedialog.askopenfilename(parent=root, initialdir=os.getcwd(), title='Upload QA0 file', + filetypes=(("QA0 files", "*.QA0"), ("all files", "*.*"))) if format == "csv": - path = tkinter.filedialog.askopenfilename(parent=root, initialdir="/", title='Upload CSV file', + path = tkinter.filedialog.askopenfilename(parent=root, initialdir=os.getcwd(), title='Upload CSV file', filetypes=(("csv files", "*.csv"), ("all files", "*.*"))) + root.destroy() + if len(path) < 1: messagebox.showerror("Error", "File not provided. Please Try Again.") - root.after(3, root.destroy()) sys.exit() - root.after(1, root.destroy()) + return path diff --git a/SERI-QC_with_QCFIT/qcfit_script_ios.py b/SERI-QC_with_QCFIT/qcfit_script_ios.py index c27882b..037c68a 100644 --- a/SERI-QC_with_QCFIT/qcfit_script_ios.py +++ b/SERI-QC_with_QCFIT/qcfit_script_ios.py @@ -51,7 +51,7 @@ def getFilePath(): return path -def getQC0FilePath(): +def getQA0FilePath(): root = tk.Tk() root.withdraw() @@ -64,8 +64,8 @@ def getQC0FilePath(): center_y = int((screen_height - dialog_height) / 2) root.geometry(f"{dialog_width}x{dialog_height}+{center_x}+{center_y}") - path = tkinter.filedialog.askopenfilename(parent=root, initialdir=os.getcwd(), title='Upload QC0 file', - filetypes=(("QC0 files", "*.QC0"), ("all files", "*.*"))) + path = tkinter.filedialog.askopenfilename(parent=root, initialdir=os.getcwd(), title='Upload QA0 file', + filetypes=(("QA0 files", "*.QA0"), ("all files", "*.*"))) return path @@ -131,16 +131,16 @@ def getKspace(ip): def hitOpen(): def newSite(): - def nsQC0Browse(): + def nsQA0Browse(): global data, siteInfo - nsPath = tkinter.filedialog.askdirectory(parent=newSiteRoot) - data["qc0Path"] = nsPath + "/" + nssiteIDEntry.get() + ".qc0" - qc0PathLabel = tk.Label(newSiteRoot, text=nsPath, font=(None, 12), anchor="w") - qc0PathLabel.place(relx=0.15, rely=0.47, relwidth=0.84, relheight=0.04) + nsPath = tkinter.filedialog.askdirectory(parent=newSiteRoot, initialdir=os.getcwd()) + data["qa0Path"] = nsPath + "/" + nssiteIDEntry.get() + ".qa0" + qa0PathLabel = tk.Label(newSiteRoot, text=nsPath, font=(None, 12), anchor="w") + qa0PathLabel.place(relx=0.15, rely=0.47, relwidth=0.84, relheight=0.04) def nsDatafolBrowse(): # global data - dfPath = tkinter.filedialog.askdirectory(parent=newSiteRoot) + dfPath = tkinter.filedialog.askdirectory(parent=newSiteRoot, initialdir=os.getcwd()) dfPathLabel = tk.Label(definFrame, text=dfPath, font=(None, 12), anchor="w") dfPathLabel.place(relx=0.14, rely=0.82, relwidth=0.85, relheight=0.12) data["defaultDataFolder"] = dfPath @@ -149,7 +149,7 @@ def nsOK(): # global data, siteInfo try: if nssiteIDEntry.get() == "" or nssiteDescEntry.get() == "" or nsLatEntry.get() == "" or nsLongEntry.get() == "" or nsTZEntry.get() == "" or \ - data["qc0Path"] == "": + data["qa0Path"] == "": messagebox.showerror("Error", "Bad input! Please provide all the values.") else: data["siteCode"] = nssiteIDEntry.get() @@ -157,13 +157,13 @@ def nsOK(): data["siteIdentifier"] = data["siteCode"] + "," + " " + data["siteDesc"] data["latitude"] = float(nsLatEntry.get()) data["longitude"] = float(nsLongEntry.get()) + data["elevation"] = float(nsElevVar.get()) data["timeZone"] = nsTZEntry.get() data["comments"] = comments.get("1.0", tk.END) data["integration"] = int(nsIntegVar.get()) data["plane"] = nsplaneVar.get() # data["3compFilter"] = enableVar.get() data["threshold"] = float(nsThreshVar.get()) - data["elevation"] = float(nsElevVar.get()) if nsplaneVar.get() == 1: data["plane"] = 1 @@ -176,19 +176,19 @@ def nsOK(): if nsplaneVar == 3: data["plane"] = 3 # r3.select() - # creating blank Qc0 file - f = open('dataFiles/blankQC0', 'r') + # creating blank QA0 file + f = open('dataFiles/blankQA0', 'r') rawData = f.read() f.close() f.flush rawData = rawData.replace("Site Identifier:", "Site Identifier: " + data["siteIdentifier"]) rawData = rawData.replace(" --- Latitude:", " --- Latitude: " + str(nsLatEntry.get())) - rawData = rawData.replace(" -- Longitude:", " -- Longitude: " + str(nsLongEntry.get())) - rawData = rawData.replace(" -- Time Zone:", " -- Time Zone: " + str(nsTZEntry.get())) + rawData = rawData.replace(" --- Longitude:", " --- Longitude: " + str(nsLongEntry.get())) + rawData = rawData.replace(" --- Elevation:", " --- Elevation: " + str(data["elevation"])) + rawData = rawData.replace(" --- Time Zone:", " --- Time Zone: " + str(nsTZEntry.get())) rawData = rawData.replace("Integration (minutes):", "Integration (minutes): " + str(data["integration"])) rawData = rawData.replace("Data Folder:", "Data Folder: " + data["defaultDataFolder"]) - rawData = rawData.replace("Elevation:", "Elevation: " + str(data["elevation"])) if data["plane"] == 1: plane = "0 Kt-Kn" else: @@ -202,14 +202,14 @@ def nsOK(): rawData = rawData.replace("3-Component Filter:", "3-Component Filter: " + str(data["threshold"])) rawData = rawData.replace("comments:", "comments: " + data["comments"]) - f = open(data["qc0Path"], 'w+') + f = open(data["qa0Path"], 'w+') f.write(rawData) f.close f.flush() # updating siteinfo Dict - siteInfo[data["siteIdentifier"]] = data["qc0Path"] + siteInfo[data["siteIdentifier"]] = data["qa0Path"] siteOptList.append(data["siteIdentifier"]) menu = siteOption.children["menu"] menu.delete(0, "end") @@ -232,7 +232,7 @@ def nsOK(): except ValueError: messagebox.showerror("Error", "Bad input" + nssiteIDEntry.get() + nssiteDescEntry.get() + nsLatEntry.get() + nsLongEntry.get() + nsTZEntry.get() + nsElevVar.get() + - data["qc0Path"]) + data["qa0Path"]) def nsCancel(): openRoot.deiconify() @@ -281,9 +281,9 @@ def nsCancel(): comments = tkst.ScrolledText(commentFrame) comments.place(relx=0, rely=0, relwidth=1, relheight=1) - nsqcPathLabel = tk.Label(nsFrame, text="QC0 Path", font=(None, 12), anchor="w") + nsqcPathLabel = tk.Label(nsFrame, text="QA0 Path", font=(None, 12), anchor="w") nsqcPathLabel.place(relx=0.05, rely=0.40, relwidth=0.25, relheight=0.03) - qcBrowseButton = tk.Button(nsFrame, text="Browse", command=nsQC0Browse) + qcBrowseButton = tk.Button(nsFrame, text="Browse", command=nsQA0Browse) qcBrowseButton.place(relx=0.35, rely=0.40, relwidth=0.15, relheight=0.04) # Creating defaults frame @@ -345,24 +345,24 @@ def nsCancel(): newSiteRoot.mainloop() - def browseQC0(): + def browseQA0(): global data, boundary, siteInfo - qc0Path = getQC0FilePath() - if len(qc0Path) > 1: - data["qc0Path"] = qc0Path - existQC0Data = utills.readFile(qc0Path) - index = existQC0Data.find("Site Identifier:") - string = existQC0Data[index + len("Site Identifier:"):] + qa0Path = getQA0FilePath() + if len(qa0Path) > 1: + data["qa0Path"] = qa0Path + existQA0Data = utills.readFile(qa0Path) + index = existQA0Data.find("Site Identifier:") + string = existQA0Data[index + len("Site Identifier:"):] siteID = string.split("\n") data["siteIdentifier"] = siteID[0].strip() siteOptList.append(siteID[0].strip()) - index = existQC0Data.find('Data Folder: ') - string = existQC0Data[index + len('Data Folder: '):] + index = existQA0Data.find('Data Folder: ') + string = existQA0Data[index + len('Data Folder: '):] string = string.split("\n") data["defaultDataFolder"] = string[0] # updating siteinfo Dict - siteInfo[data["siteIdentifier"]] = data["qc0Path"] + siteInfo[data["siteIdentifier"]] = data["qa0Path"] menu = siteOption.children["menu"] menu.delete(0, "end") @@ -431,9 +431,9 @@ def okOS(): monthToSave = data["month"] save(monthToSave) resetStats() - # read QC0 file - qc0dat = utills.readFile(data["qc0Path"]) - boundary = utills.getBoundariesTable(qc0dat) + # read QA0 file + qa0dat = utills.readFile(data["qa0Path"]) + boundary = utills.getBoundariesTable(qa0dat) temp = boundary data["integration"] = int(integVar.get()) @@ -537,7 +537,7 @@ def cancelOS(): newSiteButton = tk.Button(mainFrame, text="New Site", command=newSite) newSiteButton.place(relx=0.54, rely=0.2, relwidth=0.20, relheight=0.1) - newSiteBrowseButton = tk.Button(mainFrame, text="Browse", command=browseQC0) + newSiteBrowseButton = tk.Button(mainFrame, text="Browse", command=browseQA0) newSiteBrowseButton.place(relx=0.77, rely=0.2, relwidth=0.20, relheight=0.1) qcfLabel = tk.Label(mainFrame, text="QCF Data File", font=(None, 12), anchor="w") @@ -579,23 +579,23 @@ def updateSiteInfo(*args): if optVar.get() == "select a site": return else: - existQC0Data = utills.readFile(siteInfo[optVar.get()]) - latitude = utills.pickValue(existQC0Data, 'Latitude:') - longitude = utills.pickValue(existQC0Data, 'Longitude:') - timeZone = int(float(utills.pickValue(existQC0Data, 'Time Zone:'))) - elevation = float(utills.pickValue(existQC0Data, 'Elevation:')) - threshold = utills.pickValue(existQC0Data, '3-Component Filter:') + existQA0Data = utills.readFile(siteInfo[optVar.get()]) + latitude = utills.pickValue(existQA0Data, 'Latitude:') + longitude = utills.pickValue(existQA0Data, 'Longitude:') + elevation = float(utills.pickValue(existQA0Data, 'Elevation:')) + timeZone = int(float(utills.pickValue(existQA0Data, 'Time Zone:'))) + threshold = utills.pickValue(existQA0Data, '3-Component Filter:') if threshold == '': threshold = 1 else: threshold = float(threshold) data["latitude"] = latitude data["longitude"] = longitude - data["timeZone"] = int(timeZone) data["elevation"] = elevation - data["integration"] = int(utills.pickValue(existQC0Data, 'Integration (minutes):')) + data["timeZone"] = int(timeZone) + data["integration"] = int(utills.pickValue(existQA0Data, 'Integration (minutes):')) - _plane = (utills.pickValue(existQC0Data, 'Plane:')) + _plane = (utills.pickValue(existQA0Data, 'Plane:')) if _plane == "": data["plane"] = 1 else: @@ -613,159 +613,159 @@ def hitEdit(): monthToSave = data["month"] save(monthToSave) - qc0Path = getQC0FilePath() - if len(qc0Path) > 1: - QC0Data = utills.readFile(qc0Path) + qa0Path = getQA0FilePath() + if len(qa0Path) > 1: + QA0Data = utills.readFile(qa0Path) - index = QC0Data.find("Site Identifier:") - string = QC0Data[index + len("Site Identifier:"):] + index = QA0Data.find("Site Identifier:") + string = QA0Data[index + len("Site Identifier:"):] siteinf = string.split("\n") siteinf = siteinf[0].split(",") siteid = siteinf[0] siteDesc = siteinf[1] - latitude = utills.pickValue(QC0Data, 'Latitude:') - longitude = utills.pickValue(QC0Data, 'Longitude:') - timeZone = int(utills.pickValue(QC0Data, 'Time Zone:')) - elevation = float(utills.pickValue(QC0Data, 'Elevation:')) - threshold = utills.pickValue(QC0Data, '3-Component Filter:') + latitude = utills.pickValue(QA0Data, 'Latitude:') + longitude = utills.pickValue(QA0Data, 'Longitude:') + elevation = float(utills.pickValue(QA0Data, 'Elevation:')) + timeZone = int(utills.pickValue(QA0Data, 'Time Zone:')) + threshold = utills.pickValue(QA0Data, '3-Component Filter:') if threshold == 0: threshold = 1 - integration = utills.pickValue(QC0Data, 'Integration (minutes):') - plane = utills.pickValue(QC0Data, 'Plane:') - index = QC0Data.find("Data Folder: ") - string = QC0Data[index + len("Data Folder: "):] + integration = utills.pickValue(QA0Data, 'Integration (minutes):') + plane = utills.pickValue(QA0Data, 'Plane:') + index = QA0Data.find("Data Folder: ") + string = QA0Data[index + len("Data Folder: "):] defFolder = string.split("\n")[0] - index = QC0Data.find("comments:") + index = QA0Data.find("comments:") if index > 1: - comments = QC0Data[index + len("comments:"):] + comments = QA0Data[index + len("comments:"):] else: comments = "" - def editQC0Browse(): + def editQA0Browse(): - editQC0Path = tkinter.filedialog.askdirectory(parent=editQC0Root) - qc0PathLabel.config(text=editQC0Path) + editQA0Path = tkinter.filedialog.askdirectory(parent=editQA0Root, initialdir=os.getcwd()) + qa0PathLabel.config(text=editQA0Path) - def editQC0DatafolBrowse(): + def editQA0DatafolBrowse(): # global data - dfPath = tkinter.filedialog.askdirectory(parent=editQC0Root) + dfPath = tkinter.filedialog.askdirectory(parent=editQA0Root, initialdir=os.getcwd()) dfPathLabel.config(text=dfPath) - def editQC0OK(plane): + def editQA0OK(plane): # global data, siteInfo try: - if editQC0siteIDEntry.get() == "" or editQC0siteDescEntry.get() == "" or editQC0LatEntry.get() == "" or editQC0LongEntry.get() == "" or editQC0TZEntry.get() == "": + if editQA0siteIDEntry.get() == "" or editQA0siteDescEntry.get() == "" or editQA0LatEntry.get() == "" or editQA0LongEntry.get() == "" or editQA0TZEntry.get() == "": messagebox.showerror("Error", "Bad input! Please provide all the values.") else: - # creating blank Qc0 file - f = open('dataFiles/blankQC0', 'r') + # creating blank QA0 file + f = open('dataFiles/blankQA0', 'r') rawData = f.read() f.close() f.flush rawData = rawData.replace("Site Identifier:", "Site Identifier: " + str(edit_siteid.get()) + ", " + str( edit_siteDesc.get())) - rawData = rawData.replace(" --- Latitude:", " --- Latitude: " + str(editQC0LatEntry.get())) - rawData = rawData.replace(" -- Longitude:", " -- Longitude: " + str(editQC0LongEntry.get())) - rawData = rawData.replace(" -- Time Zone:", " -- Time Zone: " + str(editQC0TZEntry.get())) + rawData = rawData.replace(" --- Latitude:", " --- Latitude: " + str(editQA0LatEntry.get())) + rawData = rawData.replace(" --- Longitude:", " --- Longitude: " + str(editQA0LongEntry.get())) + rawData = rawData.replace(" --- Elevation:", " --- Elevation: " + str(editQA0ElevVar.get())) + rawData = rawData.replace(" --- Time Zone:", " --- Time Zone: " + str(editQA0TZEntry.get())) rawData = rawData.replace("Integration (minutes):", - "Integration (minutes): " + str(editQC0IntegVar.get())) + "Integration (minutes): " + str(editQA0IntegVar.get())) rawData = rawData.replace("Data Folder:", "Data Folder: " + defFolder) - rawData = rawData.replace("Elevation:", "Elevation: " + str(editQC0ElevVar.get())) - if (editQC0planeVar.get() == 1): + if (editQA0planeVar.get() == 1): plane = "0 Kt-Kn" else: - if editQC0planeVar.get() == 2: + if editQA0planeVar.get() == 2: plane = "1 Kt-Kd" else: - if editQC0planeVar.get() == 3: + if editQA0planeVar.get() == 3: plane = "2 Kn-Kd" rawData = rawData.replace("Plane:", "Plane: " + plane) # if data["3compFilter"] == 1: rawData = rawData.replace("3-Component Filter:", "3-Component Filter: " + str(threshold)) rawData = rawData.replace("comments:", "comments: " + comments) - f = open(qc0Path, 'w+') + f = open(qa0Path, 'w+') f.write(rawData) f.close f.flush() - editQC0Root.withdraw() + editQA0Root.withdraw() except ValueError: messagebox.showerror("Error", - "Bad input" + editQC0siteIDEntry.get() + editQC0siteDescEntry.get() + editQC0LatEntry.get() + editQC0LongEntry.get() + editQC0TZEntry.get() + editQC0ElevVar.get() + - data["qc0Path"]) + "Bad input" + editQA0siteIDEntry.get() + editQA0siteDescEntry.get() + editQA0LatEntry.get() + editQA0LongEntry.get() + editQA0TZEntry.get() + editQA0ElevVar.get() + + data["qa0Path"]) - def editQC0Cancel(): - editQC0Root.withdraw() + def editQA0Cancel(): + editQA0Root.withdraw() mainRoot.deiconify() # openRoot.configure(state=tk.DISABLED) - editQC0Root = tk.Tk() - editQC0Root.wm_geometry("500x600+500+250") - editQC0Root.title("Edit QC0") + editQA0Root = tk.Tk() + editQA0Root.wm_geometry("500x600+500+250") + editQA0Root.title("Edit QA0") - editQC0Frame = tk.Frame(editQC0Root) - editQC0Frame.place(relx=0, rely=0, relwidth=1, relheight=1) + editQA0Frame = tk.Frame(editQA0Root) + editQA0Frame.place(relx=0, rely=0, relwidth=1, relheight=1) - editQC0siteIDLabel = tk.Label(editQC0Frame, text="SiteID", font=(None, 12), anchor="w") - editQC0siteIDLabel.place(relx=0.05, rely=0.02, relwidth=0.2, relheight=0.03) + editQA0siteIDLabel = tk.Label(editQA0Frame, text="SiteID", font=(None, 12), anchor="w") + editQA0siteIDLabel.place(relx=0.05, rely=0.02, relwidth=0.2, relheight=0.03) - edit_siteid = tk.StringVar(editQC0Frame) - editQC0siteIDEntry = tk.Entry(editQC0Frame, font=(None, 12), textvariable=edit_siteid) - editQC0siteIDEntry.place(relx=0.05, rely=0.055, relwidth=0.2, relheight=0.04) + edit_siteid = tk.StringVar(editQA0Frame) + editQA0siteIDEntry = tk.Entry(editQA0Frame, font=(None, 12), textvariable=edit_siteid) + editQA0siteIDEntry.place(relx=0.05, rely=0.055, relwidth=0.2, relheight=0.04) edit_siteid.set(siteid) - editQC0siteDescLabel = tk.Label(editQC0Frame, text="Site Description", font=(None, 12), anchor="w") - editQC0siteDescLabel.place(relx=0.30, rely=0.02, relwidth=0.6, relheight=0.03) + editQA0siteDescLabel = tk.Label(editQA0Frame, text="Site Description", font=(None, 12), anchor="w") + editQA0siteDescLabel.place(relx=0.30, rely=0.02, relwidth=0.6, relheight=0.03) - edit_siteDesc = tk.StringVar(editQC0Frame) - editQC0siteDescEntry = tk.Entry(editQC0Frame, font=(None, 12), textvariable=edit_siteDesc) - editQC0siteDescEntry.place(relx=0.30, rely=0.055, relwidth=0.6, relheight=0.04) + edit_siteDesc = tk.StringVar(editQA0Frame) + editQA0siteDescEntry = tk.Entry(editQA0Frame, font=(None, 12), textvariable=edit_siteDesc) + editQA0siteDescEntry.place(relx=0.30, rely=0.055, relwidth=0.6, relheight=0.04) edit_siteDesc.set(siteDesc) - editQC0LatLabel = tk.Label(editQC0Frame, text="Latitude", font=(None, 12), anchor="w") - editQC0LatLabel.place(relx=0.05, rely=0.105, relwidth=0.15, relheight=0.03) + editQA0LatLabel = tk.Label(editQA0Frame, text="Latitude", font=(None, 12), anchor="w") + editQA0LatLabel.place(relx=0.05, rely=0.105, relwidth=0.15, relheight=0.03) - edit_lat = tk.StringVar(editQC0Frame) - editQC0LatEntry = tk.Entry(editQC0Frame, font=(None, 12), textvariable=edit_lat) - editQC0LatEntry.place(relx=0.05, rely=0.14, relwidth=0.15, relheight=0.04) + edit_lat = tk.StringVar(editQA0Frame) + editQA0LatEntry = tk.Entry(editQA0Frame, font=(None, 12), textvariable=edit_lat) + editQA0LatEntry.place(relx=0.05, rely=0.14, relwidth=0.15, relheight=0.04) edit_lat.set(str(latitude)) - editQC0LongLabel = tk.Label(editQC0Frame, text="Longitude", font=(None, 12), anchor="w") - editQC0LongLabel.place(relx=0.05, rely=0.19, relwidth=0.15, relheight=0.03) + editQA0LongLabel = tk.Label(editQA0Frame, text="Longitude", font=(None, 12), anchor="w") + editQA0LongLabel.place(relx=0.05, rely=0.19, relwidth=0.15, relheight=0.03) - edit_long = tk.StringVar(editQC0Frame) - editQC0LongEntry = tk.Entry(editQC0Frame, font=(None, 12), textvariable=edit_long) - editQC0LongEntry.place(relx=0.05, rely=0.225, relwidth=0.15, relheight=0.04) + edit_long = tk.StringVar(editQA0Frame) + editQA0LongEntry = tk.Entry(editQA0Frame, font=(None, 12), textvariable=edit_long) + editQA0LongEntry.place(relx=0.05, rely=0.225, relwidth=0.15, relheight=0.04) edit_long.set(str(longitude)) - editQC0TZLabel = tk.Label(editQC0Frame, text="Time Zone", font=(None, 12), anchor="w") - editQC0TZLabel.place(relx=0.05, rely=0.275, relwidth=0.15, relheight=0.03) + editQA0TZLabel = tk.Label(editQA0Frame, text="Time Zone", font=(None, 12), anchor="w") + editQA0TZLabel.place(relx=0.05, rely=0.275, relwidth=0.15, relheight=0.03) - edit_tzone = tk.StringVar(editQC0Frame) - editQC0TZEntry = tk.Entry(editQC0Frame, font=(None, 12), textvariable=edit_tzone) - editQC0TZEntry.place(relx=0.05, rely=0.31, relwidth=0.15, relheight=0.04) + edit_tzone = tk.StringVar(editQA0Frame) + editQA0TZEntry = tk.Entry(editQA0Frame, font=(None, 12), textvariable=edit_tzone) + editQA0TZEntry.place(relx=0.05, rely=0.31, relwidth=0.15, relheight=0.04) edit_tzone.set(str(timeZone)) - commentLabel = tk.Label(editQC0Frame, text="Comments", font=(None, 12), anchor="w") + commentLabel = tk.Label(editQA0Frame, text="Comments", font=(None, 12), anchor="w") commentLabel.place(relx=0.30, rely=0.105, relwidth=0.15, relheight=0.03) - commentFrame = tk.Frame(editQC0Frame, bd=1, bg="Black") + commentFrame = tk.Frame(editQA0Frame, bd=1, bg="Black") commentFrame.place(relx=0.30, rely=0.14, relwidth=0.6, relheight=0.21) commArea = tkst.ScrolledText(commentFrame) commArea.place(relx=0, rely=0, relwidth=1, relheight=1) commArea.insert(tk.INSERT, comments) - editQC0qcPathLabel = tk.Label(editQC0Frame, text="QC0 Path", font=(None, 12), anchor="w") - editQC0qcPathLabel.place(relx=0.05, rely=0.40, relwidth=0.25, relheight=0.03) - qc0PathLabel = tk.Label(editQC0Root, text=qc0Path, font=(None, 12), anchor="w") - qc0PathLabel.place(relx=0.15, rely=0.47, relwidth=0.84, relheight=0.04) - qcBrowseButton = tk.Button(editQC0Frame, text="Browse", command=editQC0Browse) + editQA0qcPathLabel = tk.Label(editQA0Frame, text="QA0 Path", font=(None, 12), anchor="w") + editQA0qcPathLabel.place(relx=0.05, rely=0.40, relwidth=0.25, relheight=0.03) + qa0PathLabel = tk.Label(editQA0Root, text=qa0Path, font=(None, 12), anchor="w") + qa0PathLabel.place(relx=0.15, rely=0.47, relwidth=0.84, relheight=0.04) + qcBrowseButton = tk.Button(editQA0Frame, text="Browse", command=editQA0Browse) qcBrowseButton.place(relx=0.35, rely=0.40, relwidth=0.15, relheight=0.04) # Creating defaults frame - defaultFrame = tk.Frame(editQC0Frame, bd=2, bg="Black") + defaultFrame = tk.Frame(editQA0Frame, bd=2, bg="Black") defaultFrame.place(relx=0.05, rely=0.55, relwidth=0.9, relheight=0.30) definFrame = tk.Frame(defaultFrame) definFrame.place(relx=0, rely=0, relwidth=1, relheight=1) @@ -773,23 +773,23 @@ def editQC0Cancel(): defLabel = tk.Label(definFrame, text="Defaults", font=(None, 16), anchor="w") defLabel.place(relx=0.03, rely=0.05, relwidth=0.18, relheight=0.15) - editQC0IntegVar = tk.StringVar(editQC0Frame) - editQC0IntegVar.set(integration) - editQC0IntegLabel = tk.Label(definFrame, text="Integration", font=(None, 12), anchor="w") - editQC0IntegLabel.place(relx=0.30, rely=0.05, relwidth=0.18, relheight=0.1) + editQA0IntegVar = tk.StringVar(editQA0Frame) + editQA0IntegVar.set(integration) + editQA0IntegLabel = tk.Label(definFrame, text="Integration", font=(None, 12), anchor="w") + editQA0IntegLabel.place(relx=0.30, rely=0.05, relwidth=0.18, relheight=0.1) integList = [1, 5, 15, 60] - editQC0integOpt = tk.OptionMenu(definFrame, editQC0IntegVar, *integList) - editQC0integOpt.place(relx=0.295, rely=0.21, relwidth=0.15, relheight=0.15) + editQA0integOpt = tk.OptionMenu(definFrame, editQA0IntegVar, *integList) + editQA0integOpt.place(relx=0.295, rely=0.21, relwidth=0.15, relheight=0.15) - editQC0PlaneLabel = tk.Label(definFrame, text="Plane", font=(None, 12)) - editQC0PlaneLabel.place(relx=0.50, rely=0.05, relwidth=0.18, relheight=0.1) + editQA0PlaneLabel = tk.Label(definFrame, text="Plane", font=(None, 12)) + editQA0PlaneLabel.place(relx=0.50, rely=0.05, relwidth=0.18, relheight=0.1) - editQC0planeVar = tk.IntVar(editQC0Frame) - rb1 = tk.Radiobutton(definFrame, text="Kt-Kn", font=(None, 12), variable=editQC0planeVar, value=1) + editQA0planeVar = tk.IntVar(editQA0Frame) + rb1 = tk.Radiobutton(definFrame, text="Kt-Kn", font=(None, 12), variable=editQA0planeVar, value=1) rb1.place(relx=0.5, rely=0.21, relwidth=0.18, relheight=0.12) - rb2 = tk.Radiobutton(definFrame, text="Kt-Kd", font=(None, 12), variable=editQC0planeVar, value=2) + rb2 = tk.Radiobutton(definFrame, text="Kt-Kd", font=(None, 12), variable=editQA0planeVar, value=2) rb2.place(relx=0.5, rely=0.34, relwidth=0.18, relheight=0.12) - rb3 = tk.Radiobutton(definFrame, text="Kn-Kd", font=(None, 12), variable=editQC0planeVar, value=3) + rb3 = tk.Radiobutton(definFrame, text="Kn-Kd", font=(None, 12), variable=editQA0planeVar, value=3) rb3.place(relx=0.5, rely=0.47, relwidth=0.18, relheight=0.12) if plane == "0 Kt-Kn": rb1.select() @@ -800,38 +800,38 @@ def editQC0Cancel(): else: rb1.select() - editQC03compLabel = tk.Label(definFrame, text="3-component Filter", font=(None, 12)) - editQC03compLabel.place(relx=0.70, rely=0.05, relwidth=0.28, relheight=0.1) + editQA03compLabel = tk.Label(definFrame, text="3-component Filter", font=(None, 12)) + editQA03compLabel.place(relx=0.70, rely=0.05, relwidth=0.28, relheight=0.1) - editQC0ThreshVar = tk.StringVar(editQC0Frame) - editQC0ThreshVar.set(str(threshold)) - editQC0ThreshOption = tk.OptionMenu(definFrame, editQC0ThreshVar, *threshList) - editQC0ThreshOption.place(relx=0.685, rely=0.21, relwidth=0.14, relheight=0.16) - # editQC0ThreshOption.configure(state=tk.DISABLED) - editQC0ThreshLabel = tk.Label(definFrame, text="Threshhold", font=(None, 12)) - editQC0ThreshLabel.place(relx=0.84, rely=0.21, relwidth=0.136, relheight=0.14) + editQA0ThreshVar = tk.StringVar(editQA0Frame) + editQA0ThreshVar.set(str(threshold)) + editQA0ThreshOption = tk.OptionMenu(definFrame, editQA0ThreshVar, *threshList) + editQA0ThreshOption.place(relx=0.685, rely=0.21, relwidth=0.14, relheight=0.16) + # editQA0ThreshOption.configure(state=tk.DISABLED) + editQA0ThreshLabel = tk.Label(definFrame, text="Threshhold", font=(None, 12)) + editQA0ThreshLabel.place(relx=0.84, rely=0.21, relwidth=0.136, relheight=0.14) dataFolderLabel = tk.Label(definFrame, text="Data Folder", anchor="w") dataFolderLabel.place(relx=0.03, rely=0.655, relwidth=0.25, relheight=0.12) dfPathLabel = tk.Label(definFrame, text=defFolder, font=(None, 12), anchor="w") dfPathLabel.place(relx=0.14, rely=0.82, relwidth=0.85, relheight=0.12) - qcBrowseButton = tk.Button(definFrame, text="Browse", command=editQC0DatafolBrowse) + qcBrowseButton = tk.Button(definFrame, text="Browse", command=editQA0DatafolBrowse) qcBrowseButton.place(relx=0.295, rely=0.655, relwidth=0.18, relheight=0.12) - editQC0ElevLabel = tk.Label(definFrame, text="Elevation", anchor="w") - editQC0ElevLabel.place(relx=0.5, rely=0.655, relwidth=0.18, relheight=0.12) - editQC0ElevVar = tk.StringVar(editQC0Frame) - editQC0ElevEntry = tk.Entry(definFrame, font=(None, 12), textvariable=editQC0ElevVar) - editQC0ElevEntry.place(relx=0.695, rely=0.67, relwidth=0.15, relheight=0.15) - editQC0ElevVar.set(str(elevation)) + editQA0ElevLabel = tk.Label(definFrame, text="Elevation", anchor="w") + editQA0ElevLabel.place(relx=0.5, rely=0.655, relwidth=0.18, relheight=0.12) + editQA0ElevVar = tk.StringVar(editQA0Frame) + editQA0ElevEntry = tk.Entry(definFrame, font=(None, 12), textvariable=editQA0ElevVar) + editQA0ElevEntry.place(relx=0.695, rely=0.67, relwidth=0.15, relheight=0.15) + editQA0ElevVar.set(str(elevation)) - editQC0OKButton = tk.Button(editQC0Frame, text="OK", command=partial(editQC0OK, plane)) - editQC0OKButton.place(relx=0.50, rely=0.90, relwidth=0.20, relheight=0.05) - editQC0CancelButton = tk.Button(editQC0Frame, text="Cancel", command=editQC0Cancel) - editQC0CancelButton.place(relx=0.75, rely=0.90, relwidth=0.20, relheight=0.05) - editQC0Root.iconbitmap('dataFiles/qcfit-icon.ico') - editQC0Root.protocol("WM_DELETE_WINDOW", editQC0Cancel) - editQC0Root.mainloop() + editQA0OKButton = tk.Button(editQA0Frame, text="OK", command=partial(editQA0OK, plane)) + editQA0OKButton.place(relx=0.50, rely=0.90, relwidth=0.20, relheight=0.05) + editQA0CancelButton = tk.Button(editQA0Frame, text="Cancel", command=editQA0Cancel) + editQA0CancelButton.place(relx=0.75, rely=0.90, relwidth=0.20, relheight=0.05) + editQA0Root.iconbitmap('dataFiles/qcfit-icon.ico') + editQA0Root.protocol("WM_DELETE_WINDOW", editQA0Cancel) + editQA0Root.mainloop() def plotUpdateThroughMonth(*args): @@ -919,27 +919,21 @@ def curvefitting(): for df in (pdLow, pdMed, pdHigh): df.loc[(df["residual"] > data["threshold"]), flag] = 0 - # calculate max values of K space - first read from QC0 if not present then find out - - knMax = boundary[boundary["month"] == data["month"][:3].upper()] - knMax = int(list(knMax["MC_KN"])[0]) - ktMax = boundary[boundary["month"] == data["month"][:3].upper()] - ktMax = int(list(ktMax["MC_KT_" + str(data["integration"])])[0]) - - # global airmass throttles for kt and kn maximus - am_thrott_kt = [0, 3, 10] - am_thrott_kn = [0, 5, 15] + # calculate max values of K space for each airmass + # Read corresponding columns first + month_content = boundary[boundary["month"] == data["month"][:3].upper()] amass = ["low", "med", "high"] - for n, am in enumerate(amass): - data[am + "AM"]["knMax"] = knMax - am_thrott_kn[n] - data[am + "AM"]["ktMax"] = ktMax - am_thrott_kt[n] + amass_acro = ["LA", "MA", "HA"] + for am, am_acro in zip(amass, amass_acro): + data[am + "AM"]["knMax"] = int(list(month_content[am_acro + "_MAX_KN"])[0]) + data[am + "AM"]["ktMax"] = int(list(month_content[am_acro + "_MAX_KT"])[0]) - for i, df, amass in zip([0, 1, 2], [pdLow, pdMed, pdHigh], amass): + for df, am in zip([pdLow, pdMed, pdHigh], amass): # reduce maximus according to the airmass - knMax = data[amass + "AM"]["knMax"] - ktMax = data[amass + "AM"]["ktMax"] - knMax = int(knMax) # - int(am_thrott_kn[i]) - ktMax = int(ktMax) # - int(am_thrott_kt[i]) + knMax = data[am + "AM"]["knMax"] + ktMax = data[am + "AM"]["ktMax"] + knMax = int(knMax) + ktMax = int(ktMax) if (knMax < 1) or (ktMax < 1): for k in (["KT", "KN"]): @@ -957,13 +951,8 @@ def curvefitting(): knMax = maxVal # now update the data dictionary - data[amass + "AM"]["ktMax"] = ktMax - data[amass + "AM"]["knMax"] = knMax - # data[amass + "AM"]["kdMax"] = kdMax - - # now update the data dictionary - data[amass + "AM"]["ktMax"] = ktMax - data[amass + "AM"]["knMax"] = knMax + data[am + "AM"]["ktMax"] = ktMax + data[am + "AM"]["knMax"] = knMax def getBoundaries(): @@ -972,45 +961,28 @@ def getBoundaries(): areaLeft = cAr.getArea("left") areaRight = cAr.getArea("right") airmasses = ["low", "med", "high"] + airmasses_acro = ["LA", "MA", "HA"] dataFrames = [pdLow, pdMed, pdHigh] location = [lowCanvas, medCanvas, highCanvas] - for amass, dframe, location in zip(airmasses, dataFrames, location): + for dim, (amass, am_acro, dframe, location) in enumerate(zip(airmasses, airmasses_acro, dataFrames, location)): # identifying column names in Boundary dataframe - if amass == "low": - boundShapeL = "LA_Left_S" - boundPosL = "LA_Left_P" - boundShapeR = "LA_Right_S" - boundPosR = "LA_Right_" - dim = 0 - elif amass == "med": - boundShapeL = "MA_Left_S" - boundPosL = "MA_Left_P" - boundShapeR = "MA_Right_S" - boundPosR = "MA_Right_" - dim = 1 - elif amass == "high": - boundShapeL = "HA_Left_S" - boundPosL = "HA_Left_P" - boundShapeR = "HA_Right_S" - boundPosR = "HA_Right_" - dim = 2 - - shapeL = boundary[boundary["month"] == data["month"][:3].upper()] - shapeL = list(shapeL[boundShapeL])[0] - posL = boundary[boundary["month"] == data["month"][:3].upper()] - posL = list(posL[boundPosL])[0] - shapeR = boundary[boundary["month"] == data["month"][:3].upper()] - shapeR = list(shapeR[boundShapeR])[0] - posR = boundary[boundary["month"] == data["month"][:3].upper()] - posR = list(posR[boundPosR + str(data["integration"])])[0] + boundShapeL = am_acro + "_Left_S" + boundPosL = am_acro + "_Left_P" + boundShapeR = am_acro + "_Right_S" + boundPosR = am_acro + "_Right_P" - # updating the data dictionary + month_content = boundary[boundary["month"] == data["month"][:3].upper()] + shapeL = int(list(month_content[boundShapeL])[0]) + posL = int(list(month_content[boundPosL])[0]) + shapeR = int(list(month_content[boundShapeR])[0]) + posR = int(list(month_content[boundPosR])[0]) - shapeL = data[amass + "AM"]["shapeLeft"] = int(shapeL) - positionL = data[amass + "AM"]["posLeft"] = int(posL) - shapeR = data[amass + "AM"]["shapeRight"] = int(shapeR) - positionR = data[amass + "AM"]["posRight"] = int(posR) + # updating the data dictionary + data[amass + "AM"]["shapeLeft"] = shapeL + data[amass + "AM"]["posLeft"] = posL + data[amass + "AM"]["shapeRight"] = shapeR + data[amass + "AM"]["posRight"] = posR # identify flag and axes based on kspaces if data["plane"] == 1: @@ -3435,12 +3407,12 @@ def save(month): if iterCount == 0: messagebox.showerror("Error", "Sorry, No data available to save.") return - fileQC = open(data["qc0Path"], "r") + fileQC = open(data["qa0Path"], "r") content = fileQC.read().splitlines() fileQC.close() # fileQC.flush() - # update QC0 data + # update QA0 data position = monList.index(month) + 9 # locating month string = content[position] @@ -3562,7 +3534,7 @@ def save(month): string = " ".join(string) content[position] = string content = "\n".join(content) - fid = open(data["qc0Path"], 'w') + fid = open(data["qa0Path"], 'w') if data["plane"] == 1: plane = "0 Kt-Kn" @@ -3716,7 +3688,7 @@ def callSave(): file = tk.Menu(menuBar, tearoff=0) file.add_command(label="Open", command=hitOpen) file.add_separator() -file.add_command(label="Edit QC0", command=hitEdit) +file.add_command(label="Edit QA0", command=hitEdit) file.add_separator() file.add_command(label="Save", command=callSave) file.add_command(label="Save BMP Image", command=saveBmp) @@ -3735,7 +3707,7 @@ def callSave(): # Variables and lists # #################################################### -data = {'qc0Path': '', 'defaultDataFolder': '', 'siteCode': '', 'siteDesc': '', 'siteIdentifier': '', 'latitude': 0.0, +data = {'qa0Path': '', 'defaultDataFolder': '', 'siteCode': '', 'siteDesc': '', 'siteIdentifier': '', 'latitude': 0.0, 'longitude': 0.0, 'timeZone': 0, 'elevation': 0.0, 'comments': '', 'integration': 1, 'plane': '', '3compFilter': '', 'threshold': 0.05, 'QCFDataFilepath': '', 'month': '', 'year': '', 'editWinFlag': 0, 'listPageFlag': 0, 'flag': 'activeKtKn', 'xAxis': 'KT', 'yAxis': 'KN', 'x1': 0, 'x2': 0, 'y1': 0, 'y2': 0, diff --git a/SERI-QC_with_QCFIT/seriqc_script.py b/SERI-QC_with_QCFIT/seriqc_script.py index 36ab5e3..d4155cf 100644 --- a/SERI-QC_with_QCFIT/seriqc_script.py +++ b/SERI-QC_with_QCFIT/seriqc_script.py @@ -759,11 +759,9 @@ def main(): # Getting input file paths ################################# - # path_QC0 = "/Users/rgupta2/Desktop/s_BMS.QC0" - # path_csv = "/Users/rgupta2/Desktop/minute edited.csv" - - path_QC0 = frm.getPath("qc0") - # frm.validateFile(path_QC0, '.QC0', '.qc0') + + path_QA0 = frm.getPath("qa0") + # frm.validateFile(path_QA0, '.QA0', '.qa0') path_csv = frm.getPath("csv") # frm.validateFile(path_csv, '.csv', '.csv') @@ -773,7 +771,7 @@ def main(): ################################# - qcData = utills.readFile(path_QC0) + qcData = utills.readFile(path_QA0) ipData = pd.read_csv(path_csv) @@ -824,7 +822,7 @@ def main(): curveLeft = utills.curveLeft curveRight = utills.curveRight Alog_4 = 1.386294361 - XDm = (0.19, 0.22, 0.24, 0.28, 0.32) + XDm = (0.19, 0.22, 0.24, 0.28, 0.32, 0.25) splitDate(ipData) ipData = ipData.merge(boundData, left_on='month', right_on='month') @@ -1019,7 +1017,7 @@ def main(): ipData.loc[(ipData['NAM'] == 2),'AMass'] = 'MA' ipData.loc[(ipData['NAM'] == 3),'AMass'] = 'HA''' - '''intBin is an integer from 1 to 4, signifying the place of the digit containing the information in the S_.QC0 file. If data approximate 1-minute resolution, 1 is chosen; if the resolution approximates 64 minutes, 4 is chosen. interval should be bounded by 1 and 60.''' + '''intBin is an integer from 1 to 4, signifying the place of the digit containing the information in the S_.QA0 file. If data approximate 1-minute resolution, 1 is chosen; if the resolution approximates 64 minutes, 4 is chosen. interval should be bounded by 1 and 60.''' iRes = max(interval, 1) iRes = min(iRes, 60) @@ -1034,7 +1032,7 @@ def main(): elif intBin == 4: pos = '60' - '''The Gompertz curve numbers were read from the .QC0 file. "l" stands for "left" and "r" stands for "right". + '''The Gompertz curve numbers were read from the .QA0 file. "l" stands for "left" and "r" stands for "right". "I" represents the shape and "J" represents the position. ''' ipData['Il'] = 0 @@ -1113,6 +1111,21 @@ def main(): ipData.loc[(ipData['goAhead'] == 1) & (ipData['IQCDiffuse'] < 99) & (ipData['XD'] >= 0.03) & ( ipData['XD'] > ipData['XDmax']), 'IQCDiffuse'] = 8 + # Rayleigh test: only evaluate diffuse values that passed physical limit tests. + rayleigh_mask = (ipData['goAhead'] == 1) & (Global > 50.0) & (ipData['IQCDiffuse'] == 1) + cz = ipData['cos(solzen*deg2rad)'] + rayleigh_limit = ( + 209.3 * cz + - 708.3 * (cz ** 2) + + 1128.7 * (cz ** 3) + - 911.2 * (cz ** 4) + + 287.85 * (cz ** 5) + - 0.046725 * cz * pressure + - 1.0 + ) + ipData.loc[rayleigh_mask & (Diffuse < rayleigh_limit), 'IQCDiffuse'] = 5 + + '''Go no further if the solar zenith angle is greater than 80 degrees. However, don't use a flag of 7 if the GLOBAL or DIFFUSE are not less than -10 W/sq m (thermocouple response effect). Also, if the ETR is 25 W/sq m or less, a GLOBAL value of 10 W/sq m should not be considered too high.''' ipData.loc[(ipData['goAhead'] == 1) & (ipData['solzen'] > 80) & (ipData['IQCGlobal'] == 7) & ( @@ -1178,26 +1191,26 @@ def main(): ipData.loc[(ipData['numpar'] == 3) & (ipData['IQC'] < 0), 'iTog'] = -1 ipData.loc[(ipData['numpar'] == 3) & (ipData['IQC'] < 0), 'IQC'] = -ipData['IQC'] - ipData['IQC0'] = 0 - ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3), 'IQC0'] = [min(i, 23) for i in ipData[ + ipData['IQA0'] = 0 + ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3), 'IQA0'] = [min(i, 23) for i in ipData[ (ipData['goAhead'] == 1) & (ipData['numpar'] == 3)]['IQC']] - ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3), 'IQC0'] = 4 * ipData['IQC0'] - 1 + ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3), 'IQA0'] = 4 * ipData['IQA0'] - 1 - ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['iTog'] == 1), 'IQC0'] = ipData['IQC0'] - 1 + ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['iTog'] == 1), 'IQA0'] = ipData['IQA0'] - 1 - # IQC1 has to take on the opposite sense (TOO HIGH/TOO LOW) from IQC0. + # IQC1 has to take on the opposite sense (TOO HIGH/TOO LOW) from IQA0. ipData['IQC1'] = 0 - ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3), 'IQC1'] = ipData['IQC0'] + ipData['iTog'] + ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3), 'IQC1'] = ipData['IQA0'] + ipData['iTog'] '''The deviation (IQC) is significant enough to be flagged. IQCt3, being on the left side of the equation, gets flagged in a different direction from the other two.''' - '''ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCGlo3'] = ipData['IQC0'] + '''ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCGlo3'] = ipData['IQA0'] ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCDir3'] = ipData['IQC1'] ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCDif3'] = ipData['IQC1']''' - ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCGlobal'] = ipData['IQC0'] + ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCGlobal'] = ipData['IQA0'] ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCDirect'] = ipData['IQC1'] ipData.loc[(ipData['goAhead'] == 1) & (ipData['numpar'] == 3) & (ipData['IQC'] >= 3), 'IQCDiffuse'] = ipData['IQC1'] diff --git a/SERI-QC_with_QCFIT/utills.py b/SERI-QC_with_QCFIT/utills.py index 2510505..77db99f 100644 --- a/SERI-QC_with_QCFIT/utills.py +++ b/SERI-QC_with_QCFIT/utills.py @@ -11,7 +11,7 @@ import os -def readFile(name): # pass the *.qc0 file name +def readFile(name): # pass the *.qa0 file name f = (open(name, 'r')) val = (f.read()) return val @@ -62,10 +62,9 @@ def getBoundariesTable(data): table = pd.DataFrame({'data': data}) - columns = ['month', 'MC_KN', 'MC_KT_1', 'MC_KT_5', 'MC_KT_15', 'MC_KT_60', 'LA_Left_S', 'LA_Left_P', 'LA_Right_S', - 'LA_Right_1', 'LA_Right_5', 'LA_Right_15', 'LA_Right_60', 'MA_Left_S', 'MA_Left_P', 'MA_Right_S', - 'MA_Right_1', 'MA_Right_5', 'MA_Right_15', 'MA_Right_60', 'HA_Left_S', 'HA_Left_P', 'HA_Right_S', - 'HA_Right_1', 'HA_Right_5', 'HA_Right_15', 'HA_Right_60'] + columns = ['month', 'LA_MAX_KN', 'LA_MAX_KT', 'LA_Left_S', 'LA_Left_P', 'LA_Right_S', 'LA_Right_P', + 'MA_MAX_KN', 'MA_MAX_KT', 'MA_Left_S', 'MA_Left_P', 'MA_Right_S', 'MA_Right_P', + 'HA_MAX_KN', 'HA_MAX_KT', 'HA_Left_S', 'HA_Left_P', 'HA_Right_S', 'HA_Right_P'] table[columns] = table['data'].str.split(',', expand=True) table = table.iloc[:, 1:] @@ -151,7 +150,18 @@ def minX(i, j): 49.1, 49.9, 50.7, 51.5, 52.3, 53.2, 54.1, 55.0, 55.9, 56.9, 57.8, 58.9, 59.9, 61.0, 62.2, 63.4, 64.6, 65.9, 67.3, 68.7, 70.3, 71.9, 73.6, 75.5, 77.5, 79.7, 82.2, 84.9, 88.0, 91.5, - 95.8, 101.0, 107.8, 117.8, 136.8, 999.9, 999.9, 999.9, 999.9, 999.9]]) + 95.8, 101.0, 107.8, 117.8, 136.8, 999.9, 999.9, 999.9, 999.9, 999.9], + + [-60.0,-60.0,-6.0,-4.4, -2.7, -1.1, 0.4, 2.0, 3.4, 4.9, + 6.3, 7.7, 9.0, 10.3, 11.6, 12.8, 14.0, 15.2, 16.3, 17.5, + 18.6, 19.6, 20.7, 21.7, 22.6, 23.6, 24.5, 25.5, 26.4, 27.2, + 28.1, 28.9, 29.7, 30.5, 31.3, 32.1, 32.8, 33.6, 34.3, 35.0, + 35.7, 36.4, 37.1, 37.7, 38.4, 39.0, 39.7, 40.3, 40.9, 41.6, + 42.2, 42.8, 43.4, 44.1, 44.7, 45.3, 45.9, 46.5, 47.1, 47.8, + 48.4, 49.0, 49.7, 50.3, 51.0, 51.6, 52.3, 53.0, 53.7, 54.4, + 55.1, 55.8, 56.6, 57.4, 58.1, 58.9, 59.7, 60.6, 61.4, 62.3, + 63.2, 64.1, 65.0, 65.9, 66.9, 67.9, 69.0, 70.0, 71.1, 72.2, + 73.3, 74.5, 75.7, 76.9, 78.2, 79.5, 80.8, 82.2, 83.6, 85.0]]) curveRight = np.array([ [13.4, 17.2, 19.6, 21.5, 23.1, 24.5, 25.8, 26.9, 27.9, 28.9, @@ -207,5 +217,16 @@ def minX(i, j): 53.4, 53.7, 54.1, 54.4, 54.7, 55.1, 55.5, 55.8, 56.2, 56.6, 57.0, 57.4, 57.8, 58.2, 58.7, 59.2, 59.6, 60.1, 60.7, 61.2, 61.8, 62.4, 63.0, 63.7, 64.4, 65.2, 66.0, 66.9, 67.8, 68.9, - 70.1, 71.4, 73.0, 74.8, 77.0, 80.0, 84.2, 91.9, 999.9, 999.9] + 70.1, 71.4, 73.0, 74.8, 77.0, 80.0, 84.2, 91.9, 999.9, 999.9], + + [13.1, 14.5, 15.8, 17.1, 18.3, 19.6, 20.8, 21.9, 23.0, 24.1, + 25.2, 26.2, 27.3, 28.2, 29.2, 30.1, 31.1, 32.0, 32.8, 33.7, + 34.5, 35.3, 36.1, 36.9, 37.6, 38.4, 39.1, 39.8, 40.5, 41.2, + 41.9, 42.5, 43.2, 43.8, 44.4, 45.1, 45.7, 46.3, 46.9, 47.5, + 48.1, 48.7, 49.3, 49.9, 50.5, 51.0, 51.6, 52.2, 52.8, 53.4, + 54.0, 54.6, 55.2, 55.9, 56.5, 57.1, 57.8, 58.4, 59.1, 59.8, + 60.5, 61.2, 61.9, 62.6, 63.4, 64.1, 64.9, 65.7, 66.5, 67.4, + 68.2, 69.1, 70.0, 71.0, 71.9, 72.9, 73.9, 74.9, 76.0, 77.1, + 78.2, 79.3, 80.5, 81.7, 83.0, 84.2, 85.5, 86.9, 88.2, 89.7, + 91.1, 92.6, 94.1, 95.7, 97.3, 98.9,100.6,102.4,104.1,106.0] ])