Skip to content

Sq2.50 Procedural Framework: Part 4

sbodorkos edited this page Jul 24, 2018 · 9 revisions

The next phase of Loop A does many of the remaining simple row-by-row calculations, followed by preparations for calculation of the key "column mean" values, which are in turn used in other row-by-row expressions. The incomplete Loop A proceeds as follows:

If pbStd = FALSE --Calculate a couple of "SampleData-only" columns:
  
  --Firstly ["7-corr204Pb/206Pb"]:  
  Term1 = Pb46cor7( ["207/206"], sComm64, sComm74, ["207corr206Pb/238UAge"] )  
  --recalling that subroutine "Pb46cor7" is defined in LudwigLibrary
  PlaceFormulae Term1, Frw, piPb46_7col, Lrw
  
  --Secondly ["8-corr204Pb/206Pb"]:  
  Term1 = Pb46cor8( ["208/206"], ["232Th/238U"], sComm64, sComm84, ["208corr206Pb/238UAge"] )  
  --recalling that subroutine "Pb46cor8" is defined in LudwigLibrary
  PlaceFormulae Term1, Frw, piPb46_8col, Lrw
  
End If

The next step is to calculate ALL of the applicable proportions of common Pb (which in turn reflect all the permutations of index isotope (204-, 207-, and 208-corrected) and daughter-Pb isotope (206Pb and 208Pb, for Pb/U and Pb/Th respectively), firstly for the StandardData sheet and secondly for the SampleData sheet:

If pbStd = TRUE --StandardData first  
  
  --First, fill column ["4-corr%com206"]:
  Term2 = 100 * sComm64 * ["204/206"]
  PlaceFormulae Term2, Frw, piStdCom6_4col, Lrw
  
  --Second, fill column ["7-corr%com206"]:
  Term2 = 100 * sComm64 * ["204/206 fr.207"]
  PlaceFormulae Term2, Frw, piStdCom6_7col, Lrw
  
  --Third, fill column ["8-corr%com206"]:
  Term2 = 100 * sComm64 * ["204/206 fr.208"]
  PlaceFormulae Term2, Frw, piStdCom6_8col, Lrw
  
  --Fourth, fill column ["4-corr%com208"]:
  Term2 = 100 * sComm84 / ["208/206"] * ["204/206"]
  PlaceFormulae Term2, Frw, piStdCom8_4col, Lrw
  
  --Fifth, fill column ["7-corr%com208"]:
  Term2 = 100 * sComm84 / ["208/206"] * ["204/206 fr.207"]
  PlaceFormulae Term2, Frw, piStdCom8_7col, Lrw

Else --i.e. SampleData second

  --First, fill column ["4-corr%com206"], same as StandardData:
  Term2 = 100 * sComm64 * ["204/206"]
  PlaceFormulae Term2, Frw, piStdCom6_4col, Lrw
  
  --Second, fill column ["7-corr%com206"], different to StandardData:
  Term2 = 100 * sComm64 * ["7-corr204Pb/206Pb"]
  PlaceFormulae Term2, Frw, piStdCom6_7col, Lrw
  
  --Third, fill column ["8-corr%com206"], different to StandardData:
  Term2 = 100 * sComm64 * ["8-corr204Pb/206Pb"]
  PlaceFormulae Term2, Frw, piStdCom6_8col, Lrw
  
  --Fourth, fill column ["4-corr%com208"], same as StandardData:
  Term2 = 100 * sComm84 / ["208/206"] * ["204/206"]
  PlaceFormulae Term2, Frw, piStdCom8_4col, Lrw
  
  --Fifth, fill column ["7-corr%com208"], different to StandardData:
  Term2 = 100 * sComm84 / ["208/206"] * ["7-corr204Pb/206Pb"]
  PlaceFormulae Term2, Frw, piStdCom8_7col, Lrw
  
End If  

The next step is to calculate all the applicable radiogenic 208Pb/206Pb values. Note that SQUID 2.50 currently calculates both possible 208Pb/206Pb values (204-corrected and 207-corrected) for all analyses on the SampleData sheet, but only calculates (at most) one radiogenic 208Pb/206Pb value for the StandardData sheet. I don't see why this should be so: I think SQUID 3.0 should calculate both (and therefore that the If criteria below should be modified accordingly):

If pbStd = FALSE OR piStdCorrType = 0 --i.e. all SampleData,
--plus StandardData when index isotope selected is 204Pb:  

  --First, prepare to fill column ["4-corr208Pb*/206Pb*"]:
  FinalTerm1 = ( ["208/206"] / ["204/206"] - sComm84 ) / ( 1 / ["204/206"] - sComm64)
  
  --Second, assemble the expression for column ["4-corr208Pb*/206Pb* %err"]:
  --Note that the following If now *seems* obsolete, because we are using the same 
  --column-name ( ["4-corr208Pb*/206Pb*"] ) for 204Pb-corrected 208Pb/206Pb in both
  --the StandardData and SampleData sheets (Ludwig did not do this).  
  --All expressions for Term5 and FinalTerm2 corrected 2018-03-21:

  If pbStd = TRUE  
    Term5 = ( (["208/206 %err"] / 100 * ["208/206"])^2 +
      (["4-corr208Pb*/206Pb*"] * sComm64 - sComm84)^2 *  
      (["204/206 %err"] / 100 * ["204/206"])^2 )  
      / (1 - sComm64 * ["204/206"])^2  
    FinalTerm2 = 100 * sqrt( Term5 ) / abs( ["4-corr208Pb*/206Pb*"] )  
    
    --Now place the FinalTerm1 formula for ["4-corr208Pb*/206Pb*"] and  
    --and the FinalTerm2 formula for ["4-corr208Pb*/206Pb* %err"]:
    OutpCol = ["4-corr208Pb*/206Pb*"]
    PlaceFormulae FinalTerm1, Frw, OutpCol, Lrw 
    PlaceFormulae FinalTerm2, Frw, 1 + OutpCol, Lrw
    
  Else  
    
    Term5 = ( (["208/206 %err"] / 100 * ["208/206"])^2 +
      (["4-corr208Pb*/206Pb*"] * sComm64 - sComm84)^2 * 
      (["204/206 %err"] / 100 * ["204/206"])^2 )  
      / (1 - sComm64 * ["204/206"])^2  
    FinalTerm2 = 100 * sqrt( Term5 ) / abs( ["4-corr208Pb*/206Pb*"] )  
    
    --Now place the FinalTerm1 formula for ["4-corr208Pb*/206Pb*"] and  
    --and the FinalTerm2 formula for ["4-corr208Pb*/206Pb* %err"]:
    OutpCol = ["4-corr208Pb*/206Pb*"]
    PlaceFormulae FinalTerm1, Frw, OutpCol, Lrw 
    PlaceFormulae FinalTerm2, Frw, 1 + OutpCol, Lrw
    
  End If
    
End If

If pbStd = FALSE OR piStdCorrType = 1 --i.e. all SampleData,
--plus StandardData when index isotope selected is 207Pb:  

  --First, prepare to fill column ["7-corr208Pb*/206Pb*"]:
  If pbStd = TRUE  
  
    FinalTerm1 = ( ["208/206"] / ["204/206 fr.207"] - sComm84 ) / 
      ( 1 / ["204/206 fr.207"] - sComm64)  
  
  Else
  
    FinalTerm1 = ( ["208/206"] / ["7-corr204Pb/206Pb"] - sComm84 ) / 
      ( 1 / ["7-corr204Pb/206Pb"] - sComm64)  
  
  End If  
  
  --Second, assemble the expression for column ["7-corr208Pb*/206Pb* %err"]:
  If pbStd = TRUE  
    --assemble 10 arguments for separate subroutine StdPb86radCor7per:
    --the following expression was corrected 2018-03-26:
    Term5 = ["208/206"], ["208/206 %err"], ["207/206"], ["207/206 %err"], 
      ["7-corr208Pb*/206Pb*"], ["204/206 fr.207"], Std_76, sComm64, sComm74, sComm84  
    FinalTerm2 = StdPb86radCor7per( Term5 )  
    --subroutine StdPb86radCor7per to be documented separately  
    
    --Now place the FinalTerm1 and 2 formulae for ["7-corr208Pb*/206Pb*"] and  
    ["7-corr208Pb*/206Pb* %err"] respectively:
    OutpCol = ["7-corr208Pb*/206Pb*"]
    PlaceFormulae FinalTerm1, Frw, OutpCol, Lrw 
    PlaceFormulae FinalTerm2, Frw, 1 + OutpCol, Lrw
    
  Else --and assuming ["Total206Pb/238U"] and ["207corr206Pb/238UAge"] both exist 
    
    --assemble 10 arguments for separate AND DIFFERENT subroutine Pb86radCor7per:
    Term5 = ["208/206"],["208/206 %err"], ["207/206"],["207/206 %err"], ["Total206Pb/238U"],
      ["Total206Pb/238U %err"],["207corr206Pb/238UAge"], sComm64, sComm74, sComm84  
    FinalTerm2 = Pb86radCor7per( Term5 )  
    --subroutine Pb86radCor7per to be documented separately  
    
    --Now place the FinalTerm1 and 2 formulae for ["7-corr208Pb*/206Pb*"] and  
    ["7-corr208Pb*/206Pb* %err"] respectively:
    OutpCol = ["7-corr208Pb*/206Pb*"]
    PlaceFormulae FinalTerm1, Frw, OutpCol, Lrw 
    PlaceFormulae FinalTerm2, Frw, 1 + OutpCol, Lrw
    
  End If
  
End If  

The next step is to calculate some column-means, firstly a weighted mean of the common-Pb calibration constants, and then biweights of some of the other columns related to 204-overcounts. The incomplete Loop A proceeds:

If pbStd = TRUE  

  If piaSpotCt[-pbStd] > 1 
  --i.e. if more than one spot-analysis corresponding to specified prefix for Standard
  --then SQUID 2.50 assigns the name "StdHrs" to the cell range corresponding to column  
  --"Hours" in sheet StandardData. Then:
  
    If pbSBMnorm = TRUE --i.e. if user requested SBM-normalisation  
    --then ReDim the following double-precision vectors (not zero-addressed!)  \
    
      ReDim SbmOffs[1 to Task.Npeaks]  --number of mass-stations in Task/XML file
      ReDim SbmOffsErr[1 to Task.Npeaks]  
      ReDim SbmPk[1 to piaSpotCt[-pbStd] ]  --number of Standard analyses in XML file  
      
    End If  
    
    --Now calculate weighted mean calibration constants for Standard
    --(subroutine documented separately)  
    WtdMeanAcalc BadSbm(), Adrift(), AdriftErr()  
    
    --Then calculate and place robust means of 204-overcount columns for Standard:  
    --(subroutine documented separately)  
    OverCtMeans plaLastDatRw[-pbStd]  
    
  Else --i.e. piaSpotCt[-pbStd] <= 1, i.e only one analysis with prefix matching that  
  --defined for the Standard <<string StdPrefix>>, or none at all. Processing must quit,   
  --but SQUID 2.50 tries to construct a helpful error-message first:  
  
    If (pbFoundStdName = TRUE) AND (piaSpotCt[-pbStd] = 0)  
      
      Msg = "Unable to parse the raw-data file."
      
    ElseIf piaSpotCt[-pbStd] = 1  

      Msg = "Only 1 spot found with label similar to <<string StdPrefix>>
             - did you correctly specify the Standard name?"
    
    Else  

      Msg = "No spots found with label similar to <<string StdPrefix>>
             - did you correctly specify the Standard name?"
     
    End If
    
    Exit Sub --quit processing
  
  End If  
  
  --Since piaSpotCt[-pbStd] > 1, attend to StandardData SBM display:  
  --2018-06-12: THIS SECTION SKIPPED; GRAPHICAL OUTPUT ONLY, ATTEND TO IT LATER
  If (pbSbmNorm = TRUE) AND (BadSBM[-pbStd] < piaSpotCt[-pbStd] * Task.Npeaks / 2)  
  
    SBMdata SbmOffs(), SbmPk(), SbmOffsErr(), pdaSbmDeltaPcnt(), CanChart
    --subroutine to be documented separately

    If CanChart = TRUE
    
      AddSBMchart plHdrRw, SbmOffs(), SbmOffsErr()
      --subroutine to be documented separately
    
    End If --CanChart
    
  End If --(pbSbmNorm = TRUE, etc.)
  
End if --pbStd = TRUE as per beginning of this Part 4.  

The code then proceeds to the final stretch of the incomplete Loop A that commenced at the beginning of Part 1. That code is documented in Part 5.

Clone this wiki locally