-
Notifications
You must be signed in to change notification settings - Fork 34
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 for 4-d variable output in standard memory mode #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,16 +456,31 @@ def nc_add_data_to_array(self, point): | |
def nc_add_data_standard(self, points): | ||
ys = points.get_ys() | ||
xs = points.get_xs() | ||
for p in points: | ||
for name in self.three_dim_vars: | ||
data = points.get_data(name, self.slice) | ||
self.f.variables[name][:, ys, xs] = data | ||
for name in self.four_dim_vars: | ||
varshape = self.f.variables[name].shape[1] | ||
for i in pyrange(varshape): | ||
sn = name + str(i) | ||
self.f.variables[name][:, i, ys, | ||
xs] = p.df[sn].values[self.slice] | ||
for name in self.three_dim_vars: | ||
yc = 0 | ||
dd = np.zeros(self.f.variables[name][:,ys,xs].shape) | ||
for p in points: | ||
dd[:,yc] = p.df[name].values[self.slice] | ||
yc = yc + 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python allow you to enumerate your for loop. You can get rid of all the |
||
|
||
self.f.variables[name][:,ys,xs] = dd | ||
del dd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The python garbage collector will handle this for you. It is almost never necessary to use the |
||
|
||
for name in self.four_dim_vars: | ||
varshape = self.f.variables[name].shape[1] | ||
|
||
for i in range(varshape): | ||
yc = 0 | ||
dd = np.zeros(self.f.variables[name][:,i,ys,xs].shape) | ||
|
||
for p in points: | ||
sn = name + str(i) | ||
dd[:,yc] = p.df[sn].values[self.slice] | ||
yc = yc + 1 | ||
|
||
self.f.variables[name][:, i, ys, | ||
xs] = dd | ||
del dd | ||
|
||
def nc_write_data_from_array(self): | ||
""" write completed data arrays to disk """ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like we're just writing the same data to all of these points.