-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample9.py
More file actions
79 lines (69 loc) · 2.36 KB
/
Copy pathexample9.py
File metadata and controls
79 lines (69 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from src import *
import argparse
# Example read:
# Demonstrates how to reconstruct and plot an emission scenario directly from an
# existing wrfchem emission NetCDF file that was produced by PrepEmisSources.
#python example9.py wrfchemv_d01.2025-11-23_08\:30\:00 --material ash
#python example9.py wrfchemv_d01.2025-11-23_08\:30\:00 --material so2
def parse_args():
parser = argparse.ArgumentParser(
description="Load an emission scenario from a wrfchem NetCDF file and plot it."
)
parser.add_argument(
"--nc-file",
default="wrfchemv_d01.2025-11-23_08:30:00",
help="Path to the wrfchem emission NetCDF file.",
)
parser.add_argument(
"nc_file_pos",
nargs="?",
help="Optional positional path to the wrfchem emission NetCDF file.",
)
parser.add_argument(
"--material",
default="so2",
choices=["ash", "so2", "sulfate", "watervapor"],
help="Which emission species to read.",
)
parser.add_argument(
"--lat",
type=float,
default=13.51,
help="Volcano latitude used when locating the cell (ignored if x/y supplied).",
)
parser.add_argument(
"--lon",
type=float,
default=40.722,
help="Volcano longitude used when locating the cell (ignored if x/y supplied).",
)
parser.add_argument(
"--x",
type=int,
default=None,
help="Optional west_east index of the emission cell (overrides lat/lon).",
)
parser.add_argument(
"--y",
type=int,
default=None,
help="Optional south_north index of the emission cell (overrides lat/lon).",
)
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
nc_path = args.nc_file_pos or args.nc_file
netcdf_handler = WRFNetCDFWriter(source_dir="./")
scenario = netcdf_handler.load_scenario_from_file(
material=args.material,
nc_path=nc_path,
lat=args.lat,
lon=args.lon,
x=args.x,
y=args.y,
)
print(scenario)
print(f"Profiles: {scenario.getNumberOfProfiles()}, total mass: {scenario.getScenarioEmittedMass():.3f} Mt")
scenario.plot()
print ("\n\n\nThe scenario can be used to recreate the scenario object using EmissionWriter_NonUniformInHeightProfiles, as in example6.py:\n")
print(repr(scenario))