This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EPIC_Latitude2degeast.py
75 lines (55 loc) · 1.73 KB
/
EPIC_Latitude2degeast.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
#!/usr/bin/env python
"""
Background:
--------
EPIC_Latitude2degeast.py
Purpose:
--------
manually adjust values in an EPIC netcdf file via a config file
History:
--------
2016-08-11: Migrate/integrage routines into EcoFOCI_MooringAnalysis package
"""
# Standard library.
import datetime
# System Stack
import argparse
from netCDF4 import Dataset
# user stack
from io_utils.EcoFOCI_netCDF_read import EcoFOCI_netCDF
__author__ = "Shaun Bell"
__email__ = "[email protected]"
__created__ = datetime.datetime(2014, 1, 13)
__modified__ = datetime.datetime(2016, 8, 11)
__version__ = "0.2.0"
__status__ = "Development"
"""------------------------------- MAIN--------------------------------------------"""
parser = argparse.ArgumentParser(
description="Convert DegreesWest to DegreesEast inplace"
)
parser.add_argument(
"sourcefile", metavar="sourcefile", type=str, help="complete path to netcdf file"
)
parser.add_argument("-m360", "--m360", action="store_true", help="make range 0-360")
args = parser.parse_args()
###nc readin
ncfile = args.sourcefile
df = EcoFOCI_netCDF(ncfile)
global_atts = df.get_global_atts()
vars_dic = df.get_vars()
data = df.ncreadfile_dic()
if "lon" in df.variables.keys():
if args.m360:
df.variables["lon"][:] = -1.0 * df.variables["lon"][:] + 360
else:
df.variables["lon"][:] = -1.0 * df.variables["lon"][:]
vars_dic["lon"].units = "degree_east"
elif "longitude" in df.variables.keys():
if args.m360:
df.variables["longitude"][:] = -1.0 * df.variables["longitude"][:] + 360
else:
df.variables["longitude"][:] = -1.0 * df.variables["longitude"][:]
vars_dic["longitude"].units = "degree_east"
else:
print("Longitude variable not found")
df.close()