SpatioTemporal / pystare

The Python interface for the SpatioTemporal Adaptive Resolution Encoding (STARE), a unified indexing for geolocated data.
https://pystare.readthedocs.io/en/latest/
12 stars 2 forks source link

error with coarsest_resolution_finer_or_equal_ms() #127

Open mbauer288 opened 1 year ago

mbauer288 commented 1 year ago
# Determine the STARE time resolution
#   example: times = array([1800000])
times = numpy.array([self.imerg_tstep], dtype=numpy.int64)
time_res_array = pystare.coarsest_resolution_finer_or_equal_ms(times)

# inside temporal.coarsest_resolution_finer_or_equal_ms()
milliseconds = array([1800000]) type(milliseconds) = <class 'numpy.ndarray'>
milliseconds.size = 1

Throws error, were it didn't previously with the same inputs.

  File "/Users/mbauer/SpatioTemporal/STAREPandas/starepandas/io/granules/imergl3.py", line 225, in __init__
    time_res_array = pystare.coarsest_resolution_finer_or_equal_ms(times)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/mbauer/SpatioTemporal/pystare/pystare/temporal.py", line 166, in coarsest_resolution_finer_or_equal_ms
    resolutions = pystare.core._coarsest_resolution_finer_or_equal_milliseconds(numpy.array([milliseconds]))[0]
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   File "/Users/mbauer/SpatioTemporal/pystare/pystare/core.py", line 286, in _coarsest_resolution_finer_or_equal_milliseconds
    return _core._coarsest_resolution_finer_or_equal_milliseconds(milliseconds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Array must have 1 dimensions.  Given array has 2 dimensions

Ah, note that

numpy.array([milliseconds]) = array([[1800000]])

which should be `array([1800000]) inside:

if milliseconds.size == 1:
        resolutions = 
         pystare.core._coarsest_resolution_finer_or_equal_milliseconds(numpy.array([milliseconds]))[0]

So I shouldn't pass a numpy.array into pystare.coarsest_resolution_finer_or_equal_ms() anymore?