-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake_scrip.py
49 lines (34 loc) · 1.16 KB
/
make_scrip.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
#! /usr/bin/env python
#==============================================================================
# make_scrip.py
"""
Python script.
This script is to generate a SCRIP grid descriptor file.
Interactive usage:
make_scrip.py <src_dir src_file src_var src_grid_title>
Arguments:
src_dir # Source directory.
src_file # Source file.
src_var # Source variable.
src_grid_title # Source grid title.
"""
#==============================================================================
import sys
import cdms2
def _make_scrip(src_dir, src_file, src_var, src_grid_title):
#-------------------------------------------------------------------
"""
See file header.
"""
scrip_filename = src_grid_title + '_scrip.nc'
fin = cdms2.openDataset(src_dir + '/' + src_file)
src_grid = fin.variables[src_var].getGrid()
cdms2.writeScripGrid(scrip_filename, src_grid, src_grid_title)
return
if __name__ == '__main__':
#-------------------------
src_dir = sys.argv[1]
src_file = sys.argv[2]
src_var = sys.argv[3]
src_grid_title = sys.argv[4]
_make_scrip(src_dir, src_file, src_var, src_grid_title)