Skip to content

Commit

Permalink
Fix doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
soaressgabriel committed Jun 30, 2021
1 parent 789d29d commit fe9db2c
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 68 deletions.
4 changes: 3 additions & 1 deletion modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# RUBEM RUBEM is a distributed hydrological model to calculate monthly
# RUBEM is a distributed hydrological model to calculate monthly
# flows with changes in land use over time.
# Copyright (C) 2020-2021 LabSid PHA EPUSP

Expand All @@ -18,6 +18,8 @@
#
# Contact: rubem.hydrological@labsid.eng.br

"""Rainfall rUnoff Balance Enhanced Model components."""

__author__ = "LabSid PHA EPUSP"
__email__ = "rubem.hydrological@labsid.eng.br"
__copyright__ = "Copyright 2020-2021, LabSid PHA EPUSP"
Expand Down
24 changes: 13 additions & 11 deletions modules/evapotranspiration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# RUBEM RUBEM is a distributed hydrological model to calculate monthly
# RUBEM is a distributed hydrological model to calculate monthly
# flows with changes in land use over time.
# Copyright (C) 2020-2021 LabSid PHA EPUSP

Expand All @@ -18,6 +18,8 @@
#
# Contact: rubem.hydrological@labsid.eng.br

"""Rainfall rUnoff Balance Enhanced Model Evapotranspiration."""

__author__ = "LabSid PHA EPUSP"
__email__ = "rubem.hydrological@labsid.eng.br"
__copyright__ = "Copyright 2020-2021, LabSid PHA EPUSP"
Expand All @@ -27,9 +29,9 @@

########## Evapotranspiration Module ##########

# - Function that returns Ks for evapotranspiration of vegetated area
def Ks_calc(self, pcr, TUr, TUw, TUcc):
"""
"""Return Ks for evapotranspiration of vegetated area.
:param pcr:
:pcr type:
Expand All @@ -51,9 +53,9 @@ def Ks_calc(self, pcr, TUr, TUw, TUcc):
return Ks


# - Function that returns evapotranspiration of vegetated area
def ETav_calc(self, pcr, ETp, Kc, Ks):
"""
"""Return evapotranspiration of vegetated area.
:param pcr:
:pcr type:
Expand All @@ -73,9 +75,9 @@ def ETav_calc(self, pcr, ETp, Kc, Ks):
return ETav


# - Function that returns Kp for evapotranspiration of open water area
def Kp_calc(self, pcr, B, U_2, UR):
"""
"""Return Kp for evapotranspiration of open water area.
:param pcr:
:pcr type:
Expand All @@ -95,9 +97,9 @@ def Kp_calc(self, pcr, B, U_2, UR):
return Kp


# - Function that returns Ks for evapotranspiration of water area
def ETao_calc(self, pcr, ETp, Kp, prec, Ao):
"""
"""Return Ks for evapotranspiration of water area.
:param pcr:
:pcr type:
Expand Down Expand Up @@ -136,9 +138,9 @@ def ETao_calc(self, pcr, ETp, Kp, prec, Ao):
return ETao


# - Function that returns Ks for evapotranspiration of bare soil area
def ETas_calc(self, pcr, ETp, kc_min, Ks):
"""
"""Return Ks for evapotranspiration of bare soil area.
:param pcr:
:pcr type:
Expand Down
24 changes: 13 additions & 11 deletions modules/interception.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# RUBEM RUBEM is a distributed hydrological model to calculate monthly
# RUBEM is a distributed hydrological model to calculate monthly
# flows with changes in land use over time.
# Copyright (C) 2020-2021 LabSid PHA EPUSP

Expand All @@ -18,6 +18,8 @@
#
# Contact: rubem.hydrological@labsid.eng.br

"""Rainfall rUnoff Balance Enhanced Model Interception."""

__author__ = "LabSid PHA EPUSP"
__email__ = "rubem.hydrological@labsid.eng.br"
__copyright__ = "Copyright 2020-2021, LabSid PHA EPUSP"
Expand All @@ -27,9 +29,9 @@

########## Interception Module ##########

# - Function that returns srmin and srmax
def sr_calc(self, pcr, NDVI):
"""
"""Return SRmin and SRmax.
:param pcr:
:pcr type:
Expand All @@ -43,9 +45,9 @@ def sr_calc(self, pcr, NDVI):
return SR


# - Function that returns Kc
def kc_calc(self, pcr, NDVI, ndvi_min, ndvi_max, kc_min, kc_max):
"""
"""Return Kc.
:param pcr:
:pcr type:
Expand All @@ -72,9 +74,9 @@ def kc_calc(self, pcr, NDVI, ndvi_min, ndvi_max, kc_min, kc_max):
return Kc


# - Function that returns fpar
def fpar_calc(self, pcr, fpar_min, fpar_max, SR, sr_min, sr_max):
"""
"""Return FPAR.
:param pcr:
:pcr type:
Expand All @@ -101,9 +103,9 @@ def fpar_calc(self, pcr, fpar_min, fpar_max, SR, sr_min, sr_max):
return FPAR


# - Function that returns LAI
def lai_function(self, pcr, FPAR, fpar_max, lai_max):
"""
"""Return LAI.
:param pcr:
:pcr type:
Expand All @@ -123,9 +125,9 @@ def lai_function(self, pcr, FPAR, fpar_max, lai_max):
return LAI


# - Function that returns Interception
def Interception_function(self, pcr, alfa, LAI, precipitation, rainy_days, a_v):
"""
"""Return Interception.
:param pcr:
:pcr type:
Expand Down
19 changes: 13 additions & 6 deletions modules/soil.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# RUBEM RUBEM is a distributed hydrological model to calculate monthly
# RUBEM is a distributed hydrological model to calculate monthly
# flows with changes in land use over time.
# Copyright (C) 2020-2021 LabSid PHA EPUSP

Expand All @@ -18,6 +18,8 @@
#
# Contact: rubem.hydrological@labsid.eng.br

"""Rainfall rUnoff Balance Enhanced Model Soil."""

__author__ = "LabSid PHA EPUSP"
__email__ = "rubem.hydrological@labsid.eng.br"
__copyright__ = "Copyright 2020-2021, LabSid PHA EPUSP"
Expand All @@ -27,7 +29,8 @@

########## Lateral Flow ##########
def LF_calc(self, pcr, f, Kr, TUr, TUsat):
"""
"""[summary].
:param pcr:
:pcr type:
Expand All @@ -49,7 +52,8 @@ def LF_calc(self, pcr, f, Kr, TUr, TUsat):

########## Recharge ##########
def REC_calc(self, pcr, f, Kr, TUr, TUsat):
"""
"""[summary].
:param pcr:
:pcr type:
Expand All @@ -74,7 +78,8 @@ def REC_calc(self, pcr, f, Kr, TUr, TUsat):

########## Base Flow ##########
def EB_calc(self, pcr, EB_prev, alfaS, REC, TUs, EB_lim):
"""
"""[summary].
:param pcr:
:pcr type:
Expand Down Expand Up @@ -105,7 +110,8 @@ def EB_calc(self, pcr, EB_prev, alfaS, REC, TUs, EB_lim):
########## Soil Balance ##########
# First soil layer
def TUr_calc(self, pcr, TUrprev, P, I, ES, LF, REC, ETr, Ao, Tsat):
"""
"""[summary].
:param pcr:
:pcr type:
Expand Down Expand Up @@ -152,7 +158,8 @@ def TUr_calc(self, pcr, TUrprev, P, I, ES, LF, REC, ETr, Ao, Tsat):

# Second soil layer
def TUs_calc(self, pcr, TUsprev, REC, EB):
"""
"""[summary].
:param pcr:
:pcr type:
Expand Down
28 changes: 15 additions & 13 deletions modules/surface_runoff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# RUBEM RUBEM is a distributed hydrological model to calculate monthly
# RUBEM is a distributed hydrological model to calculate monthly
# flows with changes in land use over time.
# Copyright (C) 2020-2021 LabSid PHA EPUSP

Expand All @@ -18,6 +18,8 @@
#
# Contact: rubem.hydrological@labsid.eng.br

"""Rainfall rUnoff Balance Enhanced Model Surface Runoff."""

__author__ = "LabSid PHA EPUSP"
__email__ = "rubem.hydrological@labsid.eng.br"
__copyright__ = "Copyright 2020-2021, LabSid PHA EPUSP"
Expand All @@ -27,9 +29,9 @@

########## Surface runoff ##########

# - Function that returns Ch
def Ch_calc(self, pcr, TUr, dg, Zr, tpor, b):
"""
"""Return Ch.
:param pcr:
:pcr type:
Expand All @@ -56,9 +58,9 @@ def Ch_calc(self, pcr, TUr, dg, Zr, tpor, b):
return Ch


# - Function that returns Cper
def Cper_calc(self, pcr, TUw, dg, Zr, S, manning, w1, w2, w3):
"""
"""Return Cper.
:param pcr:
:pcr type:
Expand Down Expand Up @@ -94,9 +96,9 @@ def Cper_calc(self, pcr, TUw, dg, Zr, S, manning, w1, w2, w3):
return Cper


# - Function that returns Cimp
def Cimp_calc(self, pcr, ao, ai):
"""
"""Return Cimp.
:param pcr:
:pcr type:
Expand All @@ -114,9 +116,9 @@ def Cimp_calc(self, pcr, ao, ai):
return Aimp, Cimp


# - Function that returns Cwp
def Cwp_calc(self, pcr, Aimp, Cper, Cimp):
"""
"""Return Cwp.
:param pcr:
:pcr type:
Expand All @@ -136,9 +138,9 @@ def Cwp_calc(self, pcr, Aimp, Cper, Cimp):
return Cwp


# - Function that returns Csr
def Csr_calc(self, pcr, Cwp, P_24, RCD):
"""
"""Return Csr.
:param pcr:
:pcr type:
Expand All @@ -158,9 +160,9 @@ def Csr_calc(self, pcr, Cwp, P_24, RCD):
return Csr


# - Function that returns Surface runoff
def ES_calc(self, pcr, Csr, Ch, prec, I, Ao, ETao):
"""
"""Return surface runoff.
:param pcr:
:pcr type:
Expand Down
30 changes: 22 additions & 8 deletions rubem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
# RUBEM RUBEM is a distributed hydrological model to calculate monthly
# RUBEM is a distributed hydrological model to calculate monthly
# flows with changes in land use over time.
# Copyright (C) 2020-2021 LabSid PHA EPUSP

Expand All @@ -18,6 +18,8 @@
#
# Contact: rubem.hydrological@labsid.eng.br

"""Rainfall rUnoff Balance Enhanced Model."""

__author__ = "LabSid PHA EPUSP"
__email__ = "rubem.hydrological@labsid.eng.br"
__copyright__ = "Copyright 2020-2021, LabSid PHA EPUSP"
Expand Down Expand Up @@ -45,11 +47,14 @@
from utilities.file_generators import *


########## Dynamic Model ##########
class Modelo(pcrfw.DynamicModel):
"""Constructor"""

"""Rainfall rUnoff Balance Enhanced Model.
Uses the PCRaster Dynamic Modelling Framework.
"""

def __init__(self):
"""Contains the initialization of the model class."""
pcrfw.DynamicModel.__init__(self)
print("RUBEM::Reading input files...", end=" ", flush=True)

Expand Down Expand Up @@ -154,7 +159,11 @@ def __init__(self):
self.ref = getRefInfo(self, self.demTif)

def initial(self):
""" """
"""Contains the initialization of variables used in the model.
Contains operations to initialise the state of the model at time step 0.
Operations included in this section are executed once.
"""
# Read DEM file
self.dem = pcrfw.readmap(self.dem_file)

Expand Down Expand Up @@ -257,13 +266,18 @@ def initial(self):
self.sampleLocs
) # read sample map location as nominal
self.mvalue = -999
# converts sample location to multidimensional array
# Convert sample location to multidimensional array
self.sample_array = pcrfw.pcr2numpy(sample_map, self.mvalue)
# create 1d array with unique locations values (1 to N number os locations)
self.sample_vals = np.asarray(np.unique(self.sample_array))

def dynamic(self):
""" """
"""Contains the implementation of the dynamic section of the model.
Contains the operations that are executed consecutively each time step.
Results of a previous time step can be used as input for the current time step.
The dynamic section is executed a specified number of timesteps.
"""
t = self.currentStep
print(f"Time: {t}", flush=True)

Expand Down Expand Up @@ -557,7 +571,7 @@ def dynamic(self):
# Check whether the generation of time series has been activated
if genTss:
print("RUBEM::Converting *.tss files to *.csv...", end=" ", flush=True)
# Converts generated time series to .csv format and removes .tss files
# Convert generated time series to .csv format and removes .tss files
tss2csv(myModel.outpath)
print("OK", flush=True) # Converting *.tss files to *.csv...

Expand Down
Loading

0 comments on commit fe9db2c

Please sign in to comment.