Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F116961585
splitgmov
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 10, 13:25
Size
3 KB
Mime Type
text/x-python
Expires
Thu, Jun 12, 13:25 (2 d)
Engine
blob
Format
Raw Data
Handle
26699838
Attached To
rPNBODY pNbody
splitgmov
View Options
#!/usr/bin/env python
import sys
import os
import getopt
from pNbody import Movie
from numpy import *
####################################################################################
def version():
####################################################################################
print 'version 1.0'
sys.exit(0)
####################################################################################
def help_message():
####################################################################################
print '''Usage : splitgmov -f input --nh=nh --nv=nv
Options: -h -- this help message
-f -- input movie
--nh -- number of horizontal images
--nv -- number of vertical images
--help -- this help message
--version -- displays version
'''
sys.exit(0)
####################################################################################
def check_arguments(options,xarguments):
####################################################################################
nh = 1
nv = 1
output = None
for a in options[:]:
if a[0] == '-h':
help_message()
if a[0] == '--help':
help_message()
if a[0] == '--version':
version()
if a[0] == '--info':
info = 1
if a[0] == '--nh':
if a[1] == '':
help_message()
else:
nh = a[1]
continue
if a[0] == '--nv':
if a[1] == '':
help_message()
else:
nv = a[1]
continue
if a[0] == '-f':
if a[1] == '':
help_message()
else:
output = a[1]
continue
if output == None:
help_message()
return nh, nv, output
####################################################################################
#
# MAIN
#
####################################################################################
try:
options, xarguments = getopt.getopt(sys.argv[1:],'f:h', ['info','help','version','nh=','nv='])
except getopt.error:
help_message()
sys.exit(0)
# check arguments
nh, nv, name = check_arguments(options,xarguments)
nh = int(nh)
nv = int(nv)
bname = os.path.split(os.path.splitext(name)[0])[1]
ext = os.path.splitext(name)[1]
film = Movie.Movie(name)
film.open()
n1 = nh # horizontal
n2 = nv # vertical
nmov = n1*n2
nh = film.numByte / n1 # sub movie horiz
nv = film.numLine / n2 # sub movie vert
#print film.numByte,n1,nh
#print film.numLine,n2,nv
dd = []
for i in range(1,n1+1):
for j in range(1,n2+1):
dd.append((i,j))
newfilms = []
for n in range(nmov):
dx,dy = dd[n]
newfilms.append(Movie.Movie('%s_%d%d%s'%(bname,dx,dy,ext)))
newfilms[n].new(nh,nv)
n = -1
while 1:
n = n + 1
mat = film.read_one("array")
if mat==None: break
print film.current_time
# sous image
for n in range(nmov):
dx,dy = dd[n]
smat = mat[nv*(dy-1):nv+(nv*(dy-1)),nh*(dx-1):nh+(nh*(dx-1))]
data = smat.tostring()
newfilms[n].write_pic(film.current_time,data)
Event Timeline
Log In to Comment