epconversions package¶
Submodules¶
epconversions.ec module¶
easy functions for conversions
- epconversions.ec.c2f(c)¶
- epconversions.ec.f2c(f)¶
epconversions.epconversions module¶
Conversion functions for EnergyPlus
- epconversions.epconversions.allipunits()[source]¶
return a list of all the IP units that this module can convert
- Returns ipunits:
a list of all ip units
- Return type:
list[str]
- epconversions.epconversions.allsiunits()[source]¶
return a list of all SI units that this module can convert
- Returns siunits:
a list of all si units
- Return type:
list[str]
- epconversions.epconversions.convert2ip(val, siunit, ipunit=None, unitstr=True, wrapin=None)[source]¶
convert val from si units to ip units
the conversion will be done to the default ip unit. if you have a specific ip unit you want to convert to, give it’s value to the ipunit parameter
By default, the function will also return the ip unit string. to return only the ip value, set unitstr=False. You can wrap the unit string by setting a value to wrapin=’[X]’ where X is replaced by the unit string. ‘[’ and ‘]’ can be any string
Sample code:
epconversions.convert2ip(4, 'm') >> (13.12335958005248, 'ft') epconversions.convert2ip(4, 'm', 'in') >> (157.48031496063, 'in') epconversions.convert2ip(4, 'm', 'in', unitstr=None) >> 157.48031496063 epconversions.convert2ip(4, 'm', 'in', wrapin='[X]') >> (157.48031496063, '[in]') epconversions.convert2ip(4, 'm', 'in', wrapin='unit = [X]') >> (157.48031496063, 'unit = [in]')
- Parameters:
val (
float) – a numeric valuesiunit (
str) – the unit for the value (kg, m, etc.)ipunit (
Optional[str]) – if you know the ip unit you want returned. Else it will use the default unitunitstr (
bool) – True if you want the unit string returnedwrapin (
Optional[str]) – wrap the init string in this.
- Returns new_val:
The new converted value
- Returns ustr:
returns unit string if unitstr=True
- Return type:
Union[float,tuple[float,str]]
- epconversions.epconversions.convert2si(val, ipunit, siunit=None, unitstr=True, wrapin=None)[source]¶
convert val from ip units to si units
the conversion will be done to the default si unit. if you have a specific si unit you want to convert to, give it’s value to the siunit parameter
By default, the function will also return the si unit string. to return only the si value, set unitstr=False. You can wrap the unit string by setting a value to wrapin=’[X]’ where X is replaced by the unit string. ‘[’ and ‘]’ can be any string
Sample code:
epconversions.convert2si(5, 'in') >> (12.700025400050801, 'cm') epconversions.convert2si(5, 'in', 'm') >> (0.12699999999999992, 'm') epconversions.convert2si(5, 'in', 'm', unitstr=False) >> 0.12699999999999992 epconversions.convert2si(5, 'in', 'm', wrapin='[X]') >> (0.12699999999999992, '[m]') epconversions.convert2si(5, 'in', 'm', wrapin='unit = [X]') >> wrapin='unit = [X]')
- Parameters:
val (
float) – a numeric valueipunit (
str) – the unit for the value (ft, in, F etc.)siunit (
Optional[str]) – if you know the si unit you want returned. Else it will use the default unitunitstr (
bool) – True if you want the unit string returnedwrapin (
Optional[str]) – wrap the init string in this.
- Returns new_val:
The new converted value
- Returns ustr:
returns unit string if unitstr=True
- Return type:
Union[float,tuple[float,str]]
- epconversions.epconversions.defaultipunit(siunit)[source]¶
get the default ip unit for the given si unit
- Parameters:
siunit (
str) – si unit- Returns ipunit:
the default ip unit for the given si unit
- Return type:
str
- epconversions.epconversions.defaultsiunit(ipunit)[source]¶
get the default si unit for the given ip unit
- Parameters:
ipunit (
str) – ip unit- Returns siunit:
the default si unit for the given ip unit
- Return type:
str
- epconversions.epconversions.getconversions(txt=None)[source]¶
create the conversion data structure for this library
This function generates the values in the constants SI, IP, SI_DEFAULT and IP_DEFAULT. Ulikely that you will ever neeed to use this function. It was used to build up this module
- Parameters:
txt (
Optional[str]) – the raw text from the IDD which contains the conversion factors- Returns SI:
The value of the SI constant
- Returns IP:
The value of the IP constant
- Returns SI_DEFAULT:
The value of the SI_DEFAULT
- Returns IP_DEFAULT:
The value of the IP_DEFAULT
- Return type:
tuple[Dict[str,Dict[str,Union[str,float,None,list[str]]]],Dict[str,Dict[str,Union[str,float,None,list[str]]]],Dict[str,str],Dict[str,str]]
- epconversions.epconversions.getipunits(siunit, si=None)[source]¶
return all the ip units avaliable for this si unit
- Parameters:
siunit (
str) – si unitsi (
Optional[Dict[str,Dict[str,Union[str,float,None,list[str]]]]]) – Use this in case you want to override the default constant SI
- Returns ipunits:
all the ip units avaliable for this si unit
- Return type:
set[str]
- epconversions.epconversions.getsiunits(ipunit, ip=None)[source]¶
return all the si units avaliable for this ip unit
- Parameters:
ipunit (
str) – ip unitip (
Optional[Dict[str,Dict[str,Union[str,float,None,list[str]]]]]) – Use this in case you want to override the default constant IP
- Returns siunts:
all the si units avaliable for this ip unit
- Return type:
set[str]
Module contents¶
Top-level package for epconversions.