Skip to content
Snippets Groups Projects
Commit eae72e99 authored by Nils-Arne Dreier's avatar Nils-Arne Dreier
Browse files

formating

parent 4de7b916
No related branches found
No related tags found
No related merge requests found
......@@ -7,12 +7,14 @@ from pathlib import Path
this_dir = Path(__file__).parent
def lonlat(string):
pair = string.split(",")
return (float(pair[0]), float(pair[1]))
parser = ArgumentParser()
parser.add_argument("--descriptorfile", type=FileType('r'), default=this_dir.parent/"descriptorfiles"/"icon_1mom.py", help="")
parser.add_argument("--descriptorfile", type=FileType('r'), default=this_dir.parent/"descriptorfiles"/"icon_1mom.py", help="")
parser.add_argument("--coords", type=lonlat, nargs="+", required=True, help="Coordinates of the groundstations")
parser.add_argument("--frequency", type=float, nargs="+", default=94)
parser.add_argument("--dt", type=str, default=None, help="Timestep")
......@@ -20,10 +22,12 @@ parser.add_argument("--source_component", type=str, default="atmo_output", help=
parser.add_argument("--source_grid", type=str, default="icon_atmos_grid", help="grid name of the source grid")
args = parser.parse_args()
from yac import YAC, UnstructuredGrid, Location, Field, TimeUnit, \
InterpolationStack, NNNReductionType, Reduction, Action
import pyPamtra
yac = YAC()
comp = yac.def_comp("pamtra")
......@@ -31,15 +35,15 @@ comp = yac.def_comp("pamtra")
coords = np.array(args.coords)
ncoords = len(args.coords)
grid = UnstructuredGrid("pamtra-grid", [3]*ncoords,
[*coords[:,0], *(coords[:,0]+0.1), *coords[:,0]],
[*coords[:,1], *coords[:,1], *(coords[:,1]+0.1)],
[*coords[:, 0], *(coords[:, 0]+0.1), *coords[:, 0]],
[*coords[:, 1], *coords[:, 1], *(coords[:, 1]+0.1)],
np.array(list(zip(range(ncoords), range(ncoords, 2*ncoords), range(2*ncoords, 3*ncoords)))).ravel())
points = grid.def_points(Location.CELL,
coords[:,0], coords[:,1])
coords[:, 0], coords[:, 1])
yac.sync_def()
#print(yac.get_field_names(*source), file=sys.stderr)
# print(yac.get_field_names(*source), file=sys.stderr)
interp = InterpolationStack()
interp.add_nnn(NNNReductionType.AVG, 1, 1.0)
......@@ -61,7 +65,8 @@ for name in ["temp", "pres", "qv", "qi", "qc", "qs", "qr", "qg", "z_ifc", "u", "
yac.enddef()
with open(args.descriptorfile, "r") as dfile:
exec(dfile.read()) # adds a variable "descriptorFile"
exec(dfile.read()) # adds a variable "descriptorFile"
def call_pamtra(temp, pres, qv, qi, qc, qs, qr, qg, z_ifc, u, v, w,
datetime):
......@@ -81,6 +86,7 @@ def call_pamtra(temp, pres, qv, qi, qc, qs, qr, qg, z_ifc, u, v, w,
pamtra.runPamtra(args.frequency)
pamtra.writeResultsToNetCDF(f"output_{datetime}.nc", xarrayCompatibleOutput=True)
while True:
datetime = fields["temp"].datetime
data = {}
......@@ -90,4 +96,3 @@ while True:
call_pamtra(**data, datetime=datetime)
if info == Action.GET_FOR_RESTART:
break
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment