How to realize the following function in scidb?


#1

import scipy as S
import psycopg2

db=psycopg2.connect(“dbname=‘hdf5db’ host=‘localhost’ user=‘cmengw’”)
cur = db.cursor()

cur.execute(“select crossid from hdf5 where crossid>0”)
rs = cur.fetchall()

crosslist = S.unique(rs)

for crossid0 in crosslist[0]:
cur.execute(“select jd,magCalib from hdf5 where crossid=%s” %(crossid0))
pp=cur.fetchall()
print pp


#2

Isn’t your query virtually the same as:

except that the results are grouped by crossid (if they are not distinct), in which case it might be more useful to do:

And even if you insist on doing two queries, you could eliminate the use of scipy by changing the first one to:


#3

[quote=“ktl”]Isn’t your query virtually the same as:

except that the results are grouped by crossid (if they are not distinct), in which case it might be more useful to do:

And even if you insist on doing two queries, you could eliminate the use of scipy by changing the first one to:

is the premise that crossID must be a dimension not a attribute?
but i didnt design crossID a dimension…

and i dont understand if delete scipy, how to realize the function in two queries?

Thanks!


#4

“SELECT jd, magCalib FROM hdf5 WHERE crossid > 0 ORDER BY crossid” is not a scidb query,

how to translate it into AQL,please?

Thanks!


#5

Right now AQL does not have an ORDER BY clause.
AFL has a sort operator but it only works for single-dimensional arrays.
So if your array has only one dimension, you could say

SELECT jd, magCalib FROM sort(hdf5, crossid) WHERE crossid > 0

Note: you can use reshape or slice or redimension to turn N-D arrays into 1-D.
We haven’t yet decided what multidimensional sorting will look like exactly.