Skip to content

Commit

Permalink
Upload the source files for version 0.3.0 of t4gpd
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-leduc committed Dec 10, 2021
1 parent eec39e6 commit fec0f2c
Showing 177 changed files with 7,307 additions and 87 deletions.
24 changes: 24 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
# Package t4gpd history

## Version 0.3.0 - rev. 11625 - 9 Dec. 2021
* Second release on PyPI
* Add new tests.io.ZipLoaderTest class
* Add new io.ZipLoader class
* Add new misc.PopulationPyramid class
* Add new pyqgis/{AddMemoryLayer,SetSymbolLib,ShowFeatureCount} classes
* Add new tests datasets: la_defense_{measurepts.csv, pathway.gpkg, waypoints.gpkg}
* Add new tests.io.ZipWriterTest class
* Add new io.ZipWriter class
* Add new io.Reloading class
* Add new tests.commons.CalendarLibTest class
* Add new commons.CalendarLib class
* Add new tests.morph.geoProcesses.{GetInteriorPointTest, IsAnIndoorPointTest} classes
* Add new morph.geoProcesses.{GetInteriorPoint, IsAnIndoorPoint} classes
* Add new comfort.{Empirical,Linear,Universal}ThermalIndices classes
* Add new comfort.indices.Tmrt{GlobeTemperature,Out,Radiometer} classes
* Add new comfort.indices.{ASV,DI,ETU,H,HI,NET,OUTSET,PE,PET,PMV,PT,SET,SETmist,THI,UTCI,WCT} classes
* Add new comfort.indices.AbstractThermalComfortIndice class
* Add new comfort.algo.Tmrt{GlobeTemperature,Out}Lib classes
* Add new comfort.algo.{ETU,PET,PMV,PT,SET,UTCI}Lib classes
* Add new comfort.algo.WindSpeedExtrapolationLib class
* Add new comfort.algo.{Constants,Commons}Lib classes

## Version 0.2.0 - rev. 11186 - 30 Apr. 2021
* First release on PyPI
* Add new tests.sun.STTreeHardShadow2Test class
* Add new tests.commons.sun.ShadowLibTest class
* Add new commons.sun.ShadowLib class
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -16,8 +16,11 @@ To be able to use the **t4gpd** plugin, perform geoprocessing and display your o
> pip install matplotlib-scalebar Dijkstar suntimes windrose
## Installation instructions
Start by downloading the **t4gpd** latest version available from the [SourceSup website](https://sourcesup.renater.fr/projects/t4gs). Then, install the Python3 plugin you downloaded:
> pip install t4gpd-0.2.0.tar.gz
As **t4gpd** is now on [PyPI](https://pypi.org/project/t4gpd/), the easiest way to install the latest version is to use the pip command as follows:
> pip install t4gpd
Alternatively, you can download the **t4gpd** latest version from the [SourceSup website](https://sourcesup.renater.fr/projects/t4gs). Then, install the Python3 plugin you downloaded:
> pip install t4gpd-0.3.0.tar.gz
## Read the documentation
Go to [https://t4gpd-docs.readthedocs.io](https://t4gpd-docs.readthedocs.io) to consult the documentation.
2 changes: 1 addition & 1 deletion t4gpd/_version.py
Original file line number Diff line number Diff line change
@@ -21,4 +21,4 @@
along with t4gpd. If not, see <https://www.gnu.org/licenses/>.
'''
# The following line *must* be the last in the module, exactly as formatted:
__version__ = '0.2.0'
__version__ = '0.3.0'
50 changes: 50 additions & 0 deletions t4gpd/comfort/EmpiricalThermalIndices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'''
Created on 2 feb. 2021
@author: tleduc
Copyright 2020 Thomas Leduc
This file is part of t4gpd.
t4gpd is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
t4gpd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with t4gpd. If not, see <https://www.gnu.org/licenses/>.
'''
from t4gpd.comfort.indices.ASV import ASV
from t4gpd.comfort.indices.AbstractThermalComfortIndice import AbstractThermalComfortIndice


class EmpiricalThermalIndices(AbstractThermalComfortIndice):
'''
classdocs
'''

def __init__(self, sensorsGdf, AirTC='AirTC_Avg', RH='RH_Avg', WS_ms='WS_ms_Avg',
SRUp='SR01Up_1_Avg'):
'''
Constructor
AirTC: air temperature [C]
RH: relative humidity [%]
Ws_ms: wind speed [m.s-1]
SRUp: incoming shortwave radiation [W.m-2]
'''
self.ops = [
ASV(sensorsGdf, AirTC, RH, WS_ms, SRUp)
]

def runWithArgs(self, row):
result = dict()
for op in self.ops:
result.update(op.runWithArgs(row))
return result
60 changes: 60 additions & 0 deletions t4gpd/comfort/LinearThermalIndices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'''
Created on 2 feb. 2021
@author: tleduc
Copyright 2020 Thomas Leduc
This file is part of t4gpd.
t4gpd is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
t4gpd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with t4gpd. If not, see <https://www.gnu.org/licenses/>.
'''
from t4gpd.comfort.indices.AbstractThermalComfortIndice import AbstractThermalComfortIndice
from t4gpd.comfort.indices.DI import DI
from t4gpd.comfort.indices.H import H
from t4gpd.comfort.indices.HI import HI
from t4gpd.comfort.indices.NET import NET
from t4gpd.comfort.indices.PE import PE
from t4gpd.comfort.indices.THI import THI
from t4gpd.comfort.indices.WCT import WCT


class LinearThermalIndices(AbstractThermalComfortIndice):
'''
classdocs
'''

def __init__(self, sensorsGdf, AirTC='AirTC_Avg', RH='RH_Avg', WS_ms='WS_ms_Avg'):
'''
Constructor
AirTC: air temperature [C]
RH: relative humidity [%]
Ws_ms: wind speed [m.s-1]
'''
self.ops = [
DI(sensorsGdf, AirTC, RH),
NET(sensorsGdf, AirTC, RH, WS_ms),
H(sensorsGdf, AirTC, RH),
HI(sensorsGdf, AirTC, RH),
THI(sensorsGdf, AirTC, RH),
PE(sensorsGdf, AirTC, WS_ms),
WCT(sensorsGdf, AirTC, WS_ms)
]

def runWithArgs(self, row):
result = dict()
for op in self.ops:
result.update(op.runWithArgs(row))
return result
71 changes: 71 additions & 0 deletions t4gpd/comfort/UniversalThermalIndices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'''
Created on 3 feb. 2021
@author: tleduc
Copyright 2020 Thomas Leduc
This file is part of t4gpd.
t4gpd is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
t4gpd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with t4gpd. If not, see <https://www.gnu.org/licenses/>.
'''
from t4gpd.comfort.indices.AbstractThermalComfortIndice import AbstractThermalComfortIndice
from t4gpd.comfort.indices.ETU import ETU
from t4gpd.comfort.indices.PET import PET
from t4gpd.comfort.indices.PMV import PMV
from t4gpd.comfort.indices.PT import PT
from t4gpd.comfort.indices.SET import SET
from t4gpd.comfort.indices.SETmist import SETmist
from t4gpd.comfort.indices.TmrtOut import TmrtOut
from t4gpd.comfort.indices.UTCI import UTCI


class UniversalThermalIndices(AbstractThermalComfortIndice):
'''
classdocs
'''

def __init__(self, sensorsGdf, AirTC='AirTC_Avg', RH='RH_Avg', WS_ms='WS_ms_Avg', T_mrt='T_mrt',
N='N', Albedo='Albedo_1_Avg', SRUp='SR01Up_1_Avg', SRDn='SR01Dn_1_Avg',
IRUp='IR01UpCo_1_Avg', IRDn='IR01DnCo_1_Avg'):
'''
Constructor
AirTC: air temperature [C]
RH: relative humidity [%]
Ws_ms: wind speed recorded at pedestrian level (at height 1.1 m) [m.s-1]
T_mrt: Mean radiant temperature [C]
N:
Albedo:
SRUp:
SRDn:
IRUp:
IRDn:
'''
self.ops = [
PET(sensorsGdf, AirTC, RH, WS_ms, T_mrt),
PMV(sensorsGdf, AirTC, RH, WS_ms, T_mrt),
PT(sensorsGdf, AirTC, RH, WS_ms, T_mrt),
UTCI(sensorsGdf, AirTC, RH, WS_ms, T_mrt),
SET(sensorsGdf, AirTC, RH, WS_ms, T_mrt),
ETU(sensorsGdf, AirTC, RH, WS_ms, T_mrt, N, Albedo, SRUp, SRDn, IRUp, IRDn),
TmrtOut(sensorsGdf, N, SRUp, SRDn, IRUp, IRDn),
SETmist(sensorsGdf, AirTC, RH, WS_ms, T_mrt)
]

def runWithArgs(self, row):
result = dict()
for op in self.ops:
result.update(op.runWithArgs(row))
return result
Empty file added t4gpd/comfort/__init__.py
Empty file.
155 changes: 155 additions & 0 deletions t4gpd/comfort/algo/CommonsLib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
'''
Created on 12 mai 2021
@author: tleduc
Copyright 2020-2021 Thomas Leduc
This file is part of t4gpd.
t4gpd is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
t4gpd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with t4gpd. If not, see <https://www.gnu.org/licenses/>.
'''
from numpy import abs, exp, mean, sin, sqrt

from t4gpd.comfort.algo.ConstantsLib import ConstantsLib


class CommonsLib(object):
'''
classdocs
'''

@staticmethod
def airPressure(AirTC, RH):
# Air pressure in Pascal and mPa
# Saturated water pressure
P_s = exp(18.956 - (4030.183 / (AirTC + 235))) # [mb] 10mb=1kPa=1000Pa=1000N.m-2
# Partial air pressure at T_air in Pascal
P_a = RH * P_s
# Partial air pressure at T_air in [kPa]
P_air = P_a / 1000
return P_a, P_air

@staticmethod
def convectiveHeatTransferCoefficient(AirTC, WS_ms, P_a):
# calculation of hc parameter depending on wind speed
if (0.1 <= WS_ms):
# convective heat transfer coefficient (W m2 K???1) after Staiger et al. (2012) as
# for external conditions only forced convection v_air > 0.1 m/s
hc = 12.1 * sqrt(WS_ms * P_a / 1013.25)
else:
# convective heat transfer coefficient (W m???2 K???1) after Parsons (2003) and Da Silva
var = WS_ms + 0.0052 * (ConstantsLib.M - 58)
hc_1 = 2.38 * abs(ConstantsLib.tsk - AirTC) ** 0.25
hc_2 = 3.5 + 5.2 * var
hc_3 = 8.7 * var ** 0.6
# max value of hc between natural and forced convection
hc = max(hc_1, hc_2, hc_3)
return hc

@staticmethod
def iterationEtu(w, heo, P_air, T_ao, hu, NUATF, SERFL, ERFS, EVCF):
'''
function to approximate ETU after Watanabe et al. (2014)
function for iterating the the universal effective temperature in degrees Celsius (C)
'''
# P_ETUs saturated water vapor pressure at ETU, kPa
P_ETUs = exp(18.956 - (4030.183 / (T_ao + 235))) # [mb] #first assumption that ETU is T_ao?????
P_ETUs = P_ETUs / 10 # [kPa]

# standard effective humid field
SEHF = w * heo * (P_air - 0.5 * P_ETUs)

ETU = T_ao + 1 / hu * (NUATF + SERFL + ERFS + SEHF + EVCF)

while True:
err_ETU = ETU - (T_ao + 1 / hu * (NUATF + SERFL + ERFS + SEHF + EVCF))
if (0.001 < abs(err_ETU)):
ETU = ETU + 0.1
P_ETUs = exp(18.956 - (4030.183 / (ETU + 235))) # [mb]
P_ETUs = P_ETUs / 10 # [kPa]
SEHF = w * heo * (P_air - 0.5 * P_ETUs)
else:
return ETU

@staticmethod
def iterationTcl(tsk, Icl, fcl, hc, T_kel, T_air, T_mrt, tcl_init):
'''
# ITERATION_TCL
# for PMV and PT calculation
# function for iterating the clothing surface temperature, in degrees Celsius (C)
'''
oldTcl = tcl_init
dif_min_tcl = 0.001 # C

while True:
newTcl = (oldTcl -
((oldTcl - tsk + Icl * fcl *
(3.96e-8 * ((oldTcl + T_kel) ** 4 - (T_mrt + T_kel) ** 4))
+hc * (oldTcl - T_air)) /
(1 + Icl * fcl * (3.96e-8 * 4 * (oldTcl + T_kel) ** 3
+hc * (oldTcl))))) # after Staiger et al. (2012)

dif = abs(oldTcl - newTcl)
oldTcl = mean([newTcl, oldTcl])
if (dif < dif_min_tcl):
return oldTcl
oldTcl = newTcl

@staticmethod
def radiantHeatTransferCoefficient(AirTC, RH, WS_ms, T_mrt):
# frd effective radiation area factor [-] assumed to be alpha_eff
frd = ConstantsLib.alpha_eff

P_a, _ = CommonsLib.airPressure(AirTC, RH)

hc = CommonsLib.convectiveHeatTransferCoefficient(AirTC, WS_ms, P_a)

# initial clothing surface temperature, in degrees Celsius (C)
tcl_init = AirTC

# Call function "ITERATION_TCL" the clothing surface temperature, in degrees Celsius (C)
tcl = CommonsLib.iterationTcl(
ConstantsLib.tsk, ConstantsLib.Icl, ConstantsLib.fcl, hc,
ConstantsLib.T_kel, AirTC, T_mrt, tcl_init)

# radiant heat transfer coefficient
hr = (ConstantsLib.epsi_p * ConstantsLib.sigma_B * frd *
((tcl + ConstantsLib.T_kel) ** 4 -
(T_mrt + ConstantsLib.T_kel) ** 4) /
((tcl + ConstantsLib.T_kel) - (T_mrt + ConstantsLib.T_kel)))
return hr

@staticmethod
def SDIF_Idn(N, SR01Up_1):
# Calculation of direct and diffuse shortwave radiation based on nebulosity approximation
# from MF weather station

# Calculation of clearness index K and diffuse solar radiation coeff DIFF
# K calcule en fonction de la regression quadratique de Black (1956)
# DIFF calcule en fonction de Muneer et al. (2004)
K = 0.803 - 0.458 * (N / 8.) ** 2 - 0.34 * (N / 8.)
if (K < 0.2):
DIFF = 0.98
else:
DIFF = 0.962 + 0.779 * K - 4.375 * K ** 2 + 2.716 * K ** 3

# Calculation of direct and diffuse repartition of incoming global radiation (SWin=UP)
SDIR = (1.0 - DIFF) * SR01Up_1
SDIF = DIFF * SR01Up_1

# Idn [W.m-2] normal direct solar radiation
Idn = SDIR / sin(ConstantsLib.h_sun_rad)

return (SDIF, Idn)
Loading

0 comments on commit fec0f2c

Please sign in to comment.