original_docstring: 
          This method writes in .csv files mean values for diameters, flows, pressures and wss.
          
docstring: This method writes in .csv files mean values for diameters, flows, pressures and wss.
docstring_tokens: This method writes in . csv files mean values for diameters flows pressures and wss .
code: def WriteToCsv(self, adaptation, solutionType, cycle = None):
          '''
          This method writes in .csv files mean values for diameters, flows, pressures and wss.
          '''
          if cycle is not None:
              Cycle = cycle
          else:
              Cycle = self.Cycles
          
          path = solutionType+'.csv' 
          ofile  = open(path, "wb")
          writer = csv.writer(ofile, delimiter=",", quoting=csv.QUOTE_ALL)
          header_list = []
          header_list.append("Id")
          header_list.append("Name")
          header_list.append("IN/OUT")
          
          for d in adaptation.solutions.keys():
              if d != -1:
                  header_list.append(d)
          header = [[],header_list]
          
          writer.writerows(header)
              
          if solutionType == 'Pressure':
              print "Writing Pressures Csv file..."
              for el in self.NetworkMesh.Elements:
                  if el.Type ==  'WavePropagation':
                      el_row_list_in = [el.Id,el.Name,"IN"]
                      el_row_list_out = [el.Id,el.Name,"OUT"]
                      for day,sol in adaptation.solutions.iteritems():
                          if day != -1:
                              P1 = (sol.Solutions[(self.DofMap.DofMap[el.Id, 0]),:])/133.3223684211
                              P1Mean = mean(P1[(self.CardiacFreq*(Cycle-1)):(self.CardiacFreq*(Cycle))])
                              P2 = (sol.Solutions[(self.DofMap.DofMap[el.Id, 2]),:])/133.3223684211
                              P2Mean = mean(P2[(self.CardiacFreq*(Cycle-1)):(self.CardiacFreq*(Cycle))])
                              el_row_list_in.append(str(P1Mean))
                              el_row_list_out.append(str(P2Mean))
                      el_row = [el_row_list_in,el_row_list_out]
                      writer.writerows(el_row)
          
          if solutionType == 'Diameter':
              print "Writing Diameters Csv file..."
              for el in self.NetworkMesh.Elements:
                  if el.Type ==  'WavePropagation':
                      el_row_list_in = [el.Id,el.Name,"IN"]
                      el_row_list_out = [el.Id,el.Name,"OUT"]
                      for day,sol in adaptation.solutions.iteritems():
                          if day != -1:
                              try:
                                  d1 = el.dayRadius[day][0]*2e3
                                  d2 = el.dayRadius[day][1]*2e3
                              except:
                                  d1 = el.Radius[0]*2e3
                                  d2 = el.Radius[len(el.Radius)-1]*2e3
                              el_row_list_in.append(str(d1))
                              el_row_list_out.append(str(d2))
                      el_row = [el_row_list_in,el_row_list_out]
                      writer.writerows(el_row)
                  
          if solutionType == 'Flow':
              print "Writing Flows Csv file..."
              for el in self.NetworkMesh.Elements:
                  if el.Type ==  'WavePropagation':
                      el_row_list = [el.Id,el.Name,""]
                      for day,sol in adaptation.solutions.iteritems():
                          if day != -1:
                              Flow = sol.dayFlow[el.Id]
                              el_row_list.append(str(Flow))
                      el_row = [el_row_list]
                      writer.writerows(el_row)
          
          if solutionType == 'Wss':
              print "Writing WssPeaks Csv file..."
              for el in self.NetworkMesh.Elements:
                  if el.Type ==  'WavePropagation':
                      el_row_list = [el.Id,el.Name,""]
                      for day,sol in adaptation.solutions.iteritems():
                          if day != -1:
                              tao = sol.dayWssP[el.Id]
                              el_row_list.append(str(tao))
                      el_row = [el_row_list]
                      writer.writerows(el_row)
code_tokens: def WriteToCsv ( self , adaptation , solutionType , cycle = None ) : if cycle is not None : Cycle = cycle else : Cycle = self . Cycles path = solutionType + '.csv' ofile = open ( path , "wb" ) writer = csv . writer ( ofile , delimiter = "," , quoting = csv . QUOTE_ALL ) header_list = [ ] header_list . append ( "Id" ) header_list . append ( "Name" ) header_list . append ( "IN/OUT" ) for d in adaptation . solutions . keys ( ) : if d != - 1 : header_list . append ( d ) header = [ [ ] , header_list ] writer . writerows ( header ) if solutionType == 'Pressure' : print "Writing Pressures Csv file..." for el in self . NetworkMesh . Elements : if el . Type == 'WavePropagation' : el_row_list_in = [ el . Id , el . Name , "IN" ] el_row_list_out = [ el . Id , el . Name , "OUT" ] for day , sol in adaptation . solutions . iteritems ( ) : if day != - 1 : P1 = ( sol . Solutions [ ( self . DofMap . DofMap [ el . Id , 0 ] ) , : ] ) / 133.3223684211 P1Mean = mean ( P1 [ ( self . CardiacFreq * ( Cycle - 1 ) ) : ( self . CardiacFreq * ( Cycle ) ) ] ) P2 = ( sol . Solutions [ ( self . DofMap . DofMap [ el . Id , 2 ] ) , : ] ) / 133.3223684211 P2Mean = mean ( P2 [ ( self . CardiacFreq * ( Cycle - 1 ) ) : ( self . CardiacFreq * ( Cycle ) ) ] ) el_row_list_in . append ( str ( P1Mean ) ) el_row_list_out . append ( str ( P2Mean ) ) el_row = [ el_row_list_in , el_row_list_out ] writer . writerows ( el_row ) if solutionType == 'Diameter' : print "Writing Diameters Csv file..." for el in self . NetworkMesh . Elements : if el . Type == 'WavePropagation' : el_row_list_in = [ el . Id , el . Name , "IN" ] el_row_list_out = [ el . Id , el . Name , "OUT" ] for day , sol in adaptation . solutions . iteritems ( ) : if day != - 1 : try : d1 = el . dayRadius [ day ] [ 0 ] * 2e3 d2 = el . dayRadius [ day ] [ 1 ] * 2e3 except : d1 = el . Radius [ 0 ] * 2e3 d2 = el . Radius [ len ( el . Radius ) - 1 ] * 2e3 el_row_list_in . append ( str ( d1 ) ) el_row_list_out . append ( str ( d2 ) ) el_row = [ el_row_list_in , el_row_list_out ] writer . writerows ( el_row ) if solutionType == 'Flow' : print "Writing Flows Csv file..." for el in self . NetworkMesh . Elements : if el . Type == 'WavePropagation' : el_row_list = [ el . Id , el . Name , "" ] for day , sol in adaptation . solutions . iteritems ( ) : if day != - 1 : Flow = sol . dayFlow [ el . Id ] el_row_list . append ( str ( Flow ) ) el_row = [ el_row_list ] writer . writerows ( el_row ) if solutionType == 'Wss' : print "Writing WssPeaks Csv file..." for el in self . NetworkMesh . Elements : if el . Type == 'WavePropagation' : el_row_list = [ el . Id , el . Name , "" ] for day , sol in adaptation . solutions . iteritems ( ) : if day != - 1 : tao = sol . dayWssP [ el . Id ] el_row_list . append ( str ( tao ) ) el_row = [ el_row_list ] writer . writerows ( el_row )
short_docstring: This method writes in .csv files mean values for diameters, flows, pressures and wss.
short_docstring_tokens: This method writes in . csv files mean values for diameters flows pressures and wss .
comment: '''
          This method writes in .csv files mean values for diameters, flows, pressures and wss.
          '''