コード例 #1
0
def create_chan(dir_path, ts_start_date, flo2d_model):

    set_db_config_file_path(
        os.path.join(ROOT_DIRECTORY, 'db_adapter_config.json'))

    try:

        # Load config details and db connection params
        config = json.loads(
            open(os.path.join(os.getcwd(), 'chan', "config.json")).read())

        start_time = ts_start_date

        output_dir = dir_path
        file_name = read_attribute_from_config_file('output_file_name', config)

        if flo2d_model is None:
            flo2d_model = "flo2d_250"
        elif flo2d_model not in ("flo2d_250", "flo2d_150"):
            print(
                "Flo2d model should be either \"flo2d_250\" or \"flo2d_150\"")
            exit(1)

        if start_time is None:
            start_time = (datetime.now() -
                          timedelta(days=2)).strftime('%Y-%m-%d 00:00:00')
        else:
            check_time_format(time=start_time)

        if output_dir is not None and file_name is not None:
            chan_file_path = os.path.join(output_dir, file_name)
        else:
            chan_file_path = os.path.join(
                r"D:\chan",
                '{}_{}_{}.DAT'.format(file_name, flo2d_model,
                                      start_time).replace(' ', '_').replace(
                                          ':', '-'))

        if not os.path.isfile(chan_file_path):
            print("{} start preparing chan".format(datetime.now()))
            prepare_chan(chan_file_path,
                         start=start_time,
                         flo2d_model=flo2d_model)
            print("{} completed preparing chan".format(datetime.now()))
        else:
            print('Chan file already in path : ', chan_file_path)

    except Exception:
        traceback.print_exc()
コード例 #2
0
                == FLO2D_30) and time.strftime('%M') not in ('15', '30', '45',
                                                             '00'):
            print(
                "Minutes should be multiple of 15 for flo2d_150 and flo2d_30")
            exit(1)

        return True
    except Exception:
        traceback.print_exc()
        print("Time {} is not in proper format".format(time))
        exit(1)


if __name__ == "__main__":

    set_db_config_file_path(
        '/home/curw/event_sim_utils/db_adapter_config.json')

    HOST = con_params.CURW_SIM_HOST
    USER = con_params.CURW_SIM_USERNAME
    PASSWORD = con_params.CURW_SIM_PASSWORD
    DB = con_params.CURW_SIM_DATABASE
    PORT = con_params.CURW_SIM_PORT

    try:
        start_time = None
        end_time = None
        model = None
        method = None
        option = None
        event_sim = False
コード例 #3
0

def usage():
    usageText = """
    Usage: ./inputs/gen_mike_input_rf_linux.py [-s "YYYY-MM-DD HH:MM:SS"] [-e "YYYY-MM-DD HH:MM:SS"]

    -h  --help          Show usage
    -s  --start_time    Mike rainfall timeseries start time (e.g: "2019-06-05 00:00:00"). Default is 00:00:00, 3 days before today.
    -e  --end_time      Mike rainfall timeseries end time (e.g: "2019-06-05 23:00:00"). Default is 00:00:00, 2 days after.
    """
    print(usageText)


if __name__ == "__main__":

    set_db_config_file_path(
        os.path.join(ROOT_DIRECTORY, 'db_adapter_config.json'))

    try:

        start_time = None
        end_time = None

        try:
            opts, args = getopt.getopt(sys.argv[1:], "h:s:e:",
                                       ["help", "start_time=", "end_time="])
        except getopt.GetoptError:
            usage()
            sys.exit(2)
        for opt, arg in opts:
            if opt in ("-h", "--help"):
                usage()
コード例 #4
0
                == FLO2D_150_v2) and time.strftime('%M') not in ('15', '30',
                                                                 '45', '00'):
            print(
                "Minutes should be multiple of 15 for flo2d_150 and flo2d_30")
            exit(1)

        return True
    except Exception:
        traceback.print_exc()
        print("Time {} is not in proper format".format(time))
        exit(1)


if __name__ == "__main__":

    set_db_config_file_path(
        '/home/uwcc-admin/curw_sim_db_utils/db_adapter_config.json')

    HOST = con_params.CURW_SIM_HOST
    USER = con_params.CURW_SIM_USERNAME
    PASSWORD = con_params.CURW_SIM_PASSWORD
    DB = con_params.CURW_SIM_DATABASE
    PORT = con_params.CURW_SIM_PORT

    try:
        start_time = None
        end_time = None
        model = None
        option = None

        try:
            opts, args = getopt.getopt(