# data source source = rcparams.data_sources["mch"] root = rcparams.data_sources["mch"]["root_path"] fmt = rcparams.data_sources["mch"]["path_fmt"] pattern = rcparams.data_sources["mch"]["fn_pattern"] ext = rcparams.data_sources["mch"]["fn_ext"] timestep = rcparams.data_sources["mch"]["timestep"] importer_name = rcparams.data_sources["mch"]["importer"] importer_kwargs = rcparams.data_sources["mch"]["importer_kwargs"] # read precip field date = datetime.strptime("201607112100", "%Y%m%d%H%M") fns = io.find_by_date(date, root, fmt, pattern, ext, timestep, num_prev_files=2) importer = io.get_method(importer_name, "importer") precip, __, metadata = io.read_timeseries(fns, importer, **importer_kwargs) precip, metadata = utils.to_rainrate(precip, metadata) # precip[np.isnan(precip)] = 0 # motion motion = dense_lucaskanade(precip) # parameters nleadtimes = 6 thr = 1 # mm / h slope = 1 * timestep # km / min
data_source = "mch" # Load data source config root_path = rcparams.data_sources[data_source]["root_path"] path_fmt = rcparams.data_sources[data_source]["path_fmt"] fn_pattern = rcparams.data_sources[data_source]["fn_pattern"] fn_ext = rcparams.data_sources[data_source]["fn_ext"] importer_name = rcparams.data_sources[data_source]["importer"] importer_kwargs = rcparams.data_sources[data_source]["importer_kwargs"] timestep = rcparams.data_sources[data_source]["timestep"] # Find the radar files in the archive fns = io.find_by_date(date, root_path, path_fmt, fn_pattern, fn_ext, timestep, num_prev_files=2) # Read the data from the archive importer = io.get_method(importer_name, "importer") R, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs) # Convert to rain rate R, metadata = conversion.to_rainrate(R, metadata) # Upscale data to 2 km to limit memory usage R, metadata = dimension.aggregate_fields_space(R, metadata, 2000) # Plot the rainfall field
############################################################################### # Read the input rain rate fields # ------------------------------- date = datetime.strptime("201701311200", "%Y%m%d%H%M") data_source = "mch" # Read the data source information from rcparams datasource_params = rcparams.data_sources[data_source] # Find the radar files in the archive fns = io.find_by_date( date, datasource_params["root_path"], datasource_params["path_fmt"], datasource_params["fn_pattern"], datasource_params["fn_ext"], datasource_params["timestep"], num_prev_files=2, ) # Read the data from the archive importer = io.get_method(datasource_params["importer"], "importer") reflectivity, _, metadata = io.read_timeseries( fns, importer, **datasource_params["importer_kwargs"]) # Convert reflectivity to rain rate rainrate, metadata = conversion.to_rainrate(reflectivity, metadata) # Upscale data to 2 km to reduce computation time rainrate, metadata = dimension.aggregate_fields_space(rainrate, metadata, 2000)