• No results found

src Documentation Release Pierre Humblot

N/A
N/A
Protected

Academic year: 2021

Share "src Documentation Release Pierre Humblot"

Copied!
13
0
0

Loading.... (view fulltext now)

Full text

(1)

src Documentation

Release

Pierre Humblot

(2)
(3)

Contents

1 src Package 3

1.1 srcPackage . . . 3 1.2 Subpackages . . . 3

2 Indices and tables 7

Python Module Index 9

(4)
(5)

src Documentation, Release

Contents:

(6)

src Documentation, Release

(7)

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.

(8)

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

(9)

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

(10)

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.

(11)

CHAPTER

2

Indices and tables

• genindex

• modindex

• search

(12)

src Documentation, Release

(13)

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

References

Related documents