Я использую пакет Regionmask 0.13.0 для маскировки данных NetCDF о климате. Я обнаружил, что если мои данные простираются от -180 до 180, функция маски возвращает все NAN даже после того, как я установил Wrap_lon=180 и не установил Wrap_lon. Я получил следующую ошибку
Код: Выделить всё
ValueError: lon has data that is larger than 180 and smaller than 0. Set `wrap_lon=False` to skip this check.
Код: Выделить всё
0 MULTIPOLYGON (((-1832380.592 2237164.258, -182 Name: geometry, dtype: geometry
Код: Выделить всё
import xarray as xr
import geopandas as gpd
import regionmask
#%% opening the dataset
t2m_file = xr.open_dataset("datafiles/"+"temp.nc")
# adjusting longitude.
t2m_file.coords['longitude'] = (t2m_file.coords['longitude'] + 180) % 360 - 180
t2m_file = t2m_file.sortby(t2m_file.longitude)
t2m = t2m_file['t2m']
#%%
filename='North_Africa'
shp_file =gpd.read_file("datafiles/"+filename+'.shp')
shp_region=regionmask.Regions(shp_file.geometry)
shp_file.plot()
#%%
mask_region=shp_region.mask(t2m.longitude,t2m.latitude,wrap_lon=180)
# masked temperture of the raw data
tem_masked_region=t2m.where(mask_region == 0)
https://app.box.com/s/nyauxuuscbk0ws5firpmyjt3y51nrlr2
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/793 ... 180-to-180