Difference between revisions of "Sacramento SMA"

From Agrineer.org Wiki
Jump to: navigation, search
(Implementation)
(SMA Module Files)
Line 3: Line 3:
 
== SMA Module Files ==
 
== SMA Module Files ==
 
There are four C programs which make up the module.<br>
 
There are four C programs which make up the module.<br>
The first two below are interface contributions:
+
The first two are interface contributions:
 
   * ini.c - reads ini style input variables, from [https://github.com/benhoyt/inih Ben Hoyt]
 
   * ini.c - reads ini style input variables, from [https://github.com/benhoyt/inih Ben Hoyt]
 
   * sma.c - interfaces between the SME and the SMA model, from Agrineer
 
   * sma.c - interfaces between the SME and the SMA model, from Agrineer

Revision as of 15:24, 27 January 2019

The SMA project/module provides a back-end soil moisture model for the Soil Moisture Estimator tool and implements a custom C interface to the National Weather Service-University of Arizona Sacramento Soil Moisture Accounting (SMA) model.

SMA Module Files

There are four C programs which make up the module.
The first two are interface contributions:

 * ini.c - reads ini style input variables, from Ben Hoyt
 * sma.c - interfaces between the SME and the SMA model, from Agrineer

The next two implement the actual model:

 * sacramento_state.c (a version of sac_sma.c)
 * fland1.c 

and were originally part of the MOSCEM package developed at University of Arizona by Yuqiong Liu and others. Permission to use and distribute these files was granted by Professor Hoshin Gupta (University of Arizona) on 2009-08-28.

The last two programs above were originally downloaded from Google's cached copy of http://info.science.uva.nl/ibed/research/Research_Fields/cbpg/software/code/moscem.0.tar.gz 2009-08-20 by Felix Andrews.

For an R language version go to Hydromad. Many descriptive phrases and source code on the model came from Hydromad.

The program sacramento_state.c (sac_sma.c) was based on code from the MOSCEM project and simplified by Felix Andrews <felix@nfrac.org> 2010-02-01. Adapted to return state by Joseph Guillaume 2013-10-24.

The program fland1.c executes the SAC-SMA operation for one time period. It was initially written in FORTRAN by Eric Anderson-HRL in April 1979. In 1993-94 Patrice O. Yapo rewrote the program in the C language. The transition from FORTRAN to C explains why the C programs use parameters by reference, an artifact from FORTRAN.

Implementation

The SMA module is part of the SME project which can be downloaded from here. The SMA module is in the "Sacramento" directory.

The main sma.c program can be run standalone. To create the sma executable, type "make" in the Sacramento directory. By default the executable is moved to its parent directory for use by sme.py. Modify the "makefile" to your preference.

Usage:

 sma -c config_file
 Where the configuration file holds "ini" parameters for:
loads - Filepath to atmospheric loads (precip and et) data, described below. soil - Filepath to soil attribute data, described below. output - Filepath to output report, described below. rain - Optional filepath for local rain input data. Overrides climate model rain data. irr - Optional filepath for irrigation events. Events count as precipitation.

An example configuration file:

[FILES]
loads = /home/agrineer/sma/input/loads.csv
soil = /home/agrineer/sma/input/soil.csv
output = /home/agrineer/sma/output/output.csv
rain = /home/agrineer/sma/input/rain.csv
irr = /home/agrineer/sma/input/irr.csv

Note that when used with the SME the SMA configuration file is constructed on the fly, based on SME data and input files. Since the SMA is a backend module the SME, the user must specify the soil model and its parameters in the SME configuration file.

For example, to reference the SMA with parameters in the sme.py, the SME configuration file might have:

[SoilModel]
model = SMA

[SMA]
program = /home/agrineer/sme/sme/sma
soil = /home/agrineer/sme/tmp/soil.csv
rain = /home/agrineer/sme/tmp/rain.csv
irr = /home/agrineer/sme/tmp/irr.csv

The "loads" file (data) would be generated by the WRF model and ETo calculations and then submitted to the SMA program.

Note that the web SME tool would construct the configuration file for the sme.py program as above. See SME description here for more detail.

Input file format and variable description

Atmospheric Loads

Soil Attributes

Local Rain Events

Irrigation Events

 - read_loads()
 - read_soils()
 - replace_precip()
 - add_irrigations()

 Output file documention can be found in the main() routine.

Paper References

Links describing the Sacramento Soil Moisture Accounting model:

calb_report7-8.pdf

EMS2009 Bai et al

hydromadPaper.pdf

MR2007_305.pdf

PAP014820.pdf

SSURGO_data_2004.pdf

Plus many more by searching for "Sacramento Soil Moisture Accounting".