def add_db(filename, tmpfilename): #sdb = interface.SciDBShimInterface('http://localhost:8080') sdb = interface.SciDBShimInterface('http://128.55.57.93:23100') paths = filename.split("/") datname = paths[-1].split(".") #sdb.query("create array T{halo1}<pid:int64,hid:int64> [i=0:*,2000000,0]",halo1=datname[0]) #print("load(T{halo1},'{filename}')",halo1=datname[0],filename=filename) #sdb.query("load(T{halo1},'{filename}')",halo1=datname[0],filename=filename); #sdb.query("load(T{halo1},'/home/tmalik/PDACS/galaxy-dist/database/files/000/dataset_121.dat')",halo1=datname[0]); #str_cmd = 'chmod 777 /home/tmalik/PDACS/galaxy-dist/database/files/000/%s.dat'%datname[0] #os.system(str_cmd) #sdb.query("load(T{halo1},'/home/tmalik/PDACS/galaxy-dist/database/files/000/{halo1}.dat')",halo1=datname[0]); return paths[-1]
def test_query_exec(self): print("establishing connection...") conn = interface.SciDBShimInterface('http://192.168.56.101:8080/') print(conn) a = zeros(ds, conn) b = ones(ds, conn) expr = a + b graph, ctx = expr.expr self.assertEqual(graph.dshape, dshape('10, 10, float64')) result = eval(expr) print(result)
def open_scidb_connection(address=SHIM_DEFAULT): return interface.SciDBShimInterface(address)
import os, sys, re, string from time import time from optparse import OptionParser import numpy as np from scidbpy import interface #sdb = interface.SciDBShimInterface('http://localhost:8080') sdb = interface.SciDBShimInterface('http://128.55.57.93:23100') def filetoarr(pathname): dirs = pathname.split('/') #print dirs arrname = dirs[-1].split(".") #print arrname return "T" + arrname[0] def main(): # define options parser = OptionParser() parser.add_option("-i", "--array1") parser.add_option("-j", "--array2") parser.add_option("-o", "--output") parser.add_option("-c", "--commands") #sdb.query("create array T100<pid:int64,hid:int64> [i=0:*,10000,0]") # parse options, args = parser.parse_args() try:
"""Utility script to clear arrays from scidb after a crash""" import re from scidbpy import interface sdb = interface.SciDBShimInterface('http://localhost:8080') arrays = sdb.list_arrays() print len(arrays), "arrays in database" R = re.compile('py[0-9]{12,14}_[0-9]{5,5}') auto_arrays = filter(R.match, arrays) print len(auto_arrays), "auto-generated arrays will be removed" for arr in auto_arrays: print " - removing", arr m = sdb.wrap_array(arr) m.persistent=False del m
from spheredb.get_data import\ get_stripe82_file, all_lsst_exposures, get_LSST_file from spheredb.conversions import FITS_to_HPX, HPX_grid_step from spheredb.util import regrid import os import pyfits import re import datetime # Note: USE INSERT NOT MERGE!!!! if 1: from scidbpy import interface sdb = interface.SciDBShimInterface('http://vega.cs.washington.edu:8080') Nside = 2**16 #19 hdulist = get_LSST_file() output = FITS_to_HPX(hdulist[1].header, hdulist[1].data, Nside, return_sparse=True) print output.shape RA_range = (output.row.min(), output.row.max()) DEC_range = (output.col.min(), output.col.max()) dRA = RA_range[1] - RA_range[0] dDEC = DEC_range[1] - DEC_range[0]
def connect(uri): """Connect to a SciDB database""" from scidbpy import interface return SciDBConn(interface.SciDBShimInterface(uri))
import numpy as np from numpy.testing import assert_equal, assert_raises from scipy import sparse from scidbpy import interface from spheredb.scidb_tools import SHIM_DEFAULT, find_index_bounds sdb = interface.SciDBShimInterface(SHIM_DEFAULT) def test_index_bounds(): row = [4, 4, 5, 5] col = [3, 6, 2, 4] data = [1, 1, 1, 1] M = sparse.coo_matrix((data, (row, col)), shape=(10, 10)) Msdb = sdb.from_sparse(M) assert_equal(find_index_bounds(Msdb, sdb), [4, 5, 2, 6]) assert_equal(find_index_bounds(Msdb, sdb, 1), [2, 6]) assert_equal(find_index_bounds(Msdb, sdb, (0, 1)), [4, 5, 2, 6]) assert_raises(ValueError, find_index_bounds, Msdb, sdb, 3)