pydfnWorks
python wrapper for dfnWorks
gen_output.py
Go to the documentation of this file.
1 """
2  :filename: gen_output.py
3  :synopsis: Main driver for dfnGen output report
4  :version: 1.0
5  :maintainer: Jeffrey Hyman
6  :moduleauthor: Jeffrey Hyman <jhyman@lanl.gov>
7 """
8 
9 import os
10 import matplotlib
11 matplotlib.use("Agg")
12 import matplotlib.pylab as plt
13 from matplotlib import rc
14 rc('text', usetex=True)
15 
24 
25 
27  """ Create working dictionary for plots. There is one directory for the entire network information and one for each family.
28 
29  Parameters
30  ------------
31  params : dictionary
32  Output report dictionary containing general parameters. See output_report for more details
33 
34  Returns
35  ---------
36  None
37 
38  Notes
39  --------
40  None
41 
42 
43  """
44 
45  if not os.path.isdir(params["output_dir"]):
46  os.mkdir(params["output_dir"])
47  if not os.path.isdir(f"{params['output_dir']}/network"):
48  os.mkdir(f"{params['output_dir']}/network")
49  for i in range(1, params["num_families"] + 1):
50  if not os.path.isdir(f"{params['output_dir']}/family_{i}"):
51  os.mkdir(f"{params['output_dir']}/family_{i}")
52 
53 
54 def output_report(self,
55  verbose=True,
56  output_dir="dfnGen_output_report"):
57  """ Creates a PDF output report for the network created by DFNGen. Plots of the fracture lengths, locations, orientations are produced for each family. Files are written into "output_dir/family_{id}/". Information about the whole network are also created and written into "output_dir/network/"
58 
59  Parameters
60  ----------
61  self : object
62  DFN Class object
63  verbose : bool
64  Toggle for the amount of information printed to screen. If true, progress information printed to screen
65  output_dir : string
66  Name of directory where all plots are saved
67 
68  Returns
69  --------
70  None
71 
72  Notes
73  ---------
74  Final output report is named "jobname"_output_report.pdf
75  User defined fractures (ellipses, rectangles, and polygons) are not supported at this time.
76 
77 
78  """
79  cwd = os.getcwd()
80  print("=" * 80)
81  print('Creating Report of DFN generation')
82  print("=" * 80 + "\n")
83  print('--> Gathering Network Information')
84  # Create a list of dictionaries with information about fracture family
85  families = get_family_information()
86  # Create a list of dictionaries with information about fracture
87  fractures = get_fracture_information()
88  # Combine information of the families and fractures, e.g., which fracture are in each family, and create a dictionary with parameters used throughout the output report
89  families, fractures, params = combine_family_and_fracture_information(
90  families, fractures)
91  params, families = parse_dfn_output(params, families)
92 
93  params["verbose"] = verbose
94  params["jobname"] = self.local_jobname
95  params["output_dir"] = output_dir
96 
98 
99  # Create Plots
100  if len(families) > 0:
101  print('--> Plotting Information')
102  plot_fracture_centers(params, families, fractures)
103  plot_fracture_radii(params, families, fractures)
104  plot_fracture_orientations(params, families, fractures)
105  plot_fram_information(params)
106  # Combine plots into a pdf
107  make_pdf(params, families, fractures)
108  print(
109  f"--> Output report is written into {self.local_jobname}_output_report.pdf\n"
110  )
111 
112  else:
113  print(
114  "--> There are no stochastic families. An output PDF will not be generated.\n"
115  )
116 
117  # Return to main directory
118  print("=" * 80)
119  print("Creating Report of DFN generation complete")
120  print("=" * 80 + "\n")
121  os.chdir(self.jobname)
def output_report(self, verbose=True, output_dir="dfnGen_output_report")
Definition: gen_output.py:56