Skip to content

Commit

Permalink
Fix rechunking for stacked data
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Jul 7, 2024
1 parent f8dbe85 commit fbca8fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pygmtsar/pygmtsar/Stack_lstsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,16 @@ def lstsq(self, data, weight=None, matrix='auto', cumsum=True, debug=False):
print (f'Note: data chunk size ({np.max(chunks_y)}, {np.max(chunks_x)}) is too large for stack processing')
chunks_y = chunks_x = self.netcdf_chunksize//2
print (f'Note: auto tune data chunk size to a half of NetCDF chunk: ({chunks_y}, {chunks_x})')
chunks = {'y': chunks_y, 'x': chunks_x}
else:
chunks_z, chunks_stack = data.chunks if data.chunks is not None else np.inf, np.inf
if np.max(chunks_stack) > self.chunksize1d:
print (f'Note: data chunk size ({np.max(chunks_stack)} is too large for stack processing')
# 1D chunk size can be defined straightforward
chunks_stack = self.chunksize1d
print (f'Note: auto tune data chunk size to 1D chunk: ({chunks_stack})')
data = data.chunk({'y': chunks_y, 'x': chunks_x})
chunks = {'stack': chunks_stack}
data = data.chunk(chunks)

if weight is None:
# this case should be processed inside lstq_block function
Expand Down Expand Up @@ -346,7 +348,6 @@ def lstq_block(ys, xs, stacks=None):

return model


def rmse(self, data, solution, weight=None):
"""
Calculate difference between pairs and dates
Expand Down

0 comments on commit fbca8fa

Please sign in to comment.