[
https://issues.apache.org/jira/browse/CLIMATE-812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15337725#comment-15337725
]
ASF GitHub Bot commented on CLIMATE-812:
----------------------------------------
Github user jarifibrahim commented on a diff in the pull request:
https://github.com/apache/climate/pull/361#discussion_r67598748
--- Diff: ocw/dataset_processor.py ---
@@ -202,130 +214,158 @@ def spatial_regrid(target_dataset, new_latitudes,
new_longitudes, boundary_check
ny_new, nx_new = new_lats.shape
# Make masked array of shape (times, new_latitudes,new_longitudes)
- new_values = ma.zeros([len(target_dataset.times),
- ny_new, nx_new])
+ new_values = ma.zeros([len(target_dataset.times),
+ ny_new, nx_new])
# Make masked array of shape (times, new_latitudes,new_longitudes)
- new_values = ma.zeros([len(target_dataset.times),
+ new_values = ma.zeros([len(target_dataset.times),
ny_new, nx_new])
# Boundary vertices of target_dataset
vertices = []
- if regular_grid:
- vertices.append([lons[0,0], lats[0,0]])
- vertices.append([lons[-1,0], lats[-1,0]])
- vertices.append([lons[-1,-1], lats[-1,-1]])
- vertices.append([lons[0,-1], lats[0,-1]])
- else:
- for iy in np.arange(ny_old): # from south to north along the
west boundary
- vertices.append([lons[iy,0], lats[iy,0]])
- for ix in np.arange(nx_old): # from west to east along the north
boundary
+ if regular_grid:
+ vertices.append([lons[0, 0], lats[0, 0]])
+ vertices.append([lons[-1, 0], lats[-1, 0]])
+ vertices.append([lons[-1, -1], lats[-1, -1]])
+ vertices.append([lons[0, -1], lats[0, -1]])
+ else:
+ # from south to north along the west boundary
+ for iy in np.arange(ny_old):
+ vertices.append([lons[iy, 0], lats[iy, 0]])
+ # from west to east along the north boundary
+ for ix in np.arange(nx_old):
vertices.append([lons[-1, ix], lats[-1, ix]])
- for iy in np.arange(ny_old)[::-1]: # from north to south along
the east boundary
+ # from north to south along the east boundary
+ for iy in np.arange(ny_old)[::-1]:
vertices.append([lons[iy, -1], lats[iy, -1]])
- for ix in np.arange(nx_old)[::-1]: # from east to west along the
south boundary
+ # from east to west along the south boundary
+ for ix in np.arange(nx_old)[::-1]:
vertices.append([lons[0, ix], lats[0, ix]])
path = Path(vertices)
# Convert new_lats and new_lons to float indices
new_lons_indices = np.zeros(new_lons.shape)
new_lats_indices = np.zeros(new_lats.shape)
-
+
for iy in np.arange(ny_new):
for ix in np.arange(nx_new):
- if path.contains_point([new_lons[iy,ix], new_lats[iy,ix]]) or
not boundary_check:
+ if path.contains_point([new_lons[iy, ix],
+ new_lats[iy, ix]]) or not
boundary_check:
if regular_grid:
- new_lats_indices[iy,ix] = (ny_old
-1.)*(new_lats[iy,ix] - lats.min())/(lats.max() - lats.min())
- new_lons_indices[iy,ix] = (nx_old
-1.)*(new_lons[iy,ix] - lons.min())/(lons.max() - lons.min())
+ mn = lats.min()
+ mx = lats.max()
+ new_lats_indices[iy, ix] = (
+ ny_old - 1.) * (new_lats[iy, ix] - mn / (mx - mn))
--- End diff --
`mx`, `mn` are used to reduce line length.
> Fix PEP8 Violations in dataset processor
> ----------------------------------------
>
> Key: CLIMATE-812
> URL: https://issues.apache.org/jira/browse/CLIMATE-812
> Project: Apache Open Climate Workbench
> Issue Type: Improvement
> Reporter: Ibrahim Jarif
> Assignee: Ibrahim Jarif
> Fix For: 1.1
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)