Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pamtra/pamtra-insitu
1 result
Show changes
Commits on Source (2)
......@@ -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,26 +22,28 @@ 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")
coords = np.array(args.coords)
coords = np.deg2rad(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,13 +86,13 @@ 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 = {}
for v, f in fields.items():
data[v], info = f.get()
print(v, data[v].shape, file=sys.stderr)
print(v, np.linalg.norm(data[v]), file=sys.stderr)
call_pamtra(**data, datetime=datetime)
if info == Action.GET_FOR_RESTART:
break