Skip to content

Commit

Permalink
#406 save time differences in differential Moran
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed May 4, 2016
1 parent a3bc080 commit 8acab63
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
28 changes: 27 additions & 1 deletion Explore/LisaMapNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,18 @@ void LisaMapFrame::OnSigFilter0001(wxCommandEvent& event)

void LisaMapFrame::OnSaveLisa(wxCommandEvent& event)
{

int t = template_canvas->cat_data.GetCurrentCanvasTmStep();
std::vector<SaveToTableEntry> data(3);
LisaMapCanvas* lc = (LisaMapCanvas*)template_canvas;

std::vector<SaveToTableEntry> data;

if (lc->is_diff) {
data.resize(4);
} else {
data.resize(3);
}

std::vector<double> tempLocalMoran(lisa_coord->num_obs);
for (int i=0, iend=lisa_coord->num_obs; i<iend; i++) {
tempLocalMoran[i] = lisa_coord->local_moran_vecs[t][i];
Expand All @@ -623,15 +633,31 @@ void LisaMapFrame::OnSaveLisa(wxCommandEvent& event)
data[1].type = GdaConst::long64_type;

std::vector<double> sig(lisa_coord->num_obs);
std::vector<double> diff(lisa_coord->num_obs);

for (int i=0, iend=lisa_coord->num_obs; i<iend; i++) {
sig[i] = p[i];


if (lc->is_diff ) {
int t0 = lisa_coord->var_info[0].time;
int t1 = lisa_coord->var_info[1].time;
diff[i] = lisa_coord->data[0][t0][i] - lisa_coord->data[0][t1][i];
}
}

data[2].d_val = &sig;
data[2].label = "Significances";
data[2].field_default = "LISA_P";
data[2].type = GdaConst::double_type;

if (lc->is_diff) {
data[3].d_val = &diff;
data[3].label = "Diff Values";
data[3].field_default = "DIFF_VAL";
data[3].type = GdaConst::double_type;
}

SaveToTableDlg dlg(project, this, data,
"Save Results: LISA",
wxDefaultPosition, wxSize(400,400));
Expand Down
3 changes: 2 additions & 1 deletion Explore/LisaMapNewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class LisaMapCanvas : public MapCanvas
virtual void CreateAndUpdateCategories();
virtual void TimeSyncVariableToggle(int var_index);

bool is_diff;

protected:
LisaCoordinator* lisa_coord;
bool is_clust; // true = Cluster Map, false = Significance Map
bool is_bi; // true = Bivariate, false = Univariate
bool is_rate; // true = Moran Empirical Bayes Rate Smoothing
bool is_diff;

DECLARE_EVENT_TABLE()
};
Expand Down
28 changes: 26 additions & 2 deletions Explore/LisaScatterPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,32 @@ void LisaScatterPlotCanvas::SaveMoranI()
wxString title = "Save Results: Moran's I";
std::vector<double> std_data(num_obs);
std::vector<double> lag(num_obs);

std::vector<double> diff(num_obs);


int xt = sp_var_info[0].time-sp_var_info[0].time_min;
int yt = sp_var_info[1].time-sp_var_info[1].time_min;


for (int i=0; i<num_obs; i++) {
std_data[i] = x_data[xt][i];
lag[i] = y_data[yt][i];

if (is_diff ) {
int t0 = lisa_coord->var_info[0].time;
int t1 = lisa_coord->var_info[1].time;
diff[i] = lisa_coord->data[0][t0][i] - lisa_coord->data[0][t1][i];
}
}
std::vector<SaveToTableEntry> data(2);

std::vector<SaveToTableEntry> data;

if (is_diff) {
data.resize(3);
} else {
data.resize(2);
}

data[0].d_val = &std_data;
data[0].label = "Standardized Data";
data[0].field_default = "MORAN_STD";
Expand All @@ -496,6 +513,13 @@ void LisaScatterPlotCanvas::SaveMoranI()
data[1].label = "Spatial Lag";
data[1].field_default = "MORAN_LAG";
data[1].type = GdaConst::double_type;

if (is_diff) {
data[2].d_val = &diff;
data[2].label = "Diff Values";
data[2].field_default = "DIFF_VAL";
data[2].type = GdaConst::double_type;
}

SaveToTableDlg dlg(project, this, data, title,
wxDefaultPosition, wxSize(400,400));
Expand Down
4 changes: 4 additions & 0 deletions SampleData/proj_nat_st.gda
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
<var>FH80</var>
<var>FH90</var>
</group>
<var>LISA_I</var>
<var>LISA_CL</var>
<var>LISA_P</var>
<var>DIFF_VAL</var>
</variable_order>
<custom_classifications/>
<weights_entries>
Expand Down

0 comments on commit 8acab63

Please sign in to comment.