 set status [ SclFunction "GEOLOGY DATABASE DISCONNECT" {} ]

set status [ SclFunction "BM EXIT" {
  frm20103={
    {
      exit_mode="E"
    }
  }
}]

set status [ SclFunction "EXIT GRAPHICS" {} ]

set status [ SclFunction "TOOL MODE TRADITIONAL" {} ]

set status [ SclFunction "RECALL ANY FILE" {
  file="strike_dip_plane1.str"
  mode="openInNewLayer"
}]

set status [ SclFunction "RECALL ANY FILE" {
  file="display_major_axis1.str"
  mode="openInNewLayer"
}]

set status [ SclFunction "RECALL ANY FILE" {
  file="primary_variogram_map1.dtm"
  mode="openInNewLayer"
}]


if {0} {
set status [ SclFunction "LIGHTING" {
  frm00268={
    {
      useSpotLight="Y"
      illumination_cone="90"
      sharpness_cone="30"
      spot_colour="gray"
      offset_angle="5"
      useDirectionalLights="on"
      light_y1="-1"
      light_x1="1"
      light_z1="1"
      light_colour1="white"
      light_y2="0"
      light_x2="-1"
      light_z2="1"
      light_colour2="white"
      light_y3="1"
      light_x3="1"
      light_z3="-1"
      light_colour3="white"
      rendering="G"
      edgesLighting="N"
      brightness="1.75"
    }
  }
}]

} else {

set status [ SclFunction "LIGHT OFF" {} ]

set status [ SclFunction "LIGHT ON" {
  frm00194={
    {
      y1="-1"
      x1="1"
      z1="-1"
      light_colour1="white"
      y2="0"
      x2="-1"
      z2="1"
      light_colour2="white"
      y3="0"
      x3="0"
      z3="0"
      light_colour3=""
      method="G"
      edges="N"
    }
  }
}]

}

set status [ SclFunction "DRAW SHELLS" {
  frm00530={
    {
      range1=""
      range2=""
      range3=""
      grade_field="D1"
      false_colour_type="2"
      legend_location="no legend"
      colours=table { colour expression label } {
        { "blue" null null }
        { "green" null null }
        { "yellow" null null }
        { "red" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
      }
      layer_name="primary_variogram_map1.dtm"
    }
  }
}]

set status [ SclFunction "3D GRID" {
  frm00140={
    {
      ygrid_inc="200"
      ylabel_inc="1"
      xgrid_inc="200"
      xlabel_inc="1"
      zgrid_inc="100"
      zlabel_inc="1"
      maximum=""
      minimum=""
    }
  }
}]

set status [ SclFunction "ZOOM FACTOR" {
  frm00326={
    {
      zoom_factor="1.2"
    }
  }
}]

set status [ SclFunction "ZOOM OUT" {} ]

set status [ SclFunction "ZOOM FACTOR" {
  frm00326={
    {
      zoom_factor="2"
    }
  }
}]

# rotate to a view of dip -50, azimuth 105

for {set dip -90} {$dip < -45} {set dip [expr $dip+5]} {

set status [ SclFunction "VIEW BY BEARING" {
  frm00289={
    {
      bearing="0"
      dip="$dip"
    }
  }
}]

SclPause 0.1

}

for {set bearing 0} {$bearing < 110} {set bearing [expr $bearing+5]} {

set status [ SclFunction "VIEW BY BEARING" {
  frm00289={
    {
      bearing="$bearing"
      dip="$dip"
    }
  }
}]

SclPause 0.1

}

set status [ SclFunction "VARIOGRAM MODELLING" {} ]

set status [ SclFunction "VG VARIOGRAM MAP" {
  frm20461={
    {
      location="gold_cut"
      id="17"
      str=""
      dfield="D1"
      minval=""
      maxval=""
      dip_dir="105"
      dip="40"
      num_lines="24"
      spread="30"
      spr_limit=""
      min0=""
      min1=""
      min2=""
      max0=""
      max1=""
      max2=""
      lag="100"
      maxdist="300"
      negative="NEGATIVES"
      fname="primary_variogram_map"
      report_format=".not - Surpac Note File"
      display_report="N"
      lag_minimum="10"
      lag_maximum="100"
      lag_increment="10"
    }
  }
}]


set status [ SclFunction "VG VARIANCE" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]


set status [ SclFunction "VG LAG" {
  frm77005={
    {
      lag="41.0"
    }
  }
}]

set status [ SclFunction "VG START MODEL" {
  move_chart_element=null
}]

set status [ SclFunction "VG REPORT MODEL" {
  frm20490={
    {
      mod_type="Spherical"
      nugget="0.2"
      sill0="0.8"
      range0="168"
      sill1=""
      range1=""
      sill2=""
      range2=""
      sill3=""
      range3=""
      sill4=""
      range4=""
      notefile="major_axis"
    }
  }
}]

set status [ SclFunction "SAVE EXP VG" {
  exp_vg_name="major_axis.evg"
}]

set status [ SclFunction "SAVE VG MODEL" {
  vg_model_name="major_axis.vgm"
}]

if {0} {

set status [ SclFunction "VG SAVE VARIOGRAM MAP" {
  frm77007={
    {
      str_loc="primary_variogram_map"
      str_id="1"
      purpose="graphics"
      x="1645"
      y="7235"
      z="150"
    }
  }
}]

}

set status [ SclFunction "VG MAP SET DIRECTION" {
  world_drag={
    {
      snap_mode="off"
      snap_projection="off"
      objectx="2.479"
      objecty="272.218"
      objectz="-0.048"
      dx="101.496"
      dy="-49.066"
      dz="0.100"
    }
  }
  frm77012={
    {
      angle="105"
    }
  }
}]

# macro 7 starts now

set status [ SclFunction "RECALL FILE" {
  frm00236={
    {
      location="secondary_variogram_map"
      rid="1"
      ftype="D"
      swa_desc="Y"
      append="R"
      styles_file=""
      rescale="N"
      swa_name="secondary_variogram_map1.dtm"
    }
  }
}]

set status [ SclFunction "DRAW SHELLS" {
  frm00530={
    {
      range1=""
      range2=""
      range3=""
      grade_field="D1"
      false_colour_type="2"
      legend_location="no legend"
      colours=table { colour expression label } {
        { "blue" null null }
        { "green" null null }
        { "yellow" null null }
        { "red" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
        { "" null null }
      }
      layer_name="secondary_variogram_map1.dtm"
    }
  }
}]

set status [ SclFunction "RECALL FILE" {
  frm00236={
    {
      location="display_semi_major_axis"
      rid="1"
      ftype="S"
      swa_desc="Y"
      append="R"
      styles_file=""
      rescale="N"
      swa_name="display_semi_major_axis1.str"
    }
  }
}]

set status [ SclFunction "RECALL FILE" {
  frm00236={
    {
      location="display_minor_axis"
      rid="1"
      ftype="S"
      swa_desc="Y"
      append="R"
      styles_file=""
      rescale="N"
      swa_name="display_minor_axis1.str"
    }
  }
}]

set status [ SclFunction "VIEW BY BEARING" {
  frm00289={
    {
      bearing="80"
      dip="-10"
    }
  }
}]


set status [ SclFunction "VG SHOW SECONDARY MAP" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG VARIANCE" {} ]



set status [ SclFunction "VG START MODEL" {
  move_chart_element=table { nugget num_structures sill0 range0 } {}
}]

set status [ SclFunction "VG MAP SET DIRECTION" {
  world_drag={
    {
      objectx="0.0"
      objecty="0.0"
      objectz="0.0"
      dx="136.006"
      dy="-274.152"
      dz="0.100"
    }
  }
  frm77012={
    {
      angle="135"
    }
  }
}]

set status [ SclFunction "VG LAG" {
  frm77005={
    {
      lag="32"
    }
  }
}]

set status [ SclFunction "VG REPORT MODEL" {
  frm20490={
    {
      mod_type="Spherical"
      nugget="0.4"
      sill0="0.6"
      range0="99"
      sill1=""
      range1=""
      sill2=""
      range2=""
      sill3=""
      range3=""
      sill4=""
      range4=""
      notefile="semi_major_axis"
    }
  }
}]

set status [ SclFunction "SAVE EXP VG" {
  exp_vg_name="semi_major_axis.evg"
}]

set status [ SclFunction "SAVE VG MODEL" {
  vg_model_name="semi_major_axis.vgm"
}]

set status [ SclFunction "VG SAVE VARIOGRAM MAP" {
  frm77007={
    {
      str_loc="secondary_variogram_map"
      str_id="1"
      purpose="graphics"
      x="1645"
      y="7235"
      z="150"
    }
  }
}]



#macro 8 starts here

set status [ SclFunction "RECALL FILE" {
  frm00236={
    {
      location="ellipsoid"
      rid="2"
      ftype="S"
      swa_desc="Y"
      append="R"
      styles_file=""
      rescale="N"
      swa_name="ellipsoid2.str"
    }
  }
}]

set form {
  GuidoForm form_1 {
    -default_buttons
    -label "Anisotropy ellipsoid"
    GuidoPanel panel_1 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_1 {
      -height 34
      -width 85
        GuidoTextArea text_1 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
If the continuity of the data is the same in all directions, an 'isotropic' condition is said to exist.  In other words, the major, semi-major, and minor axes would all have the same continuity.  However, in this demonstration, an 'anisotropic' condition exists, as there is variable continuity.

As mentioned previously, the major axis is the orientation which represents the greatest continuity.  By definition, the semi-major axis is the second-largest measure of continuity, and the minor axis is the smallest.  For block model estimation, it is necessary to know the strength of the major axis as compared to the strength of the other two axes.  The orientation of the three axes, as well as the strength of the continuity relative to the other axes is described by an 'anisotropy ellipsoid'.

The strength of the continuity along the major axis is compared to the continuity of the semi-major and minor axes by the following two terms:

The major to semi-major anisotropy ratio
The major to minor anisotropy ratio

These ratios are calculated by comparing the length of the ranges of the variograms along each axis.

To determine these ratios,
1) The function 'Extract variograms along axes' is performed, and the experimental variogram data and the variogram model for the major axis is displayed.
2) The 'Next variogram'  function is performed, and the experimental variogram data for the semi-major axis is presented
3) The range of the variogram is graphically modified to match the data for the semi-major axis (the nugget and sill values of the variogram model are held constant).  The lag distance may be modified to improve the quality of the variogram.
4) The major to semi-major anisotropy ratio is calculated as:
   The length of the range of the variogram model for the major axis /  The length of the range of the variogram model for the semi-major axis
5) The 'Next variogram' function is performed again, and the experimental variogram data for the minor axis is presented.
6) As in step 3, the range of the variogram is graphically modified to match the data for the minor axis (the nugget and sill values of the variogram model are held constant).  The lag distance may be modified to improve the quality of the variogram.
7) The major to minor anisotropy ratio is calculated as:
   The length of the range of the variogram model for the major axis /  The length of the range of the variogram model for the minor axis
   
The two anisotropy ratios are calculated and displayed in the upper right viewport."
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "VG SHOW AXES VARIOGRAMS" {} ]


set status [ SclFunction "RECALL VG MODEL" {
  vg_model_name="major_axis.vgm"
}]

set form {
  GuidoForm form_2 {
    -default_buttons
    -label "Anisotropy ellipsoid"
    GuidoPanel panel_2 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_2 {
      -height 18
      -width 85
        GuidoTextArea text_2 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
The 'Extract variograms along axes' function has been performed, and the experimental variogram data for the major axis is displayed.  File - Open - Variogram model (RECALL VG MODEL) has been used to display the major axis variogram model.

The 'Next variogram' function will be performed, and the experimental variogram data for the semi-major axis will be presented, along with the major axis variogram model.

After this, the macro will modify the range of the variogram (normally this is done graphically by the user) to match the data for the semi-major axis (the nugget and sill values of the variogram model for the major axis are held constant).

Once this is done, the major to semi-major anisotropy ratio will be calculated as:

   The length of the range of the variogram model for the major axis /  The length of the range of the variogram model for the semi-major axis

This anisotropy ratio will be displayed in the upper right viewport.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG EDIT ANISOTROPY" {
  move_chart_element={
    {
      anisotropy="1.7"
    }
  }
}]

set status [ SclFunction "SAVE EXP VG" {
  exp_vg_name="semi_major_axis.evg"
}]

set status [ SclFunction "SAVE VG MODEL" {
  vg_model_name="semi_major_axis.vgm"
}]

set form {
  GuidoForm form_3 {
    -default_buttons
    -label "Anisotropy ellipsoid"
    GuidoPanel panel_3 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_3 {
      -height 20
      -width 80
        GuidoTextArea text_3 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
The range of the variogram has been modified to match the data for the semi-major axis.  Note that the nugget and sill values of the variogram model are held constant.

The ranges of the variogram models for the major and semi-major axes are used to calculate the the major to semi-major anisotropy ratio:

   The length of the range of the variogram model for the major axis /  The length of the range of the variogram model for the semi-major axis

In this example, the length of the ranges of the variogram models are:
   Major axis: 168
   Semi-major axis: 99

Therefore, the major to semi-major anisotropy ratio is:   168 / 99 = 1.7

This anisotropy ratio is displayed in the upper right viewport.

Following this, the 'Next variogram' function will be performed, and the experimental variogram data for the minor axis will be presented, along with the current variogram model.  The major / minor anisotropy ratio will be calculated in the same manner.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG LAG" {
  frm77005={
    {
      lag="24.0"
    }
  }
}]


set status [ SclFunction "VG EDIT ANISOTROPY" {
  move_chart_element={
    {
      anisotropy="5.1"
    }
  }
}]

set status [ SclFunction "SAVE EXP VG" {
  exp_vg_name="minor_axis.evg"
}]

set status [ SclFunction "SAVE VG MODEL" {
  vg_model_name="minor_axis.vgm"
}]

set form {
  GuidoForm form_4 {
    -default_buttons
    -label "Anisotropy ellipsoid"
    GuidoPanel panel_4 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_4 {
      -height 25
      -width 80
        GuidoTextArea text_4 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
The 'Next variogram' (VG NEXT) function has been performed, and the experimental variogram data for the minor axis has been presented, along with the semi-major axis variogram model.  The lag distance has been changed to improve the quality of the variogram.

The range of the variogram has been modified to match the data for the minor axis.  Note that the requirement of maintaining the same nugget and sill values of the variogram model does not allow a very good fit of the variogram in this case.  Data such as this presents a challenge for interpretation.

The ranges of the variogram models for the major and minor axes are used to calculate the the major to minor anisotropy ratio:

   The length of the range of the variogram model for the major axis /  The length of the range of the variogram model for the minor axis

In this example, the length of the ranges of the variogram models are:
   Major axis: 168
   Minor axis: 33

Therefore, the major to minor anisotropy ratio is:   168 / 33 = 5.1

This anisotropy ratio is displayed in the upper right viewport.

The next step is to determine the orientation of the anisotropy ellipsoid, in terms of Surpac's rotation convention.

The function 'Create anisotropy ellipsoid report' will be used to do this.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}


set status [ SclFunction "VG ELLIPSOID REPORT" {
  frm77009={
    {
      report_name="anisotropy_ellipsoid_report"
      report_format=".not - Surpac Note File"
    }
  }
  frm45003={
    {
      _action="Yes to All"
    }
  }
}]

set form {
  GuidoForm form_5 {
    -default_buttons
    -label "Anisotropy ellipsoid"
    GuidoPanel panel_5 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_5 {
      -height 25
      -width 70
        GuidoTextArea text_5 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
Now that we have obtained all of the information below, we are ready to proceed with block model estimation:

Anisotropy ellipsoid orientation (Surpac convention):
Bearing: 206.6
Plunge:  -9.6
Dip:     -45

Major axis variogram parameters:
Co (nugget):    0.2
C (sill)   :    0.8
A (range)  :  168.0

Major to semi-major anisotropy ratio: 1.7
Major to minor anisotropy ratio: 5.1
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

# These lines below allow this macro can be run multiple times.

set status [ SclFunction "VG LAG" {
  frm77005={
    {
      lag="32"
    }
  }
}]

set status [ SclFunction "VG NEXT" {} ]

set status [ SclFunction "VG NEXT" {} ]

SclPause 3

set status [ SclFunction "VG EXIT" {} ]

puts ""
puts ""
puts " macro _08_anisotrophy_ellipsoid.tcl completed"
puts ""


