---had some problems with svn, hope everything is ok now---
added new tools to generate colormaps for paraview and gmsh, written in python removed old fortran colormap generator. removed test.py (not longer needed) and the python module reconstruct.pyd (not running under linux)
This commit is contained in:
parent
3b0eeb9956
commit
20c00288b8
|
@ -1,69 +0,0 @@
|
|||
program colormap
|
||||
|
||||
implicit none
|
||||
real startH, endH, startS, endS, startL, endL, h_strich,x,c,m
|
||||
integer steps,i,j
|
||||
character(len=100) name
|
||||
print*, '******************************************************************************'
|
||||
print*, ' write colormap for gmsh'
|
||||
print*, '******************************************************************************'
|
||||
print*, ''
|
||||
write(*, '(A)', advance = 'NO') 'Please enter startvalue for L: '
|
||||
read(*, *), startL
|
||||
write(*, '(A)', advance = 'NO') 'Please enter endvalue for L: '
|
||||
read(*, *), endL
|
||||
write(*, '(A)', advance = 'NO') 'Please enter startvalue for S: '
|
||||
read(*, *), startS
|
||||
write(*, '(A)', advance = 'NO') 'Please enter endvalue for S: '
|
||||
read(*, *), endS
|
||||
write(*, '(A)', advance = 'NO') 'Please enter steps: '
|
||||
read(*, *), steps
|
||||
do j=0,360
|
||||
write(name, *) j
|
||||
name=adjustl(name)
|
||||
startH = real(j)
|
||||
endH =real(j)
|
||||
open(20, file = ('colormap_')//trim(name)//('.map'))
|
||||
write(20,*),'View.ColorTable = {'
|
||||
if(endH<startH) endH=endH+startH
|
||||
do i=0, steps-1
|
||||
H_strich = (startH + real(i)*(endH-startH)/real(steps))/60
|
||||
if(h_strich>6.0) h_strich = h_strich-6.0
|
||||
c = (1- abs(2*(startL + real(i)*(endL-startL)/real(steps))-1))*sqrt(startS + real(i)*(endS-startS)/real(steps))
|
||||
x = c*(1- abs(mod(h_strich, real(2))-1))
|
||||
m = (startL + real(i)*(endL-startL)/real(steps)) -.5*c
|
||||
if ((0.0 <= h_strich).and.(h_strich<1.0)) then
|
||||
write(20,*),'{',(c+m)*255,',',(x+m)*255,',',(0.0+m)*255,'},'
|
||||
else if ((1.0 <= h_strich).and.(h_strich<2.0)) then
|
||||
write(20,*),'{',(x+m)*255,',',(c+m)*255,',',(0.0+m)*255,'},'
|
||||
else if ((2.0 <= h_strich).and.(h_strich<3.0)) then
|
||||
write(20,*),'{',(0.0+m)*255,',',(c+m)*255,',',(x+m)*255,'},'
|
||||
else if ((3.0 <= h_strich).and.(h_strich<4.0)) then
|
||||
write(20,*),'{',(0.0+m)*255,',',(x+m)*255,',',(c+m)*255,'},'
|
||||
else if ((4.0 <= h_strich).and.(h_strich<5.0)) then
|
||||
write(20,*),'{',(x+m)*255,',',(0.0+m)*255,',',(c+m)*255,'},'
|
||||
else if ((5.0 <= h_strich).and.(h_strich<=6.0)) then
|
||||
write(20,*),'{',(c+m)*255,',',(0.0+m)*255,',',(x+m)*255,'},'
|
||||
endif
|
||||
enddo
|
||||
H_strich = (startH + real(i)*(endH-startH)/real(steps))/60
|
||||
if(h_strich>6.0) h_strich = h_strich-6.0
|
||||
c = (1- abs(2*(startL + real(i)*(endL-startL)/real(steps))-1))*(startS + real(i)*(endS-startS)/real(steps))
|
||||
x = c*(1- abs(mod(h_strich, real(2))-1))
|
||||
m = (startL + real(i)*(endL-startL)/real(steps)) -.5*c
|
||||
if ((0.0 <= h_strich).and.(h_strich<1.0)) then
|
||||
write(20,*),'{',(c+m)*255,',',(x+m)*255,',',(0.0+m)*255,'}'
|
||||
else if ((1.0 <= h_strich).and.(h_strich<2.0)) then
|
||||
write(20,*),'{',(x+m)*255,',',(c+m)*255,',',(0.0+m)*255,'}'
|
||||
else if ((2.0 <= h_strich).and.(h_strich<3.0)) then
|
||||
write(20,*),'{',(0.0+m)*255,',',(c+m)*255,',',(x+m)*255,'}'
|
||||
else if ((3.0 <= h_strich).and.(h_strich<4.0)) then
|
||||
write(20,*),'{',(0.0+m)*255,',',(x+m)*255,',',c+m,'}'
|
||||
else if ((4.0 <= h_strich).and.(h_strich<5.0)) then
|
||||
write(20,*),'{',(x+m)*255,',',(0.0+m)*255,',',(c+m)*255,'}'
|
||||
else if ((5.0 <= h_strich).and.(h_strich<=6.0)) then
|
||||
write(20,*),'{',(c+m)*255,',',(0.0+m)*255,',',(x+m)*255,'}'
|
||||
endif
|
||||
write(20,*),'};'
|
||||
enddo
|
||||
end program
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
# This script is used to generate colormaps for gmsh (http://geuz.org/gmsh/)
|
||||
# The script writes 360 files. Each file contains one colormap.
|
||||
# More information on the used colors space can be found at http://en.wikipedia.org/wiki/HSL_and_HSV
|
||||
# written by M. Diehl, m.diehl@mpie.de
|
||||
|
||||
import math
|
||||
|
||||
print '******************************************************************************'
|
||||
print ' Write colormaps for gmsh'
|
||||
print ''
|
||||
print 'Suitable for datasets that have only positive/negative values'
|
||||
print 'The colors are described using the HSL model.'
|
||||
print 'Each of the 360 generated colormaps uses one value of (H)ue.'
|
||||
print 'The colormaps runs at constant H from given (L)ightness and (S)aturation'
|
||||
print 'to given L and S'
|
||||
print 'L is distribute linearly, S changes as the square root of a linear list.'
|
||||
print 'Suitable values: L_start = S_start = 1 , L_end = S_end = 0.'
|
||||
print '******************************************************************************'
|
||||
print ''
|
||||
startL = float(raw_input('Please enter start value for (L)ightness: '))
|
||||
endL = float(raw_input('Please enter end value for L: '))
|
||||
startS = float(raw_input('Please enter start value for (S)aturation: '))
|
||||
endS = float(raw_input('Please enter end value for S: '))
|
||||
steps = int(raw_input('Please enter steps/resolution: '))
|
||||
for h in range(0,360):
|
||||
colormap = open('colormap_' + str(h).zfill(3) + '.map',"w")
|
||||
colormap.write('View.ColorTable = {\n')
|
||||
for i in range(0,steps):
|
||||
h_strich = h/60.0
|
||||
if(h_strich>6.0):
|
||||
h_strich = h_strich-6.0
|
||||
c = (1- abs(2*(startL + i*(endL-startL)/steps)-1))*math.sqrt(startS + i*(endS-startS)/steps)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (startL + i*(endL-startL)/steps) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((x+m)*255.0)+','+str((0.0+m)*255.0)+'},\n')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((c+m)*255.0)+','+str((0.0+m)*255.0)+'},\n')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((c+m)*255.0)+','+str((x+m)*255.0)+'},\n')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((x+m)*255.0)+','+str((c+m)*255.0)+'},\n')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((0.0+m)*255.0)+','+str((c+m)*255.0)+'},\n')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((0.0+m)*255.0)+','+str((x+m)*255.0)+'},\n')
|
||||
c = (1- abs(2*(startL)-1))*(startS)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (startL) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((x+m)*255.0)+','+str((0.0+m)*255.0)+'}};')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((c+m)*255.0)+','+str((0.0+m)*255.0)+'}};')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((c+m)*255.0)+','+str((x+m)*255.0)+'}};')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((x+m)*255.0)+','+str((c+m)*255.0)+'}};')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((0.0+m)*255.0)+','+str((c+m)*255.0)+'}};')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((0.0+m)*255.0)+','+str((x+m)*255.0)+'}};')
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
# This script is used to generate colormaps for gmsh (http://geuz.org/gmsh/)
|
||||
# The script writes 360 files. Each file contains one colormap.
|
||||
# More information on the used colors space can be found at http://en.wikipedia.org/wiki/HSL_and_HSV
|
||||
# written by M. Diehl, m.diehl@mpie.de
|
||||
|
||||
import math
|
||||
|
||||
print '******************************************************************************'
|
||||
print ' Write colormaps for gmsh'
|
||||
print ''
|
||||
print 'Suitable for datasets running from negative to positive values.'
|
||||
print 'The colors are described using the HSL model.'
|
||||
print 'Each of the 360 generated colormaps uses two values of (H)ue.'
|
||||
print 'The colormaps runs at constant H from given (L)ightness and (S)aturation'
|
||||
print 'to given L_min and S_min and goes to H+180° (with given L and S)'
|
||||
print 'Suitable values: L = L_min =.5, S = 1, and S_min=0,'
|
||||
print '******************************************************************************'
|
||||
print ''
|
||||
startL = float(raw_input('Please enter start value for (L)ightness: '))
|
||||
endL = float(raw_input('Please enter minimum value for L: '))
|
||||
startS = float(raw_input('Please enter start value for (S)aturation: '))
|
||||
endS = float(raw_input('Please enter minimum value for S: '))
|
||||
steps = int(raw_input('Please enter steps/resolution: '))
|
||||
steps = steps/2
|
||||
for h in range(0,360):
|
||||
colormap = open('colormap_' + str(h).zfill(3) + '.map',"w")
|
||||
colormap.write('View.ColorTable = {\n')
|
||||
i=0
|
||||
h_strich = h/60.0
|
||||
if(h_strich>6.0):
|
||||
h_strich = h_strich-6.0
|
||||
for j in range(0,steps+1):
|
||||
# let L run linearly from 0 to 1, let S be the square root of a linear list from 0 to 1
|
||||
c = (1- abs(2*(startL - j*(startL-endL)/steps)-1))*(startS - j*(startS-endS)/steps)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (startL - j*(startL-endL)/steps) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((x+m)*255.0)+','+str((0.0+m)*255.0)+'},\n')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((c+m)*255.0)+','+str((0.0+m)*255.0)+'},\n')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((c+m)*255.0)+','+str((x+m)*255.0)+'},\n')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((x+m)*255.0)+','+str((c+m)*255.0)+'},\n')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((0.0+m)*255.0)+','+str((c+m)*255.0)+'},\n')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((0.0+m)*255.0)+','+str((x+m)*255.0)+'},\n')
|
||||
i = i+1
|
||||
h_strich = (h+180.0)/60.0
|
||||
if(h_strich>6.0):
|
||||
h_strich = h_strich-6.0
|
||||
for j in range(1,steps):
|
||||
c = (1- abs(2*(endL+j*(startL-endL)/steps)-1))*(endS+j*(startS-endS)/steps)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (endL+j*(startL-endL)/steps) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((x+m)*255.0)+','+str((0.0+m)*255.0)+'},\n')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((c+m)*255.0)+','+str((0.0+m)*255.0)+'},\n')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((c+m)*255.0)+','+str((x+m)*255.0)+'},\n')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((x+m)*255.0)+','+str((c+m)*255.0)+'},\n')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((0.0+m)*255.0)+','+str((c+m)*255.0)+'},\n')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((0.0+m)*255.0)+','+str((x+m)*255.0)+'},\n')
|
||||
i=i+1
|
||||
c = (1- abs(2*(startL)-1))*(startS)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (startL) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((x+m)*255.0)+','+str((0.0+m)*255.0)+'}};')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((c+m)*255.0)+','+str((0.0+m)*255.0)+'}};')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((c+m)*255.0)+','+str((x+m)*255.0)+'}};')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('{'+str((0.0+m)*255.0)+','+str((x+m)*255.0)+','+str((c+m)*255.0)+'}};')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('{'+str((x+m)*255.0)+','+str((0.0+m)*255.0)+','+str((c+m)*255.0)+'}};')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('{'+str((c+m)*255.0)+','+str((0.0+m)*255.0)+','+str((x+m)*255.0)+'}};')
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
# This script is used to generate colormaps for paraview (www.paraview.org)
|
||||
# The script writes 360 files. Each file contains one colormap.
|
||||
# More information on the used colors space can be found at http://en.wikipedia.org/wiki/HSL_and_HSV
|
||||
# written by M. Diehl, m.diehl@mpie.de
|
||||
|
||||
import math
|
||||
|
||||
print '******************************************************************************'
|
||||
print ' Write colormaps for paraview'
|
||||
print ''
|
||||
print 'Suitable for datasets that have only positive/negative values'
|
||||
print 'The colors are described using the HSL model.'
|
||||
print 'Each of the 360 generated colormaps uses one value of (H)ue.'
|
||||
print 'The colormaps runs at constant H from given (L)ightness and (S)aturation'
|
||||
print 'to given L and S'
|
||||
print 'L is distribute linearly, S changes as the square root of a linear list.'
|
||||
print 'Suitable values: L_start = S_start = 1 , L_end = S_end = 0.'
|
||||
print '******************************************************************************'
|
||||
print ''
|
||||
startL = float(raw_input('Please enter start value for (L)ightness: '))
|
||||
endL = float(raw_input('Please enter end value for L: '))
|
||||
startS = float(raw_input('Please enter start value for (S)aturation: '))
|
||||
endS = float(raw_input('Please enter end value for S: '))
|
||||
steps = int(raw_input('Please enter steps/resolution: '))
|
||||
for h in range(0,360):
|
||||
colormap = open('colormap_' + str(h) + '.xml',"w")
|
||||
colormap.write('<ColorMap name = "' + str(h) + '" space = "RGB">\n')
|
||||
for i in range(0,steps+1):
|
||||
h_strich = h/60.0
|
||||
if(h_strich>6.0):
|
||||
h_strich = h_strich-6.0
|
||||
c = (1- abs(2*(startL + i*(endL-startL)/steps)-1))*math.sqrt(startS + i*(endS-startS)/steps)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (startL + i*(endL-startL)/steps) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(c+m)+'" g="'+str(x+m)+'" b="'+str(0.0+m)+'"/>\n')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(x+m)+'" g="'+str(c+m)+'" b="'+str(0.0+m)+'"/>\n')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(0.0+m)+'" g="'+str(c+m)+'" b="'+str(x+m)+'"/>\n')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(0.0+m)+'" g="'+str(x+m)+'" b="'+str(c+m)+'"/>\n')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(x+m)+'" g="'+str(0.0+m)+'" b="'+str(c+m)+'"/>\n')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(c+m)+'" g="'+str(0.0+m)+'" b="'+str(x+m)+'"/>\n')
|
||||
colormap.write('</ColorMap>')
|
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
# This script is used to generate colormaps for paraview (www.paraview.org)
|
||||
# The script writes 360 files. Each file contains one colormap.
|
||||
# More information on the used colors space can be found at http://en.wikipedia.org/wiki/HSL_and_HSV
|
||||
# written by M. Diehl, m.diehl@mpie.de
|
||||
|
||||
import math
|
||||
|
||||
print '******************************************************************************'
|
||||
print ' Write colormaps for paraview'
|
||||
print ''
|
||||
print 'Suitable for datasets running from negative to positive values.'
|
||||
print 'The colors are described using the HSL model.'
|
||||
print 'Each of the 360 generated colormaps uses two values of (H)ue.'
|
||||
print 'The colormaps runs at constant H from given (L)ightness and (S)aturation'
|
||||
print 'to given L_min and S_min and goes to H+180° (with given L and S)'
|
||||
print 'Suitable values: L = L_min =.5, S = 1, and S_min=0,'
|
||||
print '******************************************************************************'
|
||||
print ''
|
||||
startL = float(raw_input('Please enter start value for (L)ightness: '))
|
||||
endL = float(raw_input('Please enter minimum value for L: '))
|
||||
startS = float(raw_input('Please enter start value for (S)aturation: '))
|
||||
endS = float(raw_input('Please enter minimum value for S: '))
|
||||
steps = int(raw_input('Please enter steps/resolution: '))
|
||||
steps = steps/2
|
||||
for h in range(0,360):
|
||||
colormap = open('colormap_' + str(h).zfill(3) + '.xml',"w")
|
||||
colormap.write('<ColorMap name = "Complementary Color ' + str(h).zfill(3) + '" space = "RGB">\n')
|
||||
i=0
|
||||
h_strich = h/60.0
|
||||
if(h_strich>6.0):
|
||||
h_strich = h_strich-6.0
|
||||
for j in range(0,steps+1):
|
||||
# let L run linearly from 0 to 1, let S be the square root of a linear list from 0 to 1
|
||||
c = (1- abs(2*(startL - j*(startL-endL)/steps)-1))*(startS - j*(startS-endS)/steps)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (startL - j*(startL-endL)/steps) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(c+m)+'" g="'+str(x+m)+'" b="'+str(0.0+m)+'"/>\n')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(x+m)+'" g="'+str(c+m)+'" b="'+str(0.0+m)+'"/>\n')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(0.0+m)+'" g="'+str(c+m)+'" b="'+str(x+m)+'"/>\n')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(0.0+m)+'" g="'+str(x+m)+'" b="'+str(c+m)+'"/>\n')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(x+m)+'" g="'+str(0.0+m)+'" b="'+str(c+m)+'"/>\n')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(c+m)+'" g="'+str(0.0+m)+'" b="'+str(x+m)+'"/>\n')
|
||||
i = i+1
|
||||
h_strich = (h+180.0)/60.0
|
||||
if(h_strich>6.0):
|
||||
h_strich = h_strich-6.0
|
||||
for j in range(1,steps+1):
|
||||
c = (1- abs(2*(endL+j*(startL-endL)/steps)-1))*(endS+j*(startS-endS)/steps)
|
||||
x = c*(1- abs(h_strich%2-1))
|
||||
m = (endL+j*(startL-endL)/steps) -.5*c
|
||||
if (0.0 <= h_strich)and(h_strich<1.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(c+m)+'" g="'+str(x+m)+'" b="'+str(0.0+m)+'"/>\n')
|
||||
elif (1.0 <= h_strich)and(h_strich<2.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(x+m)+'" g="'+str(c+m)+'" b="'+str(0.0+m)+'"/>\n')
|
||||
elif (2.0 <= h_strich)and(h_strich<3.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(0.0+m)+'" g="'+str(c+m)+'" b="'+str(x+m)+'"/>\n')
|
||||
elif (3.0 <= h_strich)and(h_strich<4.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(0.0+m)+'" g="'+str(x+m)+'" b="'+str(c+m)+'"/>\n')
|
||||
elif (4.0 <= h_strich)and(h_strich<5.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(x+m)+'" g="'+str(0.0+m)+'" b="'+str(c+m)+'"/>\n')
|
||||
elif (5.0 <= h_strich)and(h_strich<=6.0):
|
||||
colormap.write('<Point x="'+str(i)+'" o="1" r="'+str(c+m)+'" g="'+str(0.0+m)+'" b="'+str(x+m)+'"/>\n')
|
||||
i=i+1
|
||||
colormap.write('</ColorMap>')
|
Binary file not shown.
|
@ -1,112 +1,114 @@
|
|||
import array
|
||||
import struct
|
||||
#import numpy
|
||||
print('post processing for mpie_spectral')
|
||||
|
||||
filename ='results.out'
|
||||
results = open(filename, 'rb')
|
||||
print('filename:', filename)
|
||||
position=0
|
||||
|
||||
#this funtion finds a string value in the given file for a given keyword
|
||||
def searchNameForKeyword(searchstring, file, maxpos):
|
||||
results.seek(0,0)
|
||||
begin = file.read(2048).find(searchstring) + len(searchstring) # function will return -1 if string isnt found
|
||||
file.seek(begin -len(searchstring) -4) #position of header
|
||||
header = file.read(4) #store header
|
||||
file.seek(begin,0)
|
||||
length = file.read(2048).find(header)
|
||||
file.seek(begin,0)
|
||||
name = file.read(length)
|
||||
return name, max(maxpos,results.tell())
|
||||
|
||||
#this funtion finds an integer value in the given file for a given keyword
|
||||
def searchValueForKeyword(searchstring, file, maxpos):
|
||||
results.seek(0,0)
|
||||
begin = file.read(2048).find(searchstring) + len(searchstring) # function will return -1 if string isnt found
|
||||
file.seek(begin,0)
|
||||
value = array.array('i',[0])
|
||||
value = struct.unpack('i',results.read(4))[0]
|
||||
return value, max(maxpos,results.tell())
|
||||
|
||||
#finds the value for the three integers followed the given keyword
|
||||
def searchArrayForKeyword(searchstring, file, maxpos):
|
||||
values = array.array('i',[0,0,0])
|
||||
results.seek(0,0)
|
||||
begin = results.read(2048).find(searchstring) + len(searchstring) #end position of string "resolution"
|
||||
pos = results.read(60).find(b'a')
|
||||
results.seek(begin+pos+2,0) #why two, not 1??
|
||||
values[0]=struct.unpack('i',results.read(4))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'b')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[1]=struct.unpack('i',results.read(4))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'c')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[2]=struct.unpack('i',results.read(4))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
return values, maxpos
|
||||
|
||||
#finds the value for the three doubles followed the given keyword
|
||||
def searchFarrayForKeyword(searchstring, file, maxpos):
|
||||
values = array.array('d',[0,0,0])
|
||||
results.seek(0,0)
|
||||
begin = results.read(2048).find(searchstring) + len(searchstring) #end position of string "resolution"
|
||||
pos = results.read(60).find(b'x')
|
||||
results.seek(begin+pos+2,0) #why two, not 1??
|
||||
values[0]=struct.unpack('d',results.read(8))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'y')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[1]=struct.unpack('d',results.read(8))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'z')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[2]=struct.unpack('d',results.read(8))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
return values, maxpos
|
||||
|
||||
loadcase, position = searchNameForKeyword(b'Loadcase ', results, position)
|
||||
workingdir, position = searchNameForKeyword(b'Workingdir ', results, position)
|
||||
jobname, position = searchNameForKeyword(b'JobName ', results, position)
|
||||
totalincs, position = searchValueForKeyword(b'totalincs ', results, position)
|
||||
materialpoint_sizeResults, position = searchValueForKeyword(b'materialpoint_sizeResults ', results, position)
|
||||
resolution, position = searchArrayForKeyword(b'resolution ', results, position)
|
||||
geomdimension, position = searchFarrayForKeyword(b'geomdimension ', results, position)
|
||||
position=position+4 +13*8
|
||||
results.seek(position,0)
|
||||
tnsr = array.array('d',[0,0,0,0,0,0,0,0,0])
|
||||
tnsr[0]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[1]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[2]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[3]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[4]=struct.unpack('d',results.read(8))[0]
|
||||
print(tnsr)
|
||||
|
||||
|
||||
# ended reading of header. now starting to read information concerning output
|
||||
#filename = jobname[0:len(jobname)-5]+b'.outputCrystallite'
|
||||
#outputCrystallite = open(filename, 'r')
|
||||
|
||||
def InCharCount(location, character):
|
||||
subj = file(location, "r")
|
||||
body = subj.read()
|
||||
subj.close()
|
||||
return body.count(character)
|
||||
|
||||
|
||||
def InCharCount(location, character):
|
||||
subj = file(location, "r")
|
||||
|
||||
nbr_of_char = 0
|
||||
for line in subj:
|
||||
nbr_of_char = nbr_of_char + line.count(character)
|
||||
|
||||
return nbr_of_char
|
||||
|
||||
|
||||
#!/usr/bin/python
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
import array
|
||||
import struct
|
||||
#import numpy
|
||||
print('post processing for mpie_spectral')
|
||||
|
||||
filename ='results.out'
|
||||
results = open(filename, 'rb')
|
||||
print('filename:', filename)
|
||||
position=0
|
||||
|
||||
#this funtion finds a string value in the given file for a given keyword
|
||||
def searchNameForKeyword(searchstring, file, maxpos):
|
||||
results.seek(0,0)
|
||||
begin = file.read(2048).find(searchstring) + len(searchstring) # function will return -1 if string isnt found
|
||||
file.seek(begin -len(searchstring) -4) #position of header
|
||||
header = file.read(4) #store header
|
||||
file.seek(begin,0)
|
||||
length = file.read(2048).find(header)
|
||||
file.seek(begin,0)
|
||||
name = file.read(length)
|
||||
return name, max(maxpos,results.tell())
|
||||
|
||||
#this funtion finds an integer value in the given file for a given keyword
|
||||
def searchValueForKeyword(searchstring, file, maxpos):
|
||||
results.seek(0,0)
|
||||
begin = file.read(2048).find(searchstring) + len(searchstring) # function will return -1 if string isnt found
|
||||
file.seek(begin,0)
|
||||
value = array.array('i',[0])
|
||||
value = struct.unpack('i',results.read(4))[0]
|
||||
return value, max(maxpos,results.tell())
|
||||
|
||||
#finds the value for the three integers followed the given keyword
|
||||
def searchArrayForKeyword(searchstring, file, maxpos):
|
||||
values = array.array('i',[0,0,0])
|
||||
results.seek(0,0)
|
||||
begin = results.read(2048).find(searchstring) + len(searchstring) #end position of string "resolution"
|
||||
pos = results.read(60).find(b'a')
|
||||
results.seek(begin+pos+2,0) #why two, not 1??
|
||||
values[0]=struct.unpack('i',results.read(4))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'b')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[1]=struct.unpack('i',results.read(4))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'c')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[2]=struct.unpack('i',results.read(4))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
return values, maxpos
|
||||
|
||||
#finds the value for the three doubles followed the given keyword
|
||||
def searchFarrayForKeyword(searchstring, file, maxpos):
|
||||
values = array.array('d',[0,0,0])
|
||||
results.seek(0,0)
|
||||
begin = results.read(2048).find(searchstring) + len(searchstring) #end position of string "resolution"
|
||||
pos = results.read(60).find(b'x')
|
||||
results.seek(begin+pos+2,0) #why two, not 1??
|
||||
values[0]=struct.unpack('d',results.read(8))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'y')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[1]=struct.unpack('d',results.read(8))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
results.seek(begin,0)
|
||||
pos = results.read(60).find(b'z')
|
||||
results.seek(begin+pos+1,0)
|
||||
values[2]=struct.unpack('d',results.read(8))[0]
|
||||
maxpos=max(maxpos,results.tell())
|
||||
return values, maxpos
|
||||
|
||||
loadcase, position = searchNameForKeyword(b'Loadcase ', results, position)
|
||||
workingdir, position = searchNameForKeyword(b'Workingdir ', results, position)
|
||||
jobname, position = searchNameForKeyword(b'JobName ', results, position)
|
||||
totalincs, position = searchValueForKeyword(b'totalincs ', results, position)
|
||||
materialpoint_sizeResults, position = searchValueForKeyword(b'materialpoint_sizeResults ', results, position)
|
||||
resolution, position = searchArrayForKeyword(b'resolution ', results, position)
|
||||
geomdimension, position = searchFarrayForKeyword(b'geomdimension ', results, position)
|
||||
position=position+4 +13*8
|
||||
results.seek(position,0)
|
||||
tnsr = array.array('d',[0,0,0,0,0,0,0,0,0])
|
||||
tnsr[0]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[1]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[2]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[3]=struct.unpack('d',results.read(8))[0]
|
||||
tnsr[4]=struct.unpack('d',results.read(8))[0]
|
||||
print(tnsr)
|
||||
|
||||
|
||||
# ended reading of header. now starting to read information concerning output
|
||||
#filename = jobname[0:len(jobname)-5]+b'.outputCrystallite'
|
||||
#outputCrystallite = open(filename, 'r')
|
||||
|
||||
def InCharCount(location, character):
|
||||
subj = file(location, "r")
|
||||
body = subj.read()
|
||||
subj.close()
|
||||
return body.count(character)
|
||||
|
||||
|
||||
def InCharCount(location, character):
|
||||
subj = file(location, "r")
|
||||
|
||||
nbr_of_char = 0
|
||||
for line in subj:
|
||||
nbr_of_char = nbr_of_char + line.count(character)
|
||||
|
||||
return nbr_of_char
|
||||
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import numpy
|
||||
import reconstruct
|
||||
# dummy values for resolution and geomdimension (formerly called meshdimension)
|
||||
resolution=numpy.zeros((3),'i')
|
||||
resolution[0]=2
|
||||
resolution[1]=2
|
||||
resolution[2]=2
|
||||
geomdimension=numpy.zeros((3),'d')
|
||||
geomdimension[0]=1.0
|
||||
geomdimension[1]=1.0
|
||||
geomdimension[2]=1.0
|
||||
defgrad=numpy.zeros((resolution[0],resolution[1],resolution[2],3,3),'d')
|
||||
for i in range (0, resolution[0]):
|
||||
for j in range (0, resolution[1]):
|
||||
for k in range (0, resolution[2]):
|
||||
defgrad[i][j][k][0][0]=1.0
|
||||
defgrad[i][j][k][1][1]=1.0
|
||||
defgrad[i][j][k][2][2]=1.0
|
||||
print defgrad
|
||||
current_configuration=reconstruct.simple(defgrad,resolution[0],resolution[1],resolution[2],geomdimension) # don't know how to pass arrays for the resolution
|
||||
print current_configuration
|
Loading…
Reference in New Issue