-
Notifications
You must be signed in to change notification settings - Fork 48
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
Cannot allocate very large (global ~1km) ESMF grid #29
Comments
Also, what's the scientific use case for this @sdeastham? I thought that global ~1 km data are so rare right now, so didn't pay much attention to such a case (#26 (comment)). I know @bekozi is pretty interested in regridding ultra-high resolution data. Maybe a chance to collaborate. |
Thanks for raising this! The use case here is to take advantage of very fine global population density data which has become available, specifically when calculating regional and global exposure to atmospheric pollutants. The latest Gridded Population of the World dataset (GPWv4) is provided at 30 arc-second resolution, so the grid is order 1e5 cells in each dimension. I have workarounds - coarser-resolution versions of the data are available, and when considering high resolution nested domains I can work with smaller subgrids to avoid working directly with one giant grid - but I was hoping to be able to regrid the finest possible grid directly in xesmf to minimize regridding error.
Sent via the Samsung Galaxy S8, an AT&T 4G LTE smartphone
…-------- Original message --------
From: Jiawei Zhuang <notifications@github.com>
Date: 8/25/18 23:34 (GMT-05:00)
To: JiaweiZhuang/xESMF <xESMF@noreply.github.com>
Cc: Sebastian Eastham <seastham@mit.edu>, Mention <mention@noreply.github.com>
Subject: Re: [JiaweiZhuang/xESMF] Cannot allocate very large (global ~1km) ESMF grid (#29)
Also, what's the scientific use case for this @sdeastham<https://github.com/sdeastham>? I thought that global ~1 km data are so rare right now, so didn't pay much attention to such a case (#26 (comment)<#26 (comment)>). I know @bekozi<https://github.com/bekozi> is pretty interested in regridding ultra-high resolution data. Maybe a chance to collaborate.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#29 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AGT-bN_my4ieyDjJMzlrNR0YgyuEFLZAks5uUhcugaJpZM4WMoAL>.
|
@sdeastham This grid is a good test case for ultra-high resolution conservative regridding. Right now, the workflow for regridding data at this resolution works with netCDF (I see the highest resolution grid is not in netCDF format - assuming this is the dataset you are interested). I am migrating the workflow to use xarray-dask/xESMF so GeoTiff will be supported. It's good to hear you have workarounds as it will take some time to get this working. If your timeline is more pressing for the high resolution, let me know... Also thanks to @JiaweiZhuang for getting this on the tracker! Note: It often makes sense to store high resolution sparse data like these in an unstructured format if netCDF is required. |
That is indeed the dataset in question – thanks! Looking forward to seeing how this progresses, and please let me know if there’s anything useful I can do on this front.
From: Ben Koziol <notifications@github.com>
Sent: Monday, August 27, 2018 12:31 PM
To: JiaweiZhuang/xESMF <xESMF@noreply.github.com>
Cc: Sebastian Eastham <seastham@mit.edu>; Mention <mention@noreply.github.com>
Subject: Re: [JiaweiZhuang/xESMF] Cannot allocate very large (global ~1km) ESMF grid (#29)
@sdeastham<https://github.com/sdeastham> This grid is a good test case for ultra-high resolution conservative regridding. Right now, the workflow for regridding data at this resolution works with netCDF (I see the highest resolution grid is not in netCDF format - assuming this<http://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-density-rev10> is the dataset you are interested). I am migrating the workflow to use xarray-dask/xESMF so GeoTiff will be supported. It's good to hear you have workarounds as it will take some time to get this working. If your timeline is more pressing for the high resolution, let me know...
Also thanks to @JiaweiZhuang<https://github.com/JiaweiZhuang> for getting this on the tracker!
Note: It often makes sense to store high resolution sparse data like these in an unstructured format if netCDF is required.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#29 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AGT-bP93ZSOo-jZ2rblculapSzIvFU1pks5uVB7NgaJpZM4WMoAL>.
|
Also hitting this limit working with some Nasa Ice Bridge data. |
@NicWayand thanks for the data link. I'm approaching something workable as example/dev code that can handle |
Hi @bekoi, I am interested in helping but not clear exactly what your asking for? Just an example using xesmf where this issue is hit? |
@NicWayand thanks and sorry for not being more clear. I've realized I won't have time to learn and use I'm looking for help with the bit of code that regrids source/destination spatial chunks within a Anyway, no pressure of course. I'll post another PR here, and we can go from there! |
Is there any progress on this issue about the "TypeError: buffer is too small for requested array"? |
Try cropping the global data (with |
As for From the source code import ESMF.api.constants as constants
import numpy as np
import numpy.ma as ma
import ctypes as ct
import sys
def ndarray_from_esmf(data, dtype, shape):
'''
:param data: buffer of fortran allocated ESMF array
:type data: ctypes void_p
:param dtype: the type of the esmf buffer
:type dtype: ESMF.TypeKind
:param shape: N-D Python shape corresponding to 1D ESMF allocation
:type shape: list or tuple
:return: numpy array representing the data with dtype and shape
'''
# find the size of the local coordinates
size = np.prod(shape[:]) * \
np.dtype(constants._ESMF2PythonType[dtype]).itemsize
# create a numpy array to point to the ESMF data allocation
if sys.version_info[0] >= 3:
buffer = ct.pythonapi.PyMemoryView_FromMemory
buffer.restype = ct.py_object
buffer = buffer(data, ct.c_int(size), 0x200)
else:
buffer = np.core.multiarray.int_asbuffer(
ct.addressof(data.contents), size)
esmfarray = np.ndarray(tuple(shape[:]), constants._ESMF2PythonType[dtype],
buffer, order="F")
return esmfarray The error happens in the call: esmfarray = np.ndarray(tuple(shape[:]), constants._ESMF2PythonType[dtype],
buffer, order="F") The minimal code to get the same error is: np.ndarray(shape=3, buffer=np.array([0.0, 1.0]), dtype=np.float64)
# buffer size is smaller than the array size, leads to "buffer is too small for requested array" It is probably because the earlier call
Maybe @bekozi can elaborate more on this. Probably some internal memory constraints in ESMF? |
By cropping it to a regional domain, it finally works. |
Right, currently the grid cell bounds ( |
For what it's worth, this is the use case for which I installed xesmf: producing 1km global grids. These are slow with other methods. |
Add basic adaptive masking to solve JiaweiZhuang#29
Same issue when trying to downscale 1000x1000 1km data to 30000x30000 30m. Any updates? |
Just ran into this today when trying to regrid high resolution land use and vegetation density data. |
Same issue with a Field of dim 1193x843x8736 grid (X Y T) with a total size of 70286291712 |
I am also running into this issue when attempting to resample 0.25 deg data to 30 second grids (for use with a global ML model). With the wide use now of ML for producing global maps, I think that the need for handling high-resolution global grids is no longer a fringe case. |
I think this repo is unfortunately dead and/or dormant. The sparselt (https://github.com/LiamBindle/sparselt) package by @LiamBindle may be a viable alternative for regridding. |
@sdeastham failed to use xESMF to regrid global ~1 km resolution data. The issue is that ESMPy cannot create very large grid object. A minimal example is:
The last command leads to
TypeError: buffer is too small for requested array
:@bekozi Any idea about this?
The text was updated successfully, but these errors were encountered: