quantile = anom.quantile([0.90], dim='time') ax = plt.axes(projection=ccrs.PlateCarree()) anom_roll[25].plot(ax=ax, transform=ccrs.PlateCarree()) (anom_roll[25] - quantile[0]).plot.contour(levels=[0], ax=ax, transform=ccrs.PlateCarree()) ax.set_global(); ax.coastlines(); #%% # ============================================================================= # blocking class testing # ============================================================================= from contrack import contrack # initiate blocking instance block = contrack() # read ERA5 block.read('data/era5_2016_z_500.nc') # block.read('data/anom_1981_2010.nc') # clean data # Step 1: remove leap day block._ds = block._ds.sel(time=~((block._ds.time.dt.month == 2) & (block._ds.time.dt.day == 29))) block._ds = block._ds.sel(time=block._ds.time.dt.month.isin([1, 2, 12])) block._ds = block._ds.chunk({'time': 365, 'longitude': 10}) block.z = block.z.chunk({'time': 365, 'longitude': 10}) # calculate geopotential height
def test_read_xarray(): data = xr.open_dataset(dataset) contracks = contrack() contracks.read_xarray(data) assert type(contracks.ds) is xr.Dataset
def test_read_wrong(): try: contrack(wrong_dataset) except IOError as err: assert err.args[0] == "Unkown fileformat. Known formats " \ "are netcdf."
def test_read_netcdf(): contracks = contrack(dataset) assert type(contracks) == contrack
def test_init_empty(): contracks = contrack() assert contracks.ds is None
def contracks(): contracks = contrack() contracks.read(dataset) return contracks