-
Notifications
You must be signed in to change notification settings - Fork 20
/
__init__.py
executable file
·119 lines (90 loc) · 3.64 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
WELCOME = """
DESCRIPTION
===========
reflexible: A python package for working with FLEXPART Output.
EXAMPLES
========
#TODO:
A lot! This is just a starting point. See
http://reflexible.readthedocs.org for a gentle introduction to the package
and the doc strings for more information about the various functions.
Also, have a look at the different tests in reflexible/tests for more hints
on how to use the package.
AUTHOR
======
JFB: John F Burkhart <jfburkhart@gmail.com>
FA: Francesc Alted <faltet@gmail.com>
CONTRIBUTORS
============
HSO: Harald Sodemann
SEC: Sabine Eckhardt
AST: Andreas Stohl
Many functions are adaptations of Fortran / NCARG programs (AST)
or Matlab functions (HSO/SEC).
LICENSE
=======
This package follows creative commons usage.
"""
import os
from .version import __version__
this_dir = __path__[0]
def _get_hg_description(path_):
""" Get the output of hg summary when executed in a given path. """
import subprocess
# make an absolute path if required, for example when running in a clone
if not os.path.isabs(path_):
path_ = os.path.join(os.environ['PWD'], path_)
# look up the commit using subprocess and hg summary
try:
# redirect stderr to stdout to make sure the hg error message in case
# we are not in a hg repo doesn't appear on the screen and confuse the
# user.
out = subprocess.check_output(
["hg", "summary"], cwd=path_, stderr=subprocess.STDOUT).strip()
out = "".join(['\n ' + l for l in out.split('\n')])
return out
except OSError: # in case hg wasn't found
pass
except subprocess.CalledProcessError: # not in hg repo
pass
_hg_description = _get_hg_description(this_dir)
def print_versions():
"""Print all the versions for packages that reflexible relies on."""
import numpy
import sys
print("-=" * 38)
print("reflexible version: %s" % __version__)
if _hg_description:
print("reflexible hg summary: %s" % _hg_description)
print("NumPy version: %s" % numpy.__version__)
print("Python version: %s" % sys.version)
if os.name == "posix":
(sysname, nodename, release, version, machine) = os.uname()
print("Platform: %s-%s" % (sys.platform, machine))
print("Byte-ordering: %s" % sys.byteorder)
print("-=" * 38)
# Some data sources (for testing purposes mainly)
datasets = {
'Fwd1_V10.1': os.path.join(this_dir, "uio_examples/Fwd1_V10.1"),
'Bwd1_V9.02': os.path.join(this_dir, "uio_examples/Bwd1_V9.02"),
'Bwd2_V9.2beta': os.path.join(this_dir, "uio_examples/Bwd2_V9.2beta"),
'Fwd1_V9.02': os.path.join(this_dir, "uio_examples/Fwd1_V9.02"),
'Fwd2_V9.02': os.path.join(this_dir, "uio_examples/Fwd2_V9.02"),
'HelloWorld_V9.02': os.path.join(this_dir, "uio_examples/HelloWorld_V9.02"),
'Only_Outputs_V9.02': os.path.join(
this_dir, "uio_examples/HelloWorld_V9.02/outputs"),
}
# Import the public functions here
from . import conv2netcdf4
from .base_read import read_trajectories, read_partpositions
from .data_structures import Header, Command, Release, ReleasePoint, Ageclass
from .flexpart import Flexpart
from .scripts.create_ncfile import create_ncfile
from .tests.all import test
from .utils import Structure, CacheDict, curtain_agltoasl, data_range
from .plotting import (
plot_sensitivity, plot_at_level, plot_totalcolumn, plot_trajectory,
plot_markers, plot_curtain, curtain_for_line)
# XXX Keep this as plot_footprint is referenced in the docs. But maybe remove
# it in the future, as plot_footprint = plot_at_level
plot_footprint = plot_at_level