REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
NCTimeSeries Class Reference

A class to hold and interpolate time series data read from a NetCDF file. More...

#include <REMORA_NCTimeSeries.H>

Collaboration diagram for NCTimeSeries:

Public Member Functions

 NCTimeSeries (const amrex::Vector< std::string > &a_file_names, const std::string a_field_name, const std::string a_time_name, const amrex::Box &a_domain, amrex::MultiFab *a_mf_var, bool a_is2d, bool a_save_interpolated, double a_time_ref)
 Constructor.
 
void Initialize ()
 Read in time array from file and allocate data arrays.
 
void update_interpolated_to_time (double time, int lev, amrex::MultiFab *mf_lev, const amrex::Vector< amrex::Geometry > &geom, const amrex::Vector< amrex::IntVect > &ref_ratio)
 Calculate interpolated values at time, in seconds on the model clock, and fill data for level lev.
 
const amrex::MultiFab * get_interpolated_mf (int lev) const
 Access interpolated data saved for a specific level.
 

Private Member Functions

void read_in_at_time (amrex::MultiFab *mf, int itime)
 Read in data from file at time index itime and fill into mf.
 
amrex::IntVect cumulative_ref_ratio (int lev, const amrex::Vector< amrex::IntVect > &ref_ratio) const
 Build cumulative refinement ratio from level 0 to lev.
 

Private Attributes

amrex::Vector< std::string > file_names
 File names to read from.
 
amrex::Vector< int > file_is_spatially_uniform
 Whether each file stores this field as one value per time record.
 
std::string field_name
 Field name in netcdf file.
 
std::string time_name
 Field name for time series in netcdf file.
 
amrex::Box domain
 Domain.
 
bool is2d
 Whether the field we're reading in is 2d.
 
bool save_interpolated
 
double time_ref
 
amrex::Vector< double > ocean_times
 
amrex::Vector< int > file_for_time
 File index to access a particular time.
 
amrex::Vector< int > file_itime_offset
 Offset to access a particular time within its file.
 
int i_time_before
 Time index immediately before the last time interpolated to.
 
double time_before
 Time in ocean_times immediately before the last time interpolated to.
 
double time_after
 Time in ocean_times immediately after the last time interpolated to.
 
bool is_cycle
 Whether the time series is a cycle.
 
double cycle_length
 If a cycle, what is the cycle length?
 
amrex::MultiFab * mf_before
 Multifab to store data at time_before.
 
amrex::MultiFab * mf_after
 Multifab to store data at time_after.
 
amrex::MultiFab * mf_interp_lev0
 Multifab storing temporally interpolated data on level 0.
 
amrex::Vector< std::unique_ptr< amrex::MultiFab > > mf_interpolated_lev
 Interpolated data on each requested AMR level if save_interpolated=true.
 
int last_updated_lev = -1
 
amrex::MultiFab * mf_var
 

Detailed Description

A class to hold and interpolate time series data read from a NetCDF file.

The class only ever holds the two time steps necessary to interpoplate to the current simulation time.

Definition at line 16 of file REMORA_NCTimeSeries.H.

Constructor & Destructor Documentation

◆ NCTimeSeries()

NCTimeSeries::NCTimeSeries ( const amrex::Vector< std::string > &  a_file_names,
const std::string  a_field_name,
const std::string  a_time_name,
const amrex::Box &  a_domain,
amrex::MultiFab *  a_mf_var,
bool  a_is2d,
bool  a_save_interpolated,
double  a_time_ref 
)

Constructor.

Parameters
[in]a_file_namesvector of file name(s) to read from
[in]a_field_namename of field to read in
[in]a_time_namename of time variable in NetCDF file
[in]a_domainsimulation domain
[in,out]a_mf_varMultiFab of data to either store into or reference for dimensions
[in]a_is2dWhether the variable we're working with is 2D
[in]a_save_interpolatedWhether the interpolated value should be saved internally
[in]a_time_refremora.time_ref, the reference date of the model clock

Definition at line 25 of file REMORA_NCTimeSeries.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ cumulative_ref_ratio()

amrex::IntVect NCTimeSeries::cumulative_ref_ratio ( int  lev,
const amrex::Vector< amrex::IntVect > &  ref_ratio 
) const
private

Build cumulative refinement ratio from level 0 to lev.

Definition at line 326 of file REMORA_NCTimeSeries.cpp.

Referenced by update_interpolated_to_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_interpolated_mf()

const amrex::MultiFab * NCTimeSeries::get_interpolated_mf ( int  lev) const

Access interpolated data saved for a specific level.

Definition at line 338 of file REMORA_NCTimeSeries.cpp.

Here is the call graph for this function:

◆ Initialize()

void NCTimeSeries::Initialize ( )

Read in time array from file and allocate data arrays.

Definition at line 40 of file REMORA_NCTimeSeries.cpp.

Here is the call graph for this function:

◆ read_in_at_time()

void NCTimeSeries::read_in_at_time ( amrex::MultiFab *  mf,
int  itime 
)
private

Read in data from file at time index itime and fill into mf.

Parameters
[in,out]mfmultifab to store time step data into
[in]itimeindex of time step to read from file

Definition at line 355 of file REMORA_NCTimeSeries.cpp.

Referenced by update_interpolated_to_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_interpolated_to_time()

void NCTimeSeries::update_interpolated_to_time ( double  time,
int  lev,
amrex::MultiFab *  mf_lev,
const amrex::Vector< amrex::Geometry > &  geom,
const amrex::Vector< amrex::IntVect > &  ref_ratio 
)

Calculate interpolated values at time, in seconds on the model clock, and fill data for level lev.

Parameters
timetime to interpolate to

Definition at line 201 of file REMORA_NCTimeSeries.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ cycle_length

double NCTimeSeries::cycle_length
private

If a cycle, what is the cycle length?

Definition at line 85 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ domain

amrex::Box NCTimeSeries::domain
private

Domain.

Definition at line 57 of file REMORA_NCTimeSeries.H.

Referenced by NCTimeSeries(), and read_in_at_time().

◆ field_name

std::string NCTimeSeries::field_name
private

Field name in netcdf file.

Definition at line 53 of file REMORA_NCTimeSeries.H.

Referenced by get_interpolated_mf(), Initialize(), NCTimeSeries(), read_in_at_time(), and update_interpolated_to_time().

◆ file_for_time

amrex::Vector<int> NCTimeSeries::file_for_time
private

File index to access a particular time.

Definition at line 73 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and read_in_at_time().

◆ file_is_spatially_uniform

amrex::Vector<int> NCTimeSeries::file_is_spatially_uniform
private

Whether each file stores this field as one value per time record.

Definition at line 51 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and read_in_at_time().

◆ file_itime_offset

amrex::Vector<int> NCTimeSeries::file_itime_offset
private

Offset to access a particular time within its file.

Definition at line 75 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and read_in_at_time().

◆ file_names

amrex::Vector<std::string> NCTimeSeries::file_names
private

File names to read from.

Definition at line 49 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), NCTimeSeries(), and read_in_at_time().

◆ i_time_before

int NCTimeSeries::i_time_before
private

Time index immediately before the last time interpolated to.

Definition at line 77 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ is2d

bool NCTimeSeries::is2d
private

Whether the field we're reading in is 2d.

Definition at line 60 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), NCTimeSeries(), and read_in_at_time().

◆ is_cycle

bool NCTimeSeries::is_cycle
private

Whether the time series is a cycle.

Definition at line 83 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ last_updated_lev

int NCTimeSeries::last_updated_lev = -1
private

Level of the most recent update. One series serves every level, and under subcycling the levels ask for different times, so a saved buffer is only current for the level that last updated it. Callers update immediately before reading; this records enough to catch a caller that stops doing so.

Definition at line 100 of file REMORA_NCTimeSeries.H.

Referenced by get_interpolated_mf(), and update_interpolated_to_time().

◆ mf_after

amrex::MultiFab* NCTimeSeries::mf_after
private

Multifab to store data at time_after.

Definition at line 90 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ mf_before

amrex::MultiFab* NCTimeSeries::mf_before
private

Multifab to store data at time_before.

Definition at line 88 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ mf_interp_lev0

amrex::MultiFab* NCTimeSeries::mf_interp_lev0
private

Multifab storing temporally interpolated data on level 0.

Definition at line 92 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ mf_interpolated_lev

amrex::Vector<std::unique_ptr<amrex::MultiFab> > NCTimeSeries::mf_interpolated_lev
private

Interpolated data on each requested AMR level if save_interpolated=true.

Definition at line 94 of file REMORA_NCTimeSeries.H.

Referenced by get_interpolated_mf(), and update_interpolated_to_time().

◆ mf_var

amrex::MultiFab* NCTimeSeries::mf_var
private

Pointer to REMORA data that corresponds to the variable being interpolated. Filled by update_interpolated_to_time if save_interpolated==false. Otherwise, just used for getting box array, nodality, and distribution mapping

Definition at line 104 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and NCTimeSeries().

◆ ocean_times

amrex::Vector<double> NCTimeSeries::ocean_times
private

Time points in netcdf file, in seconds on the model clock. Double, like every time on the model clock: see REMORA::t_new.

Definition at line 71 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and update_interpolated_to_time().

◆ save_interpolated

bool NCTimeSeries::save_interpolated
private

Whether to save interpolated results in mf_interpolated. If false, data will be calculated to mf_var

Definition at line 63 of file REMORA_NCTimeSeries.H.

Referenced by get_interpolated_mf(), NCTimeSeries(), and update_interpolated_to_time().

◆ time_after

double NCTimeSeries::time_after
private

Time in ocean_times immediately after the last time interpolated to.

Definition at line 81 of file REMORA_NCTimeSeries.H.

Referenced by update_interpolated_to_time().

◆ time_before

double NCTimeSeries::time_before
private

Time in ocean_times immediately before the last time interpolated to.

Definition at line 79 of file REMORA_NCTimeSeries.H.

Referenced by update_interpolated_to_time().

◆ time_name

std::string NCTimeSeries::time_name
private

Field name for time series in netcdf file.

Definition at line 55 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and NCTimeSeries().

◆ time_ref

double NCTimeSeries::time_ref
private

remora.time_ref: the reference date the model clock counts from. The file's times are placed on that clock from the reference date in their units attribute. Double, like every reference date.

Definition at line 67 of file REMORA_NCTimeSeries.H.

Referenced by Initialize(), and NCTimeSeries().


The documentation for this class was generated from the following files: