creare-com / podpac

Pipeline for Observational Data Processing Analysis and Collaboration
https://podpac.org
Apache License 2.0
45 stars 6 forks source link

Helper Function to determine resolution of coordinates #502

Closed mpu-creare closed 1 year ago

mpu-creare commented 1 year ago

Description When working with lat/lon or other projected coordinates, it's hard to know the real nominal resolution of your coordinate system.

Describe the solution you'd like I want a helper function on coordinates that give me the resolution.

Sample Code

>>> coords = podpac.Coordinates([...], dims=['lat', 'lon']
>>> coords.horizontal_resolution(units='m', type='nominal')
{"lat": 10,
"lon": 20, 
"units": "m"
}
mpu-creare commented 1 year ago

This code might be useful: https://github.com/creare-com/pydem/blob/master/pydem/utils.py#L145

mpu-creare commented 1 year ago

This might also be useful: https://pyproj4.github.io/pyproj/stable/api/crs/crs.html

CFoye-Creare commented 1 year ago

Left to-do

CFoye-Creare commented 1 year ago
mpu-creare commented 1 year ago

For coords.horizontal_resolution(units='m', type='nominal'), let's talk about the different types

types =

This is a proposal, feel free to propose something better.

CFoye-Creare commented 1 year ago

Implemented 3 of the 4 types:

CFoye-Creare commented 1 year ago

9851b1cb5ce4b32bc00e96e500ffc8c78efd7376

CFoye-Creare commented 1 year ago

e05a662688b5d600aeb29784d43b5acb8c466cbe

CFoye-Creare commented 1 year ago

Wrote some code to address the problem of lat/lon evaluating to different distances based upon the other dimension's value. However, I realized once passing in non-square unstacked coordinates that I failed to account for the difference resolution changing for each differing value of the other dimension.

Let our unstacked coordinate system be a $M$ by $N$ matrix, where $M$ is the number of rows (in grid squares), and $N$ is the number of columns. See Blender visualization:

image

Previously, we were returning two arrays of size $M$ and size $N$. This meant we were returning either a single row/column or a selection of each column. For example: image Another example: image

Instead, we want to return this for latitude: image

So, for latitude we want to return a $N$ by $M$ matrix.

For longitude: image So, for longitude we want to return a $M$ by $N$ matrix.

For the "summary" type resolution, we can simply average/compute std.dev of all of these values.

CFoye-Creare commented 1 year ago

The $M+1$ or $N+1$ implementation is not possible due to the fact we don't store the values in the +1 dimension in our coords.

mpu-creare commented 1 year ago

closed by #505