def do_L1_batch(main_ui, cf_level): for i in list(cf_level.keys()): # check the stop flag if main_ui.stop_flag: # break out of the loop if user requested stop break cf_file_name = os.path.split(cf_level[i]) msg = "Starting L1 processing with " + cf_file_name[1] logger.info(msg) if not check_file_exits(cf_level[i]): return 0 try: cf_l1 = pfp_io.get_controlfilecontents(cf_level[i]) if not pfp_compliance.l1_update_controlfile(cf_l1): continue ds1 = pfp_levels.l1qc(cf_l1) outfilename = pfp_io.get_outfilenamefromcf(cf_l1) pfp_io.NetCDFWrite(outfilename, ds1) msg = "Finished L1 processing with " + cf_file_name[1] logger.info(msg) logger.info("") except Exception: msg = "Error occurred during L1 processing " + cf_file_name[1] logger.error(msg) error_message = traceback.format_exc() logger.error(error_message) continue return 1
def do_L2_batch(main_ui, cf_level): for i in list(cf_level.keys()): # check the stop flag if main_ui.stop_flag: # break out of the loop if user requested stop break cf_file_name = os.path.split(cf_level[i]) msg = "Starting L2 processing with " + cf_file_name[1] logger.info(msg) if not check_file_exits(cf_level[i]): return 0 try: cf_l2 = pfp_io.get_controlfilecontents(cf_level[i]) if not pfp_compliance.l2_update_controlfile(cf_l2): continue if "Options" not in cf_l2: cf_l2["Options"] = {} cf_l2["Options"]["call_mode"] = "batch" cf_l2["Options"]["show_plots"] = "No" infilename = pfp_io.get_infilenamefromcf(cf_l2) ds1 = pfp_io.NetCDFRead(infilename) if ds1.info["returncodes"]["value"] != 0: return ds2 = pfp_levels.l2qc(cf_l2, ds1) outfilename = pfp_io.get_outfilenamefromcf(cf_l2) pfp_io.NetCDFWrite(outfilename, ds2) msg = "Finished L2 processing with " + cf_file_name[1] logger.info(msg) if "Plots" in list(cf_l2.keys()): logger.info("Plotting L1 and L2 data") for nFig in list(cf_l2['Plots'].keys()): if "(disabled)" in nFig: continue plt_cf = cf_l2['Plots'][str(nFig)] if 'type' in plt_cf.keys(): if str(plt_cf['type']).lower() == 'xy': pfp_plot.plotxy(cf_l2, nFig, plt_cf, ds1, ds2) else: pfp_plot.plottimeseries(cf_l2, nFig, ds1, ds2) else: pfp_plot.plottimeseries(cf_l2, nFig, ds1, ds2) logger.info("Finished plotting L1 and L2 data") logger.info("") except Exception: msg = "Error occurred during L2 processing " + cf_file_name[1] logger.error(msg) error_message = traceback.format_exc() logger.error(error_message) continue return 1
def do_batch_fingerprints(cfg): """ Purpose: Plot fingerprints at the end of conatenation, L4 and L5. Author: PRI Date: Back in the day """ cfg_fp_uri = os.path.join("controlfiles", "standard", "fingerprint.txt") cfg_fp = pfp_io.get_controlfilecontents(cfg_fp_uri) file_name = pfp_io.get_outfilenamefromcf(cfg) file_path = os.path.join(os.path.split(file_name)[0], "") plot_path = pfp_utils.get_keyvaluefromcf(cfg, ["Files"], "plot_path", default="plots/") cfg_fp["Files"] = {"file_path": file_path, "in_filename": os.path.split(file_name)[1], "plot_path": plot_path} cfg_fp["Options"] = {"call_mode": "batch", "show_plots": "No"} msg = "Doing fingerprint plots using " + cfg_fp["Files"]["in_filename"] logger.info(msg) pfp_plot.plot_fingerprint(cfg_fp) logger.info("Finished fingerprint plots") return
def do_L5_batch(main_ui, cf_level): sites = sorted(list(cf_level.keys()), key=int) for i in sites: # check the stop flag if main_ui.stop_flag: # break out of the loop if user requested stop break cf_file_name = os.path.split(cf_level[i]) msg = "Starting L5 processing with " + cf_file_name[1] logger.info(msg) if not check_file_exits(cf_level[i]): return 0 try: cf_l5 = pfp_io.get_controlfilecontents(cf_level[i]) if not pfp_compliance.l5_update_controlfile(cf_l5): continue if "Options" not in cf_l5: cf_l5["Options"] = {} cf_l5["Options"]["call_mode"] = "batch" cf_l5["Options"]["show_plots"] = "No" infilename = pfp_io.get_infilenamefromcf(cf_l5) ds4 = pfp_io.NetCDFRead(infilename) if ds4.info["returncodes"]["value"] != 0: return ds5 = pfp_levels.l5qc(None, cf_l5, ds4) outfilename = pfp_io.get_outfilenamefromcf(cf_l5) pfp_io.NetCDFWrite(outfilename, ds5) msg = "Finished L5 processing with " + cf_file_name[1] logger.info(msg) # do the CF compliance check #do_batch_cfcheck(cf_l5) # plot the L5 fingerprints do_batch_fingerprints(cf_l5) logger.info("") except Exception: msg = "Error occurred during L5 with " + cf_file_name[1] logger.error(msg) error_message = traceback.format_exc() logger.error(error_message) continue return 1