예제 #1
0
def do_levels_batch(cf_batch):
    batch_log_path = pfp_log.get_batch_log_path("logfiles")
    batch_log_file_name = os.path.join(batch_log_path, "batch.log")
    logger = pfp_log.init_logger("pfp_log", batch_log_file_name, to_file=True, to_screen=True)
    start = datetime.datetime.now()
    msg = " Started batch processing at " + start.strftime("%Y%m%d%H%M")
    logger.info(msg)
    if "Options" in cf_batch:
        if "levels" in cf_batch["Options"]:
            levels = pfp_cfg.cfg_string_to_list(cf_batch["Options"]["levels"])
        else:
            msg = "No 'levels' entry found in [Options] section"
            logger.error(msg)
            sys.exit()
    else:
        msg = "No [Options] section in control file"
        logger.error(msg)
        sys.exit()
    processing_levels = ["l1", "l2", "l3",
                         "ecostress", "fluxnet", "reddyproc",
                         "concatenate", "climatology",
                         "cpd1", "cpd2", "mpt",
                         "l4", "l5", "l6"]
    for level in levels:
        if level.lower() not in processing_levels:
            msg = "Unrecognised level " + level
            logger.warning(msg)
            continue
        if level.lower() == "l1":
            # L1 processing
            do_L1_batch(cf_batch["Levels"][level])
        elif level.lower() == "l2":
            # L2 processing
            do_L2_batch(cf_batch["Levels"][level])
        elif level.lower() == "l3":
            # L3 processing
            do_L3_batch(cf_batch["Levels"][level])
        elif level.lower() == "ecostress":
            # convert netCDF files to ECOSTRESS CSV files
            do_ecostress_batch(cf_batch["Levels"][level])
        elif level.lower() == "fluxnet":
            # convert netCDF files to FluxNet CSV files
            do_fluxnet_batch(cf_batch["Levels"][level])
        elif level.lower() == "reddyproc":
            # convert netCDF files to REddyProc CSV files
            do_reddyproc_batch(cf_batch["Levels"][level])
        elif level.lower() == "concatenate":
            # concatenate netCDF files
            do_concatenate_batch(cf_batch["Levels"][level])
        elif level.lower() == "climatology":
            # climatology
            do_climatology_batch(cf_batch["Levels"][level])
        elif level.lower() == "cpd1":
            # ustar threshold from change point detection
            do_cpd1_batch(cf_batch["Levels"][level])
        elif level.lower() == "cpd2":
            # ustar threshold from change point detection
            do_cpd2_batch(cf_batch["Levels"][level])
        elif level.lower() == "mpt":
            # ustar threshold from change point detection
            do_mpt_batch(cf_batch["Levels"][level])
        elif level.lower() == "l4":
            # L4 processing
            do_L4_batch(cf_batch["Levels"][level])
        elif level.lower() == "l5":
            # L5 processing
            do_L5_batch(cf_batch["Levels"][level])
        elif level.lower() == "l6":
            # L6 processing
            do_L6_batch(cf_batch["Levels"][level])
    logger = pfp_log.change_logger_filename("pfp_log", "batch")
    end = datetime.datetime.now()
    msg = " Finished batch processing at " + end.strftime("%Y%m%d%H%M")
    logger.info(msg)
    return
예제 #2
0
# next we make sure the MPT directories are present ...
dir_list = ["./mpt/input", "./mpt/log", "./mpt/output"]
for item in dir_list:
    if not os.path.exists(item):
        os.makedirs(item)
# ... and make sure the MDS directories are present
dir_list = ["./mds/input", "./mds/log", "./mds/output"]
for item in dir_list:
    if not os.path.exists(item):
        os.makedirs(item)

now = datetime.datetime.now()
log_file_name = "pfp_" + now.strftime("%Y%m%d%H%M") + ".log"
log_file_name = os.path.join("./logfiles", log_file_name)
logger = pfp_log.init_logger("pfp_log",
                             log_file_name,
                             to_file=True,
                             to_screen=False)


class pfp_main_ui(QtWidgets.QWidget):
    def __init__(self, pfp_version):
        super(pfp_main_ui, self).__init__()

        logTextBox = pfp_log.QPlainTextEditLogger(self)
        logger.addHandler(logTextBox)

        # menu bar
        self.menubar = QtWidgets.QMenuBar(self)
        # File menu
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setTitle("File")
예제 #3
0
import sys
sys.path.append('scripts')
import time
import pfp_clim
import pfp_cpd
import pfp_io
import pfp_log
import pfp_ls
import pfp_plot
import pfp_utils

t = time.localtime()
rundatetime = datetime.datetime(t[0], t[1], t[2], t[3], t[4],
                                t[5]).strftime("%Y%m%d%H%M")
log_file_name = 'batchprocess_' + rundatetime + '.log'
logger = pfp_log.init_logger(logger_name="pfp_log",
                             log_file_name=log_file_name)

# get the batch processing control file
if len(sys.argv) == 1:
    cf_batch = pfp_io.load_controlfile(path='controlfiles')
    if len(cf_batch) == 0: sys.exit()
else:
    cfname = sys.argv[1]
    if os.path.exists(cfname):
        cf_batch = pfp_io.get_controlfilecontents(cfname)
    else:
        logger.error("Control file " + cfname + " does not exist")
        sys.exit()

level_list = [
    'L1', 'L2', 'L3', 'concatenate', 'climatology', 'cpd', 'L4', 'L5', 'L6'