source: trunk/src/simul_zi.py @ 56

Last change on this file since 56 was 9, checked in by pinsard, 10 years ago

fix thanks to coding rules

File size: 3.8 KB
Line 
1 #!/usr/bin/env python
2# -*- coding: iso-8859-1 -*-
3
4__docformat__ = 'reStructuredText'
5__autodoc__ = ['simul_zi']
6
7import sys
8
9def simul_zi(index_simulation):
10    """
11
12    ========
13    simul_zi
14    ========
15
16    .. :py:function:: simul_zi(index_simulation)
17
18    DESCRIPTION
19    ===========
20
21    Charge en mémoire des info simulées de zones of interest (zi)
22
23    Simulation #1
24      3 zones of interest named ``zone``\ xx
25
26    Parameters
27    ----------
28
29    index_simulation : {1}
30
31    Returns
32    -------
33
34    west_value : array_like
35       west most longitudes
36
37    east_value : array_like
38       east most longitudes
39
40    north_value : array_like
41       north most latitudes
42
43    south_value : array_like
44       south most latitudes
45
46    zi_code : array_like of strings
47       codes of the zone of interest
48
49    zi_description: array_like of strings
50       descriptions of the zone of interest
51
52    Raises
53    ------
54
55    Missing parameters
56
57
58    EXAMPLES
59    ========
60
61    >>> # From scratch to create 3 zones of interest associated arrays::
62    >>>
63    >>> index_simulation = 1
64    >>> (west_value, east_value, north_value, south_value, zi_code, zi_description) = simul_zi(index_simulation)
65    >>> print(west_value, east_value, north_value, south_value, zi_code, zi_description)
66    ([-19.0, -18.0, -17.0], [-14.0, -13.0, -12.0], [11.0, 12.0, 13.0], [9.0, 10.0, 11.0], ['zone01', 'zone02', 'zone03'], ['zone 01', 'zone 02', 'zone 03'])
67
68    To write these arrays in
69    :file:`${PROJECT_OD}/maps/varamma_zi_write_zi_py.csv`::
70
71    see :func:`write_zi`
72
73    To plot the zones of interest on a map grid:
74
75    see :func:`plot_zi`
76
77    SEE ALSO
78    ========
79
80    :ref:`zones`
81
82    :py:func:`write_zi`
83    :py:func:`plot_zi`
84
85    TODO
86    ====
87
88    get rid of matlab stuff
89
90    include in sphinx processing
91
92    EVOLUTIONS
93    ==========
94
95    $Id: simul_zi.py 348 2011-08-17 07:12:51Z pinsard $
96
97    $URL: svn+ssh://lelod@forge.ipsl.jussieu.fr/ipsl/forge/projets/varamma/svn/trunk/src/simul_zi.py $
98
99    - fplod 20110907T151038Z aedon.locean-ipsl.upmc.fr (Darwin)
100
101      * complete description
102      * no more preallocation
103
104    - fplod 20110816T103232Z aedon.locean-ipsl.upmc.fr (Darwin)
105
106      * creation from simul_zi.m
107
108    """
109
110    result = -1
111    #
112    usage = '(west_value, east_value, north_value, south_value, zi_code, zi_description) = simul_zi(index_simulaion)'
113    # ++ matlab if nargin~=1
114    # ++ matlab    disp(['Incorrect number of arguments ' num2str(nargin) ])
115    # ++ matlab    error(usage)
116    # ++ matlab end
117    #
118    # ++ matlab arg_info=whos('index_simulation')
119    # ++ matlab if ~strcmp(arg_info.class,'uint8')
120    # ++ matlab    disp(['Incorrect type of arg index_simulation ' arg_info.class])
121    # ++ matlab    whos index_simulation
122    # ++ matlab    error(usage)
123    # ++ matlab end
124    # ++ matlab #
125    # ++ matlab #
126    # ++ matlab # définition de la zone géographique
127
128    if index_simulation == 1:
129        nb_zi = 3
130    else:
131        print ('eee : unknown simulation %i' % (index_simulation))
132        sys.exit(1)
133
134    west_value = []
135    east_value = []
136    north_value = []
137    south_value = []
138    zi_description = []
139    zi_code = []
140
141    if index_simulation == 1:
142        for index_zi in range(0, nb_zi):
143            west_value.append(-20. + index_zi+1)
144            east_value.append(-15. + index_zi+1)
145            north_value.append(10.+ index_zi+1)
146            south_value.append(8.+ index_zi+1)
147            #
148            zi_description.append('zone ' + str(index_zi+1).zfill(2))
149            zi_code.append('zone' + str(index_zi+1).zfill(2))
150    else:
151        print ('eee : unknown simulation %i' % (index_simulation))
152        sys.exit(1)
153    #
154    #whos
155    #
156    result = 0
157    #
158    return west_value, east_value, north_value, south_value, zi_code, zi_description
159
160# Run main, if called from the command line
161if __name__ == '__main__':
162    import doctest
163    doctest.testmod()
Note: See TracBrowser for help on using the repository browser.