|
REMORA
Regional Modeling of Oceans Refined Adaptively
|
Bilinear interpolation of a 2D field from a rectilinear lat-lon grid onto REMORA's rho points, the way ROMS's regrid does for forcing. More...
#include <REMORA_LatLonRegrid.H>

Public Member Functions | |
| void | define (const std::string &file_name, const std::string &field_name, const std::vector< long long > &field_shape, const amrex::MultiFab &target_lon, const amrex::MultiFab &target_lat, const amrex::MultiFab &like, const amrex::Box &domain, const LatLonRegridOptions &options, const std::string &context) |
| Find the source grid of a variable and build the weights. Collective. | |
| bool | same_source_grid (const std::string &file_name, const std::string &field_name, const std::vector< long long > &field_shape) const |
| Whether another file's variable lies on the same source grid. Collective. | |
| void | apply (const std::string &file_name, const std::string &field_name, int itime, amrex::MultiFab &dst) const |
| Read record itime of the variable and interpolate it into dst, over the domain and its one-cell ring. Collective. | |
| std::string | summary () const |
| One line describing the source grid, for the log. | |
| amrex::Box | target_box (const amrex::MFIter &mfi) const |
| The cells filled: the valid box of mfi grown by the ring, inside the ring. | |
| void | build_weights (const amrex::MultiFab &lon, const amrex::MultiFab &lat) |
| void | interpolate (const amrex::FArrayBox &src, amrex::MultiFab &dst) const |
Static Public Member Functions | |
| static bool | has_latlon_axes (const std::string &file_name, const std::string &field_name) |
| Whether a variable's last two dimensions are CF longitude and latitude coordinates (1D variables of the dimensions' own names, in degrees east and north), which marks it as on a lat-lon grid even when its shape happens to be the model grid's. Collective. | |
Static Public Attributes | |
| static constexpr int | stencil_size = 4 |
| Number of stencil points per target cell. | |
Private Attributes | |
| std::vector< double > | lon_file |
| std::vector< double > | lat_file |
| int | nlon = 0 |
| int | nlat = 0 |
| std::vector< double > | lon_inc |
| std::vector< double > | lat_inc |
| bool | flip_lon = false |
| bool | flip_lat = false |
| bool | periodic_lon = false |
| bool | has_fill = false |
| bool | has_missing = false |
| double | fill_value = 0.0 |
| double | missing_value = 0.0 |
| double | scale_factor = 1.0 |
| double | add_offset = 0.0 |
| std::string | lon_name |
| std::string | lat_name |
| int | fill_max_rings = 3 |
| amrex::Box | domain |
| amrex::MultiFab | weights |
| amrex::iMultiFab | indices |
Bilinear interpolation of a 2D field from a rectilinear lat-lon grid onto REMORA's rho points, the way ROMS's regrid does for forcing.
The source grid is given by 1D longitude and latitude axes, each strictly monotone in either direction; the longitude may be in [-180, 180) or [0, 360), may cross the branch cut, and may cover the globe, in which case it is treated as periodic. The target points are the model's lon_rho and lat_rho on level 0 over the domain and its one-cell ring, the cells a file on the model grid fills.
The interpolation weights are computed once, in define(), and stored per target cell in the layout the coupling remap uses: up to four weights, and the (i, j, k) source index of each. apply() reads one record of the field, sets aside source values equal to the variable's _FillValue or missing_value (or not finite), unpacks the rest with its scale_factor and add_offset, renormalizes the remaining weights, and gives a target point whose four corners are all missing the nearest valid source value within LatLonRegridOptions::fill_max_rings cells.
Definition at line 52 of file REMORA_LatLonRegrid.H.
| void LatLonRegrid::apply | ( | const std::string & | file_name, |
| const std::string & | field_name, | ||
| int | itime, | ||
| amrex::MultiFab & | dst | ||
| ) | const |
Read record itime of the variable and interpolate it into dst, over the domain and its one-cell ring. Collective.
Definition at line 346 of file REMORA_LatLonRegrid.cpp.

| void LatLonRegrid::build_weights | ( | const amrex::MultiFab & | lon, |
| const amrex::MultiFab & | lat | ||
| ) |
Definition at line 280 of file REMORA_LatLonRegrid.cpp.
Referenced by define().


| void LatLonRegrid::define | ( | const std::string & | file_name, |
| const std::string & | field_name, | ||
| const std::vector< long long > & | field_shape, | ||
| const amrex::MultiFab & | target_lon, | ||
| const amrex::MultiFab & | target_lat, | ||
| const amrex::MultiFab & | like, | ||
| const amrex::Box & | domain, | ||
| const LatLonRegridOptions & | options, | ||
| const std::string & | context | ||
| ) |
Find the source grid of a variable and build the weights. Collective.
| [in] | file_name | file holding the variable |
| [in] | field_name | the variable, dimensioned (time, lat, lon) |
| [in] | field_shape | its shape, from the IO rank |
| [in] | target_lon | rho-point longitude on level 0, degrees east |
| [in] | target_lat | rho-point latitude on level 0, degrees north |
| [in] | like | the forcing MultiFab the field fills, for the layout |
| [in] | domain | level 0 domain |
| [in] | options | remora.frc_* settings |
| [in] | context | appended to an error finding the source axes, to say what the file would need to be read on the model grid instead |
Definition at line 209 of file REMORA_LatLonRegrid.cpp.

|
static |
Whether a variable's last two dimensions are CF longitude and latitude coordinates (1D variables of the dimensions' own names, in degrees east and north), which marks it as on a lat-lon grid even when its shape happens to be the model grid's. Collective.
Definition at line 480 of file REMORA_LatLonRegrid.cpp.
Referenced by NCTimeSeries::Initialize(), and NCTimeSeries::source_grid().


| void LatLonRegrid::interpolate | ( | const amrex::FArrayBox & | src, |
| amrex::MultiFab & | dst | ||
| ) | const |
Definition at line 399 of file REMORA_LatLonRegrid.cpp.
Referenced by apply().


| bool LatLonRegrid::same_source_grid | ( | const std::string & | file_name, |
| const std::string & | field_name, | ||
| const std::vector< long long > & | field_shape | ||
| ) | const |
Whether another file's variable lies on the same source grid. Collective.
Definition at line 459 of file REMORA_LatLonRegrid.cpp.
| std::string LatLonRegrid::summary | ( | ) | const |
One line describing the source grid, for the log.
Definition at line 500 of file REMORA_LatLonRegrid.cpp.
Referenced by build_weights(), and define().

| Box LatLonRegrid::target_box | ( | const amrex::MFIter & | mfi | ) | const |
The cells filled: the valid box of mfi grown by the ring, inside the ring.
Definition at line 511 of file REMORA_LatLonRegrid.cpp.
Referenced by apply(), build_weights(), and interpolate().

|
private |
Definition at line 116 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and same_source_grid().
|
private |
Definition at line 120 of file REMORA_LatLonRegrid.H.
Referenced by define(), and target_box().
|
private |
Definition at line 119 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and interpolate().
|
private |
Definition at line 115 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and same_source_grid().
|
private |
Definition at line 110 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), define(), and interpolate().
|
private |
Definition at line 110 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), define(), and interpolate().
|
private |
Missing-data markers, in the stored (packed) values, and the packing
Definition at line 114 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and same_source_grid().
|
private |
Definition at line 114 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and same_source_grid().
|
private |
Definition at line 124 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), define(), and interpolate().
|
private |
Definition at line 105 of file REMORA_LatLonRegrid.H.
Referenced by define(), same_source_grid(), and summary().
|
private |
Definition at line 109 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), and define().
|
private |
Definition at line 118 of file REMORA_LatLonRegrid.H.
Referenced by define(), same_source_grid(), and summary().
|
private |
Axes as read and the source shape, for comparing files
Definition at line 105 of file REMORA_LatLonRegrid.H.
Referenced by define(), same_source_grid(), and summary().
|
private |
Axes put in increasing order and, for longitude, made continuous
Definition at line 109 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), and define().
|
private |
Definition at line 118 of file REMORA_LatLonRegrid.H.
Referenced by define(), same_source_grid(), and summary().
|
private |
Definition at line 115 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and same_source_grid().
|
private |
Definition at line 106 of file REMORA_LatLonRegrid.H.
Referenced by apply(), build_weights(), define(), interpolate(), and summary().
|
private |
Definition at line 106 of file REMORA_LatLonRegrid.H.
Referenced by apply(), build_weights(), define(), interpolate(), and summary().
|
private |
Definition at line 111 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), define(), interpolate(), and summary().
|
private |
Definition at line 116 of file REMORA_LatLonRegrid.H.
Referenced by apply(), define(), and same_source_grid().
|
staticconstexpr |
Number of stencil points per target cell.
Definition at line 101 of file REMORA_LatLonRegrid.H.
Referenced by define(), and interpolate().
|
private |
Weights and the (i, j, k) source index of each, per target cell
Definition at line 123 of file REMORA_LatLonRegrid.H.
Referenced by build_weights(), define(), and interpolate().