Tangent-Images icon indicating copy to clipboard operation
Tangent-Images copied to clipboard

How do I generate tangent images for the actual earth science data in lat-lon grid?

Open manmeet3591 opened this issue 4 years ago • 9 comments

Hi @meder411 really nice work. I had the chance to read your paper some months ago and was looking out for the best possible way to transform my earth science data to tangent images and back. I can see that the example you gave in your medium post is from data on the sphere with Earth as an example and also the animation on the readme of this github repository, but how can I actually generate tangent images from the lat-lon gridded dataset ?

manmeet3591 avatar Oct 28 '20 11:10 manmeet3591

I checked that you are using the equirectangular image in your examples. But what if I want to use the actual data on a spherical latitude-longitude grid as an input.

manmeet3591 avatar Oct 28 '20 11:10 manmeet3591

Hi @manmeet3591, glad you like the paper!

Can you be a little more specific about the format of your data? Is it truly like (lat, lon, value)? If so, what is the resolution of the sampling?

meder411 avatar Oct 29 '20 21:10 meder411

Sorry for this late reply. @meder411 Yes the format of the data is truly (lat,lon). By resolution of sampling I hope you mean the spatial resolution, in that case we have in many different resolutions like 0.25 degrees x 0.25 degrees for example. Can you please also have a look at https://towardsdatascience.com/handling-netcdf-files-using-xarray-for-absolute-beginners-111a8ab4463f for more info on such data.

manmeet3591 avatar Nov 01 '20 10:11 manmeet3591

You can look at http://schubert.atmos.colostate.edu/~cslocum/netcdf_example.html also as an example

manmeet3591 avatar Nov 01 '20 10:11 manmeet3591

Do you think if I can project my data on the lat-lon grid to the projection you have used (for example the equiangular input projection file https://github.com/meder411/Tangent-Images/blob/master/examples/inputs/earthmap4k.jpg), I should be able to transform my lat-lon data to tangent images? Also I see that your input is an image, what if we want to directly input a 2d numpy array which is in equiangular projection? Can you help me with directly inputting such data to your code?

manmeet3591 avatar Nov 01 '20 10:11 manmeet3591

I am presently working with a cubed-sphere projection (using https://github.com/jweyn/DLWP-CS), but I very firmly believe that tangent images is better than that as you have also explained in your paper.

manmeet3591 avatar Nov 01 '20 10:11 manmeet3591

@meder411

manmeet3591 avatar Nov 06 '20 12:11 manmeet3591

Tangent images are really nothing more than a resampling of the data to a new, lower distortion, format. If your data is already indexed by spherical coordinates (like an equirectangular image or a cubed sphere), you just need to resample from that representation to the tangent images themselves. The way this resampling is typically done is by generating a mapping *from* the source format according to the layout of the destination format.

For example, this function generated the mapping from spherical coordinates to tangent images. If you run it, you will see that the output is the shape of the tangent images, and each tangent image pixel contains the spherical coordinates it should sample from. Similarly, this function expressly creates a sampling map from an equirectangular representation. If you look closely, it really just wraps that first function and adds a call to a function that converts spherical coordinates to a floating point pixel location on the equirectangular image.

Not having worked with the cubed sphere, I am not exactly sure how you represent that data, but I would recommend copying the create_equirectangular_to_tangent_images_sample_map function linked before, but change this line to some function you need to write that converts spherical coordinates to an index in your representation. Then, you can use the unresample function to resample from your current source representation to the target. Note that unresample on its own expects a 2D image grid and applies bilinear or nearest-neighbor interpolation per a passed argument. However, you can provide pre-computed interpolation weights if you have them and your source representation needs them.

meder411 avatar Nov 08 '20 23:11 meder411

@meder411 Thank you very much for the elaborate answer. I got your point. Ideally how many tangent images would you recommend when we are mapping from spherical data to tangent images, is there a quantitative formula for the same to ensure that the spherical distortion is minimized.

manmeet3591 avatar Nov 10 '20 12:11 manmeet3591