Exemplo n.º 1
0
#!/usr/bin/env python

import time
import cdat_converter_service as ccs
ccs.init(database="/scratch/for_ganzberger1/idx/ondemand/idx/idx.db",
         hostname="none",
         port=80,
         xmlpath="/scratch/for_ganzberger1/idx/ondemand/xml",
         idxpath="/scratch/for_ganzberger1/idx/ondemand/idx",
         visus_server="none",
         username="******",
         password="******")

idxpaths = [
    "inst30mn_2d_aer1_Nx_M01-lon_lat_time.idx",
    "inst30mn_2d_aer1_Nx_M02-lon_lat_time.idx",
    "inst30mn_2d_aer1_Nx_M03-lon_lat_time.idx",
    "inst30mn_2d_aer1_Nx_M04-lon_lat_time.idx",
    "inst30mn_2d_aer1_Nx_M05-lon_lat_time.idx",
    "inst30mn_2d_aer1_Nx_M06-lon_lat_time.idx"
]
field = "TOTANGSTR"
box = ""  #ignored
hz = 1  #ignored
for i in range(1344):
    for idxpath in idxpaths:
        t1 = time.time()
        pt1 = time.clock()
        j = i * 30
        print("converting timestep " + str(j) + "...")
Exemplo n.º 2
0
#!/usr/bin/env python

import time
import cdat_converter_service as ccs
ccs.init(database="/scratch/for_ganzberger1/idx/ondemand/idx/idx.db",hostname="none",port=80,xmlpath="/scratch/for_ganzberger1/idx/ondemand/xml",idxpath="/scratch/for_ganzberger1/idx/ondemand/idx",visus_server="none",username="******",password="******")

idxpaths=["inst30mn_2d_aer1_Nx_M01-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M02-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M03-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M04-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M05-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M06-lon_lat_time.idx"]
field="SUANGSTR"
box="" #ignored
hz=1   #ignored
for i in range(1344):
    for idxpath in idxpaths:
        t1  = time.time()
        pt1 = time.clock()
        j=i*30 
        print("converting timestep "+str(j)+"...")

        (result_str,result)=ccs.convert(idxpath,field,j,box,hz)
        if not result==ccs.RESULT_SUCCESS:
            print result_str

        proctime=time.clock()-pt1
        interval=time.time()-t1
        print('   converted in time %d msec (proc_time: %d msec)'  % (interval*1000,proctime*1000))
Exemplo n.º 3
0
#!/usr/bin/env python

import time
import cdat_converter_service as ccs
ccs.init(database="/data/idx/idx.db",hostname="none",port=80,xmlpath="/data/xml",idxpath="/data/idx",visus_server="none")

idxpath="inst30mn_2d_aer1_Nx_M01-lon_lat_time.idx"
field="SUANGSTR"
box="" #ignored
hz=1   #ignored
for i in range(1344):
    t1  = time.time()
    pt1 = time.clock()
    j=i*30 
    print("converting timestep "+str(j)+"...")

    (result_str,result)=ccs.convert(idxpath,field,j,box,hz)
    if not result==ccs.RESULT_SUCCESS:
        print result_str

    proctime=time.clock()-pt1
    interval=time.time()-t1
    print('   converted in time %d msec (proc_time: %d msec)'  % (interval*1000,proctime*1000))
Exemplo n.º 4
0
#!/usr/bin/env python

import time
import cdat_converter_service as ccs
ccs.init(database="/data/idx/idx.db",
         hostname="none",
         port=80,
         xmlpath="/data/xml",
         idxpath="/data/idx",
         visus_server="none")

idxpaths = ["nasa3d-lon_lat_lev_time.idx"]
field = "CO2"
box = ""  #ignored
hz = 1  #ignored
for i in range(1344):
    for idxpath in idxpaths:
        t1 = time.time()
        pt1 = time.clock()
        j = i * 30
        print("converting timestep " + str(j) + "...")

        (result_str, result) = ccs.convert(idxpath, field, j, box, hz)
        if not result == ccs.RESULT_SUCCESS:
            print result_str

        proctime = time.clock() - pt1
        interval = time.time() - t1
        print('   converted in time %d msec (proc_time: %d msec)' %
              (interval * 1000, proctime * 1000))
Exemplo n.º 5
0
idxpaths={['BCANGSTR','BCCMASS','BCEXTTAU','BCSCATAU','BCSMASS','CO2CL001','CO2SC001','COCL','COSC','DMSCMASS','DMSSMASS','DUANGSTR','DUCMASS','DUCMASS25','DUEXTT25','DUEXTTAU','DUSCAT25','DUSCATAU','DUSMASS','DUSMASS25','OCANGSTR','OCCMASS','OCEXTTAU','OCSCATAU','OCSMASS','SO2CMASS','SO2SMASS','SO4CMASS','SO4SMASS','SSANGSTR','SSCMASS','SSCMASS25','SSEXTT25','SSEXTTAU','SSSCAT25','SSSCATAU','SSSMASS','SSSMASS25','SUANGSTR','SUEXTTAU','SUSCATAU','TOTANGSTR','TOTEXTTAU','TOTSCATAU']:["inst30mn_2d_aer1_Nx_M01-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M02-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M03-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M04-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M05-lon_lat_time.idx","inst30mn_2d_aer1_Nx_M06-lon_lat_time.idx"]}

field=sys.argv[1]

datasets=[]
for key in idxpaths:
    if field in key:
        datasets=idxpaths[key]
        break

if len(datasets)==0:
    print "no datasets found containing field "+field
    sys.exit(1)

ccs.init(database=os.environ['ONDEMAND_DB'],hostname="none",port=80,xmlpath=os.environ['ONDEMAND_XMLPATH'],idxpath=os.environ['ONDEMAND_IDXPATH'],visus_server="none")

box="" #ignored
hz=1   #ignored
for idxpath in idxpaths:
    timesteps=ccs.get_timesteps(idxpath)
    for i in timesteps:
        t1  = time.time()
        pt1 = time.clock()
        print("converting timestep "+str(i)+"...")

        (result_str,result)=ccs.convert(idxpath,field,i,box,hz)
        if not result==ccs.RESULT_SUCCESS:
            print result_str

        proctime=time.clock()-pt1
Exemplo n.º 6
0
def main(argv):
    inputfile = ''
    outputdir = ''
    fieldname = ''
    time = 0

    try:
        opts, args = getopt.getopt(argv, "hi:o:f:t:", ["ifile=", "odir="])
    except getopt.GetoptError:
        print_usage()
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print_usage()
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-o", "--odir"):
            outputdir = arg
        elif opt in ("-f"):
            fieldname = arg
        elif opt in ("-t"):
            time = int(arg)

    if ((not os.path.isfile(inputfile)) or (not os.path.isdir(outputdir))):
        print('Invalid input or file or dir not found\n')
        print_usage()
        sys.exit(2)

    print('Input file is ', inputfile)
    print('Output dir is ', outputdir)

    inputdir = os.path.dirname(inputfile)

    database = outputdir + "/idx.db"

    if not os.path.isfile(database):
        print("Database file not found, creating it...")
        with open('create_tables.sql', 'r') as sql_file:
            sql_script = sql_file.read()
        db = sqlite3.connect(database)
        c = db.cursor()
        c.executescript(sql_script)
        db.commit()
        c.close()
        db.close()

    db = sqlite3.connect(database)

    ccs.init(database=database,
             hostname="none",
             port=80,
             xmlpath=inputdir,
             idxpath=outputdir,
             visus_server="none")

    with db:
        inputfile = os.path.abspath(inputfile)
        outputdir = os.path.abspath(outputdir)
        global idx_paths
        idx_paths, ds_id = getIdxPaths(inputfile, db)

        #if not validatePaths(idx_paths,outputdir):
        #   print "idx files do not exist: (re)creating them"
        force = False

        # if force recreate, delete existing entries in database
        if force:
            cur = db.cursor()

            cur.execute("DELETE from datasets where ds_id=%d" % ds_id[0])
            for path in idx_paths:
                cur.execute("DELETE from idxfiles where ds_id=%d" % ds_id[0])
                cur.execute("DELETE from midxfiles where ds_id=%d" % ds_id[0])

        if len(idx_paths) == 0 or force:
            conv.cdat_to_idx(inputfile, outputdir, db)

            print("done creating idx volumes for", inputfile)
            idx_paths, ds_id = getIdxPaths(inputfile, db)
        else:
            print("idx volumes already exist for", inputfile)

    db.close()

    dataset = Dataset_loadDataset(outputdir + "/" + idx_paths[0])
    print(dataset)
    f = dataset.getDefaultField()

    print("exported fields:")
    for ef in dataset.getFields():
        print(ef.name)

    if (fieldname == ''):
        field = f.name
    else:
        field = fieldname
    timestep = time
    hz = -1
    box = None

    try:
        print(">>> Converting field " + field + " at time " + str(timestep))
        convert_query.convert(idx_paths[0], field, timestep, box, hz, database)
    except (Exception, e):
        print("Exception: ", e)
Exemplo n.º 7
0
def main(argv):
  inputfile=''
  outputdir=''
  fieldname=''
  time=0

  try:
    opts, args = getopt.getopt(argv,"hi:o:f:t:",["ifile=","odir="])
  except getopt.GetoptError:
    print_usage()
    sys.exit(2)
  for opt, arg in opts:
    if opt == '-h':
       print_usage()
       sys.exit()
    elif opt in ("-i", "--ifile"):
       inputfile = arg
    elif opt in ("-o", "--odir"):
       outputdir = arg
    elif opt in ("-f"):
       fieldname = arg
    elif opt in ("-t"):
       time = int(arg)

  if((not os.path.isfile(inputfile)) or (not os.path.isdir(outputdir))):
    print('Invalid input or file or dir not found\n')
    print_usage()
    sys.exit(2)

  print('Input file is ', inputfile)
  print('Output dir is ', outputdir)

  inputdir=os.path.dirname(inputfile)

  database=outputdir+"/idx.db"

  if not os.path.isfile(database):
    print("Database file not found, creating it...")
    with open('create_tables.sql', 'r') as sql_file:
      sql_script = sql_file.read()
    db = sqlite3.connect(database)
    c = db.cursor()
    c.executescript(sql_script)
    db.commit()
    c.close()
    db.close()

  db = sqlite3.connect(database)

  ccs.init(database=database,hostname="none",port=80,xmlpath=inputdir,idxpath=outputdir,visus_server="none")

  with db:
     inputfile=os.path.abspath(inputfile)
     outputdir=os.path.abspath(outputdir)
     global idx_paths
     idx_paths,ds_id=getIdxPaths(inputfile,db)

     #if not validatePaths(idx_paths,outputdir):                                                                     
     #   print "idx files do not exist: (re)creating them"                                                           
     force=False

      # if force recreate, delete existing entries in database                                                       
     if force:
         cur=db.cursor()

         cur.execute("DELETE from datasets where ds_id=%d"%ds_id[0])
         for path in idx_paths:
                  cur.execute("DELETE from idxfiles where ds_id=%d"%ds_id[0])
                  cur.execute("DELETE from midxfiles where ds_id=%d"%ds_id[0])

     if len(idx_paths)==0 or force:
          conv.cdat_to_idx(inputfile,outputdir,db)

          print("done creating idx volumes for",inputfile)
          idx_paths,ds_id=getIdxPaths(inputfile,db)
     else:
          print("idx volumes already exist for",inputfile)

  db.close()

  dataset=Dataset_loadDataset(outputdir+"/"+idx_paths[0])
  print(dataset)
  f=dataset.getDefaultField()
  
  print("exported fields:")
  for ef in dataset.getFields():
    print(ef.name)

  if(fieldname==''):
    field=f.name
  else:
    field=fieldname
  timestep=time
  hz=-1
  box=None

  try:
    print(">>> Converting field "+field+" at time "+str(timestep))
    convert_query.convert(idx_paths[0],field,timestep,box,hz,database)
  except (Exception, e):
    print("Exception: ",e)