Skip to content
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

Generic season index - no season is length 0 #1845

Merged
merged 19 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Breaking changes
^^^^^^^^^^^^^^^^
* As updated in ``cf_xarray>=0.9.3``, dimensionless quantities now use the "1" units attribute as specified by the CF conventions, previously an empty string was returned. (:pull:`1814`).

Breaking changes
^^^^^^^^^^^^^^^^
* Definition of the ``frost_free_season_start`` and ``frost_free_season_end`` have been slightly changed to be coherent with the ``frost_free_season_length`` and xclim's notion of `season` in general. Indicator and indices signature have changed. (:pull:`1845`).
aulemahal marked this conversation as resolved.
Show resolved Hide resolved
* Season length indicators have been modified to return ``0`` for all cases where a proper season was not found, but the data is valid. Previously, a ``nan`` was given if neither a start or an end were found, even if the data was valid, and a ``0`` was given if an end was found but no start. (:pull:`1845`).

Bug fixes
^^^^^^^^^
* Fixed the indexer bug in the ``xclim.indices.standardized_index_fit_params`` when multiple or non-array indexers are specified and fitted parameters are reloaded from netCDF. (:issue:`1842`, :pull:`1843`).
Expand All @@ -26,6 +31,7 @@ Internal changes
^^^^^^^^^^^^^^^^
* Changed the French translation of "wet days" from "jours mouillés" to "jours pluvieux". (:issue:`1825`, :pull:`1826`).
* In order to adapt to changes in `pytest`, the doctest fixtures have been split from the main testing suite and doctests are now run using ``$ python -c 'from xclim.testing.utils import run_doctests; run_doctests()'``. (:pull:`1632`).
* Added ``xclim.indices.generic.season`` to make season start, end and length indices. Added a `stat` argument to ``xclim.indices.run_length.season`` to avoid returning a dataset. (:pull:`1845`).
aulemahal marked this conversation as resolved.
Show resolved Hide resolved

CI changes
^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/test_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ class TestGrowingSeasonLength:
[
("1950-01-01", "1951-01-01", 0), # No growing season
("2000-01-01", "2000-12-31", 365), # All year growing season
("2000-07-10", "2001-01-01", np.nan), # End happens before start
("2000-07-10", "2001-01-01", 0), # End happens before start
("2000-06-15", "2001-01-01", 199), # No end
("2000-06-15", "2000-07-15", 31), # Normal case
],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ class TestRunsWithDates:
[
("07-01", 210, 70),
("07-01", 190, 50),
("04-01", 150, np.nan), # date falls early
("04-01", 150, 0), # date falls early
("11-01", 150, 165), # date ends late
(None, 150, 10), # no date, real length
],
Expand Down
4 changes: 2 additions & 2 deletions tests/test_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_real_data(self, atmosds):

class TestFrostSeasonLength:
def test_simple(self, tasmin_series):
a = np.zeros(730) + K2C + 15
a = np.zeros(731) + K2C + 15
a[300:400] = K2C - 5
a[404:407] = K2C - 5
tasmin = tasmin_series(a, start="2000-01-01")
Expand All @@ -380,7 +380,7 @@ def test_simple(self, tasmin_series):
np.testing.assert_array_equal(out, [np.nan, 100, np.nan])

out = atmos.frost_season_length(tasmin=tasmin, mid_date="07-01", freq="YS")
np.testing.assert_array_equal(out, [np.nan, np.nan])
np.testing.assert_array_equal(out, [0, 181])


class TestColdSpellDays:
Expand Down
Loading
Loading