pygmt.xyz2grd: Allow more flexible ways to pass x/y/z arrays
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với tài liệu API của pygmt.xyz2grd và cách xử lý đầu vào hiện tại. Xem xét cách các mảng x/y/z 1-D và 2-D, region, spacing và registration hiện được diễn giải. Công việc được xem là hoàn tất khi các dạng đầu vào linh hoạt được đề xuất hoạt động và các đầu vào hiện có vẫn được hỗ trợ, bao gồm các giá trị mặc định đã nêu và hành vi của registration.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The pygmt.xyz2grd function accepts 1-D x/y/z arrays as input and produces a grid. Here, x/y are the x- and y-coordinates of grid nodes and z is the data values on grid nodes. Thus, for a 3x4 grid, x/y/z arrays all have 12 values (assuming it's gridline-registrated).
The pygmt.xyz2grd API documentation provides a simple example showing how we should prepare the x/y/z arrays.
import numpy as np
import pygmt
def func(x, y):
return x**2 + y**2
x, y = np.meshgrid([0, 1, 2, 3], [10.5, 11.0, 11.5, 12.0, 12.5])
z = func(x, y)
xx, yy, zz = x.flatten(), y.flatten(), z.flatten()
grid = pygmt.xyz2grd(x=xx, y=yy, z=zz, spacing=(1.0, 0.5), region=[0, 3, 10, 13])
As you can see, we have to use np.meshgrid to generate the 2-D x/y arrays, call a function (here z=x**2+y**2) to produce the 2-D z array, and use the flatten() method to convert the 2-D arrays into 1-D arrays. It's not straightforward and sometimes difficult to understand.
Here I propose to provide two more flexible ways to pass x/y/z arrays. The expected syntaxes are:
x = [0, 1, 2, 3]
y = [10.5, 11.0, 11.5, 12.0, 12.5]
z = func(*np.meshgrid(x, y))
# Case 1: 2-D z array + 1-D x/y arrays
grid = pygmt.grid(x=x, y=y, z=z) # spacing and region are no longer needed
# Case 2: 2-D z array + region + spacing
grid = pygmt.grid(z=z, region=[0, 3, 10.5, 12.5], spacing=(1, 0.5))
Some notes:
- Internally we should do something like before passing data to the
xyz2grdmodule:x = np.arange(region[0], region[1], spacing[0]) # required for case 2 y = np.arange(region[2], region[3], spacing[1]) # required for case 2 xx, yy = np.meshgrid(x, y) xx, yy, zz = xx.flatten(), yy.flatten(), z.flatten() # now pass xx/yy/zz to xyz2grd - The
-Ioption (spacingparameter) is required forxyz2grd. The spacings can be obtained byspacing = (x[1] - x[0], y[1] - y[0])assuming thatxandyare equal-spaced. - For case 2, a special case is, only the 2-D z array is given and
region/spacingare not given, thenregionis default to [0, nx-1, 0, ny-1], and spacing is default to[1, 1] - In all cases, we need to be careful with the
registrationparameter.
Comments?
- Ngôn ngữ chính
- Python
- Star
- 882
- Fork
- 261
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 29
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của GenericMappingTools/pygmt
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
GenericMappingTools/pygmt#5014 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
discussions documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
GenericMappingTools/pygmt#4992 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Improve reporting the GMT version via "pygmt.show_versions()"Có thể đã có người làm @yvonnefroehlich đã nhận 113 ngày trước. Đang mởmaintenance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
GenericMappingTools/pygmt#4812 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
GenericMappingTools/pygmt#4765 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add an AGENTS.md fileCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdiscussions
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
GenericMappingTools/pygmt#4677 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của GenericMappingTools/pygmt
Issue tương tự
-
Ubuntu for Debian DevelopersĐang mởDMB documentation good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ubuntu/ubuntu-project-docs#921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
⏳ Pending feedback 🐛 Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jumpserver/jumpserver#18282 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
ClickHouse/loom#2014 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
future-agi/future-agi#5274 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày