fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fitpack_gridded_sphere Module Reference

OOP wrapper for bivariate spline fitting on the sphere to gridded data. More...

Data Types

interface  fitpack_grid_sphere
 Bicubic spline fitter for data on a latitude-longitude grid. More...
 

Functions/Subroutines

integer function spgrid_fit_least_squares (this, smoothing, reset_knots)
 Fit a least-squares gridded spherical surface with fixed knots.
 
integer function spgrid_fit_interpolating (this, reset_knots)
 Fit an interpolating gridded spherical surface ( \( s = 0 \)).
 
integer function spgrid_fit_automatic_knots (this, smoothing, keep_knots)
 Fit a smoothing spherical surface on a lat-lon grid with automatic knot placement.
 
elemental subroutine spgrid_destroy (this)
 Release all allocated memory and reset the gridded sphere fitter to its default state.
 
subroutine spgrid_new_points (this, u, v, z)
 Load new gridded spherical data and allocate working storage.
 
type(fitpack_grid_sphere) function spgrid_new_from_points (u, v, z, ierr)
 Construct a fitpack_grid_sphere from gridded data and perform an initial fit.
 
integer function spgrid_new_fit (this, u, v, z, smoothing)
 Load new gridded data and fit a smoothing spherical spline in one call.
 
real(fp_real) function, dimension(size(v), size(u)) gridded_eval_many (this, u, v, ierr)
 Evaluate the gridded spherical spline on a grid of colatitude and longitude values.
 
real(fp_real) function gridded_eval_one (this, u, v, ierr)
 Evaluate the gridded spherical spline at a single point.
 
subroutine pole_bc (this, pole, z0, exact, differentiable, zero_grad)
 Set boundary conditions at one pole of the sphere.
 
subroutine bc_north_pole (this, z0, exact, differentiable, zero_grad)
 Set boundary conditions at the north pole ( \( u = 0 \)).
 
subroutine bc_south_pole (this, z0, exact, differentiable, zero_grad)
 Set boundary conditions at the south pole ( \( u = \pi \)).
 
subroutine gridded_to_disk (this, filename)
 Write gridded spherical data to a formatted text file.
 
elemental integer(fp_size) function gridsphere_comm_size (this)
 Return the communication buffer size for parallel pack/expand.
 
pure subroutine gridsphere_comm_pack (this, buffer)
 Pack the gridded sphere fitter state into a communication buffer.
 
pure subroutine gridsphere_comm_expand (this, buffer)
 Restore the gridded sphere fitter state from a communication buffer.
 

Detailed Description

OOP wrapper for bivariate spline fitting on the sphere to gridded data.

Provides fitpack_grid_sphere, a derived type for fitting bicubic splines to data given on a latitude-longitude grid over the sphere. The colatitude grid \( u_i \in [0, \pi] \) ( \( i = 1, \ldots, m_u \)) and the \( 2\pi \)-periodic longitude grid \( v_j \) ( \( j = 1, \ldots, m_v \)) define the sampling. Boundary conditions at the north ( \( u = 0 \)) and south ( \( u = \pi \)) poles can be configured for function value, exactness, continuity order, and gradient vanishing. Uses the spgrid core routine.

See also
Dierckx, Ch. 11, §11.2 (pp. 263–269); spgrid

Function/Subroutine Documentation

◆ bc_north_pole()

subroutine fitpack_gridded_sphere::bc_north_pole ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), intent(in), optional z0,
logical, intent(in), optional exact,
logical, intent(in), optional differentiable,
logical, intent(in), optional zero_grad )
private

Set boundary conditions at the north pole ( \( u = 0 \)).

Here is the call graph for this function:

◆ bc_south_pole()

subroutine fitpack_gridded_sphere::bc_south_pole ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), intent(in), optional z0,
logical, intent(in), optional exact,
logical, intent(in), optional differentiable,
logical, intent(in), optional zero_grad )
private

Set boundary conditions at the south pole ( \( u = \pi \)).

Here is the call graph for this function:

◆ gridded_eval_many()

real(fp_real) function, dimension(size(v),size(u)) fitpack_gridded_sphere::gridded_eval_many ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), dimension(:), intent(in) u,
real(fp_real), dimension(:), intent(in) v,
integer, intent(out), optional ierr )
private

Evaluate the gridded spherical spline on a grid of colatitude and longitude values.

Returns \( f(j,i) = s(u_i, v_j) \) for all combinations of the input vectors (tensor-product evaluation).

Parameters
[in]uColatitude evaluation points.
[in]vLongitude evaluation points.
[out]ierrOptional error flag.
Returns
Grid of spline values, dimensioned (size(v), size(u)).
See also
bispev

◆ gridded_eval_one()

real(fp_real) function fitpack_gridded_sphere::gridded_eval_one ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), intent(in) u,
real(fp_real), intent(in) v,
integer, intent(out), optional ierr )
private

Evaluate the gridded spherical spline at a single point.

Parameters
[in]uColatitude \( u \in [0, \pi] \).
[in]vLongitude \( v \).
[out]ierrOptional error flag.
Returns
Spline value \( s(u, v) \).
See also
bispev
Here is the call graph for this function:

◆ gridded_to_disk()

subroutine fitpack_gridded_sphere::gridded_to_disk ( class(fitpack_grid_sphere), intent(inout) this,
character(*), intent(in) filename )
private

Write gridded spherical data to a formatted text file.

Outputs a table with colatitude grid values in rows and longitude grid values in columns, suitable for external plotting or inspection.

Parameters
[in]fileNameOutput file path.
Here is the call graph for this function:

◆ gridsphere_comm_expand()

pure subroutine fitpack_gridded_sphere::gridsphere_comm_expand ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_comm), dimension(:), intent(in) buffer )
private

Restore the gridded sphere fitter state from a communication buffer.

◆ gridsphere_comm_pack()

pure subroutine fitpack_gridded_sphere::gridsphere_comm_pack ( class(fitpack_grid_sphere), intent(in) this,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack the gridded sphere fitter state into a communication buffer.

◆ gridsphere_comm_size()

elemental integer(fp_size) function fitpack_gridded_sphere::gridsphere_comm_size ( class(fitpack_grid_sphere), intent(in) this)
private

Return the communication buffer size for parallel pack/expand.

Here is the call graph for this function:

◆ pole_bc()

subroutine fitpack_gridded_sphere::pole_bc ( class(fitpack_grid_sphere), intent(inout) this,
integer, intent(in) pole,
real(fp_real), intent(in), optional z0,
logical, intent(in), optional exact,
logical, intent(in), optional differentiable,
logical, intent(in), optional zero_grad )
private

Set boundary conditions at one pole of the sphere.

Configures the function value, exactness, differentiability, and gradient vanishing constraints at the specified pole (1 = north, 2 = south).

Parameters
[in]polePole index (1 = north \( u=0 \), 2 = south \( u=\pi \)).
[in]z0Optional function value at the pole.
[in]exactTreat z0 as an exact constraint.
[in]differentiableRequire C1 continuity at the pole.
[in]zero_gradRequire vanishing gradient at the pole.

◆ spgrid_destroy()

elemental subroutine fitpack_gridded_sphere::spgrid_destroy ( class(fitpack_grid_sphere), intent(inout) this)
private

Release all allocated memory and reset the gridded sphere fitter to its default state.

◆ spgrid_fit_automatic_knots()

integer function fitpack_gridded_sphere::spgrid_fit_automatic_knots ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), intent(in), optional smoothing,
logical, intent(in), optional keep_knots )
private

Fit a smoothing spherical surface on a lat-lon grid with automatic knot placement.

Iterates over the smoothing schedule, calling the spgrid core routine to fit a bicubic spline on the sphere grid. Pole boundary conditions (continuity order, gradient vanishing, exact data) are applied as configured.

Parameters
[in]smoothingSmoothing factor ( \( s \ge 0 \)); default uses stored value.
[in]keep_knotsIf .true., reuse the current knot set.
Returns
Error flag.
See also
spgrid

Ensure we start with new knots (unless caller wants to keep them)

Here is the call graph for this function:

◆ spgrid_fit_interpolating()

integer function fitpack_gridded_sphere::spgrid_fit_interpolating ( class(fitpack_grid_sphere), intent(inout) this,
logical, intent(in), optional reset_knots )
private

Fit an interpolating gridded spherical surface ( \( s = 0 \)).

Parameters
[in]reset_knotsIf .true. (default), start with fresh knot placement.
Returns
Error flag.
See also
spgrid
Here is the call graph for this function:

◆ spgrid_fit_least_squares()

integer function fitpack_gridded_sphere::spgrid_fit_least_squares ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), intent(in), optional smoothing,
logical, intent(in), optional reset_knots )
private

Fit a least-squares gridded spherical surface with fixed knots.

Parameters
[in]smoothingOptional smoothing factor for the reset pass.
[in]reset_knotsIf .true., recompute knots via a smoothing fit first.
Returns
Error flag.
See also
spgrid
Here is the call graph for this function:

◆ spgrid_new_fit()

integer function fitpack_gridded_sphere::spgrid_new_fit ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), dimension(:), intent(in) u,
real(fp_real), dimension(:), intent(in) v,
real(fp_real), dimension(size(v),size(u)), intent(in) z,
real(fp_real), intent(in), optional smoothing )
private

Load new gridded data and fit a smoothing spherical spline in one call.

Parameters
[in]uColatitude grid.
[in]vLongitude grid.
[in]zGridded function values.
[in]smoothingOptional smoothing factor.
Returns
Error flag.
See also
spgrid
Here is the call graph for this function:

◆ spgrid_new_from_points()

type(fitpack_grid_sphere) function fitpack_gridded_sphere::spgrid_new_from_points ( real(fp_real), dimension(:), intent(in) u,
real(fp_real), dimension(:), intent(in) v,
real(fp_real), dimension(size(v),size(u)), intent(in) z,
integer, intent(out), optional ierr )
private

Construct a fitpack_grid_sphere from gridded data and perform an initial fit.

Parameters
[in]uColatitude grid \( u_i \in [0, \pi] \).
[in]vLongitude grid \( v_j \) ( \( 2\pi \)-periodic).
[in]zFunction values \( z(j, i) \), dimensioned (size(v), size(u)).
[out]ierrOptional error flag; if absent, halts on error.
See also
spgrid

◆ spgrid_new_points()

subroutine fitpack_gridded_sphere::spgrid_new_points ( class(fitpack_grid_sphere), intent(inout) this,
real(fp_real), dimension(:), intent(in) u,
real(fp_real), dimension(:), intent(in) v,
real(fp_real), dimension(size(v),size(u)), intent(in) z )
private

Load new gridded spherical data and allocate working storage.

Parameters
[in]uColatitude grid \( u_i \in [0, \pi] \).
[in]vLongitude grid \( v_j \) ( \( 2\pi \)-periodic).
[in]zFunction values \( z(j, i) \), dimensioned (size(v), size(u)).