Skip to content

Commit

Permalink
Merge pull request #156 from EcoExtreML/fix_linter_issues
Browse files Browse the repository at this point in the history
Fix linter issues
  • Loading branch information
SarahAlidoost committed Apr 12, 2023
2 parents 978f17b + fbfcc72 commit 8454ce4
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 50 deletions.
53 changes: 52 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ you need to configure a few things following steps 1 through 5 below.

<details>
<summary>Steps 1 to 5 </summary>

### 1. Enable two-factor authentication

It is strongly recommended using two-factor authentication. Here is the link of
Expand Down Expand Up @@ -154,4 +155,54 @@ See the [exe readme](./exe/README.md).

## Follow MATLAB style guidelines

Please follow the style introduced in [MATLAB Guidelines 2.0, Richard Johnson](http://cnl.sogang.ac.kr/cnlab/lectures/programming/matlab/Richard_Johnson-MatlabStyle2_book.pdf).
When you are introducing new changes to the codes, please follow the style introduced in [MATLAB Guidelines 2.0, Richard Johnson](http://cnl.sogang.ac.kr/cnlab/lectures/programming/matlab/Richard_Johnson-MatlabStyle2_book.pdf).

When you submit a pull request, the code is also [checked](https://github.com/EcoExtreML/STEMMUS_SCOPE/actions/workflows/lint.yml) by the [MISS_HIT](misshit.org/) linter and style checker.
The status of `MISS_HIT` checks is shown below the pull request. The checks should be successful (green) before merging the pull request.
MISS_HIT is configured in [`miss_hit.cfg`](./miss_hit.cfg).

### Installing MISS_HIT
It is best practice to install packages in environments. See the dropdown menu for instructions.
However, you can also continue below to install MISS_HIT without these steps.

<details><summary>Python environment / conda instructions</summary>

You need to have a valid python installation on your system.

Create an enviroment with `venv` or conda:

### **Venv**
```bash
python3 -m venv misshit # python on windows.
```
Activate this environment
```bash
source misshit/bin/activate
```

Or on Windows:
```pwsh
./misshit/Scripts/Activate.ps1
```

### **conda**
```bash
conda env create --name misshit
conda activate misshit
```

</details>

Install miss hit (optionally in the conda or venv environment) with:
```bash
pip install miss-hit
```

To run the style checker or linter, navigate to the STEMMUS_SCOPE repository, and run the following commands:

```
mh_style
mh_lint
```

For more information on installing and using MISS_HIT, look at [MISS_HIT's readme](https://github.com/florianschanda/miss_hit#installation-via-pip).
1 change: 1 addition & 0 deletions pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Please re-generate exe file if matlab codes are changed. About how to create an
- [ ] @mentions of the person or team responsible for reviewing proposed changes.
- [ ] This pull request has a descriptive title.
- [ ] Code is written according to the [guidelines](http://cnl.sogang.ac.kr/cnlab/lectures/programming/matlab/Richard_Johnson-MatlabStyle2_book.pdf).
- [ ] The checks by [MISS_HIT style checker and linter](https://github.com/EcoExtreML/STEMMUS_SCOPE/blob/main/CONTRIBUTING.md#follow-matlab-style-guidelines), below the pull request, are successful (green).
- [ ] Documentation is available.
- [ ] Model runs successfully.
2 changes: 1 addition & 1 deletion src/+init/calcSoilMatricHead.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
section 5.4.3 in Yijian Zeng & Zhongbo Su (2013): STEMMUS (Simultaneous
Transfer of Energy, Mass and Momentum in Unsaturated Soil): Department
of Water Resources, ITC Faculty of Geo-Information Science and Earth
Observation, University of Twente ISBN: 978–90–61643517
Observation, University of Twente ISBN: 978-90-6164-351-7
%}
matricHead = H02 + domainZ * (H01 - H02) / delta;

Expand Down
2 changes: 1 addition & 1 deletion src/+init/calcSoilTemp.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
section 5.4.3 in Yijian Zeng & Zhongbo Su (2013): STEMMUS (Simultaneous
Transfer of Energy, Mass and Momentum in Unsaturated Soil): Department
of Water Resources, ITC Faculty of Geo-Information Science and Earth
Observation, University of Twente ISBN: 978–90–61643517
Observation, University of Twente ISBN: 978-90-6164-351-7
%}
soilTemperature = T02 + domainZ * (T01 - T02) / delta;

Expand Down
2 changes: 1 addition & 1 deletion src/+io/prepareInputData.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
InputPath: path of input data.
Output:
SiteProperties A structure containing site properties variables.
SiteProperties: A structure containing site properties variables.
SoilProperties: A structure containing soil variables.
TimeProperties: A structure containing time variables like time interval in seconds, normal is 1800 s in STEMMUS-SCOPE
and the total number of time steps.
Expand Down
2 changes: 1 addition & 1 deletion src/+io/select_input.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SoilProperties.CSSOIL = ScopeParameters.CSSOIL(digitsVector(43));
SoilProperties.lambdas = ScopeParameters.lambdas(digitsVector(21));
SoilProperties.rbs = ScopeParameters.rbs(digitsVector(44));
SoilProperties.SMC = Theta_LL(54, 1); %%%%%%% SoilProperties.SMC = flip£¨Theta_LL£©£¨:,1£©
SoilProperties.SMC = Theta_LL(54, 1);
SoilProperties.BSMBrightness = ScopeParameters.BSMBrightness(digitsVector(61));
SoilProperties.BSMlat = ScopeParameters.BSMlat(digitsVector(62));
SoilProperties.BSMlon = ScopeParameters.BSMlon(digitsVector(63));
Expand Down
4 changes: 2 additions & 2 deletions src/Condg_k_g.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
end
end

%%%%%% Unit of k_g is m^2 , with UnitC^2, unit has been converted as cm^2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% 10^(-12)is used to convert the micrometer(¦Ìm) to meter(m)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Unit of k_g is m^2 , with UnitC^2, unit has been converted as cm^2 %
%%% 10^(-12)is used to convert the micrometer to meter %
66 changes: 33 additions & 33 deletions src/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Meteorological Forcing Information Variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global MO Ta U Ts Zeta_MO % U_wind is the mean wind speed at height z_ref (m��s^-1), U is the wind speed at each time step.
global MO Ta U Ts Zeta_MO % U_wind is the mean wind speed at height z_ref (m/s^-1), U is the wind speed at each time step.
global Precip SH HR_a UseTs_msrmn % Notice that Evap and Precip have only one value for each time step. Precip needs to be measured in advance as the input.
global Gsc Sigma_E
global Rns Rnl
Expand Down Expand Up @@ -166,11 +166,11 @@
SAVEDTheta_LLh = zeros(mL, nD);
SAVEDTheta_LLT = zeros(mL, nD);
Ratio_ice = zeros(mL, nD);
KL_h = zeros(mL, nD); % The hydraulic conductivity(m��s^-1);
KfL_h = zeros(mL, nD); % The hydraulic conductivity considering ice blockking effect(m��s^-1);
KfL_T = zeros(mL, nD); % The depression temperature controlled by ice(m^2��Cels^-1��s^-1);
KL_T = zeros(mL, nD); % The conductivity controlled by thermal gradient(m^2��Cels^-1��s^-1);
D_Ta = zeros(mL, nD); % The thermal dispersivity for soil water (m^2��Cels^-1��s^-1);
KL_h = zeros(mL, nD); % The hydraulic conductivity(m/s^-1);
KfL_h = zeros(mL, nD); % The hydraulic conductivity considering ice blockking effect(m/s^-1);
KfL_T = zeros(mL, nD); % The depression temperature controlled by ice(m^2/Cels^-1/s^-1);
KL_T = zeros(mL, nD); % The conductivity controlled by thermal gradient(m^2/Cels^-1/s^-1);
D_Ta = zeros(mL, nD); % The thermal dispersivity for soil water (m^2/Cels^-1/s^-1);
Theta_L = zeros(mL, nD); % The soil moisture at the start of current time step;
Theta_LL = zeros(mL, nD); % The soil moisture at the end of current time step;
Theta_U = zeros(mL, nD); % The total soil moisture(water+ice) at the start of current time step;
Expand All @@ -189,12 +189,12 @@
TT_CRIT = zeros(mN, 1); % The soil ice critical temperature at the start of current time step;
EPCT = zeros(mN, 1);
Theta_V = zeros(mL, nD); % Volumetric gas content;
W = zeros(mL, nD); % Differential heat of wetting at the start of current time step(J��kg^-1);
WW = zeros(mL, nD); % Differential heat of wetting at the end of current time step(J��kg^-1);
% Integral heat of wetting in individual time step(J��m^-2); %%%%%%%%%%%%%%% Notice: the formulation of this in 'CondL_Tdisp' is not a sure. %%%%%%%%%%%%%%
MU_W = zeros(mL, nD); % Visocity of water(kg��m^?6?1��s^?6?1);
W = zeros(mL, nD); % Differential heat of wetting at the start of current time step(J/kg^-1);
WW = zeros(mL, nD); % Differential heat of wetting at the end of current time step(J/kg^-1);
% Integral heat of wetting in individual time step(J/m^-2); %%%%%%%%%%%%%%% Notice: the formulation of this in 'CondL_Tdisp' is not a sure. %%%%%%%%%%%%%%
MU_W = zeros(mL, nD); % Visocity of water(kg/m^?6?1/s^?6?1);
f0 = zeros(mL, nD); % Tortusity factor [Millington and Quirk (1961)]; kg.m^2.s^-2.m^-2.kg.m^-3
L_WT = zeros(mL, nD); % Liquid dispersion factor in Thermal dispersivity(kg��m^-1��s^-1)=-------------------------- m^2 (1.5548e-013 m^2);
L_WT = zeros(mL, nD); % Liquid dispersion factor in Thermal dispersivity(kg/m^-1/s^-1)=-------------------------- m^2 (1.5548e-013 m^2);
DhT = zeros(mN, 1); % Difference of matric head with respect to temperature; m. kg.m^-1.s^-1
RHS = zeros(mN, 1); % The right hand side part of equations in '*_EQ' subroutine;
EHCAP = zeros(mL, nD); % Effective heat capacity;
Expand All @@ -214,29 +214,29 @@
C6 = zeros(mL, nD); % Conductivity term coefficients related to soil air pressure;
C7 = zeros(mN, 1); % Gravity term coefficients;
C9 = zeros(mN, 1); % root water uptake coefficients;
QL = zeros(mL, nD); % Soil moisture mass flux (kg��m^-2��s^-1);
QL_D = zeros(mL, nD); % Convective moisturemass flux (kg��m^-2��s^-1);
QL_disp = zeros(mL, nD); % Dispersive moisture mass flux (kg��m^-2��s^-1);
QL_h = zeros(mL, nD); % potential driven moisture mass flux (kg��m^-2��s^-1);
QL_T = zeros(mL, nD); % temperature driven moisture mass flux (kg��m^-2��s^-1);
QL = zeros(mL, nD); % Soil moisture mass flux (kg/m^-2/s^-1);
QL_D = zeros(mL, nD); % Convective moisturemass flux (kg/m^-2/s^-1);
QL_disp = zeros(mL, nD); % Dispersive moisture mass flux (kg/m^-2/s^-1);
QL_h = zeros(mL, nD); % potential driven moisture mass flux (kg/m^-2/s^-1);
QL_T = zeros(mL, nD); % temperature driven moisture mass flux (kg/m^-2/s^-1);
HR = zeros(mN, 1); % The relative humidity in soil pores, used for calculatin the vapor density;
RHOV_s = zeros(mN, 1); % Saturated vapor density in soil pores (kg��m^-3);
RHOV = zeros(mN, 1); % Vapor density in soil pores (kg��m^-3);
RHOV_s = zeros(mN, 1); % Saturated vapor density in soil pores (kg/m^-3);
RHOV = zeros(mN, 1); % Vapor density in soil pores (kg/m^-3);
DRHOV_sT = zeros(mN, 1); % Derivative of saturated vapor density with respect to temperature;
DRHOVh = zeros(mN, 1); % Derivative of vapor density with respect to matric head;
DRHOVT = zeros(mN, 1); % Derivative of vapor density with respect to temperature;
RHODA = zeros(mN, 1); % Dry air density in soil pores(kg��m^-3);
RHODA = zeros(mN, 1); % Dry air density in soil pores(kg/m^-3);
DRHODAt = zeros(mN, 1); % Derivative of dry air density with respect to time;
DRHODAz = zeros(mN, 1); % Derivative of dry air density with respect to distance;
Xaa = zeros(mN, 1); % Coefficients of derivative of dry air density with respect to temperature and matric head;
XaT = zeros(mN, 1); % Coefficients of derivative of dry air density with respect to temperature and matric head;
Xah = zeros(mN, 1); % Coefficients of derivative of dry air density with respect to temperature and matric head;
D_Vg = zeros(mL, 1); % Gas phase longitudinal dispersion coefficient (m^2��s^-1);
D_V = zeros(mL, nD); % Molecular diffusivity of water vapor in soil(m^2��s^-1);
D_A = zeros(mN, 1); % Diffusivity of water vapor in air (m^2��s^-1);
D_Vg = zeros(mL, 1); % Gas phase longitudinal dispersion coefficient (m^2/s^-1);
D_V = zeros(mL, nD); % Molecular diffusivity of water vapor in soil(m^2/s^-1);
D_A = zeros(mN, 1); % Diffusivity of water vapor in air (m^2/s^-1);
k_g = zeros(mL, nD); % Intrinsic air permeability (m^2);
Sa = zeros(mL, nD); % Saturation degree of gas in soil pores;
V_A = zeros(mL, nD); % Soil air velocity (m��s^-1);
V_A = zeros(mL, nD); % Soil air velocity (m/s^-1);
Alpha_Lg = zeros(mL, nD); % Longitudinal dispersivity in gas phase (m);
POR_C = zeros(mL, nD); % The threshold air-filled porosity;
Eta = zeros(mL, nD); % Enhancement factor for thermal vapor transport in soil.
Expand Down Expand Up @@ -290,11 +290,11 @@
Ts = zeros(Nmsrmn, 1); % Surface temperature;
U = zeros(Nmsrmn, 1); % Wind speed (m.s^-1);
HR_a = zeros(Nmsrmn, 1); % Air relative humidity;
Rns = zeros(Nmsrmn, 1); % Net shortwave radiation(W��m^-2);
Rnl = zeros(Nmsrmn, 1); % Net longwave radiation(W��m^-2);
Rns = zeros(Nmsrmn, 1); % Net shortwave radiation(W/m^-2);
Rnl = zeros(Nmsrmn, 1); % Net longwave radiation(W/m^-2);
Rn = zeros(Nmsrmn, 1);
h_SUR = zeros(Nmsrmn, 1); % Observed matric potential at surface;
SH = zeros(Nmsrmn, 1); % Sensible heat (W��m^-2);
SH = zeros(Nmsrmn, 1); % Sensible heat (W/m^-2);
MO = zeros(Nmsrmn, 1); % Monin-Obukhov's stability parameter (MO Length);
Zeta_MO = zeros(Nmsrmn, 1); % Atmospheric stability parameter;
TopPg = zeros(Nmsrmn, 1); % Atmospheric pressure above the surface as the boundary condition (Pa);
Expand Down Expand Up @@ -385,7 +385,7 @@
h_TE = 0; % Value of 1 means that the temperature dependence %
% of matric head would be considered.Otherwise,0; %
W_Chg = 1; % Value of 0 means that the heat of wetting would %
% be calculated by Milly's method��Otherwise,1. The %
% be calculated by Milly's method/Otherwise,1. The %
% method of Lyle Prunty would be used; %
ThmrlCondCap = 1; % 1; % The indicator for choosing Milly's effective thermal capacity and conductivity %
% formulation to verify the vapor and heat transport in extremly dry soil. %
Expand Down Expand Up @@ -424,13 +424,13 @@
W0 = 1.001 * 10^3; % Coefficient for calculating differential heat of wetting by Milly's method
L0 = 597.3 * 4.182;
Tr = 20; % Reference temperature
c_L = 4.186; % Specific heat capacity of liquid water (J��g^-1��Cels^-1) %%%%%%%%% Notice the original unit is 4186kg^-1
c_V = 1.870; % Specific heat capacity of vapor (J��g^-1��Cels^-1)
c_L = 4.186; % Specific heat capacity of liquid water (J/g^-1/Cels^-1) %%%%%%%%% Notice the original unit is 4186kg^-1
c_V = 1.870; % Specific heat capacity of vapor (J/g^-1/Cels^-1)
c_a = 1.005;
% c_a=1.005; % 0.0003*4.186; %Specific heat capacity of dry air (J��g^-1��Cels^-1)
c_i = 2.0455; % Specific heat capacity of ice (J��g^-1��Cels^-1)
Gsc = 1360; % The solar constant (1360 W��m^-2)
Sigma_E = 4.90 * 10^(-9); % The stefan-Boltzman constant.(=4.90*10^(-9) MJ��m^-2��Cels^-4��d^-1)
% c_a=1.005; % 0.0003*4.186; %Specific heat capacity of dry air (J/g^-1/Cels^-1)
c_i = 2.0455; % Specific heat capacity of ice (J/g^-1/Cels^-1)
Gsc = 1360; % The solar constant (1360 W/m^-2)
Sigma_E = 4.90 * 10^(-9); % The stefan-Boltzman constant.(=4.90*10^(-9) MJ/m^-2/Cels^-4/d^-1)
P_g0 = 95197.850; % 951978.50; % The mean atmospheric pressure (Should be given in new simulation period subroutine.)
rroot = 1.5 * 1e-3;
RTB = 1000; % initial root total biomass (g m-2)
Expand Down
8 changes: 4 additions & 4 deletions src/STEMMUS_SCOPE.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% STEMMUS-SCOPE.m (script)

% STEMMUS-SCOPE is a model for Integrated modeling of canopy photosynthesis, fluorescence,
% and the transfer of energy, mass, and momentum in the soilplantatmosphere continuum
% and the transfer of energy, mass, and momentum in the soil-plant-atmosphere continuum
%
% Version: 1.0.1
%
Expand Down Expand Up @@ -115,9 +115,9 @@
end

F = struct('FileID', {'Simulation_Name', 'soil_file', 'leaf_file', 'atmos_file'...
'Dataset_dir', 't_file', 'year_file', 'Rin_file', 'Rli_file' ...
, 'p_file', 'Ta_file', 'ea_file', 'u_file', 'CO2_file', 'z_file', 'tts_file' ...
, 'LAI_file', 'hc_file', 'SMC_file', 'Vcmax_file', 'Cab_file', 'LIDF_file'});
'Dataset_dir', 't_file', 'year_file', 'Rin_file', 'Rli_file' ...
, 'p_file', 'Ta_file', 'ea_file', 'u_file', 'CO2_file', 'z_file', 'tts_file' ...
, 'LAI_file', 'hc_file', 'SMC_file', 'Vcmax_file', 'Cab_file', 'LIDF_file'});
for i = 1:length(F)
k = find(strcmp(F(i).FileID, strtok(X(:, 1))));
if ~isempty(k)
Expand Down
3 changes: 2 additions & 1 deletion src/ebal.m
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@
Tch(abs(Tch) > 100) = Ta;
Tcu(abs(Tcu) > 100) = Ta;
Ts(abs(Ts) > 100) = Ta;
if any(isnan(Tch)) || any(isnan(Tcu(:))) warning('Canopy temperature gives NaNs');
if any(isnan(Tch)) || any(isnan(Tcu(:)))
warning('Canopy temperature gives NaNs');
end
if any(isnan(Ts))
warning('Soil temperature gives NaNs');
Expand Down
4 changes: 2 additions & 2 deletions src/hPARM.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function [Chh, ChT, Khh, KhT, Kha, Vvh, VvT, Chg, DTheta_LLh, DTheta_LLT, DTheta_UUh, SAVEDTheta_UUh, SAVEDTheta_LLh] = hPARM(NL, hh, ...
h, TT, T, Theta_LL, Theta_L, DTheta_LLh, DTheta_LLT, RHOV, RHOL, Theta_V, V_A, Eta, DRHOVh, ...
DRHOVT, KfL_h, D_Ta, KL_T, D_V, D_Vg, COR, Beta_g, Gamma0, Gamma_w, KLa_Switch, DVa_Switch, hThmrl, Thmrlefc, nD, TT_CRIT, T0, h_frez, hh_frez, Theta_UU, Theta_U, CORh, DTheta_UUh, Chh, ChT, Khh, KhT)
h, TT, T, Theta_LL, Theta_L, DTheta_LLh, DTheta_LLT, RHOV, RHOL, Theta_V, V_A, Eta, DRHOVh, ...
DRHOVT, KfL_h, D_Ta, KL_T, D_V, D_Vg, COR, Beta_g, Gamma0, Gamma_w, KLa_Switch, DVa_Switch, hThmrl, Thmrlefc, nD, TT_CRIT, T0, h_frez, hh_frez, Theta_UU, Theta_U, CORh, DTheta_UUh, Chh, ChT, Khh, KhT)

% piecewise linear reduction function parameters of h;(Wesseling
% 1991,Veenhof and McBride 1994)
Expand Down
Loading

0 comments on commit 8454ce4

Please sign in to comment.