pySTEPS / pysteps

Python framework for short-term ensemble prediction systems.
https://pysteps.github.io/
BSD 3-Clause "New" or "Revised" License
441 stars 160 forks source link

a problem with clip_domain #363

Closed HY-10 closed 2 months ago

HY-10 commented 2 months ago

Hi, I have a problem with clip_domain. I ran the clip_domain function and an error occurred.I hope you can help me to resolve.

ValueError Traceback (most recent call last) Cell In[11], line 54 52 # Convert reflectivity to rain rate 53 rainrate, metadata = conversion.to_rainrate(reflectivity, metadata) ---> 54 rainrate, metadata = dimension.clip_domain(rainrate, metadata, extent = [-74.25, -73.70, 40.50, 40.92])

File D:\ana\envs\learn\Lib\site-packages\pysteps\utils\dimension.py:438, in clip_domain(R, metadata, extent) 435 idxx = np.where(np.logical_and(xcoord < right, xcoord > left))[0] 437 # compose the new array --> 438 R_[:, :, idxy[0] : (idxy[-1] + 1), idxx[0] : (idxx[-1] + 1)] = R[ 439 :, :, idx_y[0] : (idx_y[-1] + 1), idx_x[0] : (idxx[-1] + 1) 440 ] 442 # update coordinates 443 metadata["y1"] = bottom

ValueError: could not broadcast input array from shape (1,3,11,14) into shape (1,3,10,13)

HY-10 commented 2 months ago

hi, This problem is solved by enlarging the extent to [-74, -72, 40, 41]. Now, I have another problem: I want to load the data at the original 1km resolution and then zoom in on it using a pixel size *2 (0.02) window. So, what should I do? (Due to the large size of the dataset (3500 x 7000), the importer reduces the original 1kmx1km resolution to 4km x 4km.)

aperezhortal commented 2 months ago

Hi @HY-10 ,

The NSSL importer has a window_size (window_size=4 by default). To load the data in the original km resolution, use window_size=1. If you want to load the data in 2 Km resolution directly, you can use window_size=2.

Take a look at the imported documentation for additional details: https://pysteps.readthedocs.io/en/v1.5.0/generated/pysteps.io.importers.import_mrms_grib.html#pysteps.io.importers.import_mrms_grib

HY-10 commented 2 months ago

嗨,

NSSL 导入程序具有window_size(默认情况下为 window_size=4)。要以原始 km 分辨率加载数据,请使用 window_size=1。如果要直接以 2 Km 分辨率加载数据,则可以使用 window_size=2。

有关更多详细信息,请查看导入的文档:https://pysteps.readthedocs.io/en/v1.5.0/generated/pysteps.io.importers.import_mrms_grib.html#pysteps.io.importers.import_mrms_grib

Hi, I just have a few more questions right now. First, io.import_mrms_grib(...) : The returned R variable is a 2D NumPy array with the shape (height, width).

io.read_timeseries(...) : The returned R variable is a 3D NumPy array with the shape (time, height, width). This represents the entire time series of radar data.

While I need to use the nowcast model, I use {io.import_mrms_grib(...) You can't get a time series.

Second, I use {io.import_mrms_grib(...) Then I found that the rainfall data was not plotted, and I didn't know what was wrong.

image

image

Looking forward to your reply.

aperezhortal commented 2 months ago

Hi @HY-10 , if you need a time series, you can pass the window_size=2 to the pysteps.io.readers.read_timeseries function. The function acepts optional keyword arguments that are passed to the importer selected.

See the function documentation for additional details.

HY-10 commented 2 months ago

嗨,如果你需要一个时间序列,你可以将 window_size=2 传递给函数。该函数接受传递给所选导入程序的可选关键字参数。pysteps.io.readers.read_timeseries

有关更多详细信息,请参阅函数文档

Thank you for your help.