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 is now starting

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 form {
  GuidoForm form_1 {
    -default_buttons
    -label "Secondary 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 16
      -width 70
        GuidoTextArea text_1 {
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
A secondary variogram map will now be created.

The selected direction of maximum continuity in the secondary variogram map is the semi-major axis.  

The minor axis will lie in the plane of the secondary variogram map, perpendicular to the semi-major axis.  The orientation of the minor axis is automatically calculated based on the orientation of the semi-major axis - no user input is required.

A DTM of the secondary variogram map has been displayed in graphics.   Click on the main window to review this data.  Note that the semi-major axis, in this case, is not contained in the plane of the primary variogram map, although it could have been.

Once you APPLY this form, it will take a few minutes to calculate the secondary variogram map.  While it is processing, you can review the secondary variogram map in the main window or read the reference manual page on variogram maps.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}


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"
    }
  }
}]

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

The secondary variogram map has been calculated, and a direction of maximum continuity has been identified.  This orientation is the semi-major axis.

The minor axis is also in the plane of the secondary variogram map, and is perpendicular to the semi-major axis.  The orientation of the minor axis is automatically calculated based on the orientation of the semi-major axis - no user input is required.

The secondary variogram map has been created perpendicular to the primary variogram map (Dip: +40   Dip direction: 105) and perpendicular to the major axis.  The secondary variogram map has the orientation of:

Dip: -80.42   Dip direction: 26.5
which is the same as:
Dip: 80.42   Dip direction: 206.5

Additionally, the variogram map has been saved as the file secondary_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.  Again, 'missing' data in any variogram map is a result of lack of data pairs at certain distances and orientations.

In this case, the semi-major axis has been selected at an orientation slightly different to the dip of the primary variogram map.  If the orientation of the semi-major axis was significantly different than the primary variogram map, it may be worth recalculating the primary variogram map at an orientation which encompasses both the major and semi-major axes as determined here.
"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "VG EXIT" {} ]

puts ""
puts ""
puts " macro _07_secondary_variogram_map.tcl completed"
puts ""


