diff --git a/xclim/indices/_agro.py b/xclim/indices/_agro.py index 2c3c8855c..9bfcb0cb4 100644 --- a/xclim/indices/_agro.py +++ b/xclim/indices/_agro.py @@ -506,7 +506,7 @@ def cool_night_index( Examples -------- >>> from xclim.indices import cool_night_index - >>> tasmin = xr.open_dataset(path_to_tasmin_file).tasmin + >>> tasmin = open_dataset(path_to_tasmin_file).tasmin >>> cni = cool_night_index(tasmin) References @@ -1170,7 +1170,7 @@ def standardized_precipitation_index( ------- >>> from datetime import datetime >>> from xclim.indices import standardized_precipitation_index - >>> ds = xr.open_dataset(path_to_pr_file) + >>> ds = open_dataset(path_to_pr_file) >>> pr = ds.pr >>> cal_start, cal_end = "1990-05-01", "1990-08-31" >>> spi_3 = standardized_precipitation_index( diff --git a/xclim/indices/_anuclim.py b/xclim/indices/_anuclim.py index 76256c984..8702bc5af 100644 --- a/xclim/indices/_anuclim.py +++ b/xclim/indices/_anuclim.py @@ -128,7 +128,7 @@ def temperature_seasonality( The following would compute for each grid cell of file `tas.day.nc` the annual temperature seasonality: >>> import xclim.indices as xci - >>> t = xr.open_dataset(path_to_tas_file).tas + >>> t = open_dataset(path_to_tas_file).tas >>> tday_seasonality = xci.temperature_seasonality(t) >>> t_weekly = xci.tg_mean(t, freq="7D") >>> tweek_seasonality = xci.temperature_seasonality(t_weekly) @@ -179,7 +179,7 @@ def precip_seasonality(pr: xarray.DataArray, freq: str = "YS") -> xarray.DataArr The following would compute for each grid cell of file `pr.day.nc` the annual precipitation seasonality: >>> import xclim.indices as xci - >>> p = xr.open_dataset(path_to_pr_file).pr + >>> p = open_dataset(path_to_pr_file).pr >>> pday_seasonality = xci.precip_seasonality(p) >>> p_weekly = xci.precip_accumulation(p, freq="7D") @@ -242,7 +242,7 @@ def tg_mean_warmcold_quarter( warmest quarter mean temperature: >>> from xclim.indices import tg_mean_warmcold_quarter - >>> t = xr.open_dataset(path_to_tas_file) + >>> t = open_dataset(path_to_tas_file) >>> t_warm_qrt = tg_mean_warmcold_quarter(tas=t.tas, op="warmest") Notes @@ -353,7 +353,7 @@ def prcptot_wetdry_quarter( The following would compute for each grid cell of file `pr.day.nc` the annual wettest quarter total precipitation: >>> from xclim.indices import prcptot_wetdry_quarter - >>> p = xr.open_dataset(path_to_pr_file) + >>> p = open_dataset(path_to_pr_file) >>> pr_warm_qrt = prcptot_wetdry_quarter(pr=p.pr, op="wettest") Notes diff --git a/xclim/indices/_multivariate.py b/xclim/indices/_multivariate.py index 6785f2d3c..be5cf71da 100644 --- a/xclim/indices/_multivariate.py +++ b/xclim/indices/_multivariate.py @@ -127,7 +127,7 @@ def cold_spell_duration_index( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import cold_spell_duration_index - >>> tasmin = xr.open_dataset(path_to_tasmin_file).tasmin.isel(lat=0, lon=0) + >>> tasmin = open_dataset(path_to_tasmin_file).tasmin.isel(lat=0, lon=0) >>> tn10 = percentile_doy(tasmin, per=10).sel(percentiles=10) >>> cold_spell_duration_index(tasmin, tn10) @@ -971,7 +971,7 @@ def precip_accumulation( precipitation at the seasonal frequency, ie DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import precip_accumulation - >>> pr_day = xr.open_dataset(path_to_pr_file).pr + >>> pr_day = open_dataset(path_to_pr_file).pr >>> prcp_tot_seasonal = precip_accumulation(pr_day, freq="QS-DEC") """ if phase == "liquid": @@ -1034,7 +1034,7 @@ def precip_average( precipitation at the seasonal frequency, ie DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import precip_average - >>> pr_day = xr.open_dataset(path_to_pr_file).pr + >>> pr_day = open_dataset(path_to_pr_file).pr >>> prcp_tot_seasonal = precip_average(pr_day, freq="QS-DEC") """ if phase == "liquid": @@ -1146,8 +1146,8 @@ def high_precip_low_temp( Example ------- To compute the number of days with intense rainfall while minimum temperatures dip below -0.2C: - >>> pr = xr.open_dataset(path_to_pr_file).pr - >>> tasmin = xr.open_dataset(path_to_tasmin_file).tasmin + >>> pr = open_dataset(path_to_pr_file).pr + >>> tasmin = open_dataset(path_to_tasmin_file).tasmin >>> high_precip_low_temp( ... pr, tas=tasmin, pr_thresh="10 mm/d", tas_thresh="-0.2 degC" ... ) @@ -1204,7 +1204,7 @@ def days_over_precip_thresh( Examples -------- >>> from xclim.indices import days_over_precip_thresh - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> p75 = pr.quantile(0.75, dim="time", keep_attrs=True) >>> r75p = days_over_precip_thresh(pr, p75) """ @@ -1333,7 +1333,7 @@ def tg90p( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import tg90p - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas >>> tas_per = percentile_doy(tas, per=90).sel(percentiles=90) >>> hot_days = tg90p(tas, tas_per) """ @@ -1391,7 +1391,7 @@ def tg10p( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import tg10p - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas >>> tas_per = percentile_doy(tas, per=10).sel(percentiles=10) >>> cold_days = tg10p(tas, tas_per) """ @@ -1449,7 +1449,7 @@ def tn90p( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import tn90p - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas >>> tas_per = percentile_doy(tas, per=90).sel(percentiles=90) >>> hot_days = tn90p(tas, tas_per) """ @@ -1507,7 +1507,7 @@ def tn10p( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import tn10p - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas >>> tas_per = percentile_doy(tas, per=10).sel(percentiles=10) >>> cold_days = tn10p(tas, tas_per) """ @@ -1565,7 +1565,7 @@ def tx90p( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import tx90p - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas >>> tasmax_per = percentile_doy(tas, per=90).sel(percentiles=90) >>> hot_days = tx90p(tas, tasmax_per) """ @@ -1623,7 +1623,7 @@ def tx10p( -------- >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import tx10p - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas >>> tasmax_per = percentile_doy(tas, per=10).sel(percentiles=10) >>> cold_days = tx10p(tas, tasmax_per) """ @@ -1762,7 +1762,7 @@ def warm_spell_duration_index( >>> from xclim.core.calendar import percentile_doy >>> from xclim.indices import warm_spell_duration_index - >>> tasmax = xr.open_dataset(path_to_tasmax_file).tasmax.isel(lat=0, lon=0) + >>> tasmax = open_dataset(path_to_tasmax_file).tasmax.isel(lat=0, lon=0) >>> tasmax_per = percentile_doy(tasmax, per=90).sel(percentiles=90) >>> warm_spell_duration_index(tasmax, tasmax_per) """ diff --git a/xclim/indices/_simple.py b/xclim/indices/_simple.py index c97d714a4..f93ae5cc4 100644 --- a/xclim/indices/_simple.py +++ b/xclim/indices/_simple.py @@ -103,7 +103,7 @@ def tg_mean(tas: xarray.DataArray, freq: str = "YS") -> xarray.DataArray: at the seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import tg_mean - >>> t = xr.open_dataset(path_to_tas_file).tas + >>> t = open_dataset(path_to_tas_file).tas >>> tg = tg_mean(t, freq="QS-DEC") """ return select_resample_op(tas, op="mean", freq=freq) @@ -428,7 +428,7 @@ def max_1day_precipitation_amount( The following would compute for each grid cell the highest 1-day total at an annual frequency: >>> from xclim.indices import max_1day_precipitation_amount - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> rx1day = max_1day_precipitation_amount(pr, freq="YS") """ return select_resample_op(pr, op="max", freq=freq) @@ -462,7 +462,7 @@ def max_n_day_precipitation_amount( The following would compute for each grid cell the highest 5-day total precipitation at an annual frequency: >>> from xclim.indices import max_n_day_precipitation_amount - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> out = max_n_day_precipitation_amount(pr, window=5, freq="YS") """ # Rolling sum of the values @@ -499,7 +499,7 @@ def max_pr_intensity( The following would compute the maximum 6-hour precipitation intensity at an annual frequency: >>> from xclim.indices import max_pr_intensity - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> out = max_pr_intensity(pr, window=5, freq="YS") """ # Rolling sum of the values @@ -569,7 +569,7 @@ def sfcWind_max( # noqa: N802 at the seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import sfcWind_max - >>> fg = xr.open_dataset(path_to_sfcWind_file).sfcWind + >>> fg = open_dataset(path_to_sfcWind_file).sfcWind >>> fg_max = sfcWind_max(fg, freq="QS-DEC") """ return sfcWind.resample(time=freq).max(dim="time").assign_attrs(units=sfcWind.units) @@ -610,7 +610,7 @@ def sfcWind_mean( # noqa: N802 at the seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import sfcWind_mean - >>> fg = xr.open_dataset(path_to_sfcWind_file).sfcWind + >>> fg = open_dataset(path_to_sfcWind_file).sfcWind >>> fg_mean = sfcWind_mean(fg, freq="QS-DEC") """ return ( @@ -653,7 +653,7 @@ def sfcWind_min( # noqa: N802 at the seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import sfcWind_min - >>> fg = xr.open_dataset(path_to_sfcWind_file).sfcWind + >>> fg = open_dataset(path_to_sfcWind_file).sfcWind >>> fg_min = sfcWind_min(fg, freq="QS-DEC") """ return sfcWind.resample(time=freq).min(dim="time").assign_attrs(units=sfcWind.units) diff --git a/xclim/indices/_threshold.py b/xclim/indices/_threshold.py index 150c55b04..3916dbc8c 100644 --- a/xclim/indices/_threshold.py +++ b/xclim/indices/_threshold.py @@ -773,7 +773,7 @@ def daily_pr_intensity( precipitation >= 5 mm at seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import daily_pr_intensity - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> daily_int = daily_pr_intensity(pr, thresh="5 mm/day", freq="QS-DEC") """ t = convert_units_to(thresh, pr, "hydro") @@ -1142,7 +1142,7 @@ def growing_season_length( Examples -------- >>> from xclim.indices import growing_season_length - >>> tas = xr.open_dataset(path_to_tas_file).tas + >>> tas = open_dataset(path_to_tas_file).tas For the Northern Hemisphere: @@ -1228,7 +1228,7 @@ def frost_season_length( Examples -------- >>> from xclim.indices import frost_season_length - >>> tasmin = xr.open_dataset(path_to_tasmin_file).tasmin + >>> tasmin = open_dataset(path_to_tasmin_file).tasmin For the Northern Hemisphere: @@ -1411,7 +1411,7 @@ def frost_free_season_length( Examples -------- >>> from xclim.indices import frost_season_length - >>> tasmin = xr.open_dataset(path_to_tasmin_file).tasmin + >>> tasmin = open_dataset(path_to_tasmin_file).tasmin For the Northern Hemisphere: @@ -2604,7 +2604,7 @@ def wetdays( at the seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import wetdays - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> wd = wetdays(pr, thresh="5 mm/day", freq="QS-DEC") """ thresh = convert_units_to(thresh, pr, "hydro") @@ -2646,7 +2646,7 @@ def wetdays_prop( 5 mm at the seasonal frequency, i.e. DJF, MAM, JJA, SON, DJF, etc.: >>> from xclim.indices import wetdays_prop - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> wd = wetdays_prop(pr, thresh="5 mm/day", freq="QS-DEC") """ thresh = convert_units_to(thresh, pr, "hydro") @@ -3179,7 +3179,7 @@ def dry_spell_frequency( Examples -------- >>> from xclim.indices import dry_spell_frequency - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> dsf = dry_spell_frequency(pr=pr, op="sum") >>> dsf = dry_spell_frequency(pr=pr, op="max") """ @@ -3372,7 +3372,7 @@ def wet_spell_frequency( Examples -------- >>> from xclim.indices import wet_spell_frequency - >>> pr = xr.open_dataset(path_to_pr_file).pr + >>> pr = open_dataset(path_to_pr_file).pr >>> dsf = wet_spell_frequency(pr=pr, op="sum") >>> dsf = wet_spell_frequency(pr=pr, op="max") """