cerfacs-globc/icclim

Error in slicing the data

Patty-Lyn opened this issue · 6 comments

Description
Hi, I would like to make the TX90X using the data from 1950-2021, the base period is 1961-1990, and I want to calculate the seasonal data:JJA, but everytime I tried to do so it said the error in the length of the data, I am wondering what did I do wrong?

Minimal reproducible example

dt1 = datetime.datetime(1950,1,1)
dt2 = datetime.datetime(2021,12,31)

dt1r = datetime.datetime(1961,1,1)
dt2r = datetime.datetime(1990,12,31)

out_f = 'tx90p-icclim.nc'
filename = '/Users/linyucong/PycharmProjects/pythonProject/eatmax-1.nc'
icclim.index(index_name='TX90p',in_files=filename,var_name='tmax',slice_mode=['month',[6,7,8]],base_period_time_range=[dt1r,dt2r],time_range=[dt1,dt2],
out_unit='%',out_file=out_f,logs_verbosity='HIGH')

Output received

ValueError: conflicting sizes for dimension 'dayofyear': length 93 on and length 242 on {'lat': 'lat', 'lon': 'lon', 'dayofyear': 'dayofyear', 'percentiles': 'percentiles'}

bzah commented

Hey, it's a bug on icclim/xclim.
We will work on a fix in xclim and hopefully get it done before their next release.

Hey, it's a bug on icclim/xclim. We will work on a fix in xclim and hopefully get it done before their next release.

Hi, thank you, may i ask if there is a way to compute it seasonally?

bzah commented

Yes you can compute JJA season with either slice_mode="JJA" or slice_mode=['season',[6,7,8]]:

icclim.index(
  index_name='TX90p',
  in_files=filename,
  var_name='tmax',
  slice_mode="JJA",
  base_period_time_range=[dt1r, dt2r],
  time_range=[dt1, dt2],
  out_unit='%',
  out_file=out_f,
  logs_verbosity='HIGH')

Yes you can compute JJA season with either slice_mode="JJA" or slice_mode=['season',[6,7,8]]:

icclim.index(
  index_name='TX90p',
  in_files=filename,
  var_name='tmax',
  slice_mode="JJA",
  base_period_time_range=[dt1r, dt2r],
  time_range=[dt1, dt2],
  out_unit='%',
  out_file=out_f,
  logs_verbosity='HIGH')

Hi I have tried both and encountered the same error with : " conflicting sizes for dimension 'dayofyear': length 93 on and length 244 on {'lat': 'lat', 'lon': 'lon', 'dayofyear': 'dayofyear', 'percentiles': 'percentiles'}"

bzah commented

Yes sorry I should have warned you, both relies on on the same code to compute percentiles which is broken.
I'm working on a fix.

bzah commented

Fixed in xclim with Ouranosinc/xclim#1099.
I'm closing this one as it will be fixed in icclim with the next release using latest xclim version.