Skip to content

Error: Changing months combination in xarray season for India Region #6012

Answered by keewis
HARSHBARDHANK94 asked this question in Q&A
Discussion options

You must be logged in to vote

if you look at the implementation of time.season, it will translate months to season labels here:

def _season_from_months(months):
"""Compute season (DJF, MAM, JJA, SON) from month ordinal"""
# TODO: Move "season" accessor upstream into pandas
seasons = np.array(["DJF", "MAM", "JJA", "SON"])
months = np.asarray(months)
return seasons[(months // 3) % 4]

Since your groups are not that different, you can take the expression (months // 3) % 4 and change the group for September (9):

def indian_mainland_seasons(months):
    seasons = np.array(["DJF", "MAM", "JJAS", "ON"])
    months = np.asarray(

Replies: 5 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@HARSHBARDHANK94
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@HARSHBARDHANK94
Comment options

Answer selected by HARSHBARDHANK94
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants