Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/ein16/synth/d2/test_createField.py
ViewVC logotype

View of /branches/ein16/synth/d2/test_createField.py

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3874 - (download) (as text) (annotate)
Wed May 18 16:45:54 2016 UTC (3 years, 10 months ago) by cchiw
File size: 2313 byte(s)
added some binary operators for 2-d
import sys
import re
import os

from test_examples import value_scalarFd2
from test_examples import value_vec2Fd2
from test_examples import value_scalarT
from test_examples import value_vec2T

ty_scalarF_d2 = value_scalarFd2()
ty_vec2F_d2 = value_vec2Fd2()
ty_scalarT = value_scalarT()
ty_vec2T = value_vec2T()

branch="/Users/chariseechiw/diderot/vis12/bin/diderotc --exec "

#convert coefficnets
def llist(cmd, coeff):
    a=" -"+cmd
    for i in coeff:
        a+=" "+str(i)
    return a

#call program due to field type
def progName(itype,outSize):
    #call program due to field type
    if (itype==ty_scalarF_d2):
        return ("symb_fsd2"," -which 0 "," -s 1 "+str(outSize * outSize))          # 2-d scalar field
    elif(itype==ty_vec2F_d2):                      # 2-d length 2 vector field
        return ("symb_fv2d2"," -which 4 "," -s 1 "+str(2*outSize *outSize))         # creates field with coefficients for each axis
        s= "type not supported in program name:"
        print s 

# shape-input field
# outSize-samples
# orig- name of synthetic field created with coefficients
# base,xsq,ysq,diag-coeffs
def createSingleField(itype,outSize,orig,  coeff):
    print "coeff",coeff
    print "shape inside create single field",itype
    (base, xsq, ysq, diag)=  coeff
    SIZE=" -sz0 "+ sout +" -sz1 "+ sout +" -width 1"    # giving sample size
    COEFF=llist("base",base)+llist("xsq",xsq)+llist("ysq",ysq)+llist("diag",diag) #convert coeff to strings
    # get program name and which command
    (e_Orig,w_coeff,w_shape) = progName(itype, outSize)
    p_Orig=  e_Orig+".diderot"
    #compile program

    #execute program
    os.system("./"+e_Orig+w_coeff+PARAMS+"| unu save -f nrrd -o "+outputnrrd)
    os.system("unu reshape -i "+outputnrrd+w_shape+" | unu save -f text -o "+orig+".txt")

    #save nrrd file
    os.system("rm *.o")
    os.system("rm *.h")
    os.system("rm *.c")
    os.system("rm "+e_Orig)

def createField(itypes,outSize,inputfile, coeffs):
    print "coeffs",coeffs
    print "input file",inputfile
    print "shape inside createField",itypes
    for (i,c,s)in zip(inputfile,coeffs,itypes):
        createSingleField(s,outSize,i, c)

ViewVC Help
Powered by ViewVC 1.0.0