老实说,我不确定这是否是寻找沉淀对SIF的影响时比较这两个值的最佳方法,因此我愿意接受不同方法的想法。至于当前合并数据,我正在使用xr.combine_by_coords
,但这给了我下面将要描述的错误。我也可以通过将netcdfs转换为geotiff,然后使用rasterio使其变形来完成此操作,但这似乎是进行这种比较的一种无效方法。到目前为止,这是我所拥有的:
import netCDF4
import numpy as np
import dask
import xarray as xr
rainy_bbox = np.array([
[-69.29519955115512,-13.861261028444734],
[-69.29519955115512,-12.384786628185896],
[-71.19583431678012,-12.384786628185896],
[-71.19583431678012,-13.861261028444734]])
max_lon_lat = np.max(rainy_bbox, axis=0)
min_lon_lat = np.min(rainy_bbox, axis=0)
# this dataset is available here: ftp://fluo.gps.caltech.edu/data/tropomi/gridded/
sif = xr.open_dataset('../data/TROPO_SIF_03-2018.nc')
# the dataset is global so subset to my study area in the Amazon
rainy_sif_xds = sif.sel(lon=slice(min_lon_lat[0], max_lon_lat[0]), lat=slice(min_lon_lat[1], max_lon_lat[1]))
# this data can all be downloaded from NASA Goddard here either manually or with wget but you'll need an account on https://disc.gsfc.nasa.gov/: https://pastebin.com/viZckVdn
imerg_xds = xr.open_mfdataset('../data/3B-DAY.MS.MRG.3IMERG.201803*.nc4')
# spatial subset
rainy_imerg_xds = imerg_xds.sel(lon=slice(min_lon_lat[0], max_lon_lat[0]), lat=slice(min_lon_lat[1], max_lon_lat[1]))
# I'm not sure the best way to combine these datasets but am trying this
combo_xds = xr.combine_by_coords([rainy_imerg_xds, rainy_xds])
当前,我在最后一行上似乎没有帮助RecursionError: maximum recursion depth exceeded in comparison
。当我添加自变量join='left'
时,来自rainy_imerg_xds
数据集的数据位于combo_xds
中,当我执行join='right'
时,rainy_xds
数据存在,如果我做join='inner'
没有数据。我以为有一些内部插值功能,但似乎没有。
答案 0 :(得分:1)
此documentation from xarray非常简单地概述了该问题的解决方案。 MAX EFFDT
允许您内插多个尺寸,并指定另一个数据集的x和y尺寸作为输出尺寸。因此,在这种情况下,它是通过
Plan_Type
xarray