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 form {
  GuidoForm form_1 {
    -default_buttons
    -label "Primary variogram map"
    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 30
      -width 70
        GuidoTextArea text_1 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
A variogram map is a set of experimental variograms, calculated at regular angular increments, coloured by gamma(h) values.

For the purpose of this demonstration, it is important to understand a couple of basic concepts.

There are two variogram maps:

1) The primary variogram map will contain the major axis.
2) The secondary variogram map is perpendicular to the major axis, and contains the semi-major and minor axes.

The primary variogram map, with  Dip: +40   Dip direction: 105  has been displayed by this macro in the main graphics window.

The orientation of the major axis in this case has been selected as a 'pitch' or 'rake angle' of 15 degrees from the horizontal strike of the variogram map plane.

This direction was selected based on an interpretation that the range of the variogram at this orientation was longer than the range of any other variogram on this plane.

Many aspects of geostatistics are not an exact science.  The interpretation of variogram data, and the selection of the orientation of the direction of maximum continuity is done here to demonstrate the geostatistical functionality available.

After this form, the the variogram modelling form will be presented.  Once you APPLY that form, it will take a few minutes to calculate the variogram map.  While it is processing, you may click on this window to review the data, or read the reference manual page.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "VARIOGRAM MODELLING" {} ]

set status [ SclFunction "VG VARIOGRAM MAP" {
  frm20461={
    {
      _action=display
      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"
    }
  }
}]

set form {
  GuidoForm form_2 {
    -default_buttons
    -label "Primary variogram map"
    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 30
      -width 70
        GuidoTextArea text_2 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "


The primary variogram map, with  Dip: +40   Dip direction: 105  is now displayed.  Additionally, the variogram map has been saved as the file primary_variogram_map1.DTM, and is displayed in the main graphics window.  It has been coloured by gamma(h) values, which are stored in the D1 field.  You may want to review and rotate the data there before proceeding with the next macro.

The variogram map currently displayed appears to be 'incomplete', or has 'missing' data.  There is actually nothing wrong - the 'missing' parts of the variogram map are simply where no data pairs exist at that distance and orientation.

The orientation of the major axis has been selected as a 'pitch' or 'rake angle' of 15 degrees from the horizontal strike of the variogram map plane.

This direction was selected based on an interpretation that the range of the variogram at this orientation was longer than the range of any other variogram on this plane.  As previously stated, interpretations of geostatistical data are performed here only to demonstrate the functionality of the software.  Alternate interpretations may be deemed more appropriate.

The function File - Save - Experimental variogram (SAVE EXP VG) has been used to save the file major_axis.evg.  It is possible to review the experimental variogram data by opening this file.

Additionally, The function File - Save - Variogram model (SAVE VG MODEL) has been used to save the file major_axis.vgm.  When the experimental variogram data is displayed, it is possible to review the variogram model by opening this file.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "VG EXIT" {} ]

puts ""
puts ""
puts " macro _06_primary_variogram.tcl completed"
puts ""


