Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: GateMapper will now map source field to destination radar even if field not in destination radar #1418

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pyart/map/gate_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,15 @@ def mapped_radar(self, field_list):

src_fields = {}
for field in field_list:
mapped_radar.fields[field]["data"] = np.ma.masked_where(
True, mapped_radar.fields[field]["data"]
)
if field in list(mapped_radar.fields.keys()):
mapped_radar.fields[field]["data"] = np.ma.masked_where(
True, mapped_radar.fields[field]["data"]
)
else:
mapped_radar.fields[field] = deepcopy(self.src_radar.fields[field])
mapped_radar.fields[field]["data"] = np.ma.masked_where(
True, np.ma.zeros((mapped_radar.nrays, mapped_radar.ngates))
)
src_fields[field] = np.ma.masked_where(
self.gatefilter_src.gate_excluded, self.src_radar.fields[field]["data"]
)
Expand Down
16 changes: 12 additions & 4 deletions tests/map/test_gatemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ def test_gatemapper():
new_radar = deepcopy(old_radar)
new_radar.latitude["data"] = old_radar.latitude["data"] + 0.001
new_radar.longitude["data"] = old_radar.longitude["data"] + 0.001
gate_mapper = pyart.map.GateMapper(new_radar, old_radar)
old_radar.fields["reflectivity_copy"] = old_radar.fields["reflectivity"]
gate_mapper = pyart.map.GateMapper(old_radar, new_radar)
mapped_radar = gate_mapper.mapped_radar(["reflectivity"])

# Test point outside of 1 min tolerance
assert gate_mapper[20, 20] == (None, None)
assert gate_mapper[4, 4] == (26, 11)
assert gate_mapper[40, 40] == (40, 33)
assert (
mapped_radar.fields["reflectivity"]["data"][40, 33]
== old_radar.fields["reflectivity"]["data"][40, 40]
)

# Check case where source radar has field destination doesn't
mapped_radar = gate_mapper.mapped_radar(["reflectivity_copy"])
assert (
mapped_radar.fields["reflectivity"]["data"][26, 11]
== old_radar.fields["reflectivity"]["data"][4, 4]
mapped_radar.fields["reflectivity_copy"]["data"][40, 33]
== old_radar.fields["reflectivity_copy"]["data"][40, 40]
)


Expand Down