Package qtcm :: Module defaults
[hide private]
[frames] | no frames]

Source Code for Module qtcm.defaults

  1  #!/usr/bin/python -tt 
  2  #======================================================================= 
  3  #                        General Documentation 
  4   
  5  """Defaults for QTCM fields in the QTCM package. 
  6   
  7  QTCM fields are model parameters or variables, and includes diagnotic 
  8  and prognostic variables, run parameters, coefficients, etc.  They 
  9  can be scalars (numeric or string) or arrays.  The values of these 
 10  QTCM parameter objects can be changed in the model by a call at the 
 11  Python level, though the types of their compiled model counterparts 
 12  cannot be changed (without recompiling the compiled model, of 
 13  course). 
 14   
 15  The default values of QTCM fields that are defined in the defaults 
 16  module specify the type of the variables, as well as the rank.  This 
 17  information is used by the Qtcm class to properly interface with 
 18  the compiled model.  Thus, fields that are not specified in the 
 19  defaults module will not properly interface with the compiled model. 
 20   
 21  Module Parameters Defined: 
 22  * init_prognostic_dict:  Dictionary giving the default initial 
 23    values of each prognostic variable and right-hand side (as defined 
 24    by the restart file specification). 
 25  * qtcm_fields_ids:  List of all the ids in qtcm_fields. 
 26  * qtcm_fields:  Dictionary of parameters. 
 27   
 28  Examples: 
 29  >>> print qtcm_fields['dt']['long_name'] 
 30  time step 
 31  >>> print qtcm_fields['dt']['units'] 
 32  s 
 33  >>> print int(qtcm_fields['dt']['value']) 
 34  1200 
 35  >>> print int(init_prognostic_dict['q1']) 
 36  -50 
 37  """ 
 38   
 39  #----------------------------------------------------------------------- 
 40  #                       Additional Documentation 
 41  # 
 42  # RCS Revision Code: 
 43  #   $Id: defaults.py 4 2008-06-25 01:03:28Z jlin $ 
 44  # 
 45  # Modification History: 
 46  # - 29 May 2008:  Original by Johnny Lin, Physics Department, North 
 47  #   Park University.  Passed passably reasonable tests. 
 48  # 
 49  # Notes: 
 50  # - Written for Python 2.4. 
 51  # - Module docstrings can be tested using the doctest module.  To 
 52  #   test, execute "python defaults.py". 
 53  # - See import statements throughout for non-"built-in" packages and 
 54  #   modules required. 
 55  # 
 56  # Copyright (c) 2008 by Johnny Lin.  For licensing, distribution  
 57  # conditions, contact information, and additional documentation see 
 58  # the URL http://www.johnny-lin.com/py_pkgs/qtcm/doc/. 
 59  #======================================================================= 
 60   
 61   
 62   
 63   
 64  #---------------- Module General Import and Declarations --------------- 
 65   
 66  #- If you're importing this module in testing mode, or you're running 
 67  #  pydoc on this module via the command line, import user-specific 
 68  #  settings to make sure any non-standard libraries are found: 
 69   
 70  import os, sys 
 71  if (__name__ == "__main__") or \ 
 72     ("pydoc" in os.path.basename(sys.argv[0])): 
 73      import user 
 74   
 75   
 76  #- Import package version and set module version to package version: 
 77   
 78  import package_version as _package_version 
 79  __version__ = _package_version.version 
 80  __author__  = _package_version.author 
 81  __date__    = _package_version.date 
 82  __credits__ = _package_version.credits 
 83   
 84   
 85  #- Import numpy/Numeric/numarray as appropriate and other modules: 
 86   
 87  from num_settings import N 
 88  import copy 
 89   
 90   
 91   
 92   
 93  #-------------------------- Module Variables --------------------------- 
 94   
 95  #- Very private variables: 
 96  # 
 97  #  __viscT, __viscQ, and __viscU are used *only in this module* to set  
 98  #  viscxu0, viscyu0, visc4x, visc4y, viscxu1, viscyu1, viscxT, viscyT,  
 99  #  viscxq, and viscyq.  The settings will not have any effect outside 
100  #  this module because all three variables are set to literals. 
101   
102  __viscT = 12.0e5    #- temperature diffusion parameter [m^2/s] 
103  __viscQ = 12.0e5    #- humidity diffusion parameter [m^2/s] 
104  __viscU = 7.0e5     #- viscocity parameter [m^2/s] 
105   
106   
107  #- init_prognostic_dict:  Dictionary giving the default initial 
108  #  values of each prognostic variable and right-hand side (as defined 
109  #  by the restart file specification). 
110   
111  init_prognostic_dict = {'u1':0.0, 'v1':0.0, 'T1':-100.0, 'q1':-50.0, 
112                          'u0':0.0, 'v0':0.0, 'vort0':0.0, 'rhsvort0':0.0, 
113                          'u0bar':0.0, 'rhsu0bar':0.0, 'Ts':295.0, 'psi0':0.0, 
114                          'WD':0.0} 
115   
116   
117  #- qtcm_fields:  Dictionary of all QTCM parameters that can be 
118  #  changed in the model by a call at the Python level: 
119   
120  qtcm_fields = {}        #- Initialize dictionary 
121   
122   
123  #+ Scalars: 
124   
125  qtcm_fields['title'] = { 'value' : 'QTCM default title' \ 
126                         , 'units' : '' \ 
127                         , 'long_name' : 'a descriptive title' } 
128   
129  qtcm_fields['bnddir'] = { 'value' : os.path.join(os.pardir, 'bnddata') \ 
130                          , 'units' : '' \ 
131                          , 'long_name' : 'boundary data other than SST' } 
132   
133  qtcm_fields['SSTdir'] = { 'value' : \ 
134                            os.path.join(os.pardir, 'bnddata', 'SST_Reynolds') \ 
135                          , 'units' : '' \ 
136                          , 'long_name' : 'where SST files are' } 
137   
138  qtcm_fields['outdir'] = { 'value' : \ 
139                            os.path.join(os.pardir, 'proc', 'qtcm_output') \ 
140                          , 'units' : '' \ 
141                          , 'long_name' : 'where output goes to' } 
142   
143  qtcm_fields['runname'] = { 'value' : 'runname' \ 
144                           , 'units' : '' \ 
145                           , 'long_name' : 'string for an output filename' } 
146   
147  qtcm_fields['landon'] = { 'value' : 1 \ 
148                          , 'units' : '' \ 
149                          , 'long_name' : \ 
150                            'if not 1: land = ocean with fake SST' } 
151   
152  qtcm_fields['SSTmode'] = { 'value' : 'seasonal' \ 
153                           , 'units' : '' \ 
154                           , 'long_name' : 'decide what kind of SST to use' } 
155   
156  qtcm_fields['year0']  = { 'value' : 0 \ 
157                          , 'units' : 'yr' \ 
158                          , 'long_name' : \ 
159                            'starting year; if < 0 use year in restart' } 
160   
161  qtcm_fields['month0']  = { 'value' : -1 \ 
162                           , 'units' : 'mo' \ 
163                           , 'long_name' : \ 
164                             'starting month; if < 0 use mo in restart' } 
165   
166  qtcm_fields['day0']  = { 'value' : -1 \ 
167                         , 'units' : 'dy' \ 
168                         , 'long_name' : \ 
169                           'starting day; if < 0 use day in restart' } 
170   
171  qtcm_fields['lastday']  = { 'value' : 365 \ 
172                            , 'units' : 'dy' \ 
173                            , 'long_name' : 'last day of integration' } 
174   
175  qtcm_fields['dateofmodel']  = { 'value' : 0 \ 
176                                , 'units' : '' \ 
177                                , 'long_name' : \ 
178      'date of model coded as an integer as yyyymmdd' } 
179   
180  qtcm_fields['it']  = { 'value' : 1 \ 
181                       , 'units' : '' \ 
182                       , 'long_name' : 'time of day in time steps' } 
183   
184  qtcm_fields['interval']  = { 'value' : 1 \ 
185                             , 'units' : 'dy' \ 
186                             , 'long_name' : \ 
187                               'atmosphere-ocean coupling interval' } 
188   
189  qtcm_fields['noout'] = { 'value' : 0 \ 
190                         , 'units' : 'dy' \ 
191                         , 'long_name' : 'no output for the first noout days' } 
192   
193  qtcm_fields['nooutr'] = { 'value' : 0 \ 
194                          , 'units' : 'dy' \ 
195                          , 'long_name' : \ 
196                            'no restart file for the first nooutr days' } 
197   
198  qtcm_fields['ntout'] = { 'value' : -30 \ 
199                         , 'units' : 'dy' \ 
200                         , 'long_name' : 'monthly mean output' } 
201   
202  qtcm_fields['ntouti'] = { 'value' : 0 \ 
203                          , 'units' : 'dy' \ 
204                          , 'long_name' : 'monthly instantaneous data output' } 
205   
206  qtcm_fields['ntoutr'] = { 'value' : 0 \ 
207                          , 'units' : 'dy' \ 
208                          , 'long_name' : \ 
209                            'restart file only at end of model run' } 
210   
211  qtcm_fields['nastep'] = { 'value' : 1 \ 
212                          , 'units' : '' \ 
213                          , 'long_name' : \ 
214                            'number of atmosphere time steps within one ' \ 
215                            +'air-sea coupling interval' } 
216   
217  qtcm_fields['mrestart'] = { 'value' : 0 \ 
218                            , 'units' : '' \ 
219                            , 'long_name' : '=1: restart using qtcm.restart' } 
220   
221  qtcm_fields['dt'] = { 'value' : 1200. \ 
222                      , 'long_name' : 'time step' \ 
223                      , 'units' : 's' } 
224   
225  qtcm_fields['eps_c'] = { 'value' : 0.13888889E-03 \ 
226                         , 'long_name' : '1/tau_c NZ (5.7)' \ 
227                         , 'units' : '1/s' } 
228   
229  qtcm_fields['mt0'] = { 'value' : 1 \ 
230                       , 'units' : '' \ 
231                       , 'long_name' : 'barotropic timestep every mt0 timesteps' } 
232   
233  qtcm_fields['ziml'] = { 'value' : 500. \ 
234                        , 'units' : 'm' \ 
235                        , 'long_name' : \ 
236                          'atmosphere mixed layer depth ~ cloud base'} 
237   
238  qtcm_fields['weml'] = { 'value' : 0.01 \ 
239                        , 'units' : 'm/s' \ 
240                        , 'long_name' : 'mixed layer entrainment velocity'} 
241   
242  qtcm_fields['VVsmin'] = { 'value' : 4.5 \ 
243                          , 'units' : 'm/s' \ 
244                          , 'long_name' : 'minimum wind speed for fluxes' } 
245   
246  qtcm_fields['viscxu0'] = { 'value' : __viscU \ 
247                           , 'units' : 'm^2/s' \ 
248                           , 'long_name' : 'viscocity parameter for u0 in x' } 
249   
250  qtcm_fields['viscyu0'] = { 'value' : __viscU \ 
251                           , 'units' : 'm^2/s' \ 
252                           , 'long_name' : 'viscocity parameter for u0 in y' } 
253   
254  qtcm_fields['visc4x'] = { 'value' : __viscU \ 
255                          , 'units' : 'm^2/s' \ 
256                          , 'long_name' : 'del 4 viscocity parameter in x' } 
257   
258  qtcm_fields['visc4y'] = { 'value' : __viscU \ 
259                          , 'units' : 'm^2/s' \ 
260                          , 'long_name' : 'del 4 viscocity parameter in y' } 
261   
262  qtcm_fields['viscxu1'] = { 'value' : __viscU \ 
263                           , 'units' : 'm^2/s' \ 
264                           , 'long_name' : 'viscocity parameter for u1 in x' } 
265   
266  qtcm_fields['viscyu1'] = { 'value' : __viscU \ 
267                           , 'units' : 'm^2/s' \ 
268                           , 'long_name' : 'viscocity parameter for u1 in y' } 
269   
270  qtcm_fields['viscxT'] = { 'value' : __viscT \ 
271                          , 'units' : 'm^2/s' \ 
272                          , 'long_name' : \ 
273                            'temperature diffusion parameter in x' } 
274   
275  qtcm_fields['viscyT'] = { 'value' : __viscT \ 
276                          , 'units' : 'm^2/s' \ 
277                          , 'long_name' : \ 
278                            'temperature diffusion parameter in y' } 
279   
280  qtcm_fields['viscxq'] = { 'value' : __viscQ \ 
281                          , 'units' : 'm^2/s' \ 
282                          , 'long_name' : 'humidity diffusion parameter in x' } 
283   
284  qtcm_fields['viscyq'] = { 'value' : __viscQ \ 
285                          , 'units' : 'm^2/s' \ 
286                          , 'long_name' : 'humidity diffusion parameter in y' } 
287   
288  qtcm_fields['u0bar'] = { 'value' : 0.0 \ 
289                       , 'units' : '' \ 
290                       , 'long_name' : '' } 
291   
292   
293  #+ Arrays: 
294   
295  qtcm_fields['Qc'] = { 'value' : N.zeros([1,1], dtype=float) \ 
296                      , 'units' : 'K' \ 
297                      , 'long_name' : 'precipitation' } 
298   
299  qtcm_fields['STYPE'] = { 'value' : N.zeros([1,1], dtype=float) \ 
300                       , 'units' : '' \ 
301                       , 'long_name' : \ 
302                         'surface type; ocean or vegetation type over land' } 
303   
304  qtcm_fields['FLWds'] = { 'value' : N.zeros([1,1], dtype=float) \ 
305                      , 'units' : '' \ 
306                      , 'long_name' : '' } 
307   
308  qtcm_fields['FLWus'] = { 'value' : N.zeros([1,1], dtype=float) \ 
309                      , 'units' : '' \ 
310                      , 'long_name' : '' } 
311   
312  qtcm_fields['FSWds'] = { 'value' : N.zeros([1,1], dtype=float) \ 
313                      , 'units' : '' \ 
314                      , 'long_name' : '' } 
315   
316  qtcm_fields['FSWus'] = { 'value' : N.zeros([1,1], dtype=float) \ 
317                       , 'units' : '' \ 
318                       , 'long_name' : '' } 
319   
320  qtcm_fields['Evap'] = { 'value' : N.zeros([1,1], dtype=float) \ 
321                      , 'units' : '' \ 
322                      , 'long_name' : '' } 
323   
324  qtcm_fields['FTs'] = { 'value' : N.zeros([1,1], dtype=float) \ 
325                       , 'units' : '' \ 
326                       , 'long_name' : '' } 
327   
328  qtcm_fields['taux'] = { 'value' : N.zeros([1,1], dtype=float) \ 
329                        , 'units' : '' \ 
330                        , 'long_name' : '' } 
331   
332  qtcm_fields['tauy'] = { 'value' : N.zeros([1,1], dtype=float) \ 
333                        , 'units' : '' \ 
334                        , 'long_name' : '' } 
335   
336  qtcm_fields['FLWut'] = { 'value' : N.zeros([1,1], dtype=float) \ 
337                         , 'units' : '' \ 
338                         , 'long_name' : '' } 
339   
340  qtcm_fields['FLW'] = { 'value' : N.zeros([1,1], dtype=float) \ 
341                       , 'units' : '' \ 
342                       , 'long_name' : '' } 
343   
344  qtcm_fields['S0'] = { 'value' : N.zeros([1,1], dtype=float) \ 
345                      , 'units' : '' \ 
346                      , 'long_name' : '' } 
347   
348  qtcm_fields['FSWut'] = { 'value' : N.zeros([1,1], dtype=float) \ 
349                       , 'units' : '' \ 
350                       , 'long_name' : '' } 
351   
352  qtcm_fields['FSW'] = { 'value' : N.zeros([1,1], dtype=float) \ 
353                     , 'units' : '' \ 
354                     , 'long_name' : '' } 
355   
356  qtcm_fields['u1'] = { 'value' : N.zeros([1,1], dtype=float) \ 
357                    , 'units' : 'm/s' \ 
358                    , 'long_name' : 'current time step baroclinic zonal wind' } 
359   
360  qtcm_fields['v1'] = { 'value' : N.zeros([1,1], dtype=float) \ 
361                    , 'units' : 'm/s' \ 
362                    , 'long_name' : '' } 
363   
364  qtcm_fields['T1'] = { 'value' : N.zeros([1,1], dtype=float) \ 
365                    , 'units' : 'K' \ 
366                    , 'long_name' : '' } 
367   
368  qtcm_fields['q1'] = { 'value' : N.zeros([1,1], dtype=float) \ 
369                    , 'units' : 'K' \ 
370                    , 'long_name' : '' } 
371   
372  qtcm_fields['u0'] = { 'value' : N.zeros([1,1], dtype=float) \ 
373                    , 'units' : 'm/s' \ 
374                    , 'long_name' : 'barotropic zonal wind' } 
375   
376  qtcm_fields['v0'] = { 'value' : N.zeros([1,1], dtype=float) \ 
377                    , 'units' : 'm/s' \ 
378                    , 'long_name' : 'barotropic meridional wind' } 
379   
380  qtcm_fields['vort0'] = { 'value' : N.zeros([1,1], dtype=float) \ 
381                    , 'units' : '' \ 
382                    , 'long_name' : '' } 
383   
384  qtcm_fields['psi0'] = { 'value' : N.zeros([1,1], dtype=float) \ 
385                    , 'units' : '' \ 
386                    , 'long_name' : '' } 
387   
388  qtcm_fields['rhsvort0'] = { 'value' : N.zeros([1,1,1], dtype=float) \ 
389                          , 'units' : '' \ 
390                          , 'long_name' : '' } 
391   
392  qtcm_fields['rhsu0bar'] = { 'value' : N.zeros([1,], dtype=float) \ 
393                          , 'units' : '' \ 
394                          , 'long_name' : '' } 
395   
396  qtcm_fields['Ts'] = { 'value' : N.zeros([1,1], dtype=float) \ 
397                    , 'units' : 'K' \ 
398                    , 'long_name' : 'surface temperature' } 
399   
400  qtcm_fields['WD'] = { 'value' : N.zeros([1,1], dtype=float) \ 
401                    , 'units' : '' \ 
402                    , 'long_name' : '' } 
403   
404  qtcm_fields['WD0'] = { 'value' : N.zeros([1,], dtype=float) \ 
405                    , 'units' : '' \ 
406                    , 'long_name' : 'field capacity SIB2/CSU (approximately)' } 
407   
408  qtcm_fields['arr1'] = { 'value' : N.zeros([1,1], dtype=float) \ 
409                      , 'units' : '' \ 
410                      , 'long_name' : \ 
411                        'auxiliary optional output array 1' } 
412   
413  qtcm_fields['arr2'] = { 'value' : N.zeros([1,1], dtype=float) \ 
414                      , 'units' : '' \ 
415                      , 'long_name' : \ 
416                        'auxiliary optional output array 2' } 
417   
418  qtcm_fields['arr3'] = { 'value' : N.zeros([1,1], dtype=float) \ 
419                      , 'units' : '' \ 
420                      , 'long_name' : \ 
421                        'auxiliary optional output array 3' } 
422   
423  qtcm_fields['arr4'] = { 'value' : N.zeros([1,1], dtype=float) \ 
424                      , 'units' : '' \ 
425                      , 'long_name' : \ 
426                        'auxiliary optional output array 4' } 
427   
428  qtcm_fields['arr5'] = { 'value' : N.zeros([1,1], dtype=float) \ 
429                      , 'units' : '' \ 
430                      , 'long_name' : \ 
431                        'auxiliary optional output array 5' } 
432   
433  qtcm_fields['arr6'] = { 'value' : N.zeros([1,1], dtype=float) \ 
434                      , 'units' : '' \ 
435                      , 'long_name' : \ 
436                        'auxiliary optional output array 6' } 
437   
438  qtcm_fields['arr7'] = { 'value' : N.zeros([1,1], dtype=float) \ 
439                      , 'units' : '' \ 
440                      , 'long_name' : \ 
441                        'auxiliary optional output array 7' } 
442   
443  qtcm_fields['arr8'] = { 'value' : N.zeros([1,1], dtype=float) \ 
444                      , 'units' : '' \ 
445                      , 'long_name' : \ 
446                        'auxiliary optional output array 8' } 
447   
448   
449  #- qtcm_fields_ids:  List of all the ids in qtcm_fields: 
450   
451  qtcm_fields_ids = qtcm_fields.keys() 
452   
453   
454   
455   
456  #-------------------------- Main:  Test Module ------------------------- 
457   
458  #- Execute doctest if module is run from command line: 
459   
460  if __name__ == "__main__": 
461      """Test the module. 
462   
463      Note:  To help ensure that module testing of this file works, the  
464      parent directory to the current directory is added to sys.path. 
465      """ 
466      import doctest, sys, os 
467      sys.path.append(os.pardir) 
468      doctest.testmod(sys.modules[__name__]) 
469   
470   
471   
472   
473  # ===== end file ===== 
474