Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cs-137 (line plot) #3

Open
Danapit opened this issue Mar 3, 2023 · 7 comments
Open

Cs-137 (line plot) #3

Danapit opened this issue Mar 3, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@Danapit
Copy link

Danapit commented Mar 3, 2023

Hey Rosalie,
Is there a way of disabling the points in Cs-137 plot being connected by a line? It's a bit misleading in case some values are missing (not measured or below detection limit). Instead, some way of adding values of level of determination (< = less than) would be great. But already not having the line plot would be a great improvement.
Cheers!
Dana

@rosalieb rosalieb self-assigned this Mar 3, 2023
@rosalieb rosalieb added the enhancement New feature or request label Mar 3, 2023
@rosalieb
Copy link
Owner

rosalieb commented Mar 3, 2023

Hi Dana,

Thank you for your message.
In the original function, we wanted to visualise the line to help the user identify the Cesium peak, even when Cesium would have not been measured at every interval (which could make sense if someone is trying to limit the cost of the analyses).
We had implement the option that any line between two non-consecutive points of measurements would have a smaller width (lwd = 0.5 instead of default of lwd = 1), but I realise it may be too subtle. Therefore, I added on top of that a different line type (dotted line) to make it more obvious that values are missing and that it is an interpolation between 2 points.
That would answer the question if you have NAs in your dataset.

I also added 3 more arguments regarding the detection limit. DL_Pb, DL_Cs and DL_Am, respectively for the detection limits of Pbex, Cs and Am. Any values below these DL for Cs and Am be changed as NA in the first part of the code. For Pb, the values below the detection limit are added to the "ignore" vector (they will be plotted in grey).
I cannot do better than that at the moment - it would require a bit of work to implement a more flexible solution!

Finally, I also added a new argument in the function to prevent from plotting the Cs line to answer the second part of your comment.
Detach the package and reinstall it to be able to use the new argument: plot_Cs_line. The default is TRUE, but if you turn it to FALSE, you will not get the line.

# Re-install serac
detach("package:serac", unload = TRUE)
devtools::install_github("rosalieb/serac", build_vignettes = TRUE)
library(serac)

# Run your code using the argument plot_Cs_lines
serac(..., plot_Cs_line = FALSE, DL_Cs = 20)

To summarise:

  1. I made more obvious what was already implemented for NAs in the Cesium visualisation.
  2. I added 3 arguments to enter detection limits - default for these arguments are NULL.
  3. I added a logical argument to plot or not the Cesium line altogether.

@Danapit
Copy link
Author

Danapit commented Mar 3, 2023

Thanks a lot for the rapid answer! Will test this :)

@rosalieb
Copy link
Owner

rosalieb commented Mar 3, 2023

I actually did a few tests with the Am and Cs values totally removed, and it was misleading.. So I changed the code again.
Now, in the same way than it did for Pb, if a value of Cs is < DL_Cs, and a value of Am is < DL_Am, it will be shown on the graph, but in light grey.

The values are still accounted for in the Cesium inventory though...

Here is the result for the test data, with different detection limits (see home page of the package to get the data):

model_ALO09P12 <-
  serac(name="serac_example_ALO09P12", coring_yr=2009, model=c("CFCS"),
        plotphoto=FALSE, minphoto=c(0), maxphoto=c(210),
        plot_Pb=T, plot_Am=T, plot_Cs=T, Cher=c(30,40), Hemisphere=c("NH"), NWT=c(51,61),
        sedchange=c(75.5),
        plot_Pb_inst_deposit=T, inst_deposit=c(20,28,100,107,135,142,158,186),
        suppdescriptor=TRUE, descriptor_lab=c("Ca/Fe"),
        historic_d=c(20,28,100,107,135,142,158,186),
        historic_a=c(1994,1920,1886,1868),
        historic_n=c("sept 1994 flood","1920 flood","1886 flood","1868 flood ?"), 
        min_yr=c(1750),
        dmax=c(180), 
        plotpdf=T, preview=T,
        save_code=FALSE,
        DL_Pb = 25, DL_Cs = 25, DL_Am = 3)

ALO09P12 with random detection limits for test

@Danapit
Copy link
Author

Danapit commented Mar 15, 2023

Hey :) Sorry it took me a while to test this.

  1. I find the solution with the dotted line (to show they are some values missing) really good, thank you.
  2. If I understand correctly, DL is a single value for the entire profile? IMO an additional column in the data table would be better, because they can vary depending on each individual sample / spectrum, depending on parameters like sample mass, measurement time or presence of other radionuclides, which then in gamma spectrum contribute to the Compton background in lower energies, which would effect detectability of 241Am, for example, etc. Below I'm showing one figure from my thesis which illustrates, what I have in mind, in the lower row of figures the decision threshold is plotted for the individual samples.
    image
  3. I tested the serac plot_Cs_lines = FALSE attribute (after reinstalling the package). With this code. serac(name="BY",coring_yr=2007, mass_depth = TRUE, plot_Cs=T, plot_Cs_lines = FALSE, DL_Cs = 1, Hemisphere = "NH", NWT = c(75), sedchange = 80) I got an error Error in serac(name = "BY", coring_yr = 2007, mass_depth = TRUE, plot_Cs = T, : unused argument (plot_Cs_lines = FALSE) and as you can see below (I know, not a pretty profile), the line for 137Cs is still there. Any idea what went wrong?

Rplot_2023-03-15T1526

Thanks!

@rosalieb
Copy link
Owner

Hi!

Thanks for taking the time to test this. No worries at all about the delay: I still have had no time to check your other issue, and I may have to have you wait for a while, as I have lots of work these days. If you need an answer quicker, feel free to reach out about that other question to my co-author, Pierre Sabatier, as this is more of a "philosophical" question about what to do and not do, and he is the expert on age-depth models (I was the user of chronologies/developer).

To answer your questions:

  1. Great, I am glad this worked for you! Thanks for suggesting the improvement - we had implemented the thinner line, but it was not very visible - dotted solution is better.
  2. I understand what you mean. You are correct, the way it is implemented right now is that the code will only take one "DL_..." per element. The solution of adding a column would be totally doable, and so would be plotting the line as you did in your thesis (I like this idea!). I can try to work on that at a later time, when I have a bit more time - I think this would be great addition.
  3. It is because the argument is plot_Cs_line (no 's'). My bad, I did a typo up there in my previous answer. Re-run the same code with the typo corrected, and you should get what you want.

Let me know if this worked for you, and thank you again for helping improve serac.
PS: I am adding a little check-list for myself:

  • implement the varying detection limit with a new column in the dataset. Add an argument to visualise the DL (see Figure 11 above).
  • check out other issue.

@Danapit
Copy link
Author

Danapit commented Mar 16, 2023

Hi! No worries, and you are right, the other issue is a kind of "deeper" question and it's not at all urgent, I no longer work in this field of science and I'm just generally interested, because I find this R package a really cool tool. Plus non-linear fitting is certainly less convenient. There must be a good reason why most of the dating people use the linearized version of fitting.
3. Yes, thank you, plot_Cs_line works for me, great!
Thank you!

@rosalieb
Copy link
Owner

Thank you so much for you positive feedback!
I'll come back to work on this when I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants