NSInterpolate

Documentation for NSInterpolate.

After Naprstek and Smith, 2019.

NSInterpolate.NSInterpolateModule

The code is a conversion from c# of that published by T. Naprstek and R. S. Smith (2019, A new method for interpolating linear features in aeromagnetic data. Geophysics, 84(3), JM15-JM24). I have used version NSI_v8 from github: https://github.com/TomasNaprstek/Naprstek-Smith-Interpolation.

source
NSInterpolate.NSinterpMethod
NSinterp(param_file)

Read parameters from param_file into a dictionary, paramd, and call NSinterp(paramd)

A more detailed explanation can go here, perhaps a ref to the paper.

Arguments

  • param_file: The name of the JSON file containing the input parameters.

Notes

The parameter file contains values for the following input parameters:

input_xyz_file: Geosoft XYZ file containing the observed data
input_xyz_east: the name of the channel in `input_xyz_file` containing the eastings
input_xyz_north: the name of the channel in `input_xyz_file` containing the northings
input_xyz_value: the name of the channel in `input_xyz_file` containing the values to grid
datum: the geographic datum (e.g. WGS84) for the input data
projection: the geographic projection for the input data (e.g. "NUTM17")
outputFile: the name of the netCDF4 file that the grid will be written to
cellSize: edge size of each square cell in metres
interpDist: metres away that will be interpolated
maxLoop: the number of times the interpolation loop will be processed
searchStepSize: how much of a cell we will "travel" each search step
cellSizeF: resampled final cell size
trendM: 100 - median % location (so 0 is no trending, 100 is full trending)
autoStop: a checkbox of whether or not to auto stop
angleSearch: the number of degrees it will move each time when searching away from the initial eigenvector
multiSmooth: smooth the multiplier grid before applying the normalization process (0 is no smoothing, 100 is max smoothing) (%)
spatialSmooth: a checkbox of whether or not to use spatial smoothing (in almost all cases, should be used)
outputwritebool: if 0, outputs in x y value. if 1, outputs in a format easy for importing into Oasis Montaj.
realGridLocations: if 0, outputs real data in the equi-distance grid cell locations. If 1, then output the real data cells as an average position of all real data within the cell.

Examples

Here are the contents of an example parameter file, tokens.json:

{
	"outputwritebool":true,
	"maxLoop":10,
	"input_xyz_north":"Northing",
	"interpDist":1500.0,
	"searchStepSize":0.25,
	"cellSizeF":500.0,
	"input_xyz_value":"gD_2P67",
	"projection":"unknown",
	"input_xyz_east":"Easting",
	"datum":"unknown",
	"trendM":50.0,
	"autoStop":true,
	"angleSearch":10.0,
	"multiSmooth":100.0,
	"spatialSmooth":true,
	"outputFile":"Blackall_sm100.nc",
	"realGridLocations":true,
	"input_xyz_file":"mydatadirectory/mydatafile.xyz",
	"cellSize":500.0
}
julia>  NSinterp("tokens.json")

NSinterp
  Julia version by Mark Dransfield after Naprstek and Smith
  Version gamma!
  Tue, 28 Jan 2025 10:37:51
  6 threads.
  Julia Version - 1.8.2

Accessing XYZ data in mydatafile.xyz.

  Found 141 header records
  Found 230 lines
  Found 43 channels

  Starting anisotropic gridding loop, loop counter:  1 2 3 4 5 6 7 8 9 10

End
source
NSInterpolate.initial_averageMethod

Check through all grid cells, and if a cell has more than one reading in it: average the value over the number of readings. Also average the relative positions and restore the offset, so that the mean value is at the mean position and not at the centre, or a corner of, the cell. The flag for the cell is then set to 1.

source
NSInterpolate.initial_interpolationMethod

Now go through all cells, and assign values to the ones that have no data currently, or determine if they are too far away from real data to use. During this process we will also find all closest data to each cell which will be information needed when normalizing.

The meaning of the cell flag is changed and now becomes: +1: a cell that has observations within its borders; 0: a cell without observations within its borders and whose value has been interpolated; -1: a cell too far from data to be interpolated and which will remain un-filled.

source
NSInterpolate.xyz_channelsMethod
xyz_channels(file_name::String, num_head_recs::Integer, num_channels::Integer)

Get the names of the channels in a Geosoft XYZ file_name. The algorithm checks num_head_recs header records. If it finds one with a number of words equal to the number of channels, num_channels, then it returns those words as an array of channel names.

source
NSInterpolate.xyz_countFunction
xyz_count(file_name::String)

Count the number of header records, flight lines and channels in XYZ file.

Also the decimal precision of each channel in the Geosoft XYZ file.

params
----------
file_name ::String
    The name of the Geosoft XYZ file.

Returns
-------
num_head_recs ::Int
    The .
num_lines ::Int
    The .
num_channels ::Int
    The .
field_precisions ::Int
    The .
source
NSInterpolate.xyz_linesMethod
xyz_lines(file_name::String, num_lines)

Returns the line numbers (`line_ids`), and the number of fiducials in each line.
A helper funtion for `xyz_to_whizz`.

params
----------
whizz_file ::String
    The name of the geoWhizz file.

Returns
-------
None
source