| 1 | #!/usr/bin/env python3 |
|---|
| 2 | |
|---|
| 3 | def warn(*args, **kwargs): |
|---|
| 4 | pass |
|---|
| 5 | |
|---|
| 6 | import os, warnings |
|---|
| 7 | warnings.warn = warn |
|---|
| 8 | |
|---|
| 9 | from ecradplot import plot as eplt |
|---|
| 10 | |
|---|
| 11 | def main(input_srcfile, reference_output_srcfile, output_srcfile, dstdir): |
|---|
| 12 | """ |
|---|
| 13 | Plot radiation fields (fluxes, CRE, and heating rates) |
|---|
| 14 | """ |
|---|
| 15 | |
|---|
| 16 | import os |
|---|
| 17 | if not os.path.isdir(dstdir): |
|---|
| 18 | os.makedirs(dstdir) |
|---|
| 19 | |
|---|
| 20 | name_string = os.path.splitext(os.path.basename(input_srcfile))[0] |
|---|
| 21 | output_string = os.path.splitext(os.path.basename(output_srcfile))[0] |
|---|
| 22 | reference_name_string = os.path.splitext(os.path.basename(reference_output_srcfile))[0] |
|---|
| 23 | |
|---|
| 24 | dstfile = os.path.join(dstdir, f"{name_string}_{output_string}_vs_{reference_name_string}.png") |
|---|
| 25 | |
|---|
| 26 | print(f"Plotting output to {dstfile}") |
|---|
| 27 | eplt.compare_output(input_srcfile, reference_output_srcfile, output_srcfile, dstfile=dstfile) |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | if __name__ == "__main__": |
|---|
| 31 | import argparse |
|---|
| 32 | parser = argparse.ArgumentParser(description="Plot radiative fluxes and heating rates from ecRAD output file.") |
|---|
| 33 | parser.add_argument("input", help="ecRAD input file") |
|---|
| 34 | parser.add_argument("reference", help='ecRAD output file to use as a reference') |
|---|
| 35 | parser.add_argument("output", help="ecRAD output file") |
|---|
| 36 | parser.add_argument("--dstdir", help="Destination directory for plots", default="./") |
|---|
| 37 | args = parser.parse_args() |
|---|
| 38 | |
|---|
| 39 | main(args.input, args.reference, args.output, args.dstdir) |
|---|