argiope/abq/abqpostproc.py
def write_field_report(odb, path, label, argiope_class, variable, instance, output_position, 
                       step = -1, frame = -1, sortItem='Node Label'):
  """
  Writes a field report and rewrites it in a cleaner format.
  """
  stepKeys = get_steps(odb)
  step = xrange(len(stepKeys))[step]
  frame = xrange(get_frames(odb, stepKeys[step]))[frame]
  nf = NumberFormat(numDigits=9, 
                    precision=0, 
                    format=SCIENTIFIC)
  session.fieldReportOptions.setValues(
          printTotal=OFF, 
          printMinMax=OFF, 
          numberFormat=nf)
  leaf = dgo.LeafFromPartInstance(
          partInstanceName = instance)
  session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
  session.writeFieldReport(
          fileName       = path, 
          append         = OFF, 
          sortItem       = sortItem,
          odb            = odb, 
          step           = step, 
          frame          = frame, 
          outputPosition = output_position, 
          variable       = variable)
  lines = [line.strip() for line in open(path).readlines()]
  isdata = -1
  data = []
  for line in lines:
   if isdata == 1:
     if len(line) == 0: 
       isdata -= 1
     else:
       data.append(line)   
   elif isdata < 1:
     if line.startswith("--"):
       isdata += 1
  data = "\n".join([",".join(line.split()) for line in data if len(line) != 0])
  # HEADER
  header = str(output_position).lower() + "," 
  header += ",".join([v[1] for v in variable[0][2]]) + "\n"
  # METADATA
  metadata = (
          ("label", label),
          ("argiope_class", argiope_class) ,
          ("odb", odb.path), 
          ("instance", instance),
          ("position", output_position),
          ("step_num", step),
          ("step_label", stepKeys[step]),
          ("frame", frame),
          ("frame_value", odb.steps[stepKeys[step]].frames[frame].frameValue)
              )
  out = "*METADATA\n{0}\n*DATA\n{1}".format(
        "\n".join(["{0}={1}".format(k, v) for k, v in metadata]),
        header + data)           
  open(path, "w").write(out)
def write_field_report(odb, path, label, argiope_class, variable, instance, output_position, 
                       step = -1, frame = -1, sortItem='Node Label'):
  stepKeys = get_steps(odb)
  step = xrange(len(stepKeys))[step]
  frame = xrange(get_frames(odb, stepKeys[step]))[frame]
  nf = NumberFormat(numDigits=9, 
                    precision=0, 
                    format=SCIENTIFIC)
  session.fieldReportOptions.setValues(
          printTotal=OFF, 
          printMinMax=OFF, 
          numberFormat=nf)
  leaf = dgo.LeafFromPartInstance(
          partInstanceName = instance)
  session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
  session.writeFieldReport(
          fileName       = path, 
          append         = OFF, 
          sortItem       = sortItem,
          odb            = odb, 
          step           = step, 
          frame          = frame, 
          outputPosition = output_position, 
          variable       = variable)
  lines = [line.strip() for line in open(path).readlines()]
  isdata = -1
  data = []
  for line in lines:
   if isdata == 1:
     if len(line) == 0: 
       isdata -= 1
     else:
       data.append(line)   
   elif isdata < 1:
     if line.startswith("--"):
       isdata += 1
  data = "\n".join([",".join(line.split()) for line in data if len(line) != 0])
  # HEADER
  header = str(output_position).lower() + "," 
  header += ",".join([v[1] for v in variable[0][2]]) + "\n"
  # METADATA
  metadata = (
          ("label", label),
          ("argiope_class", argiope_class) ,
          ("odb", odb.path), 
          ("instance", instance),
          ("position", output_position),
          ("step_num", step),
          ("step_label", stepKeys[step]),
          ("frame", frame),
          ("frame_value", odb.steps[stepKeys[step]].frames[frame].frameValue)
              )
  out = "*METADATA\n{0}\n*DATA\n{1}".format(
        "\n".join(["{0}={1}".format(k, v) for k, v in metadata]),
        header + data)           
  open(path, "w").write(out)
def write_field_report ( odb , path , label , argiope_class , variable , instance , output_position , step = - 1 , frame = - 1 , sortItem = 'Node Label' ) : stepKeys = get_steps ( odb ) step = xrange ( len ( stepKeys ) ) [ step ] frame = xrange ( get_frames ( odb , stepKeys [ step ] ) ) [ frame ] nf = NumberFormat ( numDigits = 9 , precision = 0 , format = SCIENTIFIC ) session . fieldReportOptions . setValues ( printTotal = OFF , printMinMax = OFF , numberFormat = nf ) leaf = dgo . LeafFromPartInstance ( partInstanceName = instance ) session . viewports [ 'Viewport: 1' ] . odbDisplay . displayGroup . replace ( leaf = leaf ) session . writeFieldReport ( fileName = path , append = OFF , sortItem = sortItem , odb = odb , step = step , frame = frame , outputPosition = output_position , variable = variable ) lines = [ line . strip ( ) for line in open ( path ) . readlines ( ) ] isdata = - 1 data = [ ] for line in lines : if isdata == 1 : if len ( line ) == 0 : isdata -= 1 else : data . append ( line ) elif isdata < 1 : if line . startswith ( "--" ) : isdata += 1 data = "\n" . join ( [ "," . join ( line . split ( ) ) for line in data if len ( line ) != 0 ] ) # HEADER header = str ( output_position ) . lower ( ) + "," header += "," . join ( [ v [ 1 ] for v in variable [ 0 ] [ 2 ] ] ) + "\n" # METADATA metadata = ( ( "label" , label ) , ( "argiope_class" , argiope_class ) , ( "odb" , odb . path ) , ( "instance" , instance ) , ( "position" , output_position ) , ( "step_num" , step ) , ( "step_label" , stepKeys [ step ] ) , ( "frame" , frame ) , ( "frame_value" , odb . steps [ stepKeys [ step ] ] . frames [ frame ] . frameValue ) ) out = "*METADATA\n{0}\n*DATA\n{1}" . format ( "\n" . join ( [ "{0}={1}" . format ( k , v ) for k , v in metadata ] ) , header + data ) open ( path , "w" ) . write ( out )
Writes a field report and rewrites it in a cleaner format.
Writes a field report and rewrites it in a cleaner format .