ReFRACtor
FullPhysics::Output Class Referenceabstract

This is the base class for classes that write output for Level 2 Full Physics. More...

#include <output.h>

+ Inheritance diagram for FullPhysics::Output:
+ Collaboration diagram for FullPhysics::Output:

Public Member Functions

virtual ~Output ()
 
virtual void print (std::ostream &Os) const
 
std::string print_to_string () const
 Print to string. More...
 
template<class S , class T , int D>
void register_data_source (const std::string &Dataset_name, blitz::Array< T, D >(S::*Pmf)() const, const boost::shared_ptr< S > &Src)
 A common way to supply the metadata source is with a shared_ptr to an object, and a pointer to a member function. More...
 
template<class S , class T >
void register_data_source (const std::string &Dataset_name, T(S::*Pmf)() const, const boost::shared_ptr< S > &Src)
 A common way to supply the metadata source is with a shared_ptr to an object, and a pointer to a member function. More...
 
template<class T , int D>
void register_data_source (const std::string &Dataset_name, const blitz::Array< T, D > &Val)
 Handling for when data is constant. More...
 
template<class T >
void register_data_source (const std::string &Dataset_name, const T &Val)
 Handling for when data is constant. More...
 
template<class T >
void register_data_source (const std::string &Dataset_name, boost::function< T > f)
 Most general way to enter a Data source. More...
 
template<class S , class T >
void register_data_source_pad (const std::string &Dataset_name, blitz::Array< T, 1 >(S::*Pmf)() const, const boost::shared_ptr< S > &Src, int Full_size, T Fill_value)
 There are several fields that are generated on the active levels only. More...
 
template<class S , class T >
void register_data_source_pad (const std::string &Dataset_name, blitz::Array< T, 2 >(S::*Pmf)() const, const boost::shared_ptr< S > &Src, int Full_size, T Fill_value)
 
void write ()
 Write out file. More...
 
void write_best_attempt ()
 Write out the file, making a best attempt but ignoring all errors. More...
 

Protected Member Functions

virtual void end_because_of_error ()
 Notify when an error occurred. More...
 
virtual void end_write ()
 Notify when we are done. More...
 
virtual void start_write ()
 Notify derived class that we are starting to write data. More...
 
virtual void write_data (const std::string &Dataset_name, int Val)=0
 Various write functions that derived classes. More...
 
virtual void write_data (const std::string &Dataset_name, int64_t Val)=0
 
virtual void write_data (const std::string &Dataset_name, double Val)=0
 
virtual void write_data (const std::string &Dataset_name, const std::string &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const char *Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< int, 1 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< std::string, 1 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< const char *, 1 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< double, 1 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< int, 2 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< std::string, 2 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< const char *, 2 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< double, 2 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< int, 3 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< std::string, 3 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< const char *, 3 > &Val)=0
 
virtual void write_data (const std::string &Dataset_name, const blitz::Array< double, 3 > &Val)=0
 

Detailed Description

This is the base class for classes that write output for Level 2 Full Physics.

Specific derived classes are used to write out files (e.g., OutputHdf, OutputHeritage), this class just captures the common behavior.

The output is designed to be decentralized. Classes register themselves as being able to supply data to be written out when requested, and the OutputHeritage class will request this data when it wants to write out the state of the system. This "write on demand" design allows for scenarios such as "dump data out when an error occurs" and "dump data on each iteration of the retrieval solver", and "checkpoint results".

In many cases, the dataset and metadata is supplied either as a constant unchanging value, or as a pointer to a member function of an object supplied as a boost::shared_ptr<T>. The functions "register_data_source" have been overloaded to handle these common cases, most of the time these are the only functions you need. If you want to specify this with a more general boost::function, you can do so also.

The derived class need to supply various write_xxx functions to act as a data sink for this data.

This class only supports a fixed number of data types (int, double, std::string) and array rank (scalar, 1d, 2d, 3d). We also have a int64_t scalar, needed for the sounding id. We can easily extend this to other types and ranks if needed. For developers, you add a new types by adding a new write_data function to this class, along with adding the type to function "pass_to_write".

A write is intended to be atomic - either it completely succeeds or the output should be cleaned up and nothing produced. This prevents a file with "missing fields" from being generated.

In the case of a processing error, we may want to make an attempt to dump as much of the data as possible to help with diagnostics. A separate "write_best_attempt" routines is supplied, this will write out whatever we can, ignoring all errors. This can results in partial files, but in the case of a diagnostic file whatever we can get is better than nothing.

Definition at line 102 of file output.h.

Constructor & Destructor Documentation

◆ ~Output()

virtual FullPhysics::Output::~Output ( )
inlinevirtual

Definition at line 104 of file output.h.

Member Function Documentation

◆ end_because_of_error()

virtual void FullPhysics::Output::end_because_of_error ( )
inlineprotectedvirtual

Notify when an error occurred.

Derived classes should clean up any partially generated output.

Reimplemented in FullPhysics::OutputHdf, and FullPhysics::OutputHdfIteration.

Definition at line 226 of file output.h.

◆ end_write()

virtual void FullPhysics::Output::end_write ( )
inlineprotectedvirtual

Notify when we are done.

Default is to do nothing, but derived classes can override this.

Definition at line 219 of file output.h.

◆ print()

virtual void FullPhysics::Output::print ( std::ostream &  Os) const
inlinevirtual

Reimplemented in FullPhysics::OutputHdf, and FullPhysics::OutputHdfIteration.

Definition at line 105 of file output.h.

◆ print_to_string()

std::string FullPhysics::Printable< Output >::print_to_string ( ) const
inlineinherited

Print to string.

This is primarily useful for SWIG wrappers to this class, e.g. a to_s method in ruby.

Definition at line 31 of file printable.h.

◆ register_data_source() [1/5]

template<class S , class T , int D>
void FullPhysics::Output::register_data_source ( const std::string &  Dataset_name,
blitz::Array< T, D >(S::*)() const  Pmf,
const boost::shared_ptr< S > &  Src 
)
inline

A common way to supply the metadata source is with a shared_ptr to an object, and a pointer to a member function.

This supplies a simplified interface to this.

Definition at line 114 of file output.h.

◆ register_data_source() [2/5]

template<class S , class T >
void FullPhysics::Output::register_data_source ( const std::string &  Dataset_name,
T(S::*)() const  Pmf,
const boost::shared_ptr< S > &  Src 
)
inline

A common way to supply the metadata source is with a shared_ptr to an object, and a pointer to a member function.

This supplies a simplified interface to this.

Definition at line 162 of file output.h.

◆ register_data_source() [3/5]

template<class T , int D>
void FullPhysics::Output::register_data_source ( const std::string &  Dataset_name,
const blitz::Array< T, D > &  Val 
)
inline

Handling for when data is constant.

Definition at line 175 of file output.h.

◆ register_data_source() [4/5]

template<class T >
void FullPhysics::Output::register_data_source ( const std::string &  Dataset_name,
const T &  Val 
)
inline

Handling for when data is constant.

Definition at line 188 of file output.h.

◆ register_data_source() [5/5]

template<class T >
void FullPhysics::Output::register_data_source ( const std::string &  Dataset_name,
boost::function< T >  f 
)
inline

Most general way to enter a Data source.

Definition at line 200 of file output.h.

◆ register_data_source_pad() [1/2]

template<class S , class T >
void FullPhysics::Output::register_data_source_pad ( const std::string &  Dataset_name,
blitz::Array< T, 1 >(S::*)() const  Pmf,
const boost::shared_ptr< S > &  Src,
int  Full_size,
Fill_value 
)
inline

There are several fields that are generated on the active levels only.

For output, we want to pad this to the full number of levels. This utility routine will pad the given size using the given fill value.

Definition at line 130 of file output.h.

◆ register_data_source_pad() [2/2]

template<class S , class T >
void FullPhysics::Output::register_data_source_pad ( const std::string &  Dataset_name,
blitz::Array< T, 2 >(S::*)() const  Pmf,
const boost::shared_ptr< S > &  Src,
int  Full_size,
Fill_value 
)
inline

Definition at line 143 of file output.h.

◆ start_write()

virtual void FullPhysics::Output::start_write ( )
inlineprotectedvirtual

Notify derived class that we are starting to write data.

Default is to do nothing, but derived classes can override this.

Reimplemented in FullPhysics::OutputHdf.

Definition at line 212 of file output.h.

◆ write()

void Output::write ( )

Write out file.

A write is intended to be atomic - either it completely succeeds or the output should be cleaned up and nothing produced. This prevents a file with "missing fields" from being generated.

Definition at line 62 of file output.cc.

◆ write_best_attempt()

void Output::write_best_attempt ( )

Write out the file, making a best attempt but ignoring all errors.

This may result in a file that is missing fields that had an error when writing or collecting the data. This is intended for use by an error dump, when we want to get whatever we can.

Definition at line 86 of file output.cc.

◆ write_data() [1/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
int  Val 
)
protectedpure virtual

◆ write_data() [2/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
int64_t  Val 
)
protectedpure virtual

◆ write_data() [3/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
double  Val 
)
protectedpure virtual

◆ write_data() [4/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const std::string &  Val 
)
protectedpure virtual

◆ write_data() [5/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const char *  Val 
)
protectedpure virtual

◆ write_data() [6/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< int, 1 > &  Val 
)
protectedpure virtual

◆ write_data() [7/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< std::string, 1 > &  Val 
)
protectedpure virtual

◆ write_data() [8/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< const char *, 1 > &  Val 
)
protectedpure virtual

◆ write_data() [9/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< double, 1 > &  Val 
)
protectedpure virtual

◆ write_data() [10/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< int, 2 > &  Val 
)
protectedpure virtual

◆ write_data() [11/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< std::string, 2 > &  Val 
)
protectedpure virtual

◆ write_data() [12/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< const char *, 2 > &  Val 
)
protectedpure virtual

◆ write_data() [13/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< double, 2 > &  Val 
)
protectedpure virtual

◆ write_data() [14/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< int, 3 > &  Val 
)
protectedpure virtual

◆ write_data() [15/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< std::string, 3 > &  Val 
)
protectedpure virtual

◆ write_data() [16/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< const char *, 3 > &  Val 
)
protectedpure virtual

◆ write_data() [17/17]

virtual void FullPhysics::Output::write_data ( const std::string &  Dataset_name,
const blitz::Array< double, 3 > &  Val 
)
protectedpure virtual

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

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:13