Skip to content

Commit

Permalink
"Reordered __Get_regression_results__"
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmiro committed Sep 28, 2023
1 parent 952b75d commit 510e71c
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions pymica/pymica2.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,30 @@ def __get_geographical_parameters__(self):
self.field_proj.ImportFromEPSG(self.config[self.methodology]['EPSG'])
self.field_size = [int((int_bounds[3] - int_bounds[1]) / res),
int((int_bounds[2] - int_bounds[0]) / res)]

def __get_regression_results__(self, clusters, data):
if clusters:
cl_reg = ClusteredRegression(data, clusters['clusters_files'],
data_format=self.data_format)
cluster_file_index = clusters['clusters_files'].index(
cl_reg.final_cluster_file)

d_s = gdal.Open(clusters['mask_files'][cluster_file_index])
mask = d_s.ReadAsArray()
d_s = None

out_data = apply_clustered_regression(
cl_reg, self.variables,
self.data_format['x_vars'],
mask)
else:
cl_reg = MultiRegressionSigma(
data, id_key='id', y_var='value',
x_vars=list(self.variables_files.keys()))
out_data = apply_regression(cl_reg, self.variables,
list(self.variables_files.keys()))

return cl_reg, out_data

def interpolate(self, data_dict):

Expand Down Expand Up @@ -308,29 +332,6 @@ def interpolate(self, data_dict):

return field

def __get_regression_results__(self, clusters, data):
if clusters:
cl_reg = ClusteredRegression(data, clusters['clusters_files'],
data_format=self.data_format)
cluster_file_index = clusters['clusters_files'].index(
cl_reg.final_cluster_file)

d_s = gdal.Open(clusters['mask_files'][cluster_file_index])
mask = d_s.ReadAsArray()
d_s = None

out_data = apply_clustered_regression(
cl_reg, self.variables,
self.data_format['x_vars'],
mask)
else:
cl_reg = MultiRegressionSigma(
data, id_key='id', y_var='value',
x_vars=list(self.variables_files.keys()))
out_data = apply_regression(cl_reg, self.variables,
list(self.variables_files.keys()))

return cl_reg, out_data

def save_file(self, file_name):
#Saves the calculate field data into a file
Expand Down

0 comments on commit 510e71c

Please sign in to comment.