src Documentation Release Pierre Humblot June 02, 2014
Contents 1 src Package 3 1.1 src Package............................................... 3 1.2 Subpackages............................................... 3 2 Indices and tables 7 Python Module Index 9 i
ii
src Documentation, Release Contents: Contents 1
src Documentation, Release 2 Contents
CHAPTER 1 src Package 1.1 src Package The package PYSTICS. 1.2 Subpackages 1.2.1 create_input_files Package create_input_files Package The pacakge to generate stics input files. create_climat Module The module to create climate files and write them to the database. TODO : CONNECTION TO THE INTERNET AND CLIMATE ONLINE DATABASE create_itk Module The module to create itk files from the database. create_sol Module The module to create sol files from the database. create_tec Module The module to create tec files from the database. 3
src Documentation, Release 1.2.2 psql Package psql Package The package which deals with the database. psql Module The module to connect to psql database. A priori nous allons utiliser psycopg2 pour gérer postgresql téléchargement http://www.stickpeople.com/projects/python/win-psycopg/ si il ne trouve pas python dans le registre, il faut remplacer le.exe en.zip, dézipper et copier le dossier dans Lib/sitepackages. Aide configuration postgresql : https://help.ubuntu.com/10.04/serverguide/postgresql.html $ sudo apt-get install postgresql listen_addresses = localhost (dans /etc/postgresql/9.1/main/postgresql.conf) $ sudo -u postgres psql postgres (connection postgres sb as postgres user) # ALTER USER postgres with encrypted password your_password ; (set new password, #q to quit) $sudo -u postgres psql -U postgres -d postgres -c alter user postgres with password password ; (idem ci dessus mais en shell) local all postgres md5 (dans /etc/postgresql/9.1/main/pg_hba.conf, mettre mda5 à la place de peer) $ sudo /etc/init.d/postgresql-8.4 restart (restart psql server) ensuite creation de la database : $ sudo psql -U postgres -d postgres # CREATE DATABASE pystics OU, avec le terminal $ cd /usr/share/postgresql/9.1 $ createdb -h localhost -p 5432 -U postgres pystics Ensuite, charger la base de donnees de base $ cd /home/pierre/dropbox/travail/these/artix_python/pystics/database/ $ sudo psql -U postgres -d pystics -a -f template_db.sql class src.psql.psql.connectiondatabase(name_db, user, password, host, port) Mise en place et interfaçage d une base de données psql Constuctor. Creation of the connection and of the cursor Parameters name_db (str) The name of the database to connect to usr (str) user name password (str) Password host (str) The host (ex : localhost) port (int) The port (ex 5430) execute_query(query) Execution of the query, with error detection 4 Chapter 1. src Package
src Documentation, Release Parameters query (str) the sql query to execute query(query) Execution of the query and return result. Parameters query (str) the sql query to execute Returns tup A tuple of tuple result_query() Return the result of the previous query Returns tup A tuple of tuple 1.2.3 simulation Package simulation Package The main package where simulations are defined and launched. run_loop Module The module which performs stics simulations for different nitrogen/water input values. class src.simulation.run_loop.runloop(nitrogen, water, finit, nomsol, fstation, fclim1, fclim2, fplt, ftec, flai, begindate, enddate, culturean) The class to perform the various simulations according to various N and W values Constructor. Parameters nitrogen (list) nitrogen values in a list of integers (in kg/ha) water (list) irrigation percentage values (from 0 to 100%) finit (str) init file nomsol (str) soil name (usually a number) fstation (str) station climate file fclim1 (str) climate file 1 fclim2 (str) climate file 2 fplt (str) plant file ftec (str) tec file flai (str) lai file begindate (str) date of simulation beginning enddate (str) date of simulation ending culturean (int) yearly crop or not (1 or 0) all_simulations() High level functions which performs all required simulations. automatic_irrigation_simulation() The first simulation should determine the amount of water needed for optimal yields 1.2. Subpackages 5
src Documentation, Release save_results() Reads output files and save the results in the database. single_simulation(n, W) Performs a single stics simulation for N and W fixed. Parameters N (int) Nitrogen input (in kg/ha) W (float) Irrigation as a percentage of irrigation optimal amount (in ) set_simulation Module Main module where simulations to performed are defined. 1.2.4 stics Package stics Package The package which prepare stics input files, run stics simulations and get stics output. get_stics_output Module The module which reads stics output files and write useful results to the database. load_stics_input Module The module which loads in the stics simulation workspace all the necessary files to perform the current simulation run_stics Module The module which run the stics program (stics.exe). class src.stics.run_stics.runstics(path_stics) The class for executing the STICS.exe Constructor. Parameters path_stics (str) path to stics directory run_stics() Call the stics executable file through the shell command... note:: Test if stics execution failed 1.2.5 xml Package xml Package The module for xml parsing. process_xml Module The module which deals with xml files. 6 Chapter 1. src Package
CHAPTER 2 Indices and tables genindex modindex search 7
src Documentation, Release 8 Chapter 2. Indices and tables
Python Module Index c create_climat, 3 create_itk, 3 create_sol, 3 create_tec, 3 g get_stics_output, 6 l load_stics_input, 6 p process_xml, 6 psql, 4 r run_loop, 5 run_stics, 6 s set_simulation, 6 src. init, 3 src.create_input_files, 3 src.create_input_files.create_climat, 3 src.create_input_files.create_itk, 3 src.create_input_files.create_sol, 3 src.create_input_files.create_tec, 3 src.psql, 4 src.psql.psql, 4 src.simulation, 5 src.simulation.run_loop, 5 src.simulation.set_simulation, 6 src.stics, 6 src.stics.get_stics_output, 6 src.stics.load_stics_input, 6 src.stics.run_stics, 6 src.xml, 6 src.xml.process_xml, 6 9