Skip to content

Bug in threshold data type conversion

For all tested precip indices climix crashes, see below. Probably the threshold should be casted as np.float32 already when read into climix?

climix -s -e -x cdd    /home/sm_lbarr/PROJ/test_climix/indata/CLIMPACT2_TEST/precip_AUS_climpact2-sampledata_gridded-obs_v1_ET-SCI_v1_1991-2010.nc
INFO:root:Loading metadata
INFO:root:Scheduler ready; starting main program.
INFO:root:Preparing indices
INFO:root:Found implementation for index_function <spell_length> from distribution <climix 0.9.0+14.g29e95e2>
INFO:root:Starting calculations for index <climix.index.Index object at 0x2ab6840234a8>
INFO:root:Building output filename
INFO:root:Preparing input data
INFO:root:Calculating index
INFO:root:Adding coord categorisation.
INFO:root:Extracting period cube
INFO:root:Preparing cube
INFO:root:Calculation took 3.6670 seconds.
Traceback (most recent call last):
  File "/home/sm_lbarr/.conda/envs/climix-devel-3/bin/climix", line 11, in <module>
    load_entry_point('climix', 'console_scripts', 'climix')()
  File "/home/sm_lbarr/CODE/climix/climix/main.py", line 126, in main
    args.output_template, args.sliced_mode)
  File "/home/sm_lbarr/CODE/climix/climix/main.py", line 105, in do_main
    result = index(input_data)
  File "/home/sm_lbarr/CODE/climix/climix/index.py", line 23, in __call__
    self.index_function.prepare(sub_cube)
  File "/home/sm_lbarr/CODE/climix/climix/index_functions.py", line 200, in prepare
    input_cube.standard_name)
  File "/home/sm_lbarr/CODE/climix/climix/util/__init__.py", line 9, in change_units
    change_pr_units(cube_or_coord, new_units, new_standard_name)
  File "/home/sm_lbarr/CODE/climix/climix/util/change_pr_units.py", line 118, in change_pr_units
    cube_or_coord.points *= float(conv_factor)
numpy.core._exceptions.UFuncTypeError: Cannot cast ufunc 'multiply' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'