port=CURW_SIM_PORT, db=CURW_SIM_DATABASE) # [station_name,latitude,longitude,target] extract_stations = read_csv('grids/tide_stations/extract_stations.csv') extract_stations_dict = { } # keys: station_name , value: [latitude, longitude, target_model] for obs_index in range(len(extract_stations)): extract_stations_dict[extract_stations[obs_index][0]] = [ extract_stations[obs_index][1], extract_stations[obs_index][2], extract_stations[obs_index][3] ] methods = [] methods.append(MethodEnum.getAbbreviation(MethodEnum.TSF)) methods.append(MethodEnum.getAbbreviation(MethodEnum.MGF)) for station_name in extract_stations_dict.keys(): # if station_name not in ('wellawatta'): #######temp######## for method in methods: meta_data = { 'latitude': float('%.6f' % float(extract_stations_dict.get(station_name)[0])), 'longitude': float('%.6f' % float(extract_stations_dict.get(station_name)[1])),
""" if attribute in config and (config[attribute]!=""): return config[attribute] else: print("{} not specified in config file.".format(attribute)) exit(1) if __name__=="__main__": try: config = json.loads(open('config.json').read()) # source details model_list = read_attribute_from_config_file('model_list', config) method = MethodEnum.getAbbreviation(MethodEnum.MME) grid_interpolation = GridInterpolationEnum.getAbbreviation(GridInterpolationEnum.MDPA) print("{} : ####### Insert fcst rainfall for FLO2D 150 grids".format(datetime.now())) update_rainfall_fcsts(flo2d_model=FLO2D_150, method=method, grid_interpolation=grid_interpolation, model_list=model_list, timestep=15) except Exception as e: traceback.print_exc() finally: print("{} : ####### fcst rainfall insertion process finished for {} #######".format(datetime.now(), FLO2D_150))
if opt in ("-h", "--help"): usage() sys.exit() elif opt in ("-m", "--flo2d_model"): flo2d_model = arg.strip() elif opt in ("-s", "--start_time"): start_time = arg.strip() elif opt in ("-e", "--end_time"): end_time = arg.strip() elif opt in ("-g", "--grid_tag"): grid_tag = arg.strip() if grid_tag == "MDPA": grid_interpolation = GridInterpolationEnum.getAbbreviation( GridInterpolationEnum.MDPA) method = MethodEnum.getAbbreviation(MethodEnum.OBS) else: exit(0) if flo2d_model is None: print("Flo2d model is not specified.") exit(1) elif flo2d_model not in ("flo2d_250", "flo2d_150", "flo2d_150_v2"): print( "Flo2d model should be either \"flo2d_250\" or \"flo2d_150\" or \"flo2d_150_v2\"" ) exit(1) if start_time is None: start_time = (datetime.now() - timedelta(days=3)).strftime('%Y-%m-%d 23:30:00')