Last Updated: 09/01/2022

Kameleon Model Classes

Model Classes

One of the core functions of Kameleon is to provide an interface to models hosted at the CCMC. The most direct way of working with the models is to access them through the C++ interface. Much of this functionality has also been made available through kameleon’s wrapper libraries (see Wrappers).

Model-Independent Classes

Attribute

class ccmc::Attribute
TODO: brief description of Attribute class.

TODO: full description of Attribute class

Public Types

enum AttributeType
Values:

FLOAT
INT
STRING
Public Functions

std::string getAttributeName()
Returns the attribute’s name as a std::string object.

Return
The attribute’s name
void setAttributeName(std::string attributeName)
Sets the attribute name

Parameters
name -
The attribute name requested.

void setAttributeValue(std::string &value)
Copies the contents of value and stores them.

Parameters
value -
the new attribute value

void setAttributeValue(int &value)
Copies the contents of value and stores them.

Parameters
value -
the new attribute value

void setAttributeValue(float &value)
Copies the contents of value and stores them.

Parameters
value -
the new attribute value

Attribute::AttributeType getAttributeType()
Return
AttributeType of the Attribute object
float getAttributeFloat()
Returns the attribute value as a float, if applicable.

Return
The float value of the attribute. The value returned will be 0.f if the AttributeType of the Attribute object is not Attribute::FLOAT
std::string getAttributeString()
Returns the string representation of the attribute, if applicable.

Return
The string value of the attribute. This value will be an empty string if the AttributeType of the Attribute object is not Attribute::STRING
int getAttributeInt()
Returns the attribute value as an int, if applicable.

Return
The int value of the attribute. The value returned will be 0 if the AttributeType of the Attribute object is not Attribute::FLOAT
Attribute()
Default constructor. Initializes the attributeName to “”, the string value to “”, and the integer and float values to 0.

std::string toString() const
Return
virtual ~Attribute()
Destructor

Friends

std::ostream &operator<<(std::ostream &out, const Attribute attribute)

FileReader

class ccmc::FileReader
FileReader class is a pure virtual class for opening and accessing model variables.

All file readers are responsible for implementing the pure virtual functions listed here.

Public Functions

FileReader()
Default constructor. Does nothing.

long open(const std::string &filename, bool readonly)
Return
The status of the open call. OK is the standard successful status.
Parameters
filename -
virtual std::vector<float> *getVariable(const std::string &variable) = 0
virtual std::vector<float> *getVariable(long variableID) = 0
virtual std::vector<float> *getVariable(const std::string &variable, long startIndex, long count) = 0
virtual std::vector<float> *getVariable(long variableID, long startIndex, long count) = 0
virtual float getVariableAtIndex(const std::string &variable, long index) = 0
virtual float getVariableAtIndex(long variable_id, long index) = 0
virtual std::vector<int> *getVariableInt(const std::string &variable) = 0
virtual int getVariableIntAtIndex(const std::string &variable, long index) = 0
virtual int getNumberOfGlobalAttributes() = 0
virtual int getNumberOfVariables() = 0
virtual int getNumberOfVariableAttributes() = 0
virtual long getNumberOfRecords(const std::string &variable) = 0
virtual long getNumberOfRecords(long variable_id) = 0
virtual long getVariableID(const std::string &variable) = 0
Returns the variable ID as a long. Using the variable ID wherever possible is significantly faster than the equivalent methods accepting the variable string.

Return
Status of the file operation.
virtual std::string getVariableName(long variable_id) = 0
virtual Attribute getGlobalAttribute(long i) = 0
virtual std::string getGlobalAttributeName(long attribute_id) = 0
virtual std::string getVariableAttributeName(long attribute_id) = 0
virtual Attribute getGlobalAttribute(const std::string &attribute) = 0
virtual long getGlobalAttributeID(const std::string &attribute) = 0
virtual Attribute getVariableAttribute(const std::string &variable, const std::string &attribute) = 0
virtual std::vector<std::string> getVariableAttributeNames() = 0
virtual bool doesAttributeExist(const std::string &attribute) = 0
virtual bool doesVariableExist(const std::string &variable) = 0
void addVariableName(const std::string &variable, long id)
long close()
Closes the currently selected file.

Return
Status of close operation.
virtual const std::string &getCurrentFilename() = 0
void setCurrentFilename(const std::string &filename)
virtual void initializeVariableIDs() = 0
virtual void initializeVariableNames() = 0
virtual long closeFile() = 0
virtual long openFile(const std::string &filename, bool readonly) = 0
virtual ~FileReader()
Destructor

Public Static Attributes

const long OK
const long OPEN_ERROR
const long FILE_DOES_NOT_EXIST
const long VARIABLE_DOES_NOT_EXIST
const long ATTRIBUTE_DOES_NOT_EXIST
const long LOAD_FAILED
const long UNABLE_TO_ALLOCATE_MEMORY
const long VARIABLE_NOT_IN_MEMORY
const long MODEL_NOT_SUPPORTED
const long NOT_A_VALID_KAMELEON_FILE
Protected Functions

void initializeGlobalAttributes()
Helper method to store the global attributes in a map. This solves some issues with threaded operations on CDF files.

void initializeVariableAttributes()
Protected Attributes

std::string current_filename
int numGAttributes
int numVAttributes
boost::unordered_map<std::string, long> variableIDs
boost::unordered_map<long, std::string> variableNames
boost::unordered_map<std::string, Attribute> gAttributes
boost::unordered_map<long, Attribute> gAttributeByID
boost::unordered_map<std::string, boost::unordered_map<std::string, Attribute>> vAttributes

CDFFileReader

class ccmc::CDFFileReader
CDFFileReader allows for opening and accessing Kameleon-converted CDF files.

CDFFileReader inherits from the pure virtual FileReader class

Public Functions

CDFFileReader()
Default constructor. Does nothing.

virtual std::vector<float> *getVariable(const std::string &variable)
Returns a pointer to a std::vector<float> containing the values of the selected variable.

This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variable -
virtual std::vector<float> *getVariable(long variableID)
Returns a pointer to a std::vector<float> containing the values of the selected variable stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variable -
virtual std::vector<float> *getVariable(const std::string &variable, long startIndex, long count)
Returns a pointer to a std::vector<float> containing the values of the selected variable in the range specified by the startIndex and count (the number of records to read) stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variable -
startIndex -
count -
virtual std::vector<float> *getVariable(long variableID, long startIndex, long count)
Returns a pointer to a std::vector<float> containing the values of the selected variable in the range specified by the startIndex and count (the number of records to read) stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variableID -
startIndex -
count -
virtual float getVariableAtIndex(const std::string &variable, long index)
Returns a value in the flat array of the variable and index requested.

Use this method on variables that have a type of float

Return
float of the value in the array.
Parameters
variable -
The variable in the file

index -
The index in the variable’s array in the file

virtual float getVariableAtIndex(long variable_id, long index)
Return
Parameters
variableNum -
index -
virtual std::vector<int> *getVariableInt(const std::string &variable)
This allocates a new std::vector<int> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
vector<int> containing the integer values of the variable
Parameters
variable -
virtual int getVariableIntAtIndex(const std::string &variable, long index)
Returns a value in the flat array of the variable and index requested.

Use this method on variables that have a type of int

Return
int of the value in the array.
Parameters
variable -
The variable in the file

index -
The index in the variable’s array in the file

virtual int getNumberOfGlobalAttributes()
Retrieves the number of global attributes in the selected file. This is useful for iterating over all available global attributes.

Return
The number of global attributes stored in the selected file.
virtual int getNumberOfVariables()
Return
virtual int getNumberOfVariableAttributes()
Gets the number of variable attributes.

Return
The number of variable attributes in the opened file.
virtual long getNumberOfRecords(const std::string &variable)
Return
Parameters
variable -
virtual long getNumberOfRecords(long variable_id)
Return
Parameters
variable_id -
virtual long getVariableID(const std::string &variable)
Returns the variable ID as a long. Using the variable ID wherever possible is significantly faster than the equivalent methods accepting the variable string.

Return
Status of the file operation.
virtual std::string getVariableName(long variable_id)
Returns the string representation of the variable referred to by variable_id

Return
String representation of the variable.
virtual Attribute getGlobalAttribute(long i)
Return
Parameters
i -
The attribute number

virtual std::string getGlobalAttributeName(long attribute_id)
Return
Parameters
attribute_id -
virtual std::string getVariableAttributeName(long attribute_id)
Return
String representing the name of the attribute specified by attribute_id
Parameters
attribute_id -
virtual Attribute getGlobalAttribute(const std::string &attribute)
Return
Parameters
attribute -
virtual long getGlobalAttributeID(const std::string &attribute)
Return
Parameters
attribute -
virtual Attribute getVariableAttribute(const std::string &variable, const std::string &attribute)
Return
Parameters
variable -
vattribute -
virtual std::vector<std::string> getVariableAttributeNames()
Return
virtual bool doesAttributeExist(const std::string &attribute)
Return
Parameters
attribute -
virtual bool doesVariableExist(const std::string &variable)
Return
Parameters
variable -
bool doesAttributeExist(long attribute)
Return
Parameters
attribute -
bool doesVariableExist(long variable)
Return
Parameters
variable -
virtual const std::string &getCurrentFilename()
Returns the current filename.

Return
The current filename.
virtual ~CDFFileReader()
Destructor

Protected Functions

virtual long closeFile()
Closes the currently selected file. Call this from the close() method.

Return
Status of close operation.
virtual long openFile(const std::string &filename, bool readonly)
Opens a new file. If the previous file has been opened successfuly, and has the same filename as the requested filename, nothing will be done.

Return
The status of the open call. This method should be called from open().
Parameters
filename -
void initializeGlobalAttributes()
void initializeVariableAttributes()
virtual void initializeVariableIDs()
Helper method to initialize a map containing variable IDs. This solves some issues with threaded operations on CDF files.

virtual void initializeVariableNames()
Helper method to initialize a variable names map. This solves some issues with threaded operations on CDF files.

HDF5FileReader

class ccmc::HDF5FileReader
The HDF5FileReader allows opening and accessing Kameleon-converted HDF5 files.

HDF5FileReader implements the pure virtual functions of the FileReader class. Note: This reader should only be compiled if HDF5 is installed (HAVE_HDF5 is defined).

Public Functions

HDF5FileReader()
Default constructor. Does nothing.

virtual std::vector<float> *getVariable(const std::string &variable)
Returns a pointer to a std::vector<float> containing the values of the selected variable.

This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variable -
virtual std::vector<float> *getVariable(long variable)
Returns a pointer to a std::vector<float> containing the values of the selected variable stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variable -
virtual std::vector<float> *getVariable(const std::string &variable, long startIndex, long count)
Returns a pointer to a std::vector<float> containing the values of the selected variable in the range specified by the startIndex and count (the number of records to read) stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variable -
startIndex -
count -
virtual std::vector<float> *getVariable(long variable, long startIndex, long count)
Returns a pointer to a std::vector<float> containing the values of the selected variable in the range specified by the startIndex and count (the number of records to read) stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
std::vector<float> containing the values of the selected variable.
Parameters
variableID -
startIndex -
count -
virtual float getVariableAtIndex(const std::string &variable, long index)
Returns a value in the flat array of the variable and index requested.

Use this method on variables that have a type of float

returns std::numeric_limits<float>::min() if missing

Return
float of the value in the array.
Parameters
variable -
The variable in the file

index -
The index in the variable’s array in the file

virtual float getVariableAtIndex(long variable_id, long index)
Return
Parameters
variableNum -
index -
virtual std::vector<int> *getVariableInt(const std::string &variable)
This allocates a new std::vector<int> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Return
vector<int> containing the integer values of the variable
Parameters
variable -
virtual int getVariableIntAtIndex(const std::string &variable, long index)
Returns a value in the flat array of the variable and index requested.

Use this method on variables that have a type of int

Return
int of the value in the array.
Parameters
variable -
The variable in the file

index -
The index in the variable’s array in the file

virtual int getNumberOfGlobalAttributes()
TODO Retrieves the number of global attributes in the selected file. This is useful for iterating over all available global attributes.

Return
The number of global attributes stored in the selected file.
virtual int getNumberOfVariables()
Return
virtual int getNumberOfVariableAttributes()
Gets the number of variable attributes.

Return
The number of variable attributes in the opened file.
virtual long getNumberOfRecords(const std::string &variable)
Return
Parameters
variable -
virtual long getNumberOfRecords(long variable_id)
Return
Parameters
variable_id -
virtual long getVariableID(const std::string &variable)
Returns the variable ID as a long. Using the variable ID wherever possible is significantly faster than the equivalent methods accepting the variable string.

Return
Status of the file operation.
virtual std::string getVariableName(long variable_id)
Returns the string representation of the variable referred to by variable_id

Return
String representation of the variable.
virtual Attribute getGlobalAttribute(long i)
Return
Parameters
i -
The attribute number

virtual std::string getGlobalAttributeName(long attribute_id)
Return
Parameters
attribute_id -
virtual std::string getVariableAttributeName(long attribute_id)
Return
String representing the name of the attribute specified by attribute_id
Parameters
attribute_id -
virtual Attribute getGlobalAttribute(const std::string &attribute)
Return
Parameters
attribute -
virtual long getGlobalAttributeID(const std::string &attribute)
Return
Parameters
attribute -
virtual Attribute getVariableAttribute(const std::string &variable, const std::string &attribute)
Return
Parameters
variable -
vattribute -
virtual std::vector<std::string> getVariableAttributeNames()
Return
virtual bool doesAttributeExist(const std::string &attribute)
Return
Parameters
attribute -
virtual bool doesVariableExist(const std::string &variable)
Return
Parameters
variable -
virtual const std::string &getCurrentFilename()
Returns the current filename.

Return
The current filename.
virtual ~HDF5FileReader()
Destructor

Protected Functions

virtual long closeFile()
Closes the currently selected file. Call this from the close() method.

Return
Status of close operation.
virtual long openFile(const std::string &filename, bool readonly)
Opens a new file. If the previous file has been opened successfuly, and has the same filename as the requested filename, nothing will be done.

Return
The status of the open call. This method should be called from open().
Parameters
filename -
void initializeGlobalAttributes()
void initializeVariableAttributes()
virtual void initializeVariableIDs()
Helper method to initialize a map containing variable IDs. This solves some issues with threaded operations on CDF files.

virtual void initializeVariableNames()
Helper method to initialize a variable names map. This solves some issues with threaded operations on CDF files.

Protected Attributes

std::string current_filename
H5::H5File *current_file
H5::Group *rootGroup
H5::Group *variableGroup

GeneralFileReader

class ccmc::GeneralFileReader
The GeneralFileReader class is a factory class for creating file readers in a model-agnostic fashion.

GeneralFileReader is not a subclass of FileReader, but instead creates an instance of FileReader (CDFFileReader,HDF5FileReader, or other) and calls its functions. Warning: FileReader‘s protected maps are repeated here, so it is possible to fill the maps variableIDs, variableNames, gAttributes, gAttributeByID, and vAttributes of GeneralFileReader independently from those of the FileReader class. Try to work with the FileReader maps wherever possible to avoid confusion.

Public Functions

GeneralFileReader()
sets fileReader pointer to NULL

long open(const std::string &filename)
Attempts to open using CDFFileReader, falls back to HDF5FileReader (if HAVE_HDF5 is defined)

TODO: Add support for embedded python FileReader as third option.

Return
status
Parameters
filename -
Name of the file to be read. Note: no extension checking is done at this time.

std::vector<float> *getVariable(const std::string &variable)
std::vector<float> *getVariable(long variableID)
std::vector<float> *getVariable(const std::string &variable, long startIndex, long count)
std::vector<float> *getVariable(long variableID, long startIndex, long count)
float getVariableAtIndex(const std::string &variable, long index)
float getVariableAtIndex(long variable_id, long index)
std::vector<int> *getVariableInt(const std::string &variable)
int getVariableIntAtIndex(const std::string &variable, long index)
int getNumberOfGlobalAttributes()
int getNumberOfVariables()
int getNumberOfVariableAttributes()
long getNumberOfRecords(const std::string &variable)
long getNumberOfRecords(long variable_id)
long getVariableID(const std::string &variable)
std::string getVariableName(long variable_id)
Attribute getGlobalAttribute(long i)
std::string getGlobalAttributeName(long attribute_id)
std::string getVariableAttributeName(long attribute_id)
Attribute getGlobalAttribute(const std::string &attribute)
Attribute getVariableAttribute(const std::string &variable, const std::string &attribute)
std::vector<std::string> getVariableAttributeNames()
bool doesAttributeExist(const std::string &attribute)
bool doesVariableExist(const std::string &variable)
long close()
const std::string &getCurrentFilename()
~GeneralFileReader()
Public Members

boost::python::object python_namespace
Protected Functions

void initializeGlobalAttributes()
void initializeVariableAttributes()
void initializeVariableIDs()
calls fileReader’s initializeVariableIDs()

void initializeVariableNames()
calls fileReader’s initializeVariableNames()

Protected Attributes

std::string current_filename
boost::unordered_map<std::string, long> variableIDs
variable srtring to id map

boost::unordered_map<long, std::string> variableNames
variableID to string name

boost::unordered_map<std::string, Attribute> gAttributes
global attributes by name

boost::unordered_map<long, Attribute> gAttributeByID
global attributes by ID

boost::unordered_map<std::string, boost::unordered_map<std::string, Attribute>> vAttributes
variable attributes map

FileReader *fileReader
polymorphic pointer to FileReader. It will point to either a CDFFileReader or HDF5FileReader instance.

Model class

class ccmc::Model
The Model class inherits from GeneralFileReader and manages memory for stored variables used in interpolation.

All Kameleon models must inherit from the Model class.

Public Functions

Model()
Default constructor

virtual long open(const std::string &filename) = 0
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
void setModelName(std::string modelName)
Sets the model name to modelName.

Parameters
modelName -
std::string getModelName()
Returns the modelName of the currently selected file.

Return
long loadVariable(const std::string &variable)
Load a variable into memory.

Checks to see if this variable is loaded, and if not, checks that it exists in the file. Use this method when the variable to load is of type float

Return
status of the operation
Parameters
variable -
Variable to load into memory.

long unloadVariable(const std::string &variable)
Unload a variable from memory. This will return FileReader::OK if the variable is removed from memory, and FileReader::VARIABLE_NOT_IN_MEMORY if the variable was not already in memory.

Return
status of the operation
Parameters
variable -
Variable to unload from memory.

long loadVariableInt(const std::string &variable)
Loads a variable into memory.

Checks to see if this variable is loaded, and if not, checks that it exists in the file Use this method when the variable to load is of type int

Return
status of the operation
Parameters
variable -
std::vector<float> *getVariableFromMapRW(const std::string &variable)
Returns a pointer to the entry in the variableData map containing the variable data.

This pointer can be modified.

Return
std::vector<float>* of the requested variable. Note that the pointer points to an entry in a map. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable -
Variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL.

std::vector<int> *getIntVariableFromMapRW(const std::string &variable)
Returns a pointer to the entry in the variableDataInt map containing the variable data.

This pointer cannot be modified.

Return
std::vector<int>* of the requested variable. Note that the pointer points to an entry in a map. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable -
Variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL.

const std::vector<float> *getVariableFromMap(const std::string &variable)
Returns a const pointer to the entry in the variableData map containing the variable data.

This pointer cannot be modified.

Return
std::vector<float>* of the requested variable. Note that the pointer points to an entry in a map and should not and cannot be deleted. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable -
Variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL.

const std::vector<int> *getIntVariableFromMap(const std::string &variable)
Returns a const pointer to the entry in the variableDataInt map containing the variable data.

This pointer cannot be modified.

Return
std::vector<int>* of the requested variable. Note that the pointer points to an entry in a map and should not and cannot be deleted. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable -
Variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL.

void addFloatVariableToMap(const std::string &variable, std::vector<float> *variableData)
const std::vector<float> *getVariableFromMap(long variable_id)
Returns a const pointer to the entry in the variableDataByID map containing the variable data.

This pointer cannot be modified.

Return
std::vector<float>* of the requested variable. Note that the pointer points to an entry in a map and should not and cannot be deleted. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable_id -
Variable id of the variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL. Request the variable id by using FileReader::getVariableID(const std::string& variable)

const std::vector<int> *getIntVariableFromMap(long variable_id)
Returns a const pointer to the entry in the variableDataIntByID map containing the variable data.

This pointer cannot be modified.

Return
std::vector<int>* of the requested variable. Note that the pointer points to an entry in a map and should not and cannot be deleted. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable_id -
Variable id of the variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL. Request the variable id by using FileReader::getVariableID(const std::string& variable)

std::vector<float> *getVariableFromMapRW(long variable_id)
Returns a pointer to the entry in the variableDataByID map containing the variable data.

This pointer cannot be modified.

Return
std::vector<float>* of the requested variable. Note that the pointer points to an entry in a map. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable_id -
Variable id of the variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL. Request the variable id by using FileReader::getVariableID(const std::string& variable)

std::vector<int> *getIntVariableFromMapRW(long variable_id)
Returns a pointer to the entry in the variableDataIntByID map containing the variable data.

This pointer cannot be modified.

Return
std::vector<int>* of the requested variable. Note that the pointer points to an entry in a map. The memory pointed to by the pointer will automatically be freed when the file is closed, or the Model object is deleted.
Parameters
variable_id -
Variable id of the variable to fetch from memory. This assumes the variable has already been loaded into memory. If the variable has not been loaded, the pointer will be NULL. Request the variable id by using FileReader::getVariableID(const std::string& variable)

virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.

void setMissingValue(float missingValue)
Sets the missing value to use when no valid data exists.

Parameters
missingValue -
float getMissingValue()
Returns the missing value that will be returned when no valid data exists.

This value can be used to check whether an interpolated value is a missing value or not.

Return
Missing value
float getConversionFactorToSI(const std::string &variable)
Returns the conversion factor needed to convert the interpolated value to SI units.

Return
Conversion factor to convert the specified variable to SI units
Parameters
variable -
Variable to request the conversion factor for.

std::string getNativeUnit(const std::string &variable)
Fetches the native units of the variable as stored in the file.

Return
The native units of the specified variable, as stored in the file.
Parameters
variable -
Variable to request units for.

std::string getSIUnit(const std::string &variable)
Returns the SI units of the specified variable.

Return
Parameters
variable -
int getProgress()
int getBusyStatus()
long close()
Closes the currently selected file.

Return
virtual Interpolator *createNewInterpolator() = 0
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual ~Model()
Destructor

Public Static Attributes

const int BUSY
const int OK
Protected Types

typedef boost::unordered_map<std::string, std::vector<float> *> mapStringFloat
typedef boost::unordered_map<std::string, std::vector<int> *> mapStringInt
typedef boost::unordered_map<long, std::vector<float> *> mapLongFloat
typedef boost::unordered_map<long, std::vector<int> *> mapLongInt
Protected Functions

virtual void initializeConversionFactorsToSI() = 0
Initializes the conversionFactorsToSI map.

These factors are used to convert interpolated values to SI units.

void setBusyStatus(int busyStatus)
virtual void initializeSIUnits() = 0
Initializes the variableSIUnits map.

Protected Attributes

std::string modelName
boost::unordered_map<std::string, float> conversionFactorsToSI
boost::unordered_map<std::string, std::string> variableSIUnits
boost::unordered_map<std::string, std::vector<float> *> variableData
boost::unordered_map<std::string, std::vector<int> *> variableDataInt
boost::unordered_map<long, std::vector<float> *> variableDataByID
boost::unordered_map<long, std::vector<int> *> variableDataIntByID
std::string units_
float missingValue
int busyStatus
int progress
int variablesAdded

Time

class ccmc::Time
Public Functions

Time(const std::string &epochString)
Time(double epoch)
Time()
~Time()
short getDay() const
void setDay(short day)
void setEpoch(double epoch)
short getHour() const
void setHour(short hour)
short getMilliseconds() const
void setMilliseconds(short milliseconds)
short getMinute() const
void setMinute(short minute)
short getMonth() const
void setMonth(short month)
short getSeconds() const
void setSeconds(double seconds)
short getYear() const
void setYear(short year)
std::string toString() const
double getEpoch() const

Kameleon Class

Depending on the application, one may use the more general Kameleon class to access any of the Supported Models. This promotes code reuse when comparing results from different models. See Kameleon Class Demo for a complete example.

class ccmc::Kameleon
The Kameleon class provides access to space weather models and data products in a model-independent fashion.

The Kameleon class determines which model reader and interpolator to use. It also manages derived variables and unit conversions.

Public Functions

Kameleon()
Default constructor

virtual ~Kameleon()
Destructor

long close()
Closes the currently opened file.

Interpolator *createNewInterpolator()
Returns a new KameleonInterpolator that maintains state information independent of other interpolators. This can be used to parallelize the interpolations.

Return
A new interpolator.
KameleonInterpolator *createCoordinateInterpolator()
Return a new KameleonInterpolator that gives access to all methods rather than the polymorphic pointer returned by createNewInterpolator(). This makes explicit that we have new features for transforming between coordinate frames.

Return
A new KameleonInterpolator
bool doesAttributeExist(const std::string &attribute)
Return
Parameters
attribute -
bool doesVariableExist(const std::string &variable)
Return
Parameters
variable -
float getConversionFactorToSI(const std::string &variable)
Currently not implemented.

Return
Parameters
variable -
const std::string &getCurrentFilename()
Return
Time getCurrentTime()
Calculates the current time based on the start time and the elapsed time.

Return
Formatted string of the current time. This is currently different for different models. If the current time cannot be calculated, “TIME_UNAVAILABLE” is returned.
Attribute getGlobalAttribute(long i)
Return
Parameters
i -
Attribute getGlobalAttribute(const std::string &attribute)
Return
Parameters
attribute -
std::string getGlobalAttributeName(long attribute_id)
Return
Parameters
attribute_id -
std::vector<std::string> getLoadedVariables()
Return
float getMissingValue()
Return
const std::string &getModelName()
Returns the model name of the opened file.

Return
The model name.
std::string getNativeUnit(const std::string &variable)
Returns the units of the variable specified. The units may differ from the units in the original data.

Return
String representation of the units
Parameters
variable -
int getNumberOfGlobalAttributes()
Return
int getNumberOfVariableAttributes()
Return
int getNumberOfVariables()
Return
std::string getSIUnit(const std::string &variable)
Return
Parameters
variable -
Attribute getVariableAttribute(const std::string &variable, const std::string &attribute)
Return
Parameters
variable -
attribute -
std::string getVariableAttributeName(long attribute_id)
Return
const std::vector<float> *getVariableFromMap(const std::string &variable)
Returns a pointer to the variable data stored in a map. This method works for variables of type float. This cannot and should not be modified or deleted. Use loadVariable and unloadVariable to manange the map.

Return
Parameters
variable -
long getVariableID(const std::string &variable)
Return
Parameters
variable -
std::vector<int> *getVariableInt(const std::string &variable)
Return
Parameters
variable -
const std::vector<int> *getVariableIntFromMap(const std::string &variable)
Returns a pointer to the variable data stored in a map. This method works for variables of type int. This cannot and should not be modified or deleted. Use loadVariable and unloadVariable to manange the map.

Return
Parameters
variable -
std::string getVariableName(long variable_id)
Return
Parameters
variable_id -
std::string getVisUnit(const std::string &variable)
Return
Parameters
variable -
bool loadVariable(const std::string &variable)
Return
Parameters
variable -
bool loadVectorVariable(const std::string &variable)
Return
Parameters
variable -
long open(const std::string &filename)
Return
Parameters
filename -
void setMissingValue(float missingValue)
Return
bool unloadVariable(const std::string &variable)
Return
Parameters
variable -
bool unloadVectorVariable(const std::string &variable)
Return
Parameters
variable -
Public Static Functions

int _cxform(const char *from, const char *to, const double et, Position *v_in, Position *v_out)
Wrapper for the CXFORM function cxform(). Performs coordinate transformation from the source system to the target system at the specified time.

Parameters
from -
to -
et -
v_in -
v_out -
long _cxRound(double doub)
Wrapper for the CXFORM function cxRound()

Parameters
doub -
long _date2es(int yyyy, int mm, int dd, int hh, int mm2, int ss)
Wrapper for the CXFORM function date2es()

Parameters
yyyy -
mm -
dd -
hh -
mm2 -
ss -
double _gregorian_calendar_to_jd(int y, int m, int d, int h, int mi, int s)
Parameters
y -
m -
d -
h -
mi -
s -

Model-Dependent Classes

Adapt3D

class ccmc::Adapt3D
TODO: brief description of Adapt3D class.

TODO: full description of Adapt3D class

Public Functions

Adapt3D()
Default constructor

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.

virtual ~Adapt3D()
Destructor

BATSRUS

class ccmc::BATSRUS
TODO: brief description of BATSRUS class.

TODO: full description of BATSRUS class

Public Functions

BATSRUS()
Default constructor

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.

virtual ~BATSRUS()
Destructor

ENLIL

class ccmc::ENLIL
TODO: Brief description of ENLIL class.

TODO: Full description of ENLIL class

Public Functions

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.

LFM

class ccmc::LFM
Interface to the Lyon Fedder Mobarry MHD model.

The LFM class gives access to LFM model results which have been converted into kameleon-compatible cdf or hdf-5 format.

Public Functions

LFM()
Default constructor

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
creates a new LFM interpolator by storing positions in a kd-tree

Note: the kd-tree generation can take some time, so re-use the resulting interpolator whenever possible

Return
an LFMInterpolator object
void setResolution()
determines the model resolution by scannining positions along fastest varying index

void loadPressure()
populate pressure array

calculates pressure from sound speed and density:

void loadEfield()
Compute electric field from edge components stored in hdf file.

LFM stores edge components of electric field (ei,ej,ek), which are converted into cell-centered vectors. Note: these results might be off by a negative sign: check that E = -v x B

float averageFace(const std::vector<float> *variable, int face_index, const int i, const int j, const int k, const int ii, const int jj)
Averages requested variable for a face, holding face_index constant (holding i,j,or k constant)

std::vector<float> *getLFMVariable(const std::string &variable)
assumes requested variable is already loaded

MAS

class ccmc::MAS
TODO: Brief description of MAS class.

TODO: Full description of MAS class

Public Functions

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.

OpenGGCM

class ccmc::OpenGGCM
TODO: Brief description of OpenGGCM class.

TODO: Full description of OpenGGCM class

Public Functions

OpenGGCM()
Default constructor

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.

SWMF Ionosphere

class ccmc::SWMFIono
Public Functions

virtual long open(const std::string &filename)
Opens a file.

Opens a file and performs any necessary initialization required to work with the data.

Parameters
filename -
virtual Interpolator *createNewInterpolator()
Returns an Interpolator object for the currently opened file.

This returns an Interpolator object that contains all the necessary local variables required to interpolate independent of any other Interpolator object. The pointer must be deleted from the calling program.

Return
A pointer to an Interpolator object.
virtual const std::vector<std::string> getLoadedVariables()
Returns the list of variables that have been loaded into memory, using the loadVariable or loadVectorVariable methods.