swirlspy.qpf package
Submodules
swirlspy.qpf.persistence module
- swirlspy.qpf.persistence.persistence(xr2d, timesteps, timesteps_size)
Forecast by persistence, accepting an observation xarray and returning a forecast xarray. Persistence means that the forecast is exactly same as the observation. While it sounds trivial, this is usefulf for benchmarking the performacne of another QPF algorithm. Parameters
- xr2d: xarray.DataArray (2-dimensional, in ‘x’ ‘y’)
The xarray containing data to be forecasted.
- timesteps: int
Number of timesteps to be forecasted.
- timesteps_size: int
Time interval between each steps, in minutes.
- Returns
persistence_xrnd – Data values in ‘xr2d’ being copied along the ‘end_time’ axis, coordinates of ‘end_time’ axis have a unique value for each timestep.
- Return type
xarray.DataArray
swirlspy.qpf.qpfrover module
- swirlspy.qpf.qpfrover.flip_grid(grid)
Flip a grid vertically (in y-axis).
- Parameters
grid (numpy.ndarray) –
- Returns
flipped grid
- Return type
numpy.ndarray
- swirlspy.qpf.qpfrover.grid2ascii(grid_number, gridded_flip, ncols, nrows, xllcenter, yllcenter, cellsize, nodata_value, valid_time, steps, time_step_size, start_level, end_level, rho, alpha, sigma)
Export 2 radar data grid (cartesian coordinates) in consecutive timesteps and rover parameters on a text file (.txt) in ascii format.
Text file returned by this function is the input file for “rover” for extrpolation.
- Parameters
grid_number –
gridded_flip –
ncols –
nrows –
xllcenter –
yllcenter –
cellsize –
:param : :param nodata_value: :param valid_time: :param steps: :param time_step_size: :param start_level: :param end_level: :param : :param rho: :param alpha: :param sigma:
- Returns
“rover-input.txt”,
a text file located at directory “./input”.
- swirlspy.qpf.qpfrover.grid2txt(file, grid)
Export a data grid on a .txt file.
- Parameters
file (str) – Name of the output text file.
grid (numpy.ndarray) – Data grid to be exported.
- Returns
A .txt file named according to the above input parameter “file”,
where number of lines equals row number of the input grid,
number of data on each line equals column number of the input grid.
- swirlspy.qpf.qpfrover.rover_colorimage(path, output)
Plot radar data from “rover-output-[timestep].txt” as color images.
(“rover-output-[timestep].txt” are output files located at “./output” from the program “rover” (Default path)).
- Parameters
path (str) – Directory to look for “rover-output-[timestep].txt”.
- Returns
Color images named “rover-output-[timestep].png”, located at
”./output”(Default path).
- swirlspy.qpf.qpfrover.rover_map(reflectivity, path)
Plots a radar image from rover
- Parameters
reflectivity (xarray.DataArray) – The output of rover
path (str) – path of the python script calling this function
- Return type
Radar images named “rover-output-[timestep].png”
- swirlspy.qpf.qpfrover.rover_qpf(qpf_xarray, xllcenter, yllcenter, valid_time, steps, time_step_size, path)
Perform qpf by calling ‘rover.so’ and using xarray.
- Parameters
qpf_xarray (xarray.DataArray) – A ‘xrnd’ (Two ‘xr2d’ concatenated) from function ‘xrnd’.
xllcenter (float) – Radar site longitude.
yllcenter (float) – Radar site latitude.
valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.
steps (int) – Number of timesteps to extrapolate. Default is 6.
time_step_size (int) – Separation time between 2 input radar files in minutes.
path (str) – stores the path of the file calling the module
- Returns
motion_u (x.array.DataArray) – x component of motion field
motion_v (x.array.DataArray) – y component of motion field
reflectivity (x.array.DataArray) – reflectivity in dBz
- swirlspy.qpf.qpfrover.time_update(initial, time_step_size)
Shift time by a certain amount.
- Parameters
initial (str) – Base time, in YYYYMMDDhhmm.
time_step_size (str) – Amount of time to shift, in minutes.
- Returns
end – Updated time, in YYYYMMDDhhmm.
- Return type
str
- swirlspy.qpf.qpfrover.txt2image(file)
Plot a data grid in text file as a color image.
- Parameters
file (str) – Filename of text file containing data grid.
- Return type
Color image named “filename_of_input_text_file.png”