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

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

Open
manmeet3591 opened this issue Oct 28, 2020 · 9 comments

Comments

@manmeet3591
Copy link

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
Copy link
Author

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.

@meder411
Copy link
Owner

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?

@manmeet3591
Copy link
Author

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
Copy link
Author

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

@manmeet3591
Copy link
Author

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
Copy link
Author

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
Copy link
Author

@meder411

@meder411
Copy link
Owner

meder411 commented Nov 8, 2020

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.

@manmeet3591
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants