| 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_srcfiles, dstdir): |
|---|
| 12 | """ |
|---|
| 13 | Plot input files |
|---|
| 14 | """ |
|---|
| 15 | |
|---|
| 16 | import os |
|---|
| 17 | if not os.path.isdir(dstdir): |
|---|
| 18 | os.makedirs(dstdir) |
|---|
| 19 | |
|---|
| 20 | import seaborn as sns |
|---|
| 21 | name_string = os.path.splitext(os.path.basename(input_srcfile))[0] |
|---|
| 22 | outputs_string = "_".join([os.path.splitext(os.path.basename(f))[0] for f in output_srcfiles]) |
|---|
| 23 | reference_string = os.path.splitext(os.path.basename(reference_output_srcfile))[0] |
|---|
| 24 | |
|---|
| 25 | styles = [{'lw':2, 'color':'k', 'ls':'-', 'zorder':10}, |
|---|
| 26 | {'lw':3, 'color':sns.color_palette()[0], 'ls':'-'}, |
|---|
| 27 | {'lw':3, 'color':sns.color_palette()[2], 'ls':'-'}, |
|---|
| 28 | {'lw':2, 'color':sns.color_palette()[3], 'ls':'--'}, |
|---|
| 29 | {'lw':2, 'color':sns.color_palette()[5], 'ls':'-.'}, |
|---|
| 30 | {'lw':4, 'color':sns.color_palette()[6], 'ls':'-'}, |
|---|
| 31 | {'lw':4, 'color':sns.color_palette()[9], 'ls':'-'}] |
|---|
| 32 | |
|---|
| 33 | reference_name_string = os.path.splitext(os.path.basename(reference_output_srcfile))[0] |
|---|
| 34 | dstfile = f"{dstdir}/{name_string}_{outputs_string}_vs_{reference_name_string}_scalar.png" |
|---|
| 35 | print(f"Plotting integrated, surface and TOA outputs to {dstfile}") |
|---|
| 36 | eplt.compare_output_scalar(input_srcfile, output_srcfiles, reference_output_srcfile, styles, dstfile=dstfile) |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | if __name__ == "__main__": |
|---|
| 40 | import argparse |
|---|
| 41 | parser = argparse.ArgumentParser(description="Plot radiative fluxes and heating rates from ecRAD output file.") |
|---|
| 42 | parser.add_argument("input", help="ecRAD input file") |
|---|
| 43 | parser.add_argument("reference", help="ecRAD output file to use as a reference") |
|---|
| 44 | parser.add_argument("outputs", help="ecRAD output files", nargs='+') |
|---|
| 45 | parser.add_argument("--dstdir", help="Destination directory for plots", default="./") |
|---|
| 46 | args = parser.parse_args() |
|---|
| 47 | |
|---|
| 48 | main(args.input, args.reference, args.outputs, args.dstdir) |
|---|