NSInterpolate
Documentation for NSInterpolate.
After Naprstek and Smith, 2019.
NSInterpolate.NSInterpolateNSInterpolate.NSinterpNSInterpolate.cell_to_dimNSInterpolate.get_located_dataNSInterpolate.initial_averageNSInterpolate.initial_interpolationNSInterpolate.obs_from_geowhizzNSInterpolate.obs_from_geoxyzNSInterpolate.xyz_channelsNSInterpolate.xyz_countNSInterpolate.xyz_lines
NSInterpolate.NSInterpolate — Module
NSInterpolate interpolates data irregularly sampled in 2 dimensions onto a regular grid. It is designed originally for aeromagnetic data but is also very effective for airborne gravity and airborne gravity gradient data. These data are all sampled along flight-lines that are close to being straight lines and it is likely that the method will work well for any data sampled in this way.
The code is a conversion from c#, 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.
Mark Dransfield 2024
NSInterpolate.NSinterp — Function
NSinterp(param_file, verbose=false)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.verbose: A flag to indicate verbose reporting of progress or not (default).
Notes
The parameter file contains values for the following input parameters:
observed_data: DimDataset containing the observed data, if `nothing` (the default), get data from input_file
input_file: data file containing the observed data, either Geosoft XYZ or NetCDF4 nc format
input_east: the name of the channel in `input_file` containing the eastings
input_north: the name of the channel in `input_file` containing the northings
input_value: the name of the channel in `input_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 false, no output file is written; if true, outputs result to NetCDF4 file.
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_north":"Northing",
"interpDist":1500.0,
"searchStepSize":0.25,
"cellSizeF":500.0,
"input_value":"gD_2P67",
"projection":"unknown",
"input_east":"Easting",
"datum":"unknown",
"trendM":50.0,
"autoStop":true,
"angleSearch":10.0,
"multiSmooth":100.0,
"spatialSmooth":true,
"outputFile":"Blackall_sm100.nc",
"realGridLocations":true,
"input_file":"mydatadirectory/mydatafile.xyz",
"cellSize":500.0
}```julia 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 ```
NSInterpolate.cell_to_dim — Method
NSInterpolate.get_located_data — Method
get_located_data(whizz_file::String, line, z_chan; north_chan="", east_chan"")Returns located data for a given survey line.
NSInterpolate.initial_average — Method
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.
NSInterpolate.initial_interpolation — Method
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.
NSInterpolate.obs_from_geowhizz — Method
obs_from_geowhizz(whizz_file)
Read a set of observations and locations from a geoWhizz file.NSInterpolate.obs_from_geoxyz — Method
obs_from_geoxyz(xyz_file)
Read a set of XYZ observation locations from a Geosoft XYZ file.NSInterpolate.xyz_channels — Method
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.
NSInterpolate.xyz_count — Function
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 .NSInterpolate.xyz_lines — Method
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