Slice() operator result order

#1

Hi,

I’m using the slice() operator to get a subset of my 4-dimensional array which looks like this:

``ascat_soil_moisture<gpi:uint32,exact_time:double,soilmoisture:uint8,soilmoisture_noise:uint8,surface_state_flag:uint8,processing_flag:uint8,orbit_dir_asc:bool> [cell=1976:2251,256,0,cell_pi=0:609,512,0,day=13514:15898,2048,0,obs=0:6,4,0]``

The slice I’m doing is:

``slice(ascat_soil_moisture, cell, 1976, cell_pi, 601);``

If I print the result of this to the command line (or access it via SciDBPy), it’s semi-ordered. For example:

{day, obs} …
[…]
{14974,0} …
{14974,1} …
{14974,2} …
{14974,3} …
[some 200 other results and then]
{14974,4} …

I assume this is because obs 0-3 are in the same chunk (chunk size 4 was picked by the USING clause) while obs 4 is in the next chunk?

Since this is a timeseries that should be ordered first by day and then by obs, what do I do to get the ordering right? The sort() operator will give me a 1-dim array, which is not what I need…

#2

One way of getting the ordering right is to make the chunk interval of the second dimension span the whole dimension space. See the difference between the following sample queries, the first having a “wrong” ordering and the second having a “correct” ordering.

iquery -aq “build(<v:int64>[i=0:1,2,0,j=0:3,2,0], i*3+j)”
{i,j} v
{0,0} 0
{0,1} 1
{1,0} 3
{1,1} 4
{0,2} 2
{0,3} 3
{1,2} 5
{1,3} 6

iquery -aq “build(<v:int64>[i=0:1,2,0,j=0:3,4,0], i*3+j)”
{i,j} v
{0,0} 0
{0,1} 1
{0,2} 2
{0,3} 3
{1,0} 3
{1,1} 4
{1,2} 5
{1,3} 6