-
Notifications
You must be signed in to change notification settings - Fork 0
/
nos_processing.py
108 lines (85 loc) · 3.11 KB
/
nos_processing.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
#!/usr/bin/python
'''
Description:
-Download NOS with fetch
-separate between NOS and BAGs
-unzip any gz
-remove NOS header and convert to X,Y,Negative Z and then to NAVD88
-convert BAG to tif and chunk, and convert to NAVD88
-bag2tif2chunks2xyz.sh and vert_conv.sh and create_datalist.sh
Author:
Chris Amante
Date:
5/23/2019
'''
#################################################################
#################################################################
#################################################################
####################### IMPORT MODULES ##########################
#################################################################
#################################################################
#################################################################
import os
import sys
######################## NOS ####################################
roi_str_gmt=sys.argv[1]
conv_grd_path=sys.argv[2]
bs_dlist=sys.argv[3]
dem_dlist=sys.argv[4]
#other params
chunk_size=500
resamp_bag='yes'
resamp_res=0.000030864199
print "Current directory is ", os.getcwd()
print 'Downloading NOS / BAG Surveys'
nos_download_cmd='''fetches -R {} nos'''.format(roi_str_gmt)
print nos_download_cmd
os.system(nos_download_cmd)
print "Separating NOS and BAG Surveys"
move_xyz_gz_cmd="find . -name '*.xyz.gz' -exec mv {} nos_hydro/ \; 2>/dev/null"
os.system(move_xyz_gz_cmd)
move_bag_cmd="find . -name '*.bag*' -exec mv {} nos_bag/ \; 2>/dev/null"
os.system(move_bag_cmd)
move_bag_gz_cmd="find . -name '*.bag.gz' -exec mv {} nos_bag/ \; 2>/dev/null"
os.system(move_bag_gz_cmd)
print "Unzipping NOS"
os.chdir('nos_hydro')
os.system('gunzip *.xyz.gz')
print "Moving all xyz files to xyz directory"
move_xyz_cmd="find . -name '*.xyz' -exec mv {} xyz/ \; 2>/dev/null"
os.system(move_xyz_cmd)
print "Converting NOS to X,Y,Negative Z"
os.chdir('xyz')
neg_z_cmd=('./nos2xyz.sh')
os.system(neg_z_cmd)
print "Converting NOS to NAVD88"
os.chdir('neg_m')
nos2navd88_cmd="./vert_conv.sh " + conv_grd_path + " navd88"
os.system(nos2navd88_cmd)
print "Creating NOS Datalist"
os.chdir('navd88')
nos_datalist_cmd='./create_datalist.sh nos_hydro'
os.system(nos_datalist_cmd)
current_dir=os.getcwd()
add_to_bmaster_cmd='echo ' + current_dir + '/nos_hydro.datalist -1 1 >> ' + bs_dlist
os.system(add_to_bmaster_cmd)
os.chdir('../../../..')
os.chdir('nos_bag')
print "Converting BAG to tif and to XYZ"
bag2tif2chunks2xyz_cmd='''./bag2tif2chunks2xyz.sh {} {} {}'''.format(chunk_size,resamp_bag,resamp_res)
os.system(bag2tif2chunks2xyz_cmd)
print "Converting BAG to NAVD88"
os.chdir('xyz')
bag2navd88_cmd="./vert_conv.sh " + conv_grd_path + " navd88"
#vert_conv.sh /media/sf_external_hd/al_fl/data/conv_grd/cgrid_mllw2navd88.tif navd88
os.system(bag2navd88_cmd)
print "Creating BAG Datalist"
os.chdir('navd88')
bag_datalist_cmd='./create_datalist.sh nos_bag'
os.system(bag_datalist_cmd)
current_dir=os.getcwd()
add_to_bmaster_cmd='echo ' + current_dir + '/nos_bag.datalist -1 10 >> ' + bs_dlist
os.system(add_to_bmaster_cmd)
add_to_master_cmd='echo ' + current_dir + '/nos_bag.datalist -1 1 >> ' + dem_dlist
os.system(add_to_master_cmd)