gcmprocpy 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gcmprocpy-1.0.0/PKG-INFO +23 -0
- gcmprocpy-1.0.0/README.md +7 -0
- gcmprocpy-1.0.0/setup.cfg +4 -0
- gcmprocpy-1.0.0/setup.py +37 -0
- gcmprocpy-1.0.0/src/gcmprocpy/__init__.py +5 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/__init__.py +0 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/cmd_lat_lon.py +50 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/cmd_lat_time.py +45 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/cmd_lev_lat.py +45 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/cmd_lev_lon.py +45 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/cmd_lev_time.py +45 -0
- gcmprocpy-1.0.0/src/gcmprocpy/cmd/cmd_lev_var.py +39 -0
- gcmprocpy-1.0.0/src/gcmprocpy/convert_units.py +56 -0
- gcmprocpy-1.0.0/src/gcmprocpy/data_emissions.py +275 -0
- gcmprocpy-1.0.0/src/gcmprocpy/data_parse.py +1094 -0
- gcmprocpy-1.0.0/src/gcmprocpy/getoptions.py +208 -0
- gcmprocpy-1.0.0/src/gcmprocpy/io.py +41 -0
- gcmprocpy-1.0.0/src/gcmprocpy/main.py +182 -0
- gcmprocpy-1.0.0/src/gcmprocpy/mov_gen.py +94 -0
- gcmprocpy-1.0.0/src/gcmprocpy/plot_gen.py +827 -0
- gcmprocpy-1.0.0/src/gcmprocpy.egg-info/PKG-INFO +23 -0
- gcmprocpy-1.0.0/src/gcmprocpy.egg-info/SOURCES.txt +24 -0
- gcmprocpy-1.0.0/src/gcmprocpy.egg-info/dependency_links.txt +1 -0
- gcmprocpy-1.0.0/src/gcmprocpy.egg-info/entry_points.txt +7 -0
- gcmprocpy-1.0.0/src/gcmprocpy.egg-info/requires.txt +6 -0
- gcmprocpy-1.0.0/src/gcmprocpy.egg-info/top_level.txt +1 -0
gcmprocpy-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gcmprocpy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python3 post processing tool for TIE-GCM and WACCM-X
|
|
5
|
+
Home-page: https://github.com/NCAR/gcmprocpy
|
|
6
|
+
Author: Nikhil Rao
|
|
7
|
+
Author-email: nikhilr@ucar.edu
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: cartopy
|
|
11
|
+
Requires-Dist: matplotlib
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: xarray
|
|
14
|
+
Requires-Dist: ipython
|
|
15
|
+
Requires-Dist: geomag
|
|
16
|
+
|
|
17
|
+
# GCMPROCPY
|
|
18
|
+
|
|
19
|
+
GCMprocpy is a tool used for TIE-GCM and WACCM-X post processing and plot generation.
|
|
20
|
+
|
|
21
|
+
## Documentation on readthedocs
|
|
22
|
+
## https://gcmprocpy.readthedocs.io
|
|
23
|
+
|
gcmprocpy-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name='gcmprocpy',
|
|
8
|
+
version='1.0.0',
|
|
9
|
+
author = "Nikhil Rao",
|
|
10
|
+
author_email = "nikhilr@ucar.edu",
|
|
11
|
+
description='A Python3 post processing tool for TIE-GCM and WACCM-X',
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
url='https://github.com/NCAR/gcmprocpy',
|
|
15
|
+
python_requires='>=3.8',
|
|
16
|
+
install_requires=[
|
|
17
|
+
'cartopy',
|
|
18
|
+
'matplotlib',
|
|
19
|
+
'numpy',
|
|
20
|
+
'xarray',
|
|
21
|
+
'ipython',
|
|
22
|
+
'geomag',
|
|
23
|
+
],
|
|
24
|
+
package_dir={'': 'src'},
|
|
25
|
+
packages=find_packages(where='src'),
|
|
26
|
+
entry_points={
|
|
27
|
+
'console_scripts': [
|
|
28
|
+
'lat_lon= gcmprocpy.cmd.cmd_lat_lon:cmd_plt_lat_lon',
|
|
29
|
+
'lev_var= gcmprocpy.cmd.cmd_lev_var:cmd_plt_lev_var',
|
|
30
|
+
'lev_lat= gcmprocpy.cmd.cmd_lev_lat:cmd_plt_lev_lat',
|
|
31
|
+
'lev_lon= gcmprocpy.cmd.cmd_lev_lon:cmd_plt_lev_lon',
|
|
32
|
+
'lev_time= gcmprocpy.cmd.cmd_lev_time:cmd_plt_lev_time',
|
|
33
|
+
'lat_time= gcmprocpy.cmd.cmd_lat_time:cmd_plt_lat_time',
|
|
34
|
+
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from .plot_gen import plt_lat_lon, plt_lev_var, plt_lev_lon, plt_lev_lat, plt_lev_time, plt_lat_time
|
|
2
|
+
from .data_parse import arr_lat_lon,arr_lev_var,arr_lev_lon, arr_lev_lat,arr_lev_time,arr_lat_time, arr_var, get_mtime, get_time, time_list, var_list, level_list, lon_list, lat_list
|
|
3
|
+
from .io import load_datasets
|
|
4
|
+
from .mov_gen import mov_lat_lon
|
|
5
|
+
from .data_emissions import mkeno53, mkeco215, mkeoh83, arr_mkeno53, arr_mkeco215, arr_mkeoh83
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from ..plot_gen import plt_lat_lon
|
|
3
|
+
from ..io import load_datasets, save_output
|
|
4
|
+
import argparse
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
def cmd_parser():
|
|
8
|
+
parser = argparse.ArgumentParser(description="Parser for loading, plotting, and saving")
|
|
9
|
+
|
|
10
|
+
# Loading datasets
|
|
11
|
+
parser.add_argument('-dir','--directory', type=str, help='Path to the directory containing the datasets')
|
|
12
|
+
parser.add_argument('-dsf','--dataset_filter', type=str, help='Filter for the dataset file names', default=None)
|
|
13
|
+
|
|
14
|
+
# Saving output
|
|
15
|
+
parser.add_argument('-o_dir','--output_directory', type=str, help='Directory where the plot will be saved.', default=os.getcwd())
|
|
16
|
+
parser.add_argument('-o_file','--filename', type=str, required=True, help='Filename for the saved plot.')
|
|
17
|
+
parser.add_argument('-o_format','--output_format', type=str, help='Format of the output plot, e.g., "png", "pdf".', default='jpg')
|
|
18
|
+
|
|
19
|
+
# Plotting parameters
|
|
20
|
+
parser.add_argument('-var','--variable_name', type=str, required=True, help='The name of the variable with latitude, longitude, and lev/ilev dimensions.')
|
|
21
|
+
parser.add_argument('-t','--time', type=str, help='The selected time, e.g., "2022-01-01T12:00:00".')
|
|
22
|
+
parser.add_argument('-mt','--mtime', nargs='+', type=int, help='The selected time as a list, e.g., [1, 12, 0] for 1st day, 12 hours, 0 mins.')
|
|
23
|
+
parser.add_argument('-lvl','--level', type=float, help='The selected lev/ilev value.')
|
|
24
|
+
parser.add_argument('-unit','--variable_unit', type=str, help='The desired unit of the variable.')
|
|
25
|
+
parser.add_argument('-ci','--contour_intervals', type=int, help='The number of contour intervals. Defaults to 20.')
|
|
26
|
+
parser.add_argument('-cv','--contour_value', type=int, help='The value between each contour interval.')
|
|
27
|
+
parser.add_argument('-si','--symmetric_interval', action='store_true', help='If True, the contour intervals will be symmetric around zero. Defaults to False.')
|
|
28
|
+
parser.add_argument('-cmc','--cmap_color', type=str, help='The color map of the contour. Defaults to "viridis" for Density, "inferno" for Temp, "bwr" for Wind, "viridis" for undefined.')
|
|
29
|
+
parser.add_argument('-lc','--line_color', type=str, default='white', help='The color for all lines in the plot. Defaults to "white".')
|
|
30
|
+
parser.add_argument('-cst','--coastlines', action='store_true', help='Shows coastlines on the plot. Defaults to False.')
|
|
31
|
+
parser.add_argument('-nsh','--nightshade', action='store_true', help='Shows nightshade on the plot. Defaults to False.')
|
|
32
|
+
parser.add_argument('-gm','--gm_equator', action='store_true', help='Shows geomagnetic equator on the plot. Defaults to False.')
|
|
33
|
+
parser.add_argument('-lat_min','--latitude_minimum', type=float, help='Minimum latitude to slice plots. Defaults to -87.5.')
|
|
34
|
+
parser.add_argument('-lat_max','--latitude_maximum', type=float, help='Maximum latitude to slice plots. Defaults to 87.5.')
|
|
35
|
+
parser.add_argument('-lon_min','--longitude_minimum', type=float, help='Minimum longitude to slice plots. Defaults to -180.')
|
|
36
|
+
parser.add_argument('-lon_max','--longitude_maximum', type=float, help='Maximum longitude to slice plots. Defaults to 175.')
|
|
37
|
+
return (parser)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def cmd_plt_lat_lon():
|
|
43
|
+
parser = cmd_parser()
|
|
44
|
+
args = parser.parse_args()
|
|
45
|
+
datasets = load_datasets(args.directory,args.dataset_filter)
|
|
46
|
+
plot = plt_lat_lon(datasets, variable_name=args.variable_name, time=args.time, mtime=args.mtime, level=args.level, variable_unit=args.variable_unit, contour_intervals=args.contour_intervals, contour_value=args.contour_value, symmetric_interval=args.symmetric_interval, cmap_color=args.cmap_color, line_color=args.line_color, coastlines=args.coastlines, nightshade=args.nightshade, gm_equator=args.gm_equator, latitude_minimum=args.latitude_minimum, latitude_maximum=args.latitude_maximum, longitude_minimum=args.longitude_minimum, longitude_maximum=args.longitude_maximum)
|
|
47
|
+
save_output(args.output_directory,args.filename,args.output_format,plot)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from ..plot_gen import plt_lat_time
|
|
3
|
+
from ..io import load_datasets, save_output
|
|
4
|
+
import argparse
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
def cmd_parser():
|
|
8
|
+
parser = argparse.ArgumentParser(description="Parser for loading, plotting, and saving")
|
|
9
|
+
|
|
10
|
+
# Loading datasets
|
|
11
|
+
parser.add_argument('-dir','--directory', type=str, help='Path to the directory containing the datasets')
|
|
12
|
+
parser.add_argument('-dsf','--dataset_filter', type=str, help='Filter for the dataset file names', default=None)
|
|
13
|
+
|
|
14
|
+
# Saving output
|
|
15
|
+
parser.add_argument('-o_dir','--output_directory', type=str, help='Directory where the plot will be saved.', default=os.getcwd())
|
|
16
|
+
parser.add_argument('-o_file','--filename', type=str, required=True, help='Filename for the saved plot.')
|
|
17
|
+
parser.add_argument('-o_format','--output_format', type=str, required=True, help='Format of the output plot, e.g., "png", "pdf".', default='jpg')
|
|
18
|
+
|
|
19
|
+
# Plotting parameters
|
|
20
|
+
parser.add_argument('-var','--variable_name', type=str, help="The name of the variable with latitude, longitude, time, and ilev dimensions.")
|
|
21
|
+
parser.add_argument('-lvl','--level', type=float, help="The specific level value for the plot.", default=None)
|
|
22
|
+
parser.add_argument('-lon','--longitude', type=float, help="The specific longitude value for the plot.", default=None)
|
|
23
|
+
parser.add_argument('-unit','--variable_unit', type=str, help="The desired unit of the variable.", default=None)
|
|
24
|
+
parser.add_argument('-ci','--contour_intervals', type=int, help="The number of contour intervals. Defaults to 10.", default=10)
|
|
25
|
+
parser.add_argument('-cv','--contour_value', type=int, help="The value between each contour interval.", default=None)
|
|
26
|
+
parser.add_argument('-si','--symmetric_interval', action='store_true', help="If True, the contour intervals will be symmetric around zero. Defaults to False.")
|
|
27
|
+
parser.add_argument('-cmc','--cmap_color', type=str, help="The color map of the contour. Defaults to 'viridis' for Density, 'inferno' for Temp, 'bwr' for Wind, 'viridis' for undefined.", default=None)
|
|
28
|
+
parser.add_argument('-lc','--line_color', type=str, help="The color for all lines in the plot. Defaults to 'white'.", default='white')
|
|
29
|
+
parser.add_argument('-lat_min','--latitude_minimum', type=float, help="Minimum latitude value for the plot. Defaults to -87.5.", default=-87.5)
|
|
30
|
+
parser.add_argument('-lat_max','--latitude_maximum', type=float, help="Maximum latitude value for the plot. Defaults to 87.5.", default=87.5)
|
|
31
|
+
parser.add_argument('--mtime_minimum', type=float, help="Minimum time value for the plot. Defaults to None.", default=None)
|
|
32
|
+
parser.add_argument('--mtime_maximum', type=float, help="Maximum time value for the plot. Defaults to None.", default=None)
|
|
33
|
+
|
|
34
|
+
return (parser)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def cmd_plt_lat_time():
|
|
40
|
+
parser = cmd_parser()
|
|
41
|
+
args = parser.parse_args()
|
|
42
|
+
datasets = load_datasets(args.directory,args.dataset_filter)
|
|
43
|
+
plot = plt_lat_time(datasets, variable_name=args.variable_name, level=args.level, longitude=args.longitude, variable_unit=args.variable_unit, contour_intervals=args.contour_intervals, contour_value=args.contour_value, symmetric_interval=args.symmetric_interval, cmap_color=args.cmap_color, line_color=args.line_color, latitude_minimum=args.latitude_minimum, latitude_maximum=args.latitude_maximum, mtime_minimum=args.mtime_minimum, mtime_maximum=args.mtime_maximum)
|
|
44
|
+
save_output(args.output_directory,args.filename,args.output_format,plot)
|
|
45
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from ..plot_gen import plt_lev_lat
|
|
3
|
+
from ..io import load_datasets, save_output
|
|
4
|
+
import argparse
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
def cmd_parser():
|
|
8
|
+
parser = argparse.ArgumentParser(description="Parser for loading, plotting, and saving")
|
|
9
|
+
|
|
10
|
+
# Loading datasets
|
|
11
|
+
parser.add_argument('-dir','--directory', type=str, help='Path to the directory containing the datasets')
|
|
12
|
+
parser.add_argument('-dsf','--dataset_filter', type=str, help='Filter for the dataset file names', default=None)
|
|
13
|
+
|
|
14
|
+
# Saving output
|
|
15
|
+
parser.add_argument('-o_dir','--output_directory', type=str, help='Directory where the plot will be saved.', default=os.getcwd())
|
|
16
|
+
parser.add_argument('-o_file','--filename', type=str, required=True, help='Filename for the saved plot.')
|
|
17
|
+
parser.add_argument('-o_format','--output_format', type=str, required=True, help='Format of the output plot, e.g., "png", "pdf".', default='jpg')
|
|
18
|
+
|
|
19
|
+
# Plotting parameters
|
|
20
|
+
parser.add_argument('-var','--variable_name', type=str, help="The name of the variable with latitude, longitude, and lev/ilev dimensions.")
|
|
21
|
+
parser.add_argument('-t','--time', type=str, help="The selected time, e.g., '2022-01-01T12:00:00'.", default=None)
|
|
22
|
+
parser.add_argument('-mt','--mtime', type=int, nargs=3, help="The selected time as a list, e.g., [1, 12, 0] for 1st day, 12 hours, 0 mins.", default=None)
|
|
23
|
+
parser.add_argument('-lon','--longitude', type=float, help="The specific longitude value for the plot.", default=None)
|
|
24
|
+
parser.add_argument('-unit','--variable_unit', type=str, help="The desired unit of the variable.", default=None)
|
|
25
|
+
parser.add_argument('-ci','--contour_intervals', type=int, help="The number of contour intervals. Defaults to 20.", default=20)
|
|
26
|
+
parser.add_argument('-cv','--contour_value', type=int, help="The value between each contour interval.", default=None)
|
|
27
|
+
parser.add_argument('-si','--symmetric_interval', action='store_true', help="If True, the contour intervals will be symmetric around zero. Defaults to False.")
|
|
28
|
+
parser.add_argument('-cmc','--cmap_color', type=str, help="The color map of the contour. Defaults to 'viridis' for Density, 'inferno' for Temp, 'bwr' for Wind, 'viridis' for undefined.", default=None)
|
|
29
|
+
parser.add_argument('-lc','--line_color', type=str, help="The color for all lines in the plot. Defaults to 'white'.", default='white')
|
|
30
|
+
parser.add_argument('-lvl_min','--level_minimum', type=float, help="Minimum level value for the plot. Defaults to None.", default=None)
|
|
31
|
+
parser.add_argument('-lvl_max','--level_maximum', type=float, help="Maximum level value for the plot. Defaults to None.", default=None)
|
|
32
|
+
parser.add_argument('-lat_min','--latitude_minimum', type=float, help="Minimum latitude value for the plot. Defaults to -87.5.", default=-87.5)
|
|
33
|
+
parser.add_argument('-lat_max','--latitude_maximum', type=float, help="Maximum latitude value for the plot. Defaults to 87.5.", default=87.5)
|
|
34
|
+
|
|
35
|
+
return (parser)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def cmd_plt_lev_lat():
|
|
41
|
+
parser = cmd_parser()
|
|
42
|
+
args = parser.parse_args()
|
|
43
|
+
datasets = load_datasets(args.directory,args.dataset_filter)
|
|
44
|
+
plot = plt_lev_lat(datasets, variable_name=args.variable_name, time=args.time, mtime=args.mtime, longitude=args.longitude, variable_unit=args.variable_unit, contour_intervals=args.contour_intervals, contour_value=args.contour_value, symmetric_interval=args.symmetric_interval, cmap_color=args.cmap_color, line_color=args.line_color, level_minimum=args.level_minimum, level_maximum=args.level_maximum, latitude_minimum=args.latitude_minimum, latitude_maximum=args.latitude_maximum)
|
|
45
|
+
save_output(args.output_directory,args.filename,args.output_format,plot)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from ..plot_gen import plt_lev_lon
|
|
3
|
+
from ..io import load_datasets, save_output
|
|
4
|
+
import argparse
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
def cmd_parser():
|
|
8
|
+
parser = argparse.ArgumentParser(description="Parser for loading, plotting, and saving")
|
|
9
|
+
|
|
10
|
+
# Loading datasets
|
|
11
|
+
parser.add_argument('-dir','--directory', type=str, help='Path to the directory containing the datasets')
|
|
12
|
+
parser.add_argument('-dsf','--dataset_filter', type=str, help='Filter for the dataset file names', default=None)
|
|
13
|
+
|
|
14
|
+
# Saving output
|
|
15
|
+
parser.add_argument('-o_dir','--output_directory', type=str, help='Directory where the plot will be saved.', default=os.getcwd())
|
|
16
|
+
parser.add_argument('-o_file','--filename', type=str, required=True, help='Filename for the saved plot.')
|
|
17
|
+
parser.add_argument('-o_format','--output_format', type=str, required=True, help='Format of the output plot, e.g., "png", "pdf".', default='jpg')
|
|
18
|
+
|
|
19
|
+
# Plotting parameters
|
|
20
|
+
parser.add_argument('-var','--variable_name', type=str, help="The name of the variable with latitude, longitude, and lev/ilev dimensions.")
|
|
21
|
+
parser.add_argument('-lat','--latitude', type=float, help="The specific latitude value for the plot.")
|
|
22
|
+
parser.add_argument('-t','--time', type=str, help="The selected time, e.g., '2022-01-01T12:00:00'.", default=None)
|
|
23
|
+
parser.add_argument('-mt','--mtime', type=int, nargs=3, help="The selected time as a list, e.g., [1, 12, 0] for 1st day, 12 hours, 0 mins.", default=None)
|
|
24
|
+
parser.add_argument('-unit','--variable_unit', type=str, help="The desired unit of the variable.", default=None)
|
|
25
|
+
parser.add_argument('-ci','--contour_intervals', type=int, help="The number of contour intervals. Defaults to 20.", default=20)
|
|
26
|
+
parser.add_argument('-cv','--contour_value', type=int, help="The value between each contour interval.", default=None)
|
|
27
|
+
parser.add_argument('-si','--symmetric_interval', action='store_true', help="If True, the contour intervals will be symmetric around zero. Defaults to False.")
|
|
28
|
+
parser.add_argument('-cmc','--cmap_color', type=str, help="The color map of the contour. Defaults to 'viridis' for Density, 'inferno' for Temp, 'bwr' for Wind, 'viridis' for undefined.", default=None)
|
|
29
|
+
parser.add_argument('-lc','--line_color', type=str, help="The color for all lines in the plot. Defaults to 'white'.", default='white')
|
|
30
|
+
parser.add_argument('-lvl_min','--level_minimum', type=float, help="Minimum level value for the plot. Defaults to None.", default=None)
|
|
31
|
+
parser.add_argument('-lvl_max','--level_maximum', type=float, help="Maximum level value for the plot. Defaults to None.", default=None)
|
|
32
|
+
parser.add_argument('-lon_min','--longitude_minimum', type=float, help="Minimum longitude value for the plot. Defaults to -180.", default=-180)
|
|
33
|
+
parser.add_argument('-lon_max','--longitude_maximum', type=float, help="Maximum longitude value for the plot. Defaults to 175.", default=175)
|
|
34
|
+
return (parser)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def cmd_plt_lev_lon():
|
|
40
|
+
parser = cmd_parser()
|
|
41
|
+
args = parser.parse_args()
|
|
42
|
+
datasets = load_datasets(args.directory,args.dataset_filter)
|
|
43
|
+
plot = plt_lev_lon(datasets, variable_name=args.variable_name, latitude=args.latitude, time=args.time, mtime=args.mtime, variable_unit=args.variable_unit, contour_intervals=args.contour_intervals, contour_value=args.contour_value, symmetric_interval=args.symmetric_interval, cmap_color=args.cmap_color, line_color=args.line_color, level_minimum=args.level_minimum, level_maximum=args.level_maximum, longitude_minimum=args.longitude_minimum)
|
|
44
|
+
save_output(args.output_directory,args.filename,args.output_format,plot)
|
|
45
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from ..plot_gen import plt_lev_time
|
|
3
|
+
from ..io import load_datasets, save_output
|
|
4
|
+
import argparse
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
def cmd_parser():
|
|
8
|
+
parser = argparse.ArgumentParser(description="Parser for loading, plotting, and saving")
|
|
9
|
+
|
|
10
|
+
# Loading datasets
|
|
11
|
+
parser.add_argument('-dir','--directory', type=str, help='Path to the directory containing the datasets')
|
|
12
|
+
parser.add_argument('-dsf','--dataset_filter', type=str, help='Filter for the dataset file names', default=None)
|
|
13
|
+
|
|
14
|
+
# Saving output
|
|
15
|
+
parser.add_argument('-o_dir','--output_directory', type=str, help='Directory where the plot will be saved.', default=os.getcwd())
|
|
16
|
+
parser.add_argument('-o_file','--filename', type=str, required=True, help='Filename for the saved plot.')
|
|
17
|
+
parser.add_argument('-o_format','--output_format', type=str, required=True, help='Format of the output plot, e.g., "png", "pdf".', default='jpg')
|
|
18
|
+
|
|
19
|
+
# Plotting parameters
|
|
20
|
+
parser.add_argument('-var','--variable_name', type=str, help="The name of the variable with latitude, longitude, time, and ilev dimensions.")
|
|
21
|
+
parser.add_argument('-lat','--latitude', type=float, help="The specific latitude value for the plot.")
|
|
22
|
+
parser.add_argument('-lon','--longitude', type=float, help="The specific longitude value for the plot.", default=None)
|
|
23
|
+
parser.add_argument('-unit','--variable_unit', type=str, help="The desired unit of the variable.", default=None)
|
|
24
|
+
parser.add_argument('-ci','--contour_intervals', type=int, help="The number of contour intervals. Defaults to 10.", default=10)
|
|
25
|
+
parser.add_argument('-cv','--contour_value', type=int, help="The value between each contour interval.", default=None)
|
|
26
|
+
parser.add_argument('-si','--symmetric_interval', action='store_true', help="If True, the contour intervals will be symmetric around zero. Defaults to False.")
|
|
27
|
+
parser.add_argument('-cmc','--cmap_color', type=str, help="The color map of the contour. Defaults to 'viridis' for Density, 'inferno' for Temp, 'bwr' for Wind, 'viridis' for undefined.", default=None)
|
|
28
|
+
parser.add_argument('-lc','--line_color', type=str, help="The color for all lines in the plot. Defaults to 'white'.", default='white')
|
|
29
|
+
parser.add_argument('-lvl_min','--level_minimum', type=float, help="Minimum level value for the plot. Defaults to None.", default=None)
|
|
30
|
+
parser.add_argument('-lvl_max','--level_maximum', type=float, help="Maximum level value for the plot. Defaults to None.", default=None)
|
|
31
|
+
parser.add_argument('--mtime_minimum', type=float, help="Minimum time value for the plot. Defaults to None.", default=None)
|
|
32
|
+
parser.add_argument('--mtime_maximum', type=float, help="Maximum time value for the plot. Defaults to None.", default=None)
|
|
33
|
+
return (parser)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def cmd_plt_lev_time():
|
|
39
|
+
parser = cmd_parser()
|
|
40
|
+
args = parser.parse_args()
|
|
41
|
+
datasets = load_datasets(args.directory,args.dataset_filter)
|
|
42
|
+
plot = plt_lev_time(datasets, variable_name=args.variable_name, latitude=args.latitude, longitude=args.longitude, variable_unit=args.variable_unit, contour_intervals=args.contour_intervals, contour_value=args.contour_value, symmetric_interval=args.symmetric_interval, cmap_color=args.cmap_color, line_color=args.line_color, level_minimum=args.level_minimum, level_maximum=args.level_maximum, mtime_minimum=args.mtime_minimum, mtime_maximum=args.mtime_maximum)
|
|
43
|
+
save_output(args.output_directory,args.filename,args.output_format,plot)
|
|
44
|
+
|
|
45
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from ..plot_gen import plt_lev_var
|
|
3
|
+
from ..io import load_datasets, save_output
|
|
4
|
+
import argparse
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
def cmd_parser():
|
|
8
|
+
parser = argparse.ArgumentParser(description="Parser for loading, plotting, and saving")
|
|
9
|
+
|
|
10
|
+
# Loading datasets
|
|
11
|
+
parser.add_argument('-dir','--directory', type=str, help='Path to the directory containing the datasets')
|
|
12
|
+
parser.add_argument('-dsf','--dataset_filter', type=str, help='Filter for the dataset file names', default=None)
|
|
13
|
+
|
|
14
|
+
# Saving output
|
|
15
|
+
parser.add_argument('-o_dir','--output_directory', type=str, help='Directory where the plot will be saved.', default=os.getcwd())
|
|
16
|
+
parser.add_argument('-o_file','--filename', type=str, required=True, help='Filename for the saved plot.')
|
|
17
|
+
parser.add_argument('-o_format','--output_format', type=str, required=True, help='Format of the output plot, e.g., "png", "pdf".', default='jpg')
|
|
18
|
+
|
|
19
|
+
# Plotting parameters
|
|
20
|
+
parser.add_argument('-var','--variable_name', type=str, help='The name of the variable with latitude, longitude, and lev/ilev dimensions')
|
|
21
|
+
parser.add_argument('-lat','--latitude', type=float, help='The specific latitude value for the plot')
|
|
22
|
+
parser.add_argument('-t','--time', type=str, help='The selected time, e.g., "2022-01-01T12:00:00"', default=None)
|
|
23
|
+
parser.add_argument('-mt','--mtime', nargs=3, type=int, help='The selected time as a list, e.g., [1, 12, 0] for 1st day, 12 hours, 0 mins', default=None)
|
|
24
|
+
parser.add_argument('-lon','--longitude', type=float, help='The specific longitude value for the plot', default=None)
|
|
25
|
+
parser.add_argument('-unit','--variable_unit', type=str, help='The desired unit of the variable', default=None)
|
|
26
|
+
parser.add_argument('-lvl_min','--level_minimum', type=float, help='Minimum level value for the plot', default=None)
|
|
27
|
+
parser.add_argument('-lvl_max','--level_maximum', type=float, help='Maximum level value for the plot', default=None)
|
|
28
|
+
return (parser)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def cmd_plt_lev_var():
|
|
34
|
+
parser = cmd_parser()
|
|
35
|
+
args = parser.parse_args()
|
|
36
|
+
datasets = load_datasets(args.directory,args.dataset_filter)
|
|
37
|
+
plot = plt_lev_var(datasets,args.variable_name,args.latitude,args.time,args.mtime,args.longitude,args.variable_unit,args.level_minimum,args.level_maximum)
|
|
38
|
+
save_output(args.output_directory,args.filename,args.output_format,plot)
|
|
39
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
conversion_units = {
|
|
2
|
+
'cm-3': {'m-3': 1000000.0},
|
|
3
|
+
'km': {'m': 1000.0},
|
|
4
|
+
'cm/s': {'m/s': 0.01, 'km/s': 1e-5},
|
|
5
|
+
'erg/g/s': {'J/kg/s': 1e-7},
|
|
6
|
+
'ergs/cm2/s': {'J/m2/s': 0.001},
|
|
7
|
+
'millibars': {'pascals': 100},
|
|
8
|
+
'microbars': {'pascals': 0.1},
|
|
9
|
+
'g/cm3': {'kg/m3': 1000.0},
|
|
10
|
+
'degrees': {'radians': 0.0174533},
|
|
11
|
+
'degrees_east': {'radians': 0.0174533},
|
|
12
|
+
'degrees_north': {'radians': 0.0174533},
|
|
13
|
+
'km/s': {'m/s': 1000.0, 'cm/s': 100000.0},
|
|
14
|
+
'GW': {'MW': 1000.0, 'kW': 1000000.0, 'W': 1000000000.0},
|
|
15
|
+
'keV': {'eV': 1000.0, 'J': 1.60218e-16},
|
|
16
|
+
'nT': {'µT': 0.001, 'T': 1e-9},
|
|
17
|
+
'cm': {'m': 0.01, 'km': 1e-5},
|
|
18
|
+
'K': {
|
|
19
|
+
'C': {'factor': 1, 'offset': -273.15}, # Celsius = Kelvin - 273.15
|
|
20
|
+
'F': {'factor': 9/5, 'offset': -459.67} # Fahrenheit = Kelvin * 9/5 - 459.67
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def convert_units(data, from_unit, to_unit):
|
|
25
|
+
"""
|
|
26
|
+
Convert data from one unit to another based on predefined conversion factors.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
data (float): Numeric data to be converted.
|
|
30
|
+
from_unit (str): The current unit of the data.
|
|
31
|
+
to_unit (str): The desired unit to convert to.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
float: Converted data.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
if from_unit == to_unit:
|
|
38
|
+
return data, from_unit
|
|
39
|
+
|
|
40
|
+
# Check if conversion is possible
|
|
41
|
+
if from_unit in conversion_units and to_unit in conversion_units[from_unit]:
|
|
42
|
+
conversion = conversion_units[from_unit][to_unit]
|
|
43
|
+
print(f"Converting from {from_unit} to {to_unit}")
|
|
44
|
+
|
|
45
|
+
# Check if conversion is a dictionary or direct float
|
|
46
|
+
if isinstance(conversion, dict):
|
|
47
|
+
factor = conversion.get('factor', 1)
|
|
48
|
+
offset = conversion.get('offset', 0)
|
|
49
|
+
|
|
50
|
+
return data * factor + offset, to_unit
|
|
51
|
+
else:
|
|
52
|
+
return data * conversion, to_unit
|
|
53
|
+
else:
|
|
54
|
+
#raise ValueError(f"No conversion factor found for {from_unit} to {to_unit}")
|
|
55
|
+
print(f"No conversion factor found for {from_unit} to {to_unit}")
|
|
56
|
+
return data, from_unit
|