src Documentation
Release
Pierre Humblot
Contents
1 src Package 3
1.1 srcPackage . . . 3 1.2 Subpackages . . . 3
2 Indices and tables 7
Python Module Index 9
src Documentation, Release
Contents:
src Documentation, Release
CHAPTER
1
src Package
1.1
src
Package
The package PYSTICS.
1.2 Subpackages
1.2.1 create_input_files Package
create_input_filesPackage
The pacakge to generate stics input files.
create_climatModule
The module to create climate files and write them to the database. TODO : CONNECTION TO THE INTERNET AND CLIMATE ONLINE DATABASE
create_itkModule
The module to create itk files from the database.
create_solModule
The module to create sol files from the database.
create_tecModule
The module to create tec files from the database.
src Documentation, Release
1.2.2 psql Package
psqlPackage
The package which deals with the database.
psqlModule
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
classsrc.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
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
simulationPackage
The main package where simulations are defined and launched.
run_loopModule
The module which performs stics simulations for different nitrogen/water input values.
classsrc.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
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_simulationModule
Main module where simulations to performed are defined.
1.2.4 stics Package
sticsPackage
The package which prepare stics input files, run stics simulations and get stics output.
get_stics_outputModule
The module which reads stics output files and write useful results to the database.
load_stics_inputModule
The module which loads in the stics simulation workspace all the necessary files to perform the current simulation
run_sticsModule
The module which run the stics program (stics.exe).
classsrc.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
xmlPackage
The module for xml parsing.
process_xmlModule
The module which deals with xml files.
CHAPTER
2
Indices and tables
• genindex
• modindex
• search
src Documentation, Release
Python Module Index