Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workflow to Python 3.12 #539

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: update pip
run: python -m pip install -U pip
run: pip install -U pip
- name: install setuptools (needed with Python 3.12)
run: pip install setuptools
- name: install uv for dependency conflict resolution
run: pip install uv
- name: Get requirements
run: uv pip compile requirements.txt > reqs-py-312.txt
- name: install python deps
run: python -m pip install -U -r requirements.txt
run: python -m pip install -U -r reqs-py-312.txt
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
jinja2==3.1
numpy==1.23.2
pandas==2.1
pyproj==3.6.0
rasterio==1.3.7
scikit-image==0.20.0
requests==2.31.0
skyfield==1.45.0
jinja2>=3.1
numpy<2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so it turns out you don't have to have numpy 2 for the updated rasterio?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to build with numpy 2 but it conflicted with other deps. It seems rasterio is still compatible with numpy 1.

pandas>=2.2.3
pyproj>=3.7
rasterio>=1.4.3
scikit-image>=0.20.0
requests>=2.31.0
skyfield>=1.45.0
10 changes: 6 additions & 4 deletions src/latlon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ def getlatlon(imgpath):
nrows, ncols = im.shape
cols, rows = np.meshgrid(np.arange(ncols), np.arange(nrows))
xs, ys = rasterio.transform.xy(im.transform, rows, cols)
xs = np.array(xs)
ys = np.array(ys)


# rasterio v1.3.7 returns lists; leaving casting to array for backward compatibility
xs = np.array(xs).reshape(im.shape) # rasterio>=1.4.3 returns 1D arrays so reshaping is needed
ys = np.array(ys).reshape(im.shape)

# X and Y are the 1D index vectors
X = xs[0, :]
Y = ys[:, 0]
ps_to_ll = Transformer.from_crs(im.crs, "WGS84", always_xy=True)
lons, lats = ps_to_ll.transform(np.ravel(xs), np.ravel(ys))

# longitude and latitude are 2D index arrays
longitude = np.reshape(lons, (nrows, ncols))
latitude = np.reshape(lats, (nrows, ncols))
Expand Down
Loading