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

add cases in OMFReader #2061

Merged
merged 3 commits into from
Jul 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions src/sas/sascalc/calculator/sas_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,15 @@ def read(self, path):
logging.error(str(exc)+" when processing %r"%line)
elif line:
# Reading Header; Segment count ignored

s_line = line.split(":", 1)
dehoni marked this conversation as resolved.
Show resolved Hide resolved
if s_line[0].lower().count("oommf") > 0:
oommf = s_line[1].lstrip()
try:
oommf = s_line[1].lstrip()
dehoni marked this conversation as resolved.
Show resolved Hide resolved
except IndexError:
s_line = line.split(" ", 1)
oommf = s_line[1].lstrip()

if s_line[0].lower().count("title") > 0:
title = s_line[1].lstrip()
if s_line[0].lower().count("desc") > 0:
Expand Down Expand Up @@ -1117,12 +1123,17 @@ def read(self, path):
msg += "We accept only mT or A/m as valueunit"
logging.error(msg)
return None
elif valueunit.count("mT") > 1 or valueunit.count("A/m") > 1:
dehoni marked this conversation as resolved.
Show resolved Hide resolved
valueunit = valueunit.split(" ", 1)
valueunit = valueunit[0].lstrip()
if s_line[0].lower().count("valuemultiplier") > 0:
valuemultiplier = s_line[1].lstrip()
if s_line[0].lower().count("valuerangeminmag") > 0:
valuerangeminmag = s_line[1].lstrip()
if s_line[0].lower().count("valuerangemaxmag") > 0:
valuerangemaxmag = s_line[1].lstrip()
else:
valuemultiplier = 1
# if s_line[0].lower().count("valuerangeminmag") > 0:
dehoni marked this conversation as resolved.
Show resolved Hide resolved
# valuerangeminmag = s_line[1].lstrip()
# if s_line[0].lower().count("valuerangemaxmag") > 0:
# valuerangemaxmag = s_line[1].lstrip()
if s_line[0].lower().count("end") > 0:
output.filename = os.path.basename(path)
output.oommf = oommf
Expand All @@ -1145,10 +1156,10 @@ def read(self, path):
output.ymax = float(ymax) * METER2ANG
output.zmax = float(zmax) * METER2ANG
output.valuemultiplier = valuemultiplier
output.valuerangeminmag \
= mag2sld(float(valuerangeminmag), valueunit)
output.valuerangemaxmag \
= mag2sld(float(valuerangemaxmag), valueunit)
# output.valuerangeminmag \
# = mag2sld(float(valuerangeminmag), valueunit)
# output.valuerangemaxmag \
# = mag2sld(float(valuerangemaxmag), valueunit)
mx = np.reshape(mx, (len(mx),))
my = np.reshape(my, (len(my),))
mz = np.reshape(mz, (len(mz),))
Expand Down Expand Up @@ -1416,8 +1427,8 @@ def __init__(self):
self.my = None
self.mz = None
self.valuemultiplier = 1.
self.valuerangeminmag = 0
self.valuerangemaxmag = 0
# self.valuerangeminmag = 0
# self.valuerangemaxmag = 0

def __str__(self):
"""
Expand Down Expand Up @@ -1450,10 +1461,10 @@ def __str__(self):
_str += "zmax: %s [%s]\n" % (str(self.zmax), self.meshunit)
_str += "valueunit: %s\n" % self.valueunit
_str += "valuemultiplier: %s\n" % str(self.valuemultiplier)
_str += "ValueRangeMinMag:%s [%s]\n" % (str(self.valuerangeminmag),
self.valueunit)
_str += "ValueRangeMaxMag:%s [%s]\n" % (str(self.valuerangemaxmag),
self.valueunit)
# _str += "ValueRangeMinMag:%s [%s]\n" % (str(self.valuerangeminmag),
# self.valueunit)
# _str += "ValueRangeMaxMag:%s [%s]\n" % (str(self.valuerangemaxmag),
# self.valueunit)
return _str

def set_m(self, mx, my, mz):
Expand Down