question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prepare project_grid for the future grid method in Verde gridders

See original GitHub issue

Description

Since Verde v2.0.0 the grid method of every gridder in Verde will not take the spacing, shape or region arguments. They will not create the desired grid, but will be able to take the coordinates of a predefined regular grid (see #326 for more details).

Currently the verde.project_grid makes use of the Chain.grid method to produce the projected and interpolated grid. During this step, the output grid is generated by passing the soon-to-be-deprecated region and spacing arguments. This raises a FutureWarning when calling project_grid that isn’t due to any misuse from the user.

Here I copy a working example that reproduces this problem:

import pyproj
import ensaio
import xarray as xr
import verde as vd

# Download the data using ensaio
fname = ensaio.fetch_earth_topography(version=1)

# Load it with xarray
grid = xr.load_dataarray(fname)

# Crop it to a smaller region
region = (-70, -67, -45, -40)
grid = grid.sel(longitude=slice(*region[:2]), latitude=slice(*region[2:]))

# Define a projection
projection = pyproj.Proj(proj="merc", lat_ts=grid.latitude.values.mean())

# Project the grid
grid_proj = vd.project_grid(grid, projection)

/home/santi/git/verde/verde/base/base_classes.py:463: FutureWarning: The 'spacing', 'shape' and 'region' arguments will be removed in Verde v2.0.0. Please use the 'verde.grid_coordinates' function to define grid coordinates and pass them as the 'coordinates' argument.
  warnings.warn(

How to solve this?

We need verde.project_grid to predefine the output grid through the verde.grid_coordinates and use the Chain.grid method by passing the coordinates argument with the coordinates of this predefined grid.

This change wouldn’t need significant tests, just one that checks that no FutureWarning is raised after using it. We can do so with pytest.warns (see Warnings Capture for further details and examples).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
santisolercommented, Apr 24, 2022

You’re right! The interpolator.grid method creates the xarray object, so grid coordinates can be 2D arrays obtained directly from grid_coordinates. Editing the issue description…

0reactions
leouiedacommented, Nov 3, 2022

👍🏽 will do

Read more comments on GitHub >

github_iconTop Results From Across the Web

verde.project_grid | Verde v1.7.0 - Fatiando a Terra
Creates a new grid in the projected coordinates by interpolating the original values using the chosen method (linear by default). Before ...
Read more >
The Grid Method - Art is Fun
The grid method is an effective way to transfer and/or enlarge your original image onto canvas, ensuring correct proportions.
Read more >
New England's Future Grid Initiative Key Project
Work on this high-priority initiative follows two tracks taking place within the stakeholder process throughout 2020 and 2021: Future Grid Reliability Study ...
Read more >
GRID SCALE TECHNIQUE - YouTube
The grid method involves drawing a grid over your reference photo, and then drawing a grid of equal ratio on your work surface....
Read more >
Reimagining the Grid - Edison International
Achieving a reimagined grid for a clean energy future calls for a collaborative, industry-wide approach to be most effective and less costly to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found