DIFM-Brain / ofpetrial

GNU General Public License v3.0
0 stars 1 forks source link

Plot width error #41

Closed brittanikedge closed 3 months ago

brittanikedge commented 4 months ago

Plot width is not exactly the intended plot width

brittanikedge commented 4 months ago

@tmieno2 I'm working on changing the way the figures are created, and it should be much more efficient eliminating the need to consider the abline after choosing the trial plot, but I now think I understand where all of the problems might be coming from. It looks like there is a problem in this latest version of the package. I don't know if it is related to conv_unit(). I tried moving things back and forth from feet to meters and back in conv_unit(), and I didn't notice any rounding error. But this plot that should be 9.144 meters is actually slightly less as you can see in this screenshot. That would explain why the planter abline isn't right on the border as I expected.

Screenshot 2024-05-06 at 2 31 24 PM

I'm going to look at another example and see if that is also the case.

tmieno2 commented 4 months ago

Ah, I see. Let me know if you would like me to look at this as well.

brittanikedge commented 4 months ago

I'm looking into it. I'm inside make_trial_plots_by_input(). All the measurements are exact in the input_plot_info(). I'll let you know if I think it would be more efficient for you to look at it if it takes too much longer. I imagine it will take you less time since you wrote that function.

brittanikedge commented 4 months ago

@tmieno2 As you might expect, the problem starts at make_strips(), specifically the problem happens after st_make_grid(). It looks like the function is not sufficiently precise. I wonder if we can change the tolerance level?

tmieno2 commented 4 months ago

I don't see any options to make st_make_grid more precise. I think we need to adjust make_trial_plot(). Is this hard to accommodate this exception?

brittanikedge commented 4 months ago

Nor do I after looking. Theoretically, we shouldn't have any problem because sf layer is in meters, so it should be exactly 9.144. Let me look at make_trial_plot(). Also, I'm not sure that it's only happening here. It could be the case that other examples also had imprecise trial plot widths, but we didn't notice because the figures in the report looked fine. I will check if this is a problem for more than V0 example.

tmieno2 commented 3 months ago

Okay, @brittanikedge, this may have been creating a real problem for us. R CRAN came back to me saying one of the systems (R checks only 5 systems, Mac, Windows, Linux, etc at the time of submission, which we passed) is producing errors.

Screenshot 2024-05-13 at 9 44 15 AM Screenshot 2024-05-13 at 9 44 04 AM

The error is about invalid polygons created with the polygon not closing. Then I immediately thought of this. The rounding error may be causing the computer to recognize the polygon not closing. The problem is I have no way to testing this on my computer as the system the package is failing is Linux Fedora, which nobody really seems to use.

tmieno2 commented 3 months ago

@brittanikedge, this with td_single_input, right?

brittanikedge commented 3 months ago

@brittanikedge, this with td_single_input, right?

@tmieno2 What is "this" in the above sentence? If you are referring to my original error, I don't remember what example I was testing, but I looked at various examples and found the same problem for all of them.

I'm surprised that there is an unclosed polygon. While the issue of the plot widths exists, I assumed that the method for creating the polygons ensured that there would be 5 points to close them. When I looked at the code, I found that the error with the plot width begins with st_make_grids() inside the make_strips() function.

tmieno2 commented 3 months ago

Yeah, I am surprised about it because the code is does ensure that. But, I cannot think of any other reasons. So, I thought I would start from this one. This may not be solvable.