[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 0afec90: Statistics: greaterequal2 and lesstha
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 0afec90: Statistics: greaterequal2 and lessthan2 properly used in 2d histogram |
Date: |
Fri, 14 Aug 2020 09:28:52 -0400 (EDT) |
branch: master
commit 0afec90648385ee9cfe6db56f3ff8c22236d83d2
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Statistics: greaterequal2 and lessthan2 properly used in 2d histogram
Until now, while the two values given to '--greaterequal2' and
'--lessthan2' by the user where recorded, they weren't actually used to
limit the dataset. As a result, unless the ranges weren't set manually
(with '--manualbinrange'), they would effectively not get used.
With this commit, upon reading the input columns, we apply the given
ranges, just like we do with the first column and the resulting 2D
histogram is similarly truncated.
Also, we noticed that the minimal working PGFPlots source to make a 2D
histogram hadn't properly explained what to put instead of 'XXXXXX', so
that has also been corrected.
Both issues were reported by Samane Raji.
---
bin/statistics/ui.c | 22 +++++++++++++++++++++-
doc/gnuastro.texi | 13 +++++++++----
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/bin/statistics/ui.c b/bin/statistics/ui.c
index a35e727..08ccb20 100644
--- a/bin/statistics/ui.c
+++ b/bin/statistics/ui.c
@@ -584,7 +584,7 @@ ui_out_of_range_to_blank(struct statisticsparams *p)
unsigned char flags=GAL_ARITHMETIC_NUMOK;
unsigned char flagsor = ( GAL_ARITHMETIC_INPLACE
| GAL_ARITHMETIC_NUMOK );
- gal_data_t *tmp, *cond_g=NULL, *cond_l=NULL, *cond, *blank, *ref;
+ gal_data_t *tmp, *tmp2, *cond_g=NULL, *cond_l=NULL, *cond, *blank, *ref;
/* Set the dataset that should be used for the condition. */
@@ -621,6 +621,16 @@ ui_out_of_range_to_blank(struct statisticsparams *p)
cond_g=gal_arithmetic(GAL_ARITHMETIC_OP_LT, 1, flags, ref, tmp);
gal_data_free(tmp);
}
+ if( p->input->next && !isnan(p->greaterequal2) )
+ {
+ tmp=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, 1, &one, NULL, 0, -1, 1,
+ NULL, NULL, NULL);
+ *((float *)(tmp->array)) = p->greaterequal2;
+ tmp2=gal_arithmetic(GAL_ARITHMETIC_OP_LT, 1, flags, p->input->next, tmp);
+ cond_g=gal_arithmetic(GAL_ARITHMETIC_OP_OR, 1, flagsor, cond_g, tmp2);
+ gal_data_free(tmp);
+ gal_data_free(tmp2);
+ }
/* Same reasoning as above for 'p->greaterthan'. */
@@ -632,6 +642,16 @@ ui_out_of_range_to_blank(struct statisticsparams *p)
cond_l=gal_arithmetic(GAL_ARITHMETIC_OP_GE, 1, flags, ref, tmp);
gal_data_free(tmp);
}
+ if(p->input->next && !isnan(p->lessthan2))
+ {
+ tmp=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, 1, &one, NULL, 0, -1, 1,
+ NULL, NULL, NULL);
+ *((float *)(tmp->array)) = p->lessthan2;
+ tmp2=gal_arithmetic(GAL_ARITHMETIC_OP_GE, 1, flags, p->input->next, tmp);
+ cond_l=gal_arithmetic(GAL_ARITHMETIC_OP_OR, 1, flagsor, cond_l, tmp2);
+ gal_data_free(tmp);
+ gal_data_free(tmp2);
+ }
/* Now, set the final condition. If both values were specified, then use
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 294c3db..4263b56 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -12762,9 +12762,14 @@ Gnuastro's Statistics program has the
@option{--histogram2d} option for this tas
Its output will be three columns that have the centers of every box in both
dimensions.
The first column is the central box coordinates in the first dimension, the
second has values along the second dimension and the third has the number of
input points that fall within each box.
You can specify the number of bins along each dimension through the
@option{--numbins} (for first input column) an @option{--numbins2} (for second
input column).
-the output file from this command can then be given to any plotting tool to
visualize the distribution.
+The output file from this command can then be given to any plotting tool to
visualize the distribution.
-You can then make high-quality plots within your paper (all in @LaTeX{}), you
can use @url{https://ctan.org/pkg/pgfplots, PGFPlots} with the following
minimal @LaTeX{} source:
+For example, you can make high-quality plots within your paper (using the same
@LaTeX{} engine, thus blending very nicely with your text) using
@url{https://ctan.org/pkg/pgfplots, PGFPlots}.
+Below you can see one such minimal example, using your favorite text editor,
save it into a file, make the two small corrections in it, then run the
commands shown at the top.
+This assumes that you have @LaTeX{} installed, if not the steps to install a
minimally sufficient @LaTeX{} package on your system, see the respective
section in @ref{Bootstrapping dependencies}.
+
+The two parts that need to be corrected are marked with '@code{%% <--}': the
first one (@code{XXXXXXXXX}) should be replaced by the value to the
@option{--numbins} option which is the number of bins along the first dimension.
+The second one (@code{FILE.txt}) should be replaced with the name of the file
generated by Statistics.
@example
%% Replace 'XXXXXXXXX' with your selected number of bins in the first
@@ -12819,8 +12824,8 @@ You can then make high-quality plots within your paper
(all in @LaTeX{}), you ca
surf,
shader=flat corner,
mesh/ordering=rowwise,
- mesh/cols=XXXXXXXXX, %% <---- Correct this!
- ] file @{cm-hist2d.txt@};
+ mesh/cols=XXXXXXXXX, %% <-- Number of bins in 1st column.
+ ] file @{FILE.txt@}; %% <-- Name of aststatistics output.
\end@{axis@}
\end@{tikzpicture@}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 0afec90: Statistics: greaterequal2 and lessthan2 properly used in 2d histogram,
Mohammad Akhlaghi <=