Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize evac data by using smokeview #3

Open
godisreal opened this issue Aug 15, 2020 · 2 comments
Open

Visualize evac data by using smokeview #3

godisreal opened this issue Aug 15, 2020 · 2 comments

Comments

@godisreal
Copy link
Owner

Two major tasks are listed as below.
(1) Dumping .prt5 evac data in a single file.
(2) Writing .smv file by using python program.

@godisreal
Copy link
Owner Author


##############################################################
# The function writeFRec is modified from Topi's work
# python script: readFRec (by Topi on Google Forum)
# readFRec: Read fortran record, return payload as bytestring
##############################################################
#
def writeFRec(infile, fmt, data):
    len1 = np.size(data)
    if len1==0 or data is None:
        #len2=infile.read(4)
        #infile.write(0x00)
        temp = struct.pack('@I', 0)
        infile.write(temp)
    
        return None
    
    #if fmt=='s':
        #result  = struct.pack('@I', data.encode())
    #    infile.write(data.encode())
    # Not try data.encode().  Use standard format to write data
        
    fmt2 = str(len1)+fmt
    num  = len1 * struct.calcsize(fmt)
    
    # length of the data
    num2   = struct.pack('@I', num)
    infile.write(num2)
    
    # Write data
    for i in range(len1):
        result = struct.pack(fmt, data[i])
        infile.write(result)
    
    # End symbol
    temp = struct.pack('@I', 0)
    infile.write(temp)
    

    
#Read fortran record, return payload as bytestring
def readFRec(infile,fmt):
    len1   = infile.read(4)
    if not len1:
        return None
    len1   = struct.unpack('@I', len1)[0]

    if len1==0:
        len2=infile.read(4)
        return None
    num    = int(len1/struct.calcsize(fmt))
    fmt2   = str(num)+fmt
    if num>1:
        result = struct.unpack(fmt2,infile.read(len1))
    else:
        result = struct.unpack(fmt2,infile.read(len1))[0]
    len2   = struct.unpack('@I', infile.read(4))[0]
    if fmt == 's':
        result=result[0].rstrip()
    return result


def intiPrt(fileName, debug=True):
    
    n_part=1  # Number of PARTicle classes
    [n_quant,zero_int]=[2,0]  # Number of particle features
    
    #filename=open('test.bin', 'wb+')
    writeFRec(fileName, 'I', [1])      #! Integer 1 to check Endian-ness
    writeFRec(fileName, 'I', [653])    # FDS version number
    writeFRec(fileName, 'I', [n_part]) # Number of PARTicle classes
    for npc in range(n_part):
        writeFRec(fileName, 'I', [n_quant, zero_int])
        for nq in range(n_quant):
            if nq == 0:
                writeFRec(fileName,'s', "desired Vx") # smv_label
                writeFRec(fileName,'s', "m/s")        # units
                #q_units.append(units)  
                #q_labels.append(smv_label)
            if nq ==1:
                writeFRec(fileName,'s', "desired Vy") # smv_label
                writeFRec(fileName,'s', "m/s")        # units
                #q_units.append(units)  
                #q_labels.append(smv_label)
            # if n_quant ==2:
                #pass  #Agent features to be added
         

Now there is unexpected problem as below. Does anyone know how to solve this problem?
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python32\lib\tkinter_init_.py", line 1399, in call
return self.func(*args)
File "E:\gitwork\CrowdEgress\code\code_version2.0\ui.py", line 244, in testGe
m
sunpro1 = mp.Process(target=show_simu(self.currentSimu))
File "E:\gitwork\CrowdEgress\code\code_version2.0\draw_func.py", line 685, in
show_simu
intiPrt(fbin)
File "E:\gitwork\CrowdEgress\code\code_version2.0\data_func.py", line 792, in
intiPrt
writeFRec(fileName,'s', "desired Vx") # smv_label
File "E:\gitwork\CrowdEgress\code\code_version2.0\data_func.py", line 748, in
writeFRec
result = struct.pack(fmt, data[i])
struct.error: argument for 's' must be a bytes object
This error is not found in Python 2.7. Does anyone know how to solve this problem?

@godisreal
Copy link
Owner Author

Hi, @emanuelegissi, do you know how to solve this problem?
Also, I agree with you that it is necessary to develop another open-source evac program since fds+evac is not maintained officially. We are not sure whether Timo will release any new version of evac (decoupled from FDS) in his repo. Probably it may take a long time if he plans to do so. However, many academic users do need an open-source platform so that they can easily test their new algorithms or models. So there are still a number of researchers or grad students who need something like fds+evac, and thus I agree with you that we still need an open-source evac even if it is not maintained in FDS group.

So I am thinking if I should move forward on this small program so that it may become an alternative solution to fds+evac, and are you interested in this idea? You are sincerely invited to become a cooperator if you are interested. Maybe you would like to use Paraview to visualize the data or attract fundings by using any new ideas here... Anyway your joint efforts are much welcome and appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant