PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1"""
21D model using PHYEX
3"""
4
5import os
6
7import numpy
8
9from pyphyex import __version__ # PHYEX version
10
11
12# Command line tools (added at the end of their help messages)
13COMMANDS = {
14 'phyex1d-cases_install': 'install the DEPHY-SCM cases (download or link)',
15 'phyex1d-cases_list': 'list the installed DEPHY-SCM cases',
16 'phyex1d-exp_run': 'run experiments on a case',
17 'phyex1d-exp_list': 'list the experiments having results',
18 'phyex1d-exp_plot': 'plot the results of experiments',
19 'phyex1d-exp_2nc': 'convert the results of an experiment into a dephycf netCDF file',
20 'phyex1d-grid_list': 'list the available vertical grids',
21 'phyex1d-grid_show': 'print the description of a vertical grid',
22 'phyex1d-namel_list': 'list the available namelists',
23 'phyex1d-namel_show': 'print the content of a namelist',
24}
25
26
28 """Section, common to the help messages of the command line tools, listing them"""
29 width = max(len(command) for command in COMMANDS)
30 return '\n'.join(['phyex1d command line tools (use -h for details):'] +
31 [f' {command:{width}s} {description}'
32 for command, description in COMMANDS.items()])
33
34
35def user_dir(subdir):
36 """
37 User directory in which grids and namelists are searched before the package
38 directory: $PHYEXCONF/phyex1d/<subdir>, PHYEXCONF being ~/.phyex by default
39 :param subdir: 'grids' or 'namelists'
40 """
41 return os.path.join(os.environ.get('PHYEXCONF', os.path.expanduser('~/.phyex')),
42 'phyex1d', subdir)
43
44
45class Phyex1DError(Exception):
46 """
47 phyex1d error
48 """
49
50class Cst(): # pylint: disable=too-few-public-methods,too-many-instance-attributes
51 """Empty class to store constants"""
52 def __init__(self):
53 # pylint: disable=invalid-name
54 self.pi = 2. * numpy.arcsin(1.)
55 self.Karman = 0.4
56 self.Planck = 6.6260755E-34
57 self.boltz = 1.380658E-23
58 self.avogadro= 6.0221367e+23
59
60 self.P0 = 100000.
61 self.g = 9.80665
62 self.day = 86400.
63 self.siyear = 365.25 * self.day * 2. * self.pi / 6.283076
64 self.siday = self.day / (1. + self.day / self.siyear)
65 self.omega = 2. * self.pi / self.siday
66
67 self.md= 28.9644e-3
68 self.mv= 18.0153E-3
69 self.Rd = self.avogadro * self.boltz / self.md
70 self.Rv = self.avogadro * self.boltz / self.mv
71 self.Cpd = 7.* self.Rd / 2.
72 self.Cpv = 4.* self.Rv
73 self.Cl = 4.218E+3
74 self.Ci = 2.106E+3
75 self.Tt = 273.16
76 self.LvTt = 2.5008E+6
77 self.LsTt = 2.8345E+6
78 self.Lv_0 = self.LvTt - (self.Cpv - self.Cl) * self.Tt
79 self.Ls_0 = self.LsTt - (self.Cpv - self.Ci) * self.Tt
80 self.EsTt = 611.14
81 self.gamw = (self.Cl - self.Cpv) / self.Rv
82 self.betaw = (self.LvTt / self.Rv) + (self.gamw * self.Tt)
83 self.alpw = numpy.log(self.EsTt) + (self.betaw / self.Tt) + (self.gamw * numpy.log(self.Tt))
84 self.gami = (self.Ci - self.Cpv) / self.Rv
85 self.betai = (self.LsTt / self.Rv) + (self.gami * self.Tt)
86 self.alpi = numpy.log(self.EsTt) + (self.betai / self.Tt) + (self.gami * numpy.log(self.Tt))
87
88
89from .case import Case, CaseCommonFormat, CaseXarray
90from .grid import Grid
91from .experiment_runner import ExperimentRunner
92from .physics_base import PhysicsBase
93from .phyex import (PHYEX, PhysicsArome, PhysicsAromeTQ, PhysicsAromeThetaR,
94 PhysicsForcingTQ, PhysicsForcingThetaR)
95from .simple_physics import SimplePhysics, SimplePhysicsTQ, SimplePhysicsThetaR
user_dir(subdir)
Definition __init__.py:35