Annualising ACCESS-ESM Past 1000 data over tropical years while in a Gregorian Calendar Format

Hi All,

I been having a problem when trying to annualise precipitation, sea surface temperature and sea level pressure data from ACCESS-ESM Past 1000 over tropical years (which I define as May 1 to April 30). I am having this problem because the data are stored in a Gregorian calendar format (Year-Month-Day-Hour-Minute-Second).

I have used numpy functions to annualise other data over tropical years (by using defining a function called tropical year where months prior to may return the year - 1, and months after may return the year), but I cannot use these functions with the ACCESS-ESM Past 1000 data because of the Gregorian format (and the fact that I can’t extract the year and month within the format).

Does anyone have any ideas on how I could annualise over tropical years from Gregorian format data?

Thank you in advance for your help!

1 Like

Hi @bridgetleibold, welcome to ACCESS-Hive forum!

In general, using the function you defined (months prior to may return year - 1, and months after may return year) you should be able to convert your data to annual data, regardless of the Gregorian calendar.
If your data has a Year-Month-… format, as you said, you should be able to extract those Year and Month values to apply your defined function.

Can you please provide a few more details of the function / data you are using?
Maybe try providing a link to both data and python script (or function) you are currently using, so we can better help you.


Hi Davide - thanks for having a look at this.

The link to the working file is: g/data/v45/bl2788/working ENSO response to eruptions.ipynb

the link to the data is: g/data/v45/bl2788/PMIP4data (within the PMIP4data folder are three variables folders each with 10 files I combined and used in the working file)

I am aiming to adapt the technique I used in: g/data/v45/bl2788/15 Jan working Identify Eruptions.ipynb (which the code for is under the heading ‘annualise the monthly data over tropical years’).

Thank you so much again for your help!

Hi @bridgetleibold ,

Thank you for sharing the working script and data.
Unfortunately, I have not access to the v45 project (I requested access but still haven’t been granted).

To speed up the process, would you be able to copy the working script in /scratch/public? Maybe you can create a folder with your username there.

If the data is not too big, please copy it as well (even just one variable), otherwise I will still try to understand it based on the working script.

Thank you

Are you wanting the annual mean using your tropical year definition? You can add a custom coordinate and group over that, where() is a nice function to use here:

path = "/g/data/fs38/publications/CMIP6/PMIP/CSIRO/ACCESS-ESM1-5/past1000/r1i1p1f1/Amon/tas/gn/latest/tas_Amon_ACCESS-ESM1-5_past1000_r1i1p1f1_gn_*.nc"
ds = xarray.open_mfdataset(path, use_cftime=True, chunks={'time': 100})

def tropical_year(dates):
    # Returns year - 1 when month is before May
    return xarray.where(dates.dt.month < 5, dates.dt.year - 1, dates.dt.year)

# Add a custom coordinate to the data
ds.coords['tropical_year'] = tropical_year(ds.time)

# Group by the custom coordinate and mean
tropical_mean = ds.groupby('tropical_year').mean()

1 Like

Hi Scott, this has worked perfectly. Thank you so much for your help
Thanks, Bridget

1 Like