-
Notifications
You must be signed in to change notification settings - Fork 67
/
local.py
73 lines (57 loc) · 2.86 KB
/
local.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
## Added by Brian Blaylock
## September 30, 2021
"""
.. warning ::
This is an experimental feature.
This is a special case template for GRIB2 model data that is stored on
your local machine rather than retrieving data from remote sources.
For example, you may have output from some WRF simulations you did.
.. attention ::
Rather than editing this file, this class should be copied to a
private template file at ``~/.config/herbie/custom_template.py``.
Don't forget to create the file ``~/.config/herbie/__init__.py``.
Index files are assumed to be in the same directory as the file with
".idx" appended to the file name. If you don't have these inventory
files then they can be generated on-the-fly if you have wgrib2 installed
in your PATH or conda environment.
The keys in the SOURCES dictionary should start with "local".
Since Herbie accepts kwargs and passes them to self, you can template
the local file path with any parameter, just remember to pass that
parameter to the Herbie class 😋
To ask Herbie to find files with the template below you would type
.. code-block:: python
Herbie('2021-9-21', model="model1", fxx=0, ...)
Herbie('2021-9-21', model="model2", fxx=0, ...)
"""
class model1:
def template(self):
self.DESCRIPTION = "Local GRIB Files for model1"
self.DETAILS = {
"local": "These GRIB2 files are from a locally-stored modeling experiments."
}
self.PRODUCTS = {
# UPDATE THIS
"prs": "3D pressure level fields",
"sfc": "Surface level fields",
}
self.SOURCES = {
"local_main": f"/path/to/your/model1/templated/with/{self.model}/gribfiles/{self.date:%Y%m%d%H}/nest{self.nest}/the_file.t{self.date:%H}z.{self.product}.f{self.fxx:02d}.grib2",
"local_alt": f"/alternative/path/to/your/model1/templated/with/{self.model}/gribfiles/{self.date:%Y%m%d%H}/nest{self.nest}/the_file.t{self.date:%H}z.{self.product}.f{self.fxx:02d}.grib2",
}
self.LOCALFILE = f"{self.get_remoteFileName}"
class model2:
def template(self):
self.DESCRIPTION = "Local GRIB Files for model2"
self.DETAILS = {
"local": "These GRIB2 files are from a locally-stored modeling experiments."
}
self.PRODUCTS = {
# UPDATE THIS
"prs": "3D pressure level fields",
"sfc": "Surface level fields",
}
self.SOURCES = {
"local_main": f"/path/to/your/model2/templated/with/{self.model}/gribfiles/{self.date:%Y%m%d%H}/nest{self.nest}/the_file.t{self.date:%H}z.{self.product}.f{self.fxx:02d}.grib2",
"local_alt": f"/alternative/path/to/your/model2/templated/with/{self.model}/gribfiles/{self.date:%Y%m%d%H}/nest{self.nest}/the_file.t{self.date:%H}z.{self.product}.f{self.fxx:02d}.grib2",
}
self.LOCALFILE = f"{self.get_remoteFileName}"