NTV2 Reader¶
Tihs module provides functionality to read and utilize NTV2 grid files for coordinate transformations. It has been adapted from Jaimie Dodd’s ntv2reader.py
Classes¶
- class geodepy.ntv2reader.NTv2Grid(num_orec, num_srec, num_file, gs_type, version, system_f, system_t, major_f, minor_f, major_t, minor_t, file_path)[source]¶
NTv2 Grid Parameters
- Parameters:
num_orec – Number of header identifiers
num_srec – Number of sub-header idents
num_file – Number of subgrids in file
gs_type – grid shift type
version – grid file version
system_f – reference system
system_t – reference system
major_f – semi major of from system
minor_f – semi minor of from system
major_t – semi major of to system
minor_t – semi minor of to system
file_path – full path to ntv2 gsb file
- class geodepy.ntv2reader.SubGrid(sub_name, parent, created, updated, s_lat, n_lat, e_long, w_long, lat_inc, long_inc, gs_count)[source]¶
Sub Grid Parameters
- Parameters:
sub_name – subgrid name
parent – parent name
created – date created
updated – date modified
s_lat – south latitude extents
n_lat – north latitude extents
e_long – east longitude extents
w_long – west longitude extents
lat_inc – latitude increment
long_inc – longitude increment
gs_count – total nodes in subgrid
- ntv2_bicubic(lat, lon, num_cols, row, col, f, start_byte)[source]¶
Function to perform bicubic interpolation of the four ntv2 fields at a point of interest.
- Parameters:
lat – latitude of the point of interest (arc-seconds)
lon – longitude of the point of interest (negative arc-seconds)
num_cols – number of columns in grid
row – row number of point to the bottom right of the point of interest
col – column number of point to the bottom right of the point of interest
f – variable for open file NTv2 being read as binary
start_byte – start index of subgrid
- Returns:
Four field tuple of interpolation results at point of interest.
- ntv2_bilinear(lat, lon, num_cols, row, col, f, start_byte)[source]¶
Function to perform bicubic interpolation of the four ntv2 fields at a point of interest.
- Parameters:
lat – latitude of the point of interest (arc-seconds)
lon – longitude of the point of interest (negative arc-seconds)
num_cols – number of columns in grid
row – row number of point to the bottom right of the point of interest
col – column number of point to the bottom right of the point of interest
f – variable for open file NTv2 being read as binary
start_byte – start index of subgrid
- Returns:
Four field tuple of interpolation results at point of interest.
Functions¶
- geodepy.ntv2reader.read_ntv2_file(ntv2_gsb_file)[source]¶
Function to read an ntv2 gsb file and create grid & subgrid objects
- Parameters:
ntv2_gsb_file – full path to ntv2 file
- Returns:
Ntv2 grid object
- geodepy.ntv2reader.interpolate_ntv2(grid_object, lat, lon, method='bicubic')[source]¶
Function to interpolate Ntv2Grid objects
- Parameters:
grid_object – Ntv2Grid object
lat – latitude (decimal degrees)
lon – longitude (decimal degrees)
method – interpolation strategy, bicubic or bilinear
- Returns:
Tuple of four ntv2 fields
- geodepy.ntv2reader.read_node(f)[source]¶
Function to read in values of nodes
- Parameters:
f – variable for open file NTv2 being read as binary
- Returns:
Tuple containing the four ntv2 fields at the grid node.
- geodepy.ntv2reader.bilinear_interpolation(n1, n2, n3, n4, x, y)[source]¶
Bilinear interpolation of value for point of interest (P).
- Parameters:
n1 – value at node 1
n2 – value at node 2
n3 – value at node 3
n4 – value at node 4
x – interpolation scale factor for x axis
y – interpolation scale factor for y axis
- Returns:
Value at node P
- geodepy.ntv2reader.bicubic_interpolation(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, x, y)[source]¶
Bicubic interpolation of value for point of interest (P).
- Parameters:
n1 – value at node 1
n2 – value at node 2
n3 – value at node 3
n4 – value at node 4
n5 – value at node 5
n6 – value at node 6
n7 – value at node 7
n8 – value at node 8
n9 – value at node 9
n10 – value at node 10
n11 – value at node 11
n12 – value at node 12
n13 – value at node 13
n14 – value at node 14
n15 – value at node 16
n16 – value at node 17
x – interpolation scale factor for x axis
y – interpolation scale factor for y axis
- Returns:
Value at node P