HL-HDF
pyhlhdf_common.h File Reference
#include "pyhlcompat.h"
#include <hlhdf.h>
#include "hlhdf_arrayobject_wrap.h"

Go to the source code of this file.

Functions

int getFloatFromDictionary (char *name, float *val, PyObject *dict)
 Retrives a float from a dictionary, python equivalent would be val = dict[name].
 
int getDoubleFromDictionary (char *name, double *val, PyObject *dict)
 Retrives a double from a dictionary, python equivalent would be val = dict[name].
 
int getIntegerFromDictionary (char *name, int *val, PyObject *dict)
 Retrives a integer from a dictionary, python equivalent would be val = dict[name].
 
int getUnsignedLongFromDictionary (char *name, unsigned long *val, PyObject *dict)
 Retrives a unsigned long from a dictionary, python equivalent would be val = dict[name].
 
int getLongFromDictionary (char *name, long *val, PyObject *dict)
 Retrives a long from a dictionary, python equivalent would be val = dict[name].
 
int getFloatFromObject (char *name, float *val, PyObject *dict)
 Retrives a float from an object, python equivalent would be val = dict.name.
 
int getDoubleFromObject (char *name, double *val, PyObject *dict)
 Retrives a double from an object, python equivalent would be val = dict.name.
 
int getIntegerFromObject (char *name, int *val, PyObject *dict)
 Retrives a integer from an object, python equivalent would be val = dict.name.
 
int getLongFromObject (char *name, long *val, PyObject *dict)
 Retrives a long from an object, python equivalent would be val = dict.name.
 
int getUnsignedLongFromObject (char *name, unsigned long *val, PyObject *dict)
 Retrives a unsigned long from an object, python equivalent would be val = dict.name.
 
int getShortFromObject (char *name, short *val, PyObject *dict)
 Retrives a short from an object, python equivalent would be val = dict.name.
 
int getByteFromObject (char *name, unsigned char *val, PyObject *dict)
 Retrives a unsigned char from an object, python equivalent would be val = dict.name.
 
char * getStringFromObject (char *name, PyObject *dict)
 Retrives a string from a name in an object, python equivalent would be val = dict.name.
 
int getIdxIntegerFromTuple (int idx, int *val, PyObject *tuple)
 Retrives a integer from a index in a tuple, python equivalent would be val = tuple[idx].
 
int getIdxDoubleFromTuple (int idx, double *val, PyObject *tuple)
 Retrives a double from a index in a tuple, python equivalent would be val = tuple[idx].
 
char * getStringFromDictionary (char *name, PyObject *dict)
 Retrives a string from a dictionary, python equivalent would be val = dict[name].
 
int setMappingInteger (PyObject *info, char *keyname, int in_value)
 Sets an integer in a dictionary, the python equivalent would be: info[keyname]=in_value.
 
int setMappingDouble (PyObject *info, char *keyname, double in_value)
 Sets an double in a dictionary, the python equivalent would be: info[keyname]=in_value.
 
int setMappingFloat (PyObject *info, char *keyname, float in_value)
 Sets an float in a dictionary, the python equivalent would be: info[keyname]=in_value.
 
int setMappingString (PyObject *info, char *keyname, char *in_string)
 Sets an string in a dictionary, the python equivalent would be: info[keyname]=in_value.
 
int setMappingString_Length (PyObject *info, char *keyname, char *in_string, int len)
 Sets a string in a dictionary, the python equivalent would be: info[keyname]=in_string[0:len].
 
int setObjectInteger (PyObject *info, char *keyname, int in_value)
 Sets an integer in a object, the python equivalent would be: info.keyname=in_value.
 
int setObjectLong (PyObject *info, char *keyname, long in_value)
 Sets an long in a object, the python equivalent would be: info.keyname=in_value.
 
int setObjectUnsignedLong (PyObject *info, char *keyname, unsigned long in_value)
 Sets an unsigned long in a object, the python equivalent would be: info.keyname=in_value.
 
int setObjectDouble (PyObject *info, char *keyname, double in_value)
 Sets an double in a object, the python equivalent would be: info.keyname=in_value.
 
int setObjectFloat (PyObject *info, char *keyname, float in_value)
 Sets an float in a object, the python equivalent would be: info.keyname=in_value.
 
int setObjectString (PyObject *info, char *keyname, char *in_string)
 Sets an string in a object, the python equivalent would be: info.keyname=in_value.
 
int setObjectString_Length (PyObject *info, char *keyname, char *in_string, int len)
 Sets a string in an object, the python equivalent would be: info.keyname=in_string[0:len].
 
char * translatePyFormatToHlHdf (char type)
 Translates a PyArray type to a hlhdf known format.
 
int pyarraytypeFromHdfType (const char *format)
 Translates an hlhdf represented type into a PyArray known format.
 
PyArrayObject * new1d_ArrayObject (int nl, const char *format)
 Creates a new 1-dimensional PyArrayObject.
 
PyArrayObject * new2d_ArrayObject (int xsize, int ysize, const char *format)
 Creates a new 2-dimensional PyArrayObject.
 

Detailed Description

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-06-15

Utility functions for working with python objects.

Function Documentation

◆ getByteFromObject()

int getByteFromObject ( char * name,
unsigned char * val,
PyObject * dict )

Retrives a unsigned char from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned unsigned char
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ getDoubleFromDictionary()

int getDoubleFromDictionary ( char * name,
double * val,
PyObject * dict )

Retrives a double from a dictionary, python equivalent would be val = dict[name].

Parameters
[in]nameThe name of the attribute
[out]valThe assigned double
[in]dictThe Python dictionary
Returns
1 on success, otherwise 0

◆ getDoubleFromObject()

int getDoubleFromObject ( char * name,
double * val,
PyObject * dict )

Retrives a double from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned double
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ getFloatFromDictionary()

int getFloatFromDictionary ( char * name,
float * val,
PyObject * dict )

Retrives a float from a dictionary, python equivalent would be val = dict[name].

Parameters
[in]nameThe name of the attribute
[out]valThe assigned float
[in]dictThe Python dictionary
Returns
1 on success, otherwise 0

◆ getFloatFromObject()

int getFloatFromObject ( char * name,
float * val,
PyObject * dict )

Retrives a float from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned float
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ getIdxDoubleFromTuple()

int getIdxDoubleFromTuple ( int idx,
double * val,
PyObject * tuple )

Retrives a double from a index in a tuple, python equivalent would be val = tuple[idx].

Parameters
[in]idxThe index of the value
[out]valThe assigned double
[in]tupleThe python tuple
Returns
1 on success, otherwise 0

◆ getIdxIntegerFromTuple()

int getIdxIntegerFromTuple ( int idx,
int * val,
PyObject * tuple )

Retrives a integer from a index in a tuple, python equivalent would be val = tuple[idx].

Parameters
[in]idxThe index of the value
[out]valThe assigned integer
[in]tupleThe python tuple
Returns
1 on success, otherwise 0

◆ getIntegerFromDictionary()

int getIntegerFromDictionary ( char * name,
int * val,
PyObject * dict )

Retrives a integer from a dictionary, python equivalent would be val = dict[name].

Parameters
[in]nameThe name of the attribute
[out]valThe assigned integer
[in]dictThe Python dictionary
Returns
1 on success, otherwise 0

◆ getIntegerFromObject()

int getIntegerFromObject ( char * name,
int * val,
PyObject * dict )

Retrives a integer from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned integer
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ getLongFromDictionary()

int getLongFromDictionary ( char * name,
long * val,
PyObject * dict )

Retrives a long from a dictionary, python equivalent would be val = dict[name].

Parameters
[in]nameThe name of the attribute
[out]valThe assigned long
[in]dictThe Python dictionary
Returns
1 on success, otherwise 0

◆ getLongFromObject()

int getLongFromObject ( char * name,
long * val,
PyObject * dict )

Retrives a long from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned long
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ getShortFromObject()

int getShortFromObject ( char * name,
short * val,
PyObject * dict )

Retrives a short from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned short
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ getStringFromDictionary()

char * getStringFromDictionary ( char * name,
PyObject * dict )

Retrives a string from a dictionary, python equivalent would be val = dict[name].

Parameters
[in]nameThe name of the attribute
[in]dictThe Python dictionary
Returns
the string on success, otherwise NULL

◆ getStringFromObject()

char * getStringFromObject ( char * name,
PyObject * dict )

Retrives a string from a name in an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[in]dictThe Python dictionary
Returns
the string on success, otherwise NULL

◆ getUnsignedLongFromDictionary()

int getUnsignedLongFromDictionary ( char * name,
unsigned long * val,
PyObject * dict )

Retrives a unsigned long from a dictionary, python equivalent would be val = dict[name].

Parameters
[in]nameThe name of the attribute
[out]valThe assigned unsigned long
[in]dictThe Python dictionary
Returns
1 on success, otherwise 0

◆ getUnsignedLongFromObject()

int getUnsignedLongFromObject ( char * name,
unsigned long * val,
PyObject * dict )

Retrives a unsigned long from an object, python equivalent would be val = dict.name.

Parameters
[in]nameThe name of the attribute
[out]valThe assigned unsigned long
[in]dictThe Python object
Returns
1 on success, otherwise 0

◆ new1d_ArrayObject()

PyArrayObject * new1d_ArrayObject ( int nl,
const char * format )

Creates a new 1-dimensional PyArrayObject.

Parameters
[in]nlThe dimension
[in]formatThe hlhdf representation of the array to be created.
Returns
The PyArray if ok, NULL otherwise

◆ new2d_ArrayObject()

PyArrayObject * new2d_ArrayObject ( int xsize,
int ysize,
const char * format )

Creates a new 2-dimensional PyArrayObject.

Parameters
[in]xsizeThe x-dimension
[in]ysizeThe y-dimension
[in]formatThe hlhdf representation of the array to be created.
Returns
The PyArray if ok, NULL otherwise

◆ pyarraytypeFromHdfType()

int pyarraytypeFromHdfType ( const char * format)

Translates an hlhdf represented type into a PyArray known format.

Parameters
[in]formatThe hlhdf representation
Returns
The PyArray type if ok, -1 otherwise

◆ setMappingDouble()

int setMappingDouble ( PyObject * info,
char * keyname,
double in_value )

Sets an double in a dictionary, the python equivalent would be: info[keyname]=in_value.

Parameters
[in]infoThe Python dictionary
[in]keynameThe name of the attribute
[in]in_valuethe double value
Returns
1 on success, otherwise 0

◆ setMappingFloat()

int setMappingFloat ( PyObject * info,
char * keyname,
float in_value )

Sets an float in a dictionary, the python equivalent would be: info[keyname]=in_value.

Parameters
[in]infoThe Python dictionary
[in]keynameThe name of the attribute
[in]in_valuethe float value
Returns
1 on success, otherwise 0

◆ setMappingInteger()

int setMappingInteger ( PyObject * info,
char * keyname,
int in_value )

Sets an integer in a dictionary, the python equivalent would be: info[keyname]=in_value.

Parameters
[in]infoThe Python dictionary
[in]keynameThe name of the attribute
[in]in_valuethe integer value
Returns
1 on success, otherwise 0

◆ setMappingString()

int setMappingString ( PyObject * info,
char * keyname,
char * in_string )

Sets an string in a dictionary, the python equivalent would be: info[keyname]=in_value.

Parameters
[in]infoThe Python dictionary
[in]keynameThe name of the attribute
[in]in_stringthe string value
Returns
1 on success, otherwise 0

◆ setMappingString_Length()

int setMappingString_Length ( PyObject * info,
char * keyname,
char * in_string,
int len )

Sets a string in a dictionary, the python equivalent would be: info[keyname]=in_string[0:len].

Parameters
[in]infoThe Python dictionary
[in]keynameThe name of the attribute
[in]in_stringthe string
[in]lenThe number of characters that should be taken from the string
Returns
1 on success, otherwise 0

◆ setObjectDouble()

int setObjectDouble ( PyObject * info,
char * keyname,
double in_value )

Sets an double in a object, the python equivalent would be: info.keyname=in_value.

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_valuethe double value
Returns
1 on success, otherwise 0

◆ setObjectFloat()

int setObjectFloat ( PyObject * info,
char * keyname,
float in_value )

Sets an float in a object, the python equivalent would be: info.keyname=in_value.

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_valuethe float value
Returns
1 on success, otherwise 0

◆ setObjectInteger()

int setObjectInteger ( PyObject * info,
char * keyname,
int in_value )

Sets an integer in a object, the python equivalent would be: info.keyname=in_value.

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_valuethe integer value
Returns
1 on success, otherwise 0

◆ setObjectLong()

int setObjectLong ( PyObject * info,
char * keyname,
long in_value )

Sets an long in a object, the python equivalent would be: info.keyname=in_value.

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_valuethe long value
Returns
1 on success, otherwise 0

◆ setObjectString()

int setObjectString ( PyObject * info,
char * keyname,
char * in_string )

Sets an string in a object, the python equivalent would be: info.keyname=in_value.

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_stringthe string value
Returns
1 on success, otherwise 0

◆ setObjectString_Length()

int setObjectString_Length ( PyObject * info,
char * keyname,
char * in_string,
int len )

Sets a string in an object, the python equivalent would be: info.keyname=in_string[0:len].

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_stringthe string
[in]lenThe number of characters that should be taken from the string
Returns
1 on success, otherwise 0

◆ setObjectUnsignedLong()

int setObjectUnsignedLong ( PyObject * info,
char * keyname,
unsigned long in_value )

Sets an unsigned long in a object, the python equivalent would be: info.keyname=in_value.

Parameters
[in]infoThe Python object
[in]keynameThe name of the attribute
[in]in_valuethe unsigned long value
Returns
1 on success, otherwise 0

◆ translatePyFormatToHlHdf()

char * translatePyFormatToHlHdf ( char type)

Translates a PyArray type to a hlhdf known format.

Parameters
[in]typeThe PyArray type
Returns
The hlhdf representation if ok, NULL otherwise.